0

I have a mlx90614 sensor and I am interfacing it with raspberry pi 3 B+. I am using adafruit library python. Below is the code:

import Adafruit_GPIO.I2C as I2C

I2C.require_repeated_start()

class Melexis:

    def __init__(self, address=0x5A):
        self._i2c = I2C.Device(address,busnum=1)

    def readAmbient(self):
        return self._readTemp(0x06)

    def readObject1(self):
        return self._readTemp(0x07)

    def readObject2(self):
        return self._readTemp(0x08)

    def _readTemp(self, reg):
        temp = self._i2c.readS16(reg)
        print("raw temp {}".format(temp))
        temp = temp * .02 - 273.15
        return temp

sensor = Melexis()
t = sensor.readObject1()
a = sensor.readAmbient()
print("Object: {}C , Ambiant: {}C".format(round(t, 3), round(a, 3)))

Output:

raw temp 0
raw temp 0
Object: -273.15C , Ambiant: -273.15C

I have connected the sda pin of sensor to sda pin 3 of pi and scl pin of sensor to scl pin 5 of pi. vcc to 3.3v pin 1 and gnd to gnd. But I am not able to read the temperature values and it only shows 0*c. I have checked the output of ls /dev and I can see the i2c device connected as i2c-1. When I am doing i2cdetect -y 1, I am getting below output:

0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70: 70 71 72 73 74 75 76 77

As far as I know, this sensor has address 0x5a and I can see this in above output but still not able to understand above output. Can anyone please help me here. Thanks

0

The most likely problem is a wiring error.

When an i2cdetect probe shows all addresses it suggests SDA is being pulled to ground.

| improve this answer | |
  • Other thing to check - there are 3v and 5v versions. Not sure what gets reported if you under power it (would expect zilch TBH). – Andyroo Jun 3 at 1:45
  • If SDA is being pulled to ground, then what should I do, connect it to 3.3v – S Andrew Jun 3 at 1:57
  • @Andyroo tried with 5v, its still the same – S Andrew Jun 3 at 2:26
  • @SAndrew SDA is already being pulled to 3V3 (via an on-board resistor), The indication is that a faulty connection is pulling it to ground. A wrong wire, a solder splash, a faulty unit. You will need to investigate to find the source. – joan Jun 3 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.