Accéder au contenu principal

Ina226 voltage and current sensor with esp8266 sending by MQTT

I needed to measure the voltage and the current of my lawn mower robot, as i have already an home automation system, the point was also to integrate these measures into Openhab and idealy using mqtt protocol.
The first idea that came up was to use a voltage divider to measure the voltage with the esp8266 analog pin.Nevertheless i found some contradictives infos about this, the accepted voltage was low between 1v and 2v depending on the sources. Unfortunately my battery is a 28,4v one.

With some search I found on banggood the ina226 sensor already soldered and ready to plug with an arduino. The question was; is this compatible with an esp8266 to allow an easy integration with my home automation system.
The answer is yes.


Thanks to the help of Shelvin blog here are the details:

Pinout for a NODEMCU:
Nodemcu/INA226
D1/SCL
D2/SDA
GND/GND
5V/VCC

IN+ & IN- correspond to the current meter for the tests, I linked them before the INA226 power so as to have some current measurements.
VBS is for voltage measurement for the tests I linked it to 3,3V of the nodemcu.



And now I'm able to publish the voltage, current and power from the ina226!




Note that the INA226 library below doesn't compile currently on nodemcu (this library is not necessary with the code above)
https://github.com/jarzebski/Arduino-INA226

Note also that the code has now been integrated to OpenMQTTGateway!


Commentaires

  1. hi, is it possible to make it work with esp01 module ? thanks

    RépondreSupprimer
  2. im quite newbie with this ... so, im not sure where to connect d1 and d0 on esp01 module. can u help me with that.

    RépondreSupprimer
  3. if you are new to this may I advise beginning by a development board like nodemcu, it will be easier for you

    RépondreSupprimer

Enregistrer un commentaire