logo elektroda
logo elektroda
X
logo elektroda

Remote battery voltage monitoring system (ESP8266 and INA219)

dktr 7383 29
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • DIY electronic device for monitoring battery voltage, built with ESP8266 and INA219, housed in a plastic box.

    An acquaintance asked me to assemble "something" that would give him notification when the battery in his very little used car discharges too much.
    For a quick thought I came up with ESP8266 + ina219 and a piece of code that would take a measurement, send it to the server and put the system to sleep for a set period of time in order to start the cycle again after waking up. The board is my universal board for the ESP8266 and additionally a module with the INA219 chip which I use to measure voltage.
    The whole thing goes to my server where the data is collected, visualised and, if necessary, a notification is sent by a simple SMS through the phone which I have connected to the server and makes for a universal SMS gateway.
    The device fit into a box from some small oled display, 2 banana sockets and a 300mA fuse were installed and I prepared wires with crocodiles to plug it straight into the battery. The unit draws about 6 mA when asleep, which can be greatly improved by using another linear stabiliser instead of the 1117 and go down to about 90 μA. When sending a measurement it draws about 200 mA for 300 ms. Quite by the way there is a DS18b20 on the board.

    This is where you can look at the measurement results


    I forgot to add and have already added. The program code that is in the ESP8266, you can take a look at how the wakeup and sending data to the server is implemented.


    Graph showing car battery voltage over time.

    Cool? Ranking DIY
    About Author
    dktr
    Level 25  
    Offline 
    dktr wrote 858 posts with rating 632, helped 42 times. Live in city Ostróda. Been with us since 2003 year.
  • ADVERTISEMENT
  • #2 21089575
    gulson
    System Administrator
    Thanks for sharing the solution! All in all, if someone has 20 vintage cars it could be an interesting solution to keep an eye on the batteries. One, it's about not driving the battery to sulphation and two, so that our vintage is always ready to provide us with fun. All in all, an interesting idea for a startup ;)
    I'll send a small gift if you specify a Parcel Post.
  • #3 21089581
    xury
    Automation specialist
    This can be done on an ADC and a high-impedance divider without the INA219. If it's just a matter of measuring voltage.
    Although the ESP8266 has an ADC max of 1V.
  • #4 21089584
    dktr
    Level 25  
    You can, but that ADC in the esp8266 is kind of lame, it gives quite a spread of measurements, I tested. The INA219 is cheap and quite effective.
  • #5 21089597
    xury
    Automation specialist
    Obvious. The thing with ADC already is that it can give scattered results. This is why filtering ala ski jumping scores is used. You take a number of measurements, the extreme ones you discard the middle ones you add up and divide by the number. The INA219 is also cool and easy to implement.
  • ADVERTISEMENT
  • #6 21089687
    khoam
    Level 42  
    dktr wrote:
    Maybe, but that ADC in the esp8266 is kind of lame

    Without a proper "de-noise" circuit at the input, the ADC in the ESP8266 isn't very suitable for anything. The choice of the INA219 was, in my opinion, the right one.
  • #7 21089708
    jarekgol
    Level 39  
    This Ina can measure voltage?
  • ADVERTISEMENT
  • #8 21089726
    dktr
    Level 25  
    Yes, up to 26 volts with pretty good precision.
  • ADVERTISEMENT
  • #10 21090127
    dktr
    Level 25  
    Yes, it measures against digital earth. It can work in both directions, it will then indicate negative current.
  • #11 21090332
    sq3evp
    Level 37  
    Cool thing, but I wonder if it is better than the ready-made ones that connect after BT?

    I read the description carefully and I think that the idea more than interesting, I understand that the sleeping times can be adjusted - in total I have a similar situation and it could solve my problem. I also have such a car, I monitor the battery, but with this module I could sleep much longer.
    The ones I mentioned measure only the voltage - here I think a voltage measurement would be sufficient. Are there any modules without current measurement too?

    As far as I can see in the code there is WiFi support ( void connectToWifi ). - a lot of work is involved in implementing support for a GSM module doing the same thing, i.e. sending data to a server?
  • #12 21090375
    dktr
    Level 25  
    Quote:
    As far as I can see in the code there is support for WiFi (void connectToWifi) - a lot of work is involved in implementing support for a GSM module doing the same thing, i.e. sending data to the server?



    I think there should be no problem, I myself have not yet used mobile networks, mainly wifi, radio 433 or there lora 868. Probably a little increase in power consumption and you have to somehow sensibly put the mobile communication module to sleep so that after waking up quite quickly registers in the network and set up a connection to the Internet.

    The system in the thread connects to the AP ubnt-ac-m which is installed on a mast that is above the roof of the house, is about 200 m away and there is still quite a large margin of signal, correct transmission in this location is even at a signal of -86 dBm.
    It works as you write, every time you send a query to the server where the results of the measurements from INA and dallas are, it returns a reply in which is the time for which it should go to sleep and that's it.
  • #13 21090419
    sq3evp
    Level 37  
    dktr wrote:
    It works as you write, every time you send a query to the server in which there are measurement results from INA and dallas it returns a response in which is the time for which it should go to sleep and that's it.
    Thanks for the info - I will look, look, maybe someone has something similar implemented. Fact - the GSM module also needs to be put to sleep so it doesn't finish off the monitored battery :) .
  • #14 21090692
    jarekgol
    Level 39  
    @sq3evp after sleep, you may have a long time (and power consumption for communications) to log back on to the network. As you try this, do some research on how long it's even worth turning the modem off for, or adopt an algorithm of only sending a packet/notification in 'critical' states. Well, and certainly the modem gouges me if there's no GPRS connection set up, I've seen it play itself. But I have mains power, so I'm not worried.
  • #15 21090747
    lukiiiii
    Level 29  
    Is it possible to convert this so that measurements are sent to thingspeak instead of the server? And then display on the phone using a widget.
  • #16 21090749
    dktr
    Level 25  
    It can be done, just rework the URL line
  • #17 21090803
    PiotrSołtys
    Level 12  
    I was also thinking of doing something similar but with current measurement. You'd have to make a system that works for a long time that wouldn't discharge the battery by itself. And think what to do in a situation when someone starts the car and we measure mA :) Such a system would not say what draws more current, but some indication would already be there. In my case, for example, as it turned out, the boot light was not switching off.
  • #18 21090941
    liske1
    Level 12  
    Thank you so much for sharing this project. I currently wanted to do a similar project.
  • #19 21091135
    mariomario
    Level 18  
    I am also thinking about a similar project but on an ESP32 C3 with Supla ( https://gui-generic-builder.supla.io/ ) uploaded and sending measurements to the free Supla server. The ESP32 C3 has a more powerful antenna and higher sensitivity than the ESP8266 seen above in the pictures.
    ESP32 C3 module with pin layout

    only I don't think I can do without modifying the Supla software to make the ESP32 C3 wake up only every e.g. 1h and only send the result to the server every hour if it connects to a WiFi network (more often not needed). Alternatively, some external hardware watchdog that turns on the power for the ESP32 C3 every hour for say 1min just for a measurement. The ESP32 C3 also supposedly has a much better ADC (12bit) than the ESP8266 https://docs.espressif.com/projects/esp-idf/e....4/esp32c3/api-reference/peripherals/adc.html , and the price of this ESP32 C3 module visible in the photo on a well-known portal from majfrends is today about ~7zł/unit.
    The advantage is a ready-made Supla application and the possibility of setting up notifications, e.g. when the voltage on the battery drops below some sensible value....
  • #20 21092879
    sq3evp
    Level 37  
    I have found the module - confirm, the current measurement module has also appeared to me.
    Buy and run - wonder if I will succeed :) .
  • #21 21092896
    xury
    Automation specialist
    An interesting alternative solution is to combine an ESP8266 or ESP32 with a cheap PZEM 016 module and communicate over RS485 or with a slight modification of the PZEM via UART. I, for example, put an esp-01 inside the PZEM, desoldered the MAX485 and connected via pure UART. Simple communication via a few modbus registers. Using appropriate shunts you can measure currents up to 300A with voltages up to 300V dc.
    You can also make a meter for AC in a similar way by changing to PZEM 004t
  • #22 21093036
    jarekgol
    Level 39  
    Do these pzems have transmission opto-isolation? Which side do they feed from? And roughly how much did you buy for, as on allegro from a Chinese guy they pop up at 160£, on ali 40+
  • #23 21093084
    xury
    Automation specialist
    Yes they have transmission optoisolation. I bought for about £40 just from aliexpress.
  • #24 21097048
    acctr
    Level 38  
    If WiFi suits you then ok, but in general a GSM module, LoRa or some custom solution for 27 MHz and signalling presence in range and exit from it is more suitable for this.
    ESP with WiFi is more popular and pushed everywhere you can, but the battery in a car can discharge somewhere on a trip, left in a car park without wifi and then this is the most painful because the seemingly existing protection will detect a dangerously low voltage level, but the user will not get a notification.
    Helpful post? Buy me a coffee.
  • #25 21097109
    dktr
    Level 25  
    Yes wifi responds because it is used to monitor a very little used car that has a working battery. And not a dead battery that someone has additionally gone on a trip with :) .
  • #27 21097295
    jarekgol
    Level 39  
    Like gsm, it's convenient to have li-pol on board, cheap modems are made for that. How about throwing some small solar on the roof of the car to charge the monitor and not use the measured one, or making a charger that detects the engine running and then recharges from the car in case something happens? Of course, this will not work in a car kept in a dark garage and you still need to severely limit the amount of transmission.
  • #28 21097354
    acctr
    Level 38  
    The type of battery is a secondary issue, the GSM modem is there to send or receive an SMS or a data packet via GPRS, this is a few minutes of operation, then it can be put to sleep. If this is not the case and the monitor needs continuous communication then it is a bad design.

    Comprehending energy efficiency in today's electronics is fundamental and creating an algorithm to make this possible should be a basic skill of a person involved with new technologies.
    Helpful post? Buy me a coffee.
  • #29 21097394
    khoam
    Level 42  
    acctr wrote:
    Grasping energy efficiency in today's electronics is essential and creating an algorithm to enable this should be a core skill of a person involved with new technologies.

    It could be modelled on the Voyager satellite telecommunications module: Link
    Through the use of advanced technologies, the communications modules on the Voyager satellites enabled unprecedented communication with Earth from billions of kilometres away - that communication is still ongoing. The Voyager satellites used a coding system called Reed-Solomon, which allowed data transmission errors to be detected and corrected, with minimal power consumption.
  • #30 21097450
    acctr
    Level 38  
    khoam wrote:
    The Voyager satellites used a coding system called Reed-Solomon, which allowed the detection and correction of errors in data transmission, with minimal energy consumption.
    This is the correction coding currently widely used, inter alia in dvd.

    This is a correction coding currently widely used, e.g. in dvd, DVB, adsl, etc.
    It makes it possible to read distorted digital information, hence it is implemented at the lowest protocol layers.
    Using ready-made and available interfaces, it is rather unnecessary to worry about this.
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around a remote battery voltage monitoring system utilizing the ESP8266 microcontroller and the INA219 voltage/current sensor. The system is designed to notify users when a car battery discharges excessively, particularly for infrequently used vehicles. The proposed setup involves measuring battery voltage, sending data to a server, and utilizing a GSM module for SMS notifications. Participants discuss the effectiveness of the INA219 compared to the ESP8266's built-in ADC, emphasizing the importance of accurate voltage measurements and noise reduction. Alternatives such as using ESP32, PZEM modules, and GSM communication are also explored, along with considerations for power efficiency and potential solar charging solutions.
Summary generated by the language model.
ADVERTISEMENT