Community
cancel
Showing results for 
Search instead for 
Did you mean: 
BWebe2
Beginner
969 Views

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: http://www.emutexlabs.com/project/215-intel-edison-gpio-pin-multiplexing-guide 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_init();

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;

}

mraa_i2c_frequency(i2c,MRAA_I2C_STD);

 

// askr stores the command

// needed to ask for TEMP + Humidity

uint8_t askr[3];

askr[0]=0x03;

askr[1]=0x00;

askr[2]=0x04;

 

//Empty array to store result

 

uint8_t readr[8];

bzero(readr,8);

 

//AM2315 hibernates to avoid

// getting too hot.

// Send it its address to wake it up

 

mraa_i2c_address(i2c,addr);

usleep(2000);

//Ask for temp + humidity

mraa_i2c_address(i2c,addr);

mraa_i2c_write(i2c,askr,3);

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

usleep(10000); //sleep 10ms

//READ TEMP + HUMIDITY

mraa_i2c_read(i2c,readr,8);

//PRINT RESULT

int i;

for(i=0;i<8;i++){</span>

fprintf(stdout,"R[%d]:%x\n",i,readr[i]);

}

mraa_i2c_stop(i2c);

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

2 Replies
Pablo_M_Intel
Employee
80 Views

Hi BenjiWeb,

The UbiLinux image is supported by the guys at EmutexLabs, so I would suggest you to post your question in their forums to get a more accurate answer.

Regards,

PabloM_Intel

bweve
New Contributor I
80 Views

Did you get this to work? I'm using the sample am2315 code provided in the UPM sensors library but getting impossible readings.

Was 2x4.7k resistors the right idea? I'm using 2x10k and clearly don't know if that's right. You're using 2x4.7k to get close to a total of 10k, right?

Also- if you do i2detect, does your am2315 show up?

Anything would help- my project's dead unless I get this working.

Reply