Reputation: 21
this will be my first time asking a question. First of all, I am just a programmer, I don't know much about electronics.
I am trying to communicate with a MCP9880 temeprature sensor through i2c, but I am getting weird readings in between 'real' ones, output looks like this (in decimal):
0 29
255 255
128 0
0 29
255 255
255 255
Here the 'real' lecture would be 128 0, but normally I get either 0xff or 0x1D as you can see. This happens reading any register. Also, other i2c devices are working as expected, but the many MCP9808 that we tried keep the same behaviour. Here's the code I use to read the temperature register (in bascom, I'm forced to use it :( )
I2cstart 'StartI2C.
I2cwbyte Wr_sensor1 'MCP9808 addr.
I2cwbyte &H05 'Temperature register
I2cstart 'StartsI2C.
I2cwbyte Rd_sensor1 'MCP9808 addr
I2crbyte Temp_1621 , Ack 'Read first byte
I2crbyte Temp_1621_dec , Nack 'Read second byte
I2cstop
The addresses are checked and correct, and I really think the code should be right. I keep saying this is an electronics issue, but keep saying they checked and everything is allright.
Thanks in advance.
PS: Here's a link to the datasheet http://ww1.microchip.com/downloads/en/DeviceDoc/25095A.pdf
Upvotes: 2
Views: 259
Reputation: 21
Ok, I found the answer. Doing further tests, the device acted as if it resetted itself all the time. I suspected tiny voltage drops, so I researched the topic, plugged a capacitor, and that was it!
I hope this can help somebody :)
Upvotes: 0