Sensor Adafruit AM2315 over I2C on ESP8266 does not work

  1. My goal is: [Be able to read data from sensor using Mongoose-OS]
  2. My actions are: [describe your actions - code, commands, etc]
    . I download AM2315 library from Adafruit Git, then i followed the user guide to convert those source to Mongoose JS: https://github.com/adafruit/Adafruit_AM2315
    . After build libs successfully, i tried to write simple test like
    image
    . My mos.yml:
    image


. i tried to run “mos call I2C.Scan” and the result is:
image

  1. The result I see is: “Sensor not found”
  2. My expectation & question is: [describe your expectation and your question]
    I do not know what i was wrong. I am new to mongoose-os, so i do not know whether something while i convert from Adafruit Libs source to mongoose-os libs. Would anyone help me for this issue.

Thanks you in advance for any guidance !!!

P/s: Sorry for my best english !

Is the device 3.3V compatible?
If I2C.Scan doesn’t detect the device, try to connect the SDA, SCL lines the other way around.

Thanks for your help,

I connect wires following the guide on this link: https://github.com/adafruit/Adafruit_AM2315/blob/master/examples/am2315test/am2315test.ino

However, instead of connecting red wire to 5v, i connect to 3.3v, but when i run the example code on Arduino, esp8266 is still able to read data from sensor.

But when i tried to switch to mongoose-os, it said that could not found the sensor. I tried to run I2C.Scan, and it returns nothing.

I tried to debug, and see that it stuck here on the library

I do not understand why i works on Arduino, but could not work on mongoose-os, or i miss somethings.

Would you have any idea?

Thanks a lot for your help !!!

Try to add pull-up resistors (4.7-10k) on the I2C lines.

The delay(2) in the wake up sequence doesn’t make any sense. Move it after endTransmission.

Check the return value of the second endTransmission (0 is success).

Check the return value of requestFrom. If succes, it will return the number of bytes transferred, zero otherwise.

Thanks for your reply.

I tried to move delay(2) after endTransmission() and check the return value of the second endTransimission as you suggest, and it returns 4 :frowning: .

I connect the red wire to 3.3v, and i run code on Arduino, data returns properly, but i get error on mongoose. It is so strange

Would you have any idea ?

Many thanks !!!

P/s: Tomorrow, i will buy a pull up resistor to add it on I2C lines and try again as your suggestion

Today i add 10K resistor, the result is the same.

However, i tried to change delay(10) -> delay (600) like


And result is as picture,

I really do not understand what is the problem :frowning: . Would you have any ideas ?

Thanks in advance !!!

I could not find any solution :(. Does anyone have any ideas? Thanks so much !!!