ESP8266 Developer Zone The Official ESP8266 Forum 2016-02-04T11:02:30+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=1737 2016-02-04T11:02:30+08:00 2016-02-04T11:02:30+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1737&p=5670#p5670 <![CDATA[I2C sample code in IoT demo not working with HTU21D]]>
I'm trying to use the I2C sample code in IoT demo in the Non OS SDK to interface with HTU21D temperature and humidity sensor, however it does not seem to work i.e. the slave does not give me an ACK at all, how the same sensor work nicely when I flash Arduino software for ESP8266. The logic analyzer also shows that the slave is not giving me an acknowledgement. I have also taken care to see the hardware is proper and connections are alright.

This the code i have added in the user_init function

i2c_master_gpio_init();
//delay for 5ms
os_delay_us(5000);
i2c_master_start();
i2c_master_writeByte(0x80);
ack = i2c_master_checkAck();
if(ack)
os_printf("\r\n ack \r\n");
i2c_master_writeByte(0xFE);
ack = i2c_master_checkAck();
if(ack)
os_printf("\r\n ack \r\n");
i2c_master_stop();

Statistics: Posted by Vishwa_125 — Thu Feb 04, 2016 11:02 am


]]>