2 Replies Latest reply on Nov 13, 2015 11:31 AM by dethSwatch

    Ubilinux + libmraa i2c with AM2315 (Remote I/0 Error on write)


      I'm trying to read from the AM2315 temperature humidity sensor using libmraa. I'm using the intel edison breakout board, and I have followed example 4 from emutex multiplexing guide to configure IO18 + IO19 for i2c: EmutexLabs. Im getting the remote i/0 error errno when calling mraa_i2c_write.  Any help resolving this issue would be appreciated.


      I have connected 4.7K resistors between the SDA/SCL lines of the AM2315 sensor to 5V, and am using the I2C address 0x5C (note: the datasheet for the sensor uses 0xb8, but this appears to be a mistake as I've found several posts indicating that 5C is the correct address).


      I've initialized an i2c context on i2c-6 and have tried connecting the SCL/SDA pins of the sensor to A5/A4 as well as the SCL/SDA pins on the breakout board, but still get the remote i/0 error.


      Below is my main program which shows how Im initializing i2c-6. I'm using usleep to implement delay as this particular sensor has some wait times needed for temperature conversion and recovering from hibernation.


      int main(int argc, char** argv)



              mraa_i2c_context i2c;

              uint8_t addr = 0x5c; //Address of AM2315

              i2c = mraa_i2c_init(6);

              if (i2c == NULL) {

                      fprintf(stdout,"I2C failed init");

                      return 1;




               // askr stores the command

              // needed to ask for TEMP + Humidity


              uint8_t  askr[3];




              //Empty array to store result

              uint8_t  readr[8];




              //AM2315 hibernates to avoid

               // getting too hot.

              // Send it its address to wake it up




              //Ask for temp + humidity



              printf("ERRNO  %s\n", strerror(errno));

              usleep(10000); //sleep 10ms


              //READ TEMP + HUMIDITY




              //PRINT RESULT

              int i;





              return 0;


      Here is the output of i2c-detect on i2c-6


      i2cdetect -F 6 

      Functionalities implemented by /dev/i2c-6:

      I2C                              yes

      SMBus Quick Command              no

      SMBus Send Byte                  yes

      SMBus Receive Byte               yes

      SMBus Write Byte                 yes

      SMBus Read Byte                  yes

      SMBus Write Word                 yes

      SMBus Read Word                  yes

      SMBus Process Call               no

      SMBus Block Write                no

      SMBus Block Read                 no

      SMBus Block Process Call         no

      SMBus PEC                        no

      I2C Block Write                  yes

      I2C Block Read                   yes