I2C sample code in IoT demo not working with HTU21D

Vishwa_125
Posts: 1
Joined: Thu Feb 04, 2016 10:53 am

I2C sample code in IoT demo not working with HTU21D

Postby Vishwa_125 » Thu Feb 04, 2016 11:02 am

Hello,

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();

Who is online

Users browsing this forum: No registered users and 17 guests