New to SparkFun so I may have something not setup correctly.
I’m using an ESP32-WROOM-32 for a remote Propane Tank full level with a Hall Sensor (actually two propane tanks). I’m powering the ESP32 with a combination solar panel battery system (for powering remote wildlife cameras) which provides both 12V and 6V feeds. I’m using the 6V feed and a LD1117V33 voltage regulator to provide a constant 3.3V to the ESP32 board. I’m sending all the collected information to my MQTT Broker in Home Assistant.
I thought it would be good to add a SparkFun Lipo Fuel Gauge (TOL-20680) so I could also send an MQTT message on the voltage and SOC of the battery pack. I use a voltage divider (R1 of 104 ohms, R2 of 127 ohms) to drop the 6V supply down to 3V which the board expects. The combo solar panel and Lipo battery must have a battery management system (BMS) embedded since at full charge the pack only provides 6V.
Anyway, I followed the sample example code from the SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library but I’m getting 0.00% for the percentage and 6.42 for the voltage. Originally I purchased a board from Amazon but read how some of these boards from China are not working properly so I ordered two boards directly from SparkFun (red color boards). However, with the SparkFun boards I continue to get the same issues. (Actually the first boards I had at least gave a SOC of 0.02%).
Any help would be greatly appreciated. I’ve added a schematic of the setup and the complete copy of the code. Hopefully someone can point out what I’m doing wrong so I can get this working. Currently the project is just on a breadboard but I’m ready to solder it and put it in a weather proof container for deployment once I figure out this issue with the Fuel Gauge.
Thanks!
Propane Sensor Project Wiring Diagram.pdf (193.4 KB)
Propane_Tank_Remote_Hall_Sensor.ino.txt (14.4 KB)
PS - I forgot to add that my multimeter indicates the voltage from the Voltage Divider into the battery connections on the Fuel Gauge board to be 3.24V. I’ve double checked that I have the SDA and SCA wired correctly (since the code is “seeing” the board I feel this is correct) and the vcc and grd coming from the 3.3V pin on the ESP32 board.
I assume you tried to power cycle and re-test?
Can you hook up just a lipo, the fuel gauge, and an esp32 only to help try an isolate where it’s going wrong? I’d try that setup with the ex4 code SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/examples/Example4_MAX17048_KitchenSink/Example4_MAX17048_KitchenSink.ino at main · sparkfun/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library · GitHub and see if you can get good readings, then go back to re-try the larger implementation
I do have a “smaller” version of the program that just took hall sensor readings and the battery readings and just printed to the serial interface. I was getting the same error but I haven’t run that program with the official SparkFun fuel gauge. When I run that version, the ESP32 is powered by the USB cable to my MacBook which also powers the Fuel Gauge board but the battery inputs on the board are from the voltage divider connected to the 6V battery. I was worried as this presented two different grounds but this is the only way I can get data from the serial output. Let me switch to that program and test. I’ll paste that code back here shortly with my update.
Ok, I loaded the smaller program which I was using to just get sensor readings every so many seconds. It has the same Fuel Gauge code in it as well. I’m seeing the same output - SOC of 0.00% and Voltage of 6.53. I’ve attached the source code and some of the serial output to this posting. Hope it helps. Thanks!
Propane_Tank_Remote_Hall_Sensor.ino.txt (14.4 KB)
GetHallSensorsFuelGauge-SerialOutput.txt (1002 Bytes)
Do you have a 1s lipo around? I wonder if it being out of the max input V is making things go wonky https://cdn.sparkfun.com/datasheets/Prototyping/MAX17043-MAX17044.pdf
The fuel gauge is designed to be used with a single cell lipo battery with a voltage between 3.2 and 4.2 volts. It’s not going to work with your setup, at least it won’t give accurate state of charge. I’m not sure if it would work but if you adjust your voltage divider to provide exactly 4.2 volts when your solar battery is at it’s highest possible voltage, that should give you 100% state of charge. 3.2 volts is essentially a completely dead lipo, that should show a zero state of charge.
1 Like
I’ll look around and see if I have one but I don’t think so. I’ll see.
Ahh, good point. I was trying to get the voltage divider to be close to 3.3. I didn’t think about it needing to be at 4.2 for a full charge 1S Lipo. I’ll adjust the divider and see what happens using the smaller program. Thanks!!
1 Like
On the voltage divider I changed R1 to 996 ohms and R2 to 2.322k ohms (combined a 1.995k ohms and 327 ohms resistor). That should take my 6V supply down to 4.199v. I ran the small program and now the SOC is showing 97.98% which I think is now correct. However, the voltage from the Fuel Gauge is showing 8.35 which is incorrect. The multimeter reading at the battery input to the Fuel Gauge is showing 4.15.
Any ideas on why the voltage is so out of wack?
I’ve attached the serial output for you to see (just ignore the Hall sensor readings).
GetHallSensorsFuelGaugeNewVoltageDivider-SerialOutput.txt (1.6 KB)
I’ve been letting it run continuously taking sensor readings since my update yesterday and the SOC is now at 80.91%. It is still showing the Voltage much higher. The reported Voltage is 8.23 and the multimeter measurements is 4.14. That makes the real voltage to be 50.3% of the reported voltage. Maybe I just need to half the reported voltage from the Fuel Gauge? I didn’t see in any of the examples of needing to do anything with the reported value that comes back from the lipo.getVoltage call.
Yeah, I’d do that. You’re using a part in a way it’s not intended to be used so there are bound to be a few concessions / work arounds you’ll need to make. That seems like an easy way to fix the problem.
Thanks! I knew I was stretching a bit given the solar panel/battery pack. I’ll make the software update to half the value. Thanks again for all your help!