News:

Let's find out together what makes a PIC Tick!

Main Menu

Software i2c in Positron

Started by TimB, Mar 07, 2023, 10:51 AM

Previous topic - Next topic

tolyan249

#40
I have the same situation. I received an MLX90614 sensor, and when I scan the address=5A, it doesn't show the temperature with this address. However, when I set the address to =0, everything works as expected.


This was given to me by GPTCHAT

The situation where an MLX0614 sensor starts showing temperature readings when a request is sent to address 0 is indeed encountered and typically indicates a configuration or communication issue.


Why this happens

By default, the MLX0614 is configured with the address 0x5A (90 in decimal). Address 0 in the I2C protocol is not used for slave devices – it's a special "General Call" address that is typically employed for addressing the bus master's own internal registers (e.g., for reading/writing configuration) or for broadcasting to all devices that support it.


When you send a request with address 0, the sensor reacts in a special way: it ignores its own configured device address and begins transmitting data. As a result, you might actually receive a correct temperature value.

Frizie

Remember, the 0x5A is the 7-bit slave address, so it will need to be shifted left 1 bit, because bit-0 of the slave address is the read or write bit.

Something like:

Symbol cMLX_Address = ($5A << 1)

(See post #35 from Les)
Ohm sweet Ohm | www.picbasic.nl

Henk57

Yes Frizzie.


0101 1010 5A
1011 0100 B4
1011 0101 B5

            Select Case model
            Case 1                 
                    Str printArray = "Dig.Pb"
                      If Channel1 < 128 Then     
                          teller1 = teller1 + 1
                          Channel1 = Channel1 << 1
                      EndIf
                HBusOut $42,[$12,Channel1] ' Output naar 8 uitgangen


This piece of code I was looking for 12 years ago, almost ages.


tolyan249

#43
(I2C_addr << 1)

Yes, I'm doing it, it works fine with other sensors like LM75, the address is scanned and the temperature is obtained with this address, but with the MLX0614 sensor, it only works with address=0, and I also found that the low byte is read first, followed by the high byte, and the temperature is displayed correctly. However, if the high byte is read first and then the low byte, the temperature values are incorrect.

 I'm still unsure of the reason.

tolyan249

I found the reason in my code. When I scan the module, I find the address, but I don't assign it to the I2C_addr variable. I forced the address to be 5A, and it worked. Then I found an error, fixed it, and everything works. When I scan the address, I get it and it works with it, displaying the temperature.