Close

Data Logger Stage 2.0

A project log for imPulse

Energy harvesting alternative for bikes including data logging, smart lighting system and power distribution board for power banks

javier-betancorJavier Betancor 08/18/2018 at 19:140 Comments

Yes, I am also upgrading the Data Logger Stage. This is the last entry for this challenge as it involves all hardware/software debugging. These to parts are merged to create a unity, a system!

I am changing some of the components. To be honest with you, a physical data logger was very interesting to star with, but we are in the IoT era! Hence, here is the components list for this stage:

You can use all documentation available on my previous logs to create the voltage divider and to calibrate the current sensor. I will comment here all changes needed in order to transfer your code from a conventional Arduino (or similar) to the ESP32.

Hardware changes

The ESP32 has very nonlinear ADCs (Analogue to Digital Converter) despite of a greater resolution (12-bit or 4096 div). I had a very big headache trying to get reliable readings until I realised that the ADC was not working like the Arduino one. I measure the maximum voltage allowed for analog measuring and was 3.14V, not 3.3V. I would recommend you to read the Espressif ADC documentation (just in case).

My test circuit was just a voltage divider, but I added two extra components, a first-order-filter and multiple sampling (image below):

Here are the input parameters:

After these changes, readings were very stable, so I defined a "true voltage" calibration function and also implemented it in the code. The spreadsheet can be downloaded from GitHub. I have to point out that voltages below 0.114V were not considered by the ADC.

The current sensor requires 4.5 - 5.5V. My power banks were providing 5.016V but only around 4.3V were provided to the sensor as I had a diode for the DPDT (diagram here). The sensor worked just fine, but the reading from the module MUST go through the calibration function first (to avoid any painful headache).

Another thing I had to change in the hardware was the addition of voltage dividers for the LDRs readings. Unfortunately, I had them connected directly with the lights, so the voltage supplied was 5V instead of 3.3V.

Software changes

First of all, I planned to incorporate Blynk on my setup, so the bike rider will experience something similar to a car dashboard. Here is my dashboard setup:

I wanted to have:

Anything is possible with this app and your imagination. I encourage you to build something completely different and at your own choice, something that only you will find useful. That is why I chose Blynk!

After testing most of the codes regarding Blynk, sensors and light system separately, I finally created a unique file: imPulseMain. I had several issues with the ESP32 and now I understand why it is categorised as a developing board. No worries, all of them are listed in the code:

However, the good news are that I managed to make everything work. Still minor bugs but will be fixed in future releases in conjunction with software upgrades:

Now, the final video!

Discussions