logo elektroda
logo elektroda
X
logo elektroda

ESP8266 and ADE7953 in Shelly 2.5 - code/library for reading data

G.A.P.A 1857 9
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18707039
    G.A.P.A
    Level 16  
    Hi
    I'm looking for help on how to support the ADE7953 via the ESP8266.
    I want to use the Shelly 2.5 module which has the ADE7953 built in, and all I have been able to figure out are the pins, 12 I2C SDA, 14 I2C SCL, 16 ADE7953 IRQ.

    Does anyone have code or a library with which to make power, voltage and current readings?

    Alternatively, perhaps someone would like to undertake to write such a piece of code, I will make the module available to Shelly for testing.

    Maciek
  • ADVERTISEMENT
  • ADVERTISEMENT
  • Helpful post
    #4 18707115
    khoam
    Level 42  
    G.A.P.A wrote:
    I've tentatively found this, I'm now wondering how to integrate it into my Arduino code
    .
    1. you install into a new, separate library folder (e.g. named ADE7953) of the Arduino IDE the files: i2c_jk.h, i2c_jk.c, ADE7953_ESP82.h and ADE7953_ESP82.c
    2. in your program, you include the header file ADE7953_ESP82.h
    3) In setup() you initialise the ADE7953 via Ade7953_init()
    4. further at your discretion you use the Ade7953_getEnergy(), Ade7953_getCurrent(), Ade7953_getVoltage() and Ade7953_getActivePower() functions in your program.
    Rather simple ;) .
  • ADVERTISEMENT
  • #5 18707450
    G.A.P.A
    Level 16  
    Thanks, I'll give it a try and let you know :)
  • ADVERTISEMENT
  • #8 18710143
    G.A.P.A
    Level 16  
    The second library I also found, the reading doesn't work, and in addition something is sewn inside the library, as soon as the code is uploaded the relay is driven, so the library uses the pin it needs at some point.

    I will try with the first one.
  • Helpful post
    #9 18710939
    khoam
    Level 42  
    The default I2C pins for the ESP8266 are GPIO4 (SDA) and GPIO5 (SCL). If these are to be GPIO12 (SDA), GPIO14 (SCL) pins, then you need to slightly modify the file i2c_jk.c (first ADE7953_ESP8266 bilibrary). In place of the following lines:
    Code: C / C++
    Log in, to see the code
    enter:
    Code: C / C++
    Log in, to see the code
    .
    You do not need to call Wire.begin(12, 14) - this library does not use the Wire class.

    Added after 20 [minutes]:

    Each time before reading the voltage, current or power, call:
    Code: C / C++
    Log in, to see the code
    .
  • #10 18711255
    G.A.P.A
    Level 16  
    Hi,
    I sat down today and started looking at the I2C library because I suspected there was a problem with the communication since no value was being written to the variable.
    The place you specified was problematic, I only noticed that further down in the code the variables given during initialisation (i2c_master_gpio_init(12,14);) are substituted, up to a certain point they are hard typed (4 and 5).

    After the change everything laughs fine, I still need to scale the data - so far voltage is ok, current to scale.

    Thank you very much for your invaluable help !

Topic summary

The discussion revolves around integrating the ADE7953 energy monitoring chip with the ESP8266 microcontroller using the Shelly 2.5 module. The user seeks assistance in reading power, voltage, and current data via I2C communication. Several resources are shared, including a GitHub library specifically for ADE7953 with ESP8266 support. Instructions for setting up the library in the Arduino IDE are provided, detailing the necessary files and initialization functions. Users also discuss minor errors in the library files and suggest modifications to accommodate the specific GPIO pins used for I2C. The conversation highlights troubleshooting steps and adjustments made to ensure proper communication and data scaling.
Summary generated by the language model.
ADVERTISEMENT