Some month ago I've bought a electric scooter for my every day drive to work. He is called HP_BEXXTER (just google it for more information:-))
Now I wanted to know how many energy I need for those drives. Also I want to collect more information about my usage of the scooter but for now I started with the charger.
The function in quite simple: Collect the energy data from the charger by an ESP8266 and push it to a InfluxDB server. For visualization I'm using grafana.
Step 1: Electric Meter + ESP8266
Somehow I need to get the electric power consumption. The first idea was to create a PCB to measure the values directly. But while I'm googleing for input I've found a power meter with a S0 interface for 15€.
Now it was quite simple to get the consumption. Every 1/1000 kWh I get a peek on the interface.
All the components were then mounted on a wood plate.
To power the ESP8266 I've hacked a old usb charger... It's not the way you should do it.
Step 2: First Test and ESP8266 Schematics
After the build up from most of the hardware I've started the development of the schematics... It is ONE resistor.
But I've used a breadboard for that...
The resistor is needed to pull the voltage to ground if the S0 interface is on low.
The Code is also quite simple I'm using the std. arduino workbench for such simple projects. The code is downloadable here and based on two toggling interrupt handler.
Step 3: Hardening the HW...
... I simply need the breadboard for other projects :-)
Step 4: Set Up InfluxDB and Grafana
I've set up the influxDb and the grafana on a old raspberry pi you can do that on every computer. I don't write down a complete how to for the installation only the hints for running the stuff on a rpi1.
you can download the .deb install and run grafana:
sudo dpkg -i grafana_4.2.0_armhf.deb
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server
sudo /bin/systemctl start grafana-server
The InfluxDB is configured for UDP and the database is stored on a USB flash drive. The configuration file is stored here: /etc/influxdb/influxdb.conf
# Where the metadata/raft database is stored
dir = "/automnt/usb-stick/influxdb/meta"
# The directory where the TSM storage engine stores TSM files.
dir = "/automnt/usb-stick/influxdb/data"
enabled = true
bind-address = ":8089"
database = "test"
To configure the databases and other stuff you need to grant admin access:
# Determines whether the admin service is enabled.
enabled = true
# The default bind address used by the admin service.
bind-address = ":8083"
Now you can log in to your DB by your browser and create a database, you'll find enough example on the web how.
http://IP to influx DB:8083/
Then you can also configure grafana. Also here you'll find the examples online.
http://IP to influx DB:3000
For the visualization you can see in the screen shots what I've done.
To test the connection you can use you linux machine:
echo "powertick value=1" > /dev/udp/<IP to influx DB>/8089
Step 5: Next Steps
I want to collect data also from my Scooter:
- GPS Position
- Temperature of the Motor
- Temperature of the Battery
- Temperature of the environment
- power consumption of the drive unit
If somebody want some things explained more in detail, please contact me...
I'll also add the new data in this instructable.