Very good tutorial. I added a few extra lines in the template for the esp config in case anyone is interested. It also removes the need for an extra sensor in HA config. Just adjust the lambda value to suit. sensor: - platform: adc pin: A0 name: "Your choice" unit_of_measurement: "Volts" icon: "mdi:car-battery" accuracy_decimals: 1 update_interval: 60s filters: - multiply: 3.3 - lambda: return (x - 0.06)*5;
I like how you're straight to the point, no cheesy jokes, no cringe "I'm the ultimate dad" vibes, just very technical and to the point yet slow and clear enough to follow and not get lost. Thanks for your quality content!
You can eliminate the need for a template sensor entirely by adding a lambda section to the filters and doing the adjustment calculation in there. filters: - multiply: 3.3 - lambda: return (x-0.08)*5;
I did some math and for my sensor this is the best value filters: - multiply: 15.74838231 Its possible that some sensors have diffrent numbers but you can always try it out!
Thank you for this video, Very helpful to get started. I am using this voltage monitor for my 24V off-grid battery bank. My ESP32 ADC needs to work between about 100mV and 900mV. Expecting voltages of up to 30V, I added a 1k resistor to the voltage divider output (just soldered it between A0 and GND because that was easier than messing with the smd resistors on the "voltage sensor module". Next time, I won't use the voltage sensor module, but rather build a matching voltage divider immediately.
It is nice to see someone creating an example using HA, ESPhome and, finally the automation. There is a real need for basic training in the areas discussed. We have enough pages or websites that explain functionality at the knowledgable programmer level.
Instead of performing the additional calculations, I would just change the filter from 3.3 to 15.8 then the ESP32 would report the actual PSU voltage directly back to HA.
Actually, to make it clearer I'd have used multiple filters in esphome too, one for the d1mini voltage divider, one for the 0.14 offset and then a multiply filter for the external board. Then you wouldn't need to calculate their combination. Easier to tweak later if you change the circuit in some way (or replace the d1mini with another one that requires a slightly different tweaking value).
I think I learned more about how to build things with ESPHome and Home Assistant in this video than in many others. Not to mention it was well thought out and easy to follow. Now I'm off to set up a voltage monitor for a solar attic fan.
Long time subscriber Chris! I'm finally getting around to using this setup to monitor my vehicle batteries. Ordered the voltage dividers today. Thanks for the awesome videos man!!
Interesting video. One time no one could hear me on my radio. I bumped the knob on my power supply. I don't remember the voltage but it was very low. 🤣 I'm switched to 100% solar for all communication gear now though. I get voltage reports from my charge controller via modbus to MQTT with Tasmota now. Works great
The voltage divider in the Wemos D1 is a pair of resistors, one below the actual ADC block and one towards the input which you now attach to the center of another pair of resistors, so one towards ground and one towards the voltage you want to measure, but ... the two resistors inside the Wemos are now in parallel with the external one to ground, so the total resistance is no longer what you thought your voltage divider would provide. Since the value inside the Wemos is known, you can better simply add a single resistor from the ADC pin of the Wemos to the voltage you want to measure, basically increasing the factor the new voltage divider created this way will use.
Thanks for the explanation. The fewer the parts, the better. Still got to get that initial input voltage < 3.x volts so as to not blow up the ESP. What do you recommend as a value for the resistor?
@@mostlychris I think you will want the data sheet and schematic for your exact boards components combined with some fairly simple math to answer this definitively.
@mostlychris - Thank you very much for this excellent tutorial. I learned a lot from your video, and then even more from the comments section. @MisterkeTube - Your savvy input here launched me off into a bunch of research into the Wemos A0 architecture. You're right, it's probably more efficient to add a series resistor to A0 than to wire in another voltage divider. I'm looking at monitoring a 12VDC solar panel and ran the numbers for a safe Vmax. A 2 MΩ resistor soldered to A0 on the D1 voltage divider protects the Wemos to a Vmax of 23VDC. A 1.4 MΩ resistor protects the Wemos to a Vmax of 17VDC. I'm adjusting just the multiplier value and not using the lambda or template. By the way, you can calculate the required multiplier in ESPhome by first setting it to 1.0, and then running it. Record the reported value, and divide your DVM actual reading by that reported value, and that is the multiplier you should set in ESPhome. For example, in one test I read 2.855VDC on my DVM, and ESPhome was reporting a value of 0.1143 with a multiplier of 1. So, 2.855/0.1143=24.97812773, and that is the value I put in ESPhome for the multiplier. Running tests now on a variety of voltage levels with the 2 MΩ series resistor followed by a 1.4 MΩ series resistor and concordance in both look very suitable to my needs. Thanks again @mostlychris and all who commented with valuable detail!
If it's a linear power supply and the regulator fails, the output immediately jumps to 30 V - not gradually. There should be a crowbar protection circuit inside the PS that shorts the output on over voltage so that it blows the fuse before the connected load is damaged. Still nice to know voltage, especially for PS without a meter and for a PS mounted remotely where you wouldn't see the meter anyway! I love the video and the work.! Thanks
That's what I get for buying a cheap(er) power supply. I sent the original one back that failed at 30v. My poor radio was sitting there making a ticking noise--thought I'd lost it. The replacement supply has been doing better. It will occasionally drop to 12 or so volts for a brief moment when under load. I've got that graphed so I can see it (I don't trust these supplies).
I don't want to name the supply I'm using without digging into it a bit further to determine if I caused the issue in the first place. I've got the supply in the attic where it gets to >100 F at times and I am running it a medium loading. It just might not be able to handle the heat. That's why it's important to me that I monitor heatsink temps and voltages.
Very good walk thru from start to finish! I have been experimenting with an ESP32 reading, LP sensor voltage, 18650 battery voltage and solar panel output and the esp wakes up, takes the readings, sends it via mqtt , and goes back to sleep. I am finding that the readings are not stable and I have been chasing the calibration factor. I have a little troubleshooting to do to track down the instability. I believe I am going to feed it a known voltage and see how stable it reads it. It may be due to dipping supply voltage when it wakes up. G6EJD does several very detailed videos on measuring voltages and using voltage dividers and the calibration math to use in your code. Also, in the ESP technical specs, it notes that each chip will have a slightly different calibration requirement. Depending on your selection of resistance used in the dividers, the ESP output impedance can also change the results as it may load down the voltage since it is roughly 1.3meg that will be in parallel with R2. Some other tricks that can be utilized in your code is averaging. I use this with a flow sensor since it seems to be very erratic with my water pressure. I can also average it even more once I get the data in Node Red.
21:04 in the automation you should not use state but instead use numerical state. Now if your power suply goes from 13.9 to 14.1 your automation will not fire. With numerical state you can set a above or below value
It's cool to see how you did this but in terms of protecting your radio you're probably better off with a crowbar circuit across the power supply that shunts out the PSU and pops the fuses. I built one a few years back using an SCR turned on by a zener diode. I wouldn't want to be relying on all the moving parts of micro controllers, WiFi and services like home assistant talking to a smart plug of some sort. There's going to be some lag there and by the time it's shut off the mains the radio might already be seeing a much higher voltage than your set point. A crowbar will be pretty much instant. Not as fancy in terms of graphing and alerting but that kind of thing should always come second in scenarios like this. It's good to know about it but if your radio is already fried it's too late
About your USB cables not working:. As crazy as it sounds some cables have power and data, some have data only and some have power only. The last two are generally provided with some CE product like a portable fan that doesn't need data, just power to recharge the battery or just data to an already powered device. It seems like a dumb way to cut costs but if you're making thousands of devices every penny adds up.
If the power supply goes up to 30 volts, I don't know if it will blow up whatever you have it supplying power to, but I think it could blow up the ESP32, even after going through the voltage divider. 30 V / 5 = 6 V > 3.3 V. You may want to change your setup so that the Tasmota switch turns the power supply off automatically as soon as it gets to 3.3 V * 5 = 16.5 V.
I built the ESP 8266 with the voltage divider but cannot find the sensors.yaml file in the visual studio code. Everything works perfectly and i understand but came to a complete stop at the visual studio part.....help.....
would be really nice to have an updated version of this video with more stable and accurate solution.. as I see in comments there could be issues with voltage more that 16.5V and accuracy could be better.. and math could be done in esp :) if you have some updates on this topics, please share.. thanks! :)
From a tutorial perspective, it makes sense to start with a new espHome instance. Nicely done! Since your actual goal might be to monitor power in the same area as the two DS18B20 sensors, will ESPHome let you include 1-wire devices, analog, and maybe even other other digital inputs (and outputs?) to the same node?
sorry brother but at 6:19: this is NOT a sensor but voltage divider - the sensor is in your ESP. Something is crazy with 25V max vs 3.3V max - it is probably dividing 25V into 5V for Arduino or so. With regards to accuracy of ESP ADC: it is very non-linear. It is the best (probably) to provide many ranges if you are about to measure huge range of values. And embed them into ESPHome (it is also described there on ESPHome web) rather than in HA. My sensors send the data to HA every 3s from power supply - 1 minute for potential overvoltage can be too long to act accordingly. Also, for power supply adding ampere meters is also good - from these 2 you can easily calculate Watts. Btw: with this voltage divider, if your power supply goes to 30V, you will get on the A0 .. the killer voltage ;-) (30V/5/3.3=1.8V on pin that accepts 1V)
on the esp8266 the max voltage on ADC is 1V, but on Wemos D1 is 3.3 since it has a voltage divider already on board. I agree with you on non-linearity accuracy, also because you're reading a value that from the source is voltage-divided by the "sensor" in the video, scaled at 5V and again voltage-divided by the onboard resistors on Wemos D1....accuracy would be far from acceptable.
@@DavideFoschi that is what I meant: 5x divider on the breakout and 3.3x inside D1 = that gives 16.5x so you are good only from 0V to 16.5V with this breakout.
All good points. This isn't lab grade equipment but gives me a general indication of what is going on. Also, I'm aware that the board will blow up if that power supply goes rogue. I probably need to up my reporting resolution as I'm at 30 seconds currently. This all depends on use case of course.
@@dinodelfavero Since I have had a couple of power supply failures, I have checked the ESP against the volt meter when the values go wonky on the power supply. It has been very close. I am satisfied that this solution works for what I am using it for. If you want lab grade readings, I might not rely on it but I don't know that my cheapo volt meter would stand up in a very strict lab environment. I used to work in a world in which equipment was often sent off for calibration. For home use, we don't necessarily need that. --This is a long answer to say yes, it appears to be accurate enough.
@@mostlychris (I earlier included a link so apparently my initial comment was purged) You essentially already have this tester; connecting a board with a USBUART chip to a host with appropriate driver installed should indicate in device manager or relevant host log whether the data circuit (and any required power) is completed by recognising the device.
Another good video. I know you use the Empora energy monitor, but would you consider doing a video about an energy monitor with an esp8266 and clamp on sensors?
Thanks for the video. I tried doing this with an ESP32-C3 board to monitor the voltage of 4 batteries. The ESP32-C3 has 5 ADC inputs so I used 4 voltage sensors modules connected to a 4 ADC inputs on the ESP32-C3 board, but I am getting erratic voltage readings. Some voltage sensors will read 0v with nothing connected, while others read 0.8200v without being connected to anything. If only one sensor is connected to the board, the readings are ok. But when all are connected, the readings are completely off. Would appreciate if someone could share the way to monitor multiple voltage sources with one ESP board.
Chris I finally got this going and got the template to report correctly. Question 1 is how to get the corrected voltage to report to the HA dashboard. Question 2 is how to set a voltage trigger to alert me if the voltage goes to some preset voltage (ie 11 volts) Thanks Steve
Hey Stephen. Waiting on your message via Discord. You need to adjust the values via a template to get the multiplier. Keep in mind that this is not for precision work, but a general voltage reading. That is probably true of most low end consumer voltage devices. I thought I covered the template in this video but I've made more than one, so maybe it wasn't in this one. Chat with me on Discord to continue.
The Amazon link to the esp32 shows a different board than the one in the video. And it is a more expensive one. Is this really the correct one for the project?
There are many versions of the ESP board. That one looks like it will work. Prices will vary based on any number of factors so it is not surprising that the price is different.
Why you didn’t just change it on filter instead 3.3 to 15.88 and don’t have to use the template!! Just curious, maybe is something I am not seeing 🤷🏻♂️
I would think so. Depends on the voltage of the battery though. Be careful not to blow up the sensor. I have heard of people building vehicle battery monitoring setups using ESP boards. Those are lead acid and at least in the US, are 12v.
Yes.. and that is terrible. If I were smart, once I found one that was a data+pwer, I'd label it. For some reason, I have to go through my cable pile each time to find one that works. smh.
Dear, the problem is: Some of your USB cables are power Only, they use 2 wires inside the cable only to power supply 5V dc and 0V. For the first programming via ESPhome, you need a Data USB cable, these cables are built with 4 wires inside ( 2 power and 2 Data ). If the ESP32 is powered with the USB cable but no any new devices are detected on the PC, this is... Regards
@@mostlychris Here is a snipet of my current project on the ESP32 used to monitor it's battery voltage. Keep in mind the max input on the esp32 is 3.3v. rawbatterylevel = analogRead(VOLTAGE_PIN); // GPIO34 Serial.print("The raw battery level is "); Serial.println(rawbatterylevel); batterylevel = (rawbatterylevel/4095) * 5.25; //adjust the calibration factor to match VOM readings of battery. Serial.print("The battery supply voltage is "); Serial.print(batterylevel); Serial.println(" Volts");
Excellent. I'll try that directly on the ESP. Do you have this as a code snippet somewhere as YT doesn't allow formatting so it's hard to read spacing, etc.
@@mostlychris I put it this question here too since I thought you might not look at that old one anymore. :) What I am trying to do is connect to my Eve (Elgato) Motion sensor and read out the data. I am able to connect. I am able to read 'stuff' out but it is just garbage. I understand that it might be binary data but I can seem to figure out how to make that data meaningful. Thanks. :)
@@EricOnRUclips It might be encrypted. Depending on the firmware, some of the ESP stuff needs to have the key specified. This depends on the device--not all devices can be read using these methods. A quick search shows this to be able to be used with a homekit controller, but that adds more stuff in line with it. Hoepfully someone else knows. You might also ask this in the general Discord channel on my Discord server.
Some of your USB cables aren't working because they probably only have wires in them for power, no data line. To my understanding there needs to be power AND data wires present in order to flash.
If I had a dollar for every comment on the cables, lol! It is has been brought up a bunch in comments that there is a difference in these cables. I need a good way to test them and verify which is data and which is just power.
code is on this video - you don't code when you use ESPHome apart from what you saw inside ESPHome - that add-on is supposed to reduce code to the minimum ;-)
So I've heard. I want to do this same thing without that board just for comparison. The board does give a nice convenient package to house the connectors and resistors, though.
Your power supply likely wont creep up , it will fail quickly. You wont have time to react. A better solution would be a crowbar on the output. It my nickel. Nice vid though
Good point. I've thought of that and need to invest in something like a crowbar to protect my equipment--or just get a more expensive supply. So far, this one has been holding it's own when running the radio on high power (fingers crossed!).
Very good tutorial. I added a few extra lines in the template for the esp config in case anyone is interested. It also removes the need for an extra sensor in HA config. Just adjust the lambda value to suit.
sensor:
- platform: adc
pin: A0
name: "Your choice"
unit_of_measurement: "Volts"
icon: "mdi:car-battery"
accuracy_decimals: 1
update_interval: 60s
filters:
- multiply: 3.3
- lambda: return (x - 0.06)*5;
I like how you're straight to the point, no cheesy jokes, no cringe "I'm the ultimate dad" vibes, just very technical and to the point yet slow and clear enough to follow and not get lost. Thanks for your quality content!
Thanks! I might have slipped in a joke or two on occasion in my videos, but it isn't a lot.
You can eliminate the need for a template sensor entirely by adding a lambda section to the filters and doing the adjustment calculation in there.
filters:
- multiply: 3.3
- lambda: return (x-0.08)*5;
Good tip. Thanks!
I did some math and for my sensor this is the best value
filters:
- multiply: 15.74838231
Its possible that some sensors have diffrent numbers but you can always try it out!
Thank you for this video, Very helpful to get started. I am using this voltage monitor for my 24V off-grid battery bank. My ESP32 ADC needs to work between about 100mV and 900mV. Expecting voltages of up to 30V, I added a 1k resistor to the voltage divider output (just soldered it between A0 and GND because that was easier than messing with the smd resistors on the "voltage sensor module". Next time, I won't use the voltage sensor module, but rather build a matching voltage divider immediately.
It is nice to see someone creating an example using HA, ESPhome and, finally the automation. There is a real need for basic training in the areas discussed. We have enough pages or websites that explain functionality at the knowledgable programmer level.
Thanks for the comment!
Instead of performing the additional calculations, I would just change the filter from 3.3 to 15.8 then the ESP32 would report the actual PSU voltage directly back to HA.
my idear too. much easer
Good idea. I'm gonna try that. Leave it to me to overcomplicate things.
That is what I thought as well. Why not just do all the match in the esp8366? Chris, did you try it? Did it work doing the math in the esp8266?
Actually, to make it clearer I'd have used multiple filters in esphome too, one for the d1mini voltage divider, one for the 0.14 offset and then a multiply filter for the external board. Then you wouldn't need to calculate their combination. Easier to tweak later if you change the circuit in some way (or replace the d1mini with another one that requires a slightly different tweaking value).
@@greggotcher9336 I know it can be done but I haven't done it...yet. I got an example and will try it out.
Thank you. This is a good walkthrough and bonus Graffana intro for me!
I think I learned more about how to build things with ESPHome and Home Assistant in this video than in many others. Not to mention it was well thought out and easy to follow. Now I'm off to set up a voltage monitor for a solar attic fan.
Long time subscriber Chris! I'm finally getting around to using this setup to monitor my vehicle batteries. Ordered the voltage dividers today. Thanks for the awesome videos man!!
Interesting video. One time no one could hear me on my radio. I bumped the knob on my power supply. I don't remember the voltage but it was very low. 🤣 I'm switched to 100% solar for all communication gear now though. I get voltage reports from my charge controller via modbus to MQTT with Tasmota now. Works great
I'm jealous. I would love to have solar. Also, I've never bumped anything to make it stop working, lol.
The voltage divider in the Wemos D1 is a pair of resistors, one below the actual ADC block and one towards the input which you now attach to the center of another pair of resistors, so one towards ground and one towards the voltage you want to measure, but ... the two resistors inside the Wemos are now in parallel with the external one to ground, so the total resistance is no longer what you thought your voltage divider would provide. Since the value inside the Wemos is known, you can better simply add a single resistor from the ADC pin of the Wemos to the voltage you want to measure, basically increasing the factor the new voltage divider created this way will use.
Thanks for the explanation. The fewer the parts, the better. Still got to get that initial input voltage < 3.x volts so as to not blow up the ESP. What do you recommend as a value for the resistor?
@@mostlychris I think you will want the data sheet and schematic for your exact boards components combined with some fairly simple math to answer this definitively.
@mostlychris - Thank you very much for this excellent tutorial. I learned a lot from your video, and then even more from the comments section.
@MisterkeTube - Your savvy input here launched me off into a bunch of research into the Wemos A0 architecture. You're right, it's probably more efficient to add a series resistor to A0 than to wire in another voltage divider. I'm looking at monitoring a 12VDC solar panel and ran the numbers for a safe Vmax. A 2 MΩ resistor soldered to A0 on the D1 voltage divider protects the Wemos to a Vmax of 23VDC. A 1.4 MΩ resistor protects the Wemos to a Vmax of 17VDC.
I'm adjusting just the multiplier value and not using the lambda or template. By the way, you can calculate the required multiplier in ESPhome by first setting it to 1.0, and then running it. Record the reported value, and divide your DVM actual reading by that reported value, and that is the multiplier you should set in ESPhome. For example, in one test I read 2.855VDC on my DVM, and ESPhome was reporting a value of 0.1143 with a multiplier of 1. So, 2.855/0.1143=24.97812773, and that is the value I put in ESPhome for the multiplier.
Running tests now on a variety of voltage levels with the 2 MΩ series resistor followed by a 1.4 MΩ series resistor and concordance in both look very suitable to my needs. Thanks again @mostlychris and all who commented with valuable detail!
If it's a linear power supply and the regulator fails, the output immediately jumps to 30 V - not gradually. There should be a crowbar protection circuit inside the PS that shorts the output on over voltage so that it blows the fuse before the connected load is damaged. Still nice to know voltage, especially for PS without a meter and for a PS mounted remotely where you wouldn't see the meter anyway!
I love the video and the work.! Thanks
That's what I get for buying a cheap(er) power supply. I sent the original one back that failed at 30v. My poor radio was sitting there making a ticking noise--thought I'd lost it. The replacement supply has been doing better. It will occasionally drop to 12 or so volts for a brief moment when under load. I've got that graphed so I can see it (I don't trust these supplies).
@@mostlychris what supply should I avoid buying next? 🙏
I don't want to name the supply I'm using without digging into it a bit further to determine if I caused the issue in the first place. I've got the supply in the attic where it gets to >100 F at times and I am running it a medium loading. It just might not be able to handle the heat. That's why it's important to me that I monitor heatsink temps and voltages.
Thanks for this tutorial!
Very good walk thru from start to finish! I have been experimenting with an ESP32 reading, LP sensor voltage, 18650 battery voltage and solar panel output and the esp wakes up, takes the readings, sends it via mqtt , and goes back to sleep. I am finding that the readings are not stable and I have been chasing the calibration factor. I have a little troubleshooting to do to track down the instability.
I believe I am going to feed it a known voltage and see how stable it reads it. It may be due to dipping supply voltage when it wakes up.
G6EJD does several very detailed videos on measuring voltages and using voltage dividers and the calibration math to use in your code.
Also, in the ESP technical specs, it notes that each chip will have a slightly different calibration requirement. Depending on your selection of resistance used in the dividers, the ESP output impedance can also change the results as it may load down the voltage since it is roughly 1.3meg that will be in parallel with R2. Some other tricks that can be utilized in your code is averaging. I use this with a flow sensor since it seems to be very erratic with my water pressure. I can also average it even more once I get the data in Node Red.
Thanks! Good notes and good tips. This video was just the basics and you are correct, calibration is needed to make it ready exactly what it should.
if you need or want to become confused you are doing a great job ! ;-)
21:04 in the automation you should not use state but instead use numerical state.
Now if your power suply goes from 13.9 to 14.1 your automation will not fire. With numerical state you can set a above or below value
Good point. Thanks for correcting me.
It's cool to see how you did this but in terms of protecting your radio you're probably better off with a crowbar circuit across the power supply that shunts out the PSU and pops the fuses. I built one a few years back using an SCR turned on by a zener diode. I wouldn't want to be relying on all the moving parts of micro controllers, WiFi and services like home assistant talking to a smart plug of some sort. There's going to be some lag there and by the time it's shut off the mains the radio might already be seeing a much higher voltage than your set point. A crowbar will be pretty much instant. Not as fancy in terms of graphing and alerting but that kind of thing should always come second in scenarios like this. It's good to know about it but if your radio is already fried it's too late
About your USB cables not working:. As crazy as it sounds some cables have power and data, some have data only and some have power only. The last two are generally provided with some CE product like a portable fan that doesn't need data, just power to recharge the battery or just data to an already powered device. It seems like a dumb way to cut costs but if you're making thousands of devices every penny adds up.
Figured as much. Haven't been able to tell by looking at them which is which. I need to test them and keep them separate.
If the power supply goes up to 30 volts, I don't know if it will blow up whatever you have it supplying power to, but I think it could blow up the ESP32, even after going through the voltage divider. 30 V / 5 = 6 V > 3.3 V. You may want to change your setup so that the Tasmota switch turns the power supply off automatically as soon as it gets to 3.3 V * 5 = 16.5 V.
Good point. Thanks for the feedback.
I built the ESP 8266 with the voltage divider but cannot find the sensors.yaml file in the visual studio code. Everything works perfectly and i understand but came to a complete stop at the visual studio part.....help.....
Great video
May i know which video editor you used for recording screen together with your face cam?
What do I need to add to this set to measure a 24v battery whose value reaches up to 29v?
would be really nice to have an updated version of this video with more stable and accurate solution.. as I see in comments there could be issues with voltage more that 16.5V and accuracy could be better.. and math could be done in esp :) if you have some updates on this topics, please share.. thanks! :)
Thanks for the feedback.
how many of this sensors can be connected to a one ESP to measure three different power sources?
From a tutorial perspective, it makes sense to start with a new espHome instance. Nicely done! Since your actual goal might be to monitor power in the same area as the two DS18B20 sensors, will ESPHome let you include 1-wire devices, analog, and maybe even other other digital inputs (and outputs?) to the same node?
I believe it will. I have an ESP doing just that.
sorry brother but at 6:19: this is NOT a sensor but voltage divider - the sensor is in your ESP. Something is crazy with 25V max vs 3.3V max - it is probably dividing 25V into 5V for Arduino or so. With regards to accuracy of ESP ADC: it is very non-linear. It is the best (probably) to provide many ranges if you are about to measure huge range of values. And embed them into ESPHome (it is also described there on ESPHome web) rather than in HA.
My sensors send the data to HA every 3s from power supply - 1 minute for potential overvoltage can be too long to act accordingly.
Also, for power supply adding ampere meters is also good - from these 2 you can easily calculate Watts.
Btw: with this voltage divider, if your power supply goes to 30V, you will get on the A0 .. the killer voltage ;-) (30V/5/3.3=1.8V on pin that accepts 1V)
on the esp8266 the max voltage on ADC is 1V, but on Wemos D1 is 3.3 since it has a voltage divider already on board.
I agree with you on non-linearity accuracy, also because you're reading a value that from the source is voltage-divided by the "sensor" in the video, scaled at 5V and again voltage-divided by the onboard resistors on Wemos D1....accuracy would be far from acceptable.
@@DavideFoschi that is what I meant: 5x divider on the breakout and 3.3x inside D1 = that gives 16.5x so you are good only from 0V to 16.5V with this breakout.
All good points. This isn't lab grade equipment but gives me a general indication of what is going on. Also, I'm aware that the board will blow up if that power supply goes rogue. I probably need to up my reporting resolution as I'm at 30 seconds currently. This all depends on use case of course.
@@mostlychris but you have not checked the accuracy of the ADC in a range? you check only at 13.9V, it's usable?
@@dinodelfavero Since I have had a couple of power supply failures, I have checked the ESP against the volt meter when the values go wonky on the power supply. It has been very close. I am satisfied that this solution works for what I am using it for. If you want lab grade readings, I might not rely on it but I don't know that my cheapo volt meter would stand up in a very strict lab environment. I used to work in a world in which equipment was often sent off for calibration. For home use, we don't necessarily need that. --This is a long answer to say yes, it appears to be accurate enough.
Some cheaper USB cables that come packaged with devices for charging don’t actually include the data lines, just power.
I need a tester to figure out which of my many cables are data and which are power only. That would sure save me some time.
@@mostlychris (I earlier included a link so apparently my initial comment was purged)
You essentially already have this tester; connecting a board with a USBUART chip to a host with appropriate driver installed should indicate in device manager or relevant host log whether the data circuit (and any required power) is completed by recognising the device.
@@dmackle3849 Oh cool. I have that so yeah, I need to pull all my cables and test, then store them so I know in the future. Thanks for the tip!
Another good video. I know you use the Empora energy monitor, but would you consider doing a video about an energy monitor with an esp8266 and clamp on sensors?
Maybe. Do you have one?
Thanks for the video. I tried doing this with an ESP32-C3 board to monitor the voltage of 4 batteries. The ESP32-C3 has 5 ADC inputs so I used 4 voltage sensors modules connected to a 4 ADC inputs on the ESP32-C3 board, but I am getting erratic voltage readings. Some voltage sensors will read 0v with nothing connected, while others read 0.8200v without being connected to anything. If only one sensor is connected to the board, the readings are ok. But when all are connected, the readings are completely off. Would appreciate if someone could share the way to monitor multiple voltage sources with one ESP board.
Chris I finally got this going and got the template to report correctly. Question 1 is how to get the corrected voltage to report to the HA dashboard. Question 2 is how to set a voltage trigger to alert me if the voltage goes to some preset voltage (ie 11 volts)
Thanks Steve
Hey Stephen. Waiting on your message via Discord. You need to adjust the values via a template to get the multiplier. Keep in mind that this is not for precision work, but a general voltage reading. That is probably true of most low end consumer voltage devices. I thought I covered the template in this video but I've made more than one, so maybe it wasn't in this one. Chat with me on Discord to continue.
How to monitor lifepo4 12v from esphome? What should I multiply to get the correct value?
Many USB cables simply do not work because you generally do not use data pairs for charging
The Amazon link to the esp32 shows a different board than the one in the video. And it is a more expensive one. Is this really the correct one for the project?
There are many versions of the ESP board. That one looks like it will work. Prices will vary based on any number of factors so it is not surprising that the price is different.
I dont understad where and how create sensors.yaml to intergrate {{ ((states('sensor.voltage_sensor') | float ) * 18.2 ) | round(2) }}
Can this voltage sensor board handle low-voltage AC like 12VAC ?
I‘m also interested in this use case.
Why you didn’t just change it on filter instead 3.3 to 15.88 and don’t have to use the template!! Just curious, maybe is something I am not seeing 🤷🏻♂️
Fabulous this is what I was looking for. Can I use this circuit to monitor the voltages of ups battery which is powered by of type Lead acid battery
I would think so. Depends on the voltage of the battery though. Be careful not to blow up the sensor. I have heard of people building vehicle battery monitoring setups using ESP boards. Those are lead acid and at least in the US, are 12v.
Am I mistaken or why you did not connect the Voltage Sensor/Divider you do not connect to the power supply of 5v??
Not sure I understand the question.
@@mostlychris What I meant is why you do not need to connect the + on the voltage divider to the VCC 5v on the D1 Wemo and still works?
Arent some usb cables data/power...and others only power? Missing data pathways?
Yes.. and that is terrible. If I were smart, once I found one that was a data+pwer, I'd label it. For some reason, I have to go through my cable pile each time to find one that works. smh.
Dear, the problem is: Some of your USB cables are power Only, they use 2 wires inside the cable only to power supply 5V dc and 0V. For the first programming via ESPhome, you need a Data USB cable, these cables are built with 4 wires inside ( 2 power and 2 Data ). If the ESP32 is powered with the USB cable but no any new devices are detected on the PC, this is... Regards
I have since figured this out. One cable is not like the other cables....
You can add a multiplication factor on the ESP32 (even non linear things are possible)
Example? I'd love to do the math on the ESP and not have to create a template sensor.
@@mostlychris Here is a snipet of my current project on the ESP32 used to monitor it's battery voltage. Keep in mind the max input on the esp32 is 3.3v.
rawbatterylevel = analogRead(VOLTAGE_PIN); // GPIO34
Serial.print("The raw battery level is ");
Serial.println(rawbatterylevel);
batterylevel = (rawbatterylevel/4095) * 5.25; //adjust the calibration factor to match VOM readings of battery.
Serial.print("The battery supply voltage is ");
Serial.print(batterylevel);
Serial.println(" Volts");
Excellent. I'll try that directly on the ESP. Do you have this as a code snippet somewhere as YT doesn't allow formatting so it's hard to read spacing, etc.
@@mostlychris I do not, I would be glad to email it you.
Some USB cables only have power wires, no data wires, thats why they don't work.
Absolutely correct, I've been caught out by this a few times also
I've had a couple of comments on this very thing. I wish it was easy to identify the cables.
Hi Chris, can you, please, share with me/us the config of Home Feed card I saw on your dashboard? Thanks
Vali. You can find it here: github.com/mostlychris/homeassistant
@@mostlychris Thanks a lot Chris
Since you show videos using the ESP32, I was wondering if you could show how to use BLE instead of wifi. Would you please do a video for that? thanks.
BLE as in mesh? What specific aspect of BLE are you looking for?
@@mostlychris I put it this question here too since I thought you might not look at that old one anymore. :) What I am trying to do is connect to my Eve (Elgato) Motion sensor and read out the data. I am able to connect. I am able to read 'stuff' out but it is just garbage. I understand that it might be binary data but I can seem to figure out how to make that data meaningful. Thanks. :)
@@EricOnRUclips It might be encrypted. Depending on the firmware, some of the ESP stuff needs to have the key specified. This depends on the device--not all devices can be read using these methods. A quick search shows this to be able to be used with a homekit controller, but that adds more stuff in line with it. Hoepfully someone else knows. You might also ask this in the general Discord channel on my Discord server.
What did i do wrong in my tamplate code ?
{{ (((states('sensor.scooter_voltage') |float -0.14 ) • 5) | round(4)) }}
Do you get an error? If so, what is that error?
Some of your USB cables aren't working because they probably only have wires in them for power, no data line. To my understanding there needs to be power AND data wires present in order to flash.
Thanks Darren. I've heard that a lot lately. Maybe I should make a video to educate myself on these cables, lol.
Please make video on hx711+esphome
What use case do you have for the hx711?
Same cable is just for powering. No data. The cable needs to be for power AND data.
I'm getting this response a lot! I should have known this.
Charge vs Sync cable... one will and one wont perform data transfer
If I had a dollar for every comment on the cables, lol! It is has been brought up a bunch in comments that there is a difference in these cables. I need a good way to test them and verify which is data and which is just power.
code ?
code is on this video - you don't code when you use ESPHome apart from what you saw inside ESPHome - that add-on is supposed to reduce code to the minimum ;-)
Look at the sensors.yaml file here: github.com/mostlychris/homeassistant
That breakout board is a rip off it's just resistors in parallel. Believe me I've got a pile of them.
So I've heard. I want to do this same thing without that board just for comparison. The board does give a nice convenient package to house the connectors and resistors, though.
Your power supply likely wont creep up , it will fail quickly. You wont have time to react. A better solution would be a crowbar on the output. It my nickel. Nice vid though
Good point. I've thought of that and need to invest in something like a crowbar to protect my equipment--or just get a more expensive supply. So far, this one has been holding it's own when running the radio on high power (fingers crossed!).