I'm trying to read sensor data from an MLX90614 using an ATtiny85 to turn on some LEDs if the temperature is in the corresponding temperature range.
Right now, all my readings are under 0 degrees. I am very new to electronics so I suspect I am doing something wrong.
I am using the Digistump Attiny85 (this one). Currently I have the SCL and SDA ports directly plugged into the SCL/ SDA pins of the Attiny85. But this doesn't seem to work.
Please advise on how to get the Attiny85 to read the sensor data.
When you used the I2C scanner was your device detected. Oh wait, did you know there is a sketch to see if a I2C device can be found? My bad in assuming, sorry. Do an internet search using words "arduino i2c scanner" let us know what the scanner reports.
Adding a 4.7k pull up resistor seems to have done the trick.
However now the readings seem to be quite unreliable, the sensor sometimes reads what seems to be accurate other times it starts saying that its above 60 C and below 15 C in the next second. Any idea what is causing the flipping behavior?
This might not be the cause of the problem, but it is a problem for the logic of your code anyway. Let us suppose that the temperature is 0.5. It would satisfy both conditions to light up green and blue pins simultaneously.
It is not common practice to have LED's on the I2C lines. If you want to see LED's blinking at 400Khz then tap the lines with some sort of isolation circuit and then drive the LED's. Right now the LED's are a load on the I2C line. I2C was not designed to drive LED's.
If you insist on seeing LED's flash at 400Khz then expect issues.
I don't think that I connected the LEDs to the I2C lines though. I2C is using pin 0 and 2 (digispark board pins), LEDs are on pins 1, 3 and 4. Or am I misunderstanding?
Inserting the wires directly into the temperature sensor module did the trick. It was a faulty connection between the module and standoff pins after all.
Works both with and without the 4.7k pull up resistors.