So i have built multiple boxes for my backyard to transmit BLE to Wifi for my plant monitoring sensors, everything is working fine and i am trying to get the voltage of the battery along with the percentage but im not sure if i am calculating this properly
My system is put together just like this one at
https://randomnerdtutorials.com/power-esp32-esp8266-solar-panels-battery-level-monitoring/
Utilizing a 100k and 27k resistor as in the diagram, i am pulling voltage and converting battery percentage correctly, but im not sure if the values are correct or how to check
I followed the instructions exactly and i am just wondering if my data is correct
Here is my yaml file
# Battery Sensor
- platform: adc
id: solar_plant_batt_voltage
pin: GPIO33
attenuation: auto
name: ${friendly_name} Battery Voltage
update_interval: 1s
accuracy_decimals: 1
filters:
#u se moving median to smooth spikes
- median:
window_size: 10
send_every: 10
send_first_at: 10
- delta: 0.1 # Only send values to HA if they change
- throttle: 30s #Limit values sent to Ha
# Convert the Voltage to a battery level (%)
- platform: copy
source_id: solar_plant_batt_voltage
id: solar_plant_batt_level
icon: "mdi:battery"
name: ${friendly_name} Battery Level
unit_of_measurement: '%'
accuracy_decimals: 1
filters:
- calibrate_linear:
# Map from voltage to Battery level
- 0.41 -> 0
- 3.1 -> 100
#Handle/cap boundaries
- lambda: |
if (x < 0) return 0;
else if (x > 100) return 100;
else return (x);
- delta: 0.5 #Only send values to HA if they change
- throttle: 30s #Limit values sent to Ha
Here is what the unit is reporting
[14:58:30][D][sensor:094]: ‘BLE Proxy 4ca15c - East Garden Battery Voltage’: Sending state 3.01160 V with 1 decimals of accuracy
[14:58:30][D][sensor:094]: ‘BLE Proxy 4ca15c - East Garden Battery Level’: Sending state 96.71378 % with 1 decimals of accuracy
I have a 10000 mAh battery in the unit that runs at 3.7 i have a 6v solar panel charging the battery all is working fine there, i am using the instructions to drop the voltage down from 3.7 to 3.3 volts successfully.
Looking at the settings its mapping the voltage but is it mapping it correctly since it is stating that 3.1 is 100% which really it is not, im not sure if i can just change these numbers to reflect what they should be or are there other calculations needing to be done or should they be calculated differently???
To me this below doesnt make sense but its what the writeup states
# Map from voltage to Battery level
- 0.41 -> 0
- 3.1 -> 100
Help is appreciated i just want to get correct values so i can know where the battery is at during the night and day,
Also if possible is there a way i can get any information for how much the battery is being charged or the charging state? I am using a TP4056 solar charger to charge the battery, not sure how or if possible i can get charging state from it or the battery.
Would it be better if i used an external voltage divider or some other sensor to accomplish this or use what i currently have setup?? I see Adafruit has one the max17048 would this be better?
Thanks!