I have compiled the below program in both Arduino due board on pin no 21(scl) and 20(sda) and Arduino UNO board on pin A4(sda) and A5(scl) for I2C connection.
//AMS IAQ core P
#include "Wire.h"
#define iaqaddress 0x5A
uint16_t predict;
uint8_t statu;
int32_t resistance;
uint16_t tvoc;
void setup()
{
Serial.begin(9600);
Wire.begin();
Serial.println("Welcome to ams IAQ core sensor");
}
void loop()
{
readAllBytes();
checkStatus();
Serial.print(",");
Serial.print(", CO2,");
Serial.print(predict);
Serial.print(",");
Serial.print(statu, HEX);
Serial.print(",");
Serial.print(", Resistance");
Serial.print(resistance);
Serial.print(",");
Serial.println(tvoc);
delay(2000);
}
void readAllBytes()
{
Wire.requestFrom(iaqaddress, 9);
predict = (Wire.read()<< 8 | Wire.read());
statu = Wire.read();
resistance = (Wire.read()& 0x00)<<24| (Wire.read()<<16)| (Wire.read()<<8| Wire.read());
tvoc = (Wire.read()<<8 | Wire.read());
}
void checkStatus()
{
if(statu == 0x10)
{
Serial.print("Warming up...");
}
else if(statu == 0x00)
{
Serial.print("Ready");
}
else if(statu == 0x01)
{
Serial.print("Busy");
}
else if(statu == 0x80)
{
Serial.print("Error");
}
else
Serial.print("No Status check module,");
}
I am getting all the values correctly apart from resistance value in UNO board. For Due board I am getting the following outputs
Welcome to ams IAQ core sensor
Ready, CO2,450,0, Resistance413532,125
Ready, CO2,451,0, Resistance413015,126
Ready, CO2,451,0, Resistance413015,126
Ready, CO2,450,0, Resistance413532,125
Ready, CO2,451,0, Resistance413015,126
Ready, CO2,451,0, Resistance413015,126
Ready, CO2,451,0, Resistance413015,126
Ready, CO2,450,0, Resistance413532,125
but for the uno board, the outputs are
Welcome to ams IAQ core sensor
Ready, CO2,471,0, Resistance23435,131
Ready, CO2,470,0, Resistance23435,131
Ready, CO2,467,0, Resistance23958,130
Ready, CO2,466,0, Resistance23958,130
Ready, CO2,467,0, Resistance23435,130
Ready, CO2,464,0, Resistance23958,129
The resistance values from uno board is only 5 digits. When comparing with the data sheet of sensors, the output values from due board is correct. Since I want to use UNO board further I want to get the resistance values correctly. Sometimes I will get negative resistance values from UNO board. Please tell me what I have to do in UNO board to get the correct resistance values.
Thank you.