-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented battery voltage measurement for Heltec WiFi LoRa 32 V3 #16
Conversation
matthias-bs
commented
Apr 27, 2024
- ADC input switch (active low) controlled by GPIO37
- ADC input at pin A0 / GPIO1 (see https://github.com/espressif/arduino-esp32/blob/master/variants/heltec_wifi_lora_32_V3/pins_arduino.h)
- Voltage divider R17=100k, R14=390k => 100k / (100k + 390 k) => UBATT_DIV = 0.2041;
…eltec_wifi_lora_32_V3
Hi @matthias-bs, |
@evon800c Could you please check the battery voltage measurement with and without a battery? I'm not sure if VBAT equals VUSB / VDD_5V in the latter case. |
Hi, @matthias-bs |
Hi @evon800c , the battery connector is a white JST connector on the bottom side of the PCB.
The second case can only be tested if USB is not connected (otherwise you will still see the voltage coming from USB), which means you cannot check it in the debug output. Instead you have to check the LoRaWAN uplink payload. I have recently added some documentation and the payload formatters, so you can hopefully use this without too much effort. Best regards and a happy May Day, |
Hi, @matthias-bs you have perfectly described what i have in mind. I'll try to explain what is my lab environment at the moment. I have 2 heltec board with the same code, that are in power on. Both of them are receiving data from the same weather station. I'm doing some test to understand the better way to manage the energy... batteries, solar power panel size and and so on. node 1 node 2 From my point of view, all is working fine. At "2024-05-02 11:45:45 GMT+2" the uplink supply_v show 3325, while on tester i can see 3516, i suppose that some adjust is need to be done. I have attached the usb supply on node 2, also with battery attached (this board can charge the battery when powered with usb) At "2024-05-02 12:00:58 GMT+2" the uplink supply_v show 3995, while on tester i can see 4112. At "2024-05-02 13:44:58 GMT+2" the uplink supply_v show 4020, while on tester i can see 4196. I hope this information can be useful to you. For any other test and/or consideration, i'm here. Thanks a lot Davide |
Hi @evon800c, thank you very much for testing! The difference in voltage measurements between the ADC readings and your tester is a little bit concerning. 100...200mV difference means a lot when measuring a li-ion battery voltage. I think the usual effects like tolerances and voltage drop across the supply connections are not big enough to cause such a difference. Maybe this is caused by the weird implementation of the voltage divider as described in #4 (comment). If this is the case, the accuracy could be improved by using a lower attenuation of the ADC input. Best regards, BTW: You seem to use InfluxDB & Grafana for processing and displaying the data. If you like, you could add a short tutorial on how to set this up to the project... |
Hi, @matthias-bs no problem writing something to indicate how to integrate influxdb and / or grafana, let me know what approach to take and I'll try to do something. Note: Davide |
Hi @matthias-bs, I don't know if it can be useful... but I did some tests by varying the attenuation by inserting " I report the values detected. they are not very precise but they can be a starting point.
cheers, Davide |
Hi @evon800c , great finding! I thought it were more complicated. I'll add it in the next release! Thanks and have a nice evening! |
Should be |
yes correct, I set There is also another command "analogSetAttenuation(ADC_2_5db);" that can be used in the same way, but in that case the attenuation are applied to all pin |
Hmm, I mean it should be applied to the ADC input pin, not the ADC control pin (which is just used as digital output to switch the MOSFET between VBAT and the ADC input). |
mmmm correct |