Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC18F2580 I2C interfacing with Si7005 sensor

Status
Not open for further replies.

DarqueChaton

New Member
Hello all! Please forgive me if this is in the wrong category, I am new here !

So I have a Si7005 sensor from Silicon Labs which is a humidity and temperature sensor that communicates with an I2C interface. I've been trying to at the very least retrieve the device ID from the register specified in the datasheet with little to no result.

When I attempt to retrieve the device ID, I get 255 value, which is not what is specified in the datasheet at all (I should be getting 80)

Here is a sample of the C code I wrote for it , I am attempting to get the value and printing it out on an NHD LCD I have setup . I am us CCS C Compiler and MPLAB X :

#include "projet.h"
#include "ecran.h"



void main (void)
{
int8_t devid=24;

Initialiser_Ecran(); // LCD initialisation
Effacer_Ecran(); // Erase LCD

while(1)
{

i2c_start();
i2c_write(0x40); // Slave adress
i2c_write(0x11); // Device ID Register
i2c_start();
i2c_write(0x41); // R/W bit set to READ
devid = i2c_read(1); // No ACK
i2c_stop();


Positionner_Curseur(1,1); // Place cursor
fprintf(Ecran, "Device ID = %U",devid); // Print


}

Here is a link to the datasheet of my sensor : **broken link removed**

Any help I can get is appreciated =) Thank you!
 
Although the datasheet states that the slave address is 0x40 it is in fact shifted left one place to allow for the read\write bit. Try using ox80 to write and 0x81 to read.

HTH,

Mike.
 
Although the datasheet states that the slave address is 0x40 it is in fact shifted left one place to allow for the read\write bit. Try using ox80 to write and 0x81 to read.

HTH,

Mike.

I tried , and it worked! I got the proper address returned! At first it didn't work but it is in fact a 0 for no ACK as Master and not a 1 . Thank you!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top