I am working on weather station which uses several sensors and all are on I2C interface. I have dht22, bmp180 and few other sensors which are together works on I2C wireing. I also need to add one more sensor which is MLX90614.
First I am not able to test my new sensor with adafruit, sparkfun and master libraries as I am not getting any output on serial. I want to know how can I debug it.
Second I need to set up it with other I2C sensors but documentation says that is not possible and mlx need to stand alone in I2C interface. Let me know is there any way to solve this.
Remove everything else, and only connect the MLX90614.
Try the Adafruit library, try first the Library Manager to install them.
The MLX uses a SMBus and it needs a special condition of the bus to sleep. But does that mean it can't be used together with other sensors on a normal I2C bus ? I think it can when that special sleep condition is not used.
Which Arduino board do you use ?
Do you have a 5V or 3V MLX ?
Do you have a 5V or 3.3V I2C bus ? Do you have a level shifter ?
What are the other I2C sensors ?
Koepel:
Remove everything else, and only connect the MLX90614.
Try the Adafruit library, try first the Library Manager to install them.
The MLX uses a SMBus and it needs a special condition of the bus to sleep. But does that mean it can't be used together with other sensors on a normal I2C bus ? I think it can when that special sleep condition is not used.
Which Arduino board do you use ?
Do you have a 5V or 3V MLX ?
Do you have a 5V or 3.3V I2C bus ? Do you have a level shifter ?
What are the other I2C sensors ?
Which Arduino board do you use ? Pro Mini 8Mhz Do you have a 5V or 3V MLX ? 3.3v MLX Do you have a 5V or 3.3V I2C bus ? Do you have a level shifter ? I have (When I have purchased I tested it with 16Mhz Pro mini with level shifter and it worked OK, but now I want to have setup on 8MHZ pro mini without luck) What are the other I2C sensors ? BMP180, TSL2561, DHT22 and for transmitting NRF24L01 (I will add rain and radio radiation sensors too)
My first setup was on Pro Mini 8mhz, Now I am testing it on Aruino UNO and got following results (Actually I got same result with pro mini too, but then modified setup for testing) :
Use 0x5A for _addr.
Use 6 for register addres of ambient temperature, and 7 for object.
There is also 8 for the second object, but I don't know what that is.
And check if the sensor actually responds.
If that failes somehow, it might be broken.
The next code is not tested, you have to verify all the numbers and code yourself
// call it
read16test(6);
read16test(7);
read16test(8);
// function
uint16_t read16test(uint8_t a) {
uint16_t ret;
Wire.beginTransmission(0x5A); // start transmission to device
Wire.write(a); // sends register address to read from
int error = Wire.endTransmission(false); // end transmission with repeated start
if( error != 0) {
Serial.print("error = ");
Serial.println(error);
}
int n = Wire.requestFrom(0x5A, (uint8_t)3);// send data n-bytes read
if(n == 3) {
ret = Wire.read(); // receive DATA
ret |= Wire.read() << 8; // receive DATA
Serial.print("Data from register "):
Serial.print(a);
Serial.print(" = 0x");
Serial.println(ret);
uint8_t pec = Wire.read();
}
else {
Serial.print("Error, three bytes requested, but ");
Serial.print(n);
Serial.println(" bytes received");
}
return ret;
}
One more thing: If you print results here, we don't know what to do with it. We need to know the code that you used to get that. And if you use a library, tell us where that you got that library from, so we know the library and the version (or fork) of that library.
I use same not modified version of library with same test example you showed above:
I have tested it with direct Wire transmission nothing returned seems like it is burned know I need to wait another 20 days to receive one from China or Italy!
For some reason it started working, but it is diffidently faulty. I have refreshed wiring and power source and it started working for some 2-3 minutes but then stopped again. It is not stable and fluctuates seems like it has internal connection problem
I think I will be able to make it work for short time while new MLX will arrive. I have notice it works OK when I pre-heat it a bit
For to use it with other I2C devices I plan to put Attiny85 and then wire it to other Arduino (which controls other sensors) with some interface. I think this would cause of extra power loss and not efficient way, do you have any suggestion for this case?
The DHT11 needs specific timing, I think the rest does not need specific timing or interrupts. You might do everything on the same Arduino board. That would be the most simple solution.
The DHT11 is not very accurate by the way.
I do have a Arduino with a seperate task, but that is with VirtualWire to receive wireless data packets.
With an other Arduino I used DHT11 code that disabled the interrupt. However I needed fast interrupt timing, so I remove the disabling of interrupts and let the DHT11 code run in the background and only accept the data when the checksum is okay.
The MLX90614 might be broken. Did you try my piece of code of Reply #3 that checks the return value of Wire.endTransmission and the return value of Wire.requestFrom ?
I misread it, sorry. You have a DHT22. That one is more accurate. But if you bought it on Ebay, then the humidity might still not be very accurate.
For you, I don't see a problem when the interrupts are temporary disabled.
The DHT11 and DHT22 use a single (open-collector) wire and some timed pattern to communicate between the Arduino and the sensor.
The DS18B20 is the most common and accurate temperature sensor which uses the 1-Wire protocol. That is also a single (open-collector) wire with a timed pattern, but totally different than the DHT22.
But as I wrote, that is no problem for you. You can use the DHT22, and add a DS18B20 for fun as well.
It is even possible to measure the temperature with the forward voltage of a diode.
I dont know why but my sensor started working without 4K7 resistors :S tested on several arduinos. mine is 3.3v version may be this is normal for it, I hope sensor will not change mind on future
I have tried your code, before it not worked with resistors but now it returns some bytes without resistors.
I have DHT22 AM2303 model which is already includes DS18B20, I also have HTU21D for humidity which is very accurate but I think it would be extra wiring and power loss, so I will go only with AM2303.
I am going to compound all together to see how I2C acts.
Nice that it works.
Why it works without the resistors are a big mystery to me. Could you measure them with a multimeter to verify that they are 4k7 ? And you connected them to 3.3V (not 5V) ?
A HTU21D and DS18B20 might use less power than a single DHT22.
The DHT22 uses a polymer for the humidity, and I think the HTU21D uses some kind of capacitance of the humidity die ? (something like that).
The polymer can be changed by chemicals, even from chemicals that are used in the plastic bag it came in.
Just a heads up as I ran in to an issue with running an MLX90614 and an MLX90640 on the same I2C line. The MLX90614 seems to pull down the I2C and prevent any communications until it is fully powered on. When you power the sensor up put a delay in after power up. in my case it was 40ms.
Then all sensors seem to work.
If you don't have a delay then the sensors don't seem to respond.