Forum >Air Quality Monitor Not working(SKU: SEN0233)
ArduinoGeneral

Air Quality Monitor Not working(SKU: SEN0233)

userHead chrislifreelancer 2018-01-11 20:31:19 6336 Views7 Replies
I have purchased the arduino uno with a i/o extension recently. I tried to use it with the Air Quality Monitor sensor(PM 2.5, Formaldehyde, Temperature & Humidity Sensor). I followed the instruction of using the software serial, still got no reading at all. My code:
Code: Select all
#include <SoftwareSerial.h>
SoftwareSerial Serial1(10, 11); // Software RX, TX
char col;
unsigned int PMSa = 0,FMHDSa = 0,TPSa = 0,HDSa = 0,PMSb = 0,FMHDSb = 0,TPSb = 0,HDSb = 0;
unsigned int PMS = 0,FMHDS = 0,TPS = 0,HDS = 0,CR1 = 0,CR2 = 0;
unsigned char buffer_RTT[40]={}; //Serial buffer; Received Data
char tempStr[15];
void setup()
{
Serial.begin(115200);
Serial1.begin(9600);
}
void loop()
{
while(!Serial1.available());
while(Serial1.available()>0) //Data check: weather there is any Data in Serial1
{
for(int i=0;i<40;i++)
{
col =Serial1.read();
buffer_RTT[i]=(char)col;
delay(2);
}
Serial1.flush();
CR1 =(buffer_RTT[38]<<8) + buffer_RTT[39];
CR2 = 0;
for(int i=0;i<38;i++)
CR2 += buffer_RTT[i];
if(CR1 == CR2) //Check
{
PMSa=buffer_RTT[12]; //Read PM2.5 High 8-bit
PMSb=buffer_RTT[13]; //Read PM2.5 Low 8-bit
PMS=(PMSa<<8)+PMSb; //PM2.5 value
FMHDSa=buffer_RTT[28]; //Read Formaldehyde High 8-bit
FMHDSb=buffer_RTT[29]; //Read Formaldehyde Low 8-bit
FMHDS=(FMHDSa<<8)+FMHDSb; //Formaldehyde value
TPSa=buffer_RTT[30]; //Read Temperature High 8-bit
TPSb=buffer_RTT[31]; //Read Temperature Low 8-bit
TPS=(TPSa<<8)+TPSb; //Temperature value
HDSa=buffer_RTT[32]; //Read Humidity High 8-bit
HDSb=buffer_RTT[33]; //Read Humidity Low 8-bit
HDS=(HDSa<<8)+HDSb; //Humidity value
}
else
{
PMS = 0;
FMHDS = 0;
TPS = 0;
HDS = 0;
}
}
Serial.println("-----------------------uart--------------------------");
Serial.print("Temp : ");
sprintf(tempStr,"%d%d.%d",TPS/100,(TPS/10)%10,TPS%10);
Serial.print(tempStr);
Serial.println(" C"); //Serial pring Temperature
Serial.print("RH : ");
sprintf(tempStr,"%d%d.%d",HDS/100,(HDS/10)%10,HDS%10);
Serial.print(tempStr); //Serial print humidity
Serial.println(" %");
Serial.print("HCHO : ");
Serial.print(FMHDS);
Serial.println(" ug/m3"); //Serial print formaldehyde, unit: ug/m³
Serial.print("PM2.5: ");
Serial.print(PMS);
Serial.println(" ug/m3"); //Serial print PM2.5, unit: ug/m³
Serial.println();
}
Does anyone have clues about this? Or simply due to the damage of the sensor?
2019-01-06 10:49:16 HI,
I have some problems to display the sensor values. I don't LCD screen, just the serial monitor of Arduino IDE.
I used "Arduino Uno Wifi"
I used the same code that "chrislifreelancer" , the differents step that I followed :

1. switch PROG/RUN of IO Expansion Shield to PROG
2. Upload
3. Switch IO Expansion Shield to RUN
4. Open Serial Monitor but nothing is displayed nota: if I stay in RUN position and I upLoad, an error appears:
"avrdude: stk500_recv(): programmer is not responding"

Thanks for your help
userHeadPic lucas.alayrac
2018-02-12 17:58:57 that's the case!!! Thz, I just dont realize I have to put in on run mode, and I just keep on prog mode. thz for the tips, now is running fine. userHeadPic chrislifreelancer
2018-02-09 00:51:34 Hi,
You can do some test
1. Don't use the LCD screen and IO expansion shield, just use software serial and show the results in serial monitor to see if the sensor works.
2. If it works then it means the sensor is good, the problem may because of the wiring, check the switch PROG/RUN on the IO expansion shield, I think it should be at RUN.
userHeadPic robert.chen
2018-02-08 18:52:06 Sorry for late response, here is the photo of the wiring: Basically, I am using the i/o expansion, which doesn't need wiring, like the official photos did. I have added an ethernet shield to sent back data to my server. I have tried other sensors in the shield which is working fine, but this one has no clue. I have sent the sensor back to the retail and help me to test, they said it is working fine. It makes me really confused. Can anyone have the same problem?

I have also tried to avoid using software serial and directly print it to the LCD as the photo shown. I am using the LiquidCrystal_I2C and the code is like this:
Code: Select all
#include
#include
char col;
unsigned int PMSa = 0, FMHDSa = 0, TPSa = 0, HDSa = 0, PMSb = 0, FMHDSb = 0, TPSb = 0,
HDSb = 0,PMS = 0,TPS= 0, HDS = 0, CR1 = 0, CR2 = 0,FMHDS = 0;
unsigned char buffer_RTT[40] = {}; //Serial buffer; Received Data
char tempStr[15];
LiquidCrystal_I2C lcd(0x27,20,4);
void setup()
{
Serial.begin(9600);
lcd.init(); // initialize the lcd
lcd.init();
lcd.backlight();
lcd.setCursor(0,0); //Initialize LCD RGB Screen
lcd.print("T:");
lcd.setCursor(9, 0 );
lcd.print("H:");
lcd.setCursor(0, 1 );
lcd.print("F:");
lcd.setCursor(9, 1 );
lcd.print("P:");
}
void loop()
{
while (Serial.available() > 0) //Data check: weather there is any Data in Serial1
{
for (int i = 0; i < 40; i++) //Read Serial port data
{
col = Serial.read();
buffer_RTT[i] = (char)col;
delay(2);
}
Serial.flush();
CR1 = (buffer_RTT[38] << 8) + buffer_RTT[39];
CR2 = 0;
for (int i = 0; i < 38; i++)
CR2 += buffer_RTT[i];
if (CR1 == CR2) //Check
{
PMSa = buffer_RTT[12]; //Read PM2.5 High 8-bit
PMSb = buffer_RTT[13]; //Read PM2.5 Low 8-bit
PMS = (PMSa << 8) + PMSb; //PM2.5 value
FMHDSa = buffer_RTT[28]; //Read Formaldehyde High 8-bit
FMHDSb = buffer_RTT[29]; //Read Formaldehyde Low 8-bit
FMHDS = (FMHDSa << 8) + FMHDSb; //Formaldehyde value
TPSa = buffer_RTT[30]; //Read Temperature High 8-bit
TPSb = buffer_RTT[31]; ///Read Temperature Low 8-bit
TPS = (TPSa << 8) + TPSb; //Temperature value
HDSa = buffer_RTT[32]; //Read Humidity High 8-bit
HDSb = buffer_RTT[33]; //Read Humidity Low 8-bit
HDS = (HDSa << 8) + HDSb; //Humidity value
}
else
{
PMS = 0;
FMHDS = 0;
TPS = 0;
HDS = 0;
}
}
lcd.setCursor(2, 0 );
sprintf(tempStr,"%d%d.%d",TPS/100,(TPS/10)%10,TPS%10); //Temperature display
lcd.print(tempStr);
lcd.write(0xdf); //°
lcd.print('C'); //C
lcd.setCursor(11, 0 );
sprintf(tempStr,"%d%d.%d",HDS/100,(HDS/10)%10,HDS%10); //Humidity display
lcd.print(tempStr);
lcd.print('%'); //%
lcd.setCursor(2, 1 );
lcd.print((float)FMHDS/1000); //print formaldehyde, unit: ug/m³
lcd.print((int)FMHDS%10);
lcd.setCursor(11, 1 );
sprintf(tempStr,"%d%d%d",PMS/100,(PMS/10)%10,PMS%10); //print PM2.5, unit: ug/m³
lcd.print(tempStr);
}
Please help, thanks.
userHeadPic chrislifreelancer
2018-02-07 12:19:13 Ok - I have a different sensor - sorry for that ^^ I have the SEN0177 with the correct code it is working fine userHeadPic sachsd87
2018-02-06 13:12:23 Hi,
I have the same problem (arduino uno) - I only see 0 values on the output - when I print CR1 and CR2 - I have the following output:
stable CR1=65535 and ~CR2=2046 or sometime 2300 but nor more and it will never reach more.
When I connect TX to pin D11 and RX to pin D10 CR1 is the same and CR2 is round about 9500

What about the RST pin ? in the insturction it tells low=reset - therefore I connected it to 3.3V

Code is the same as chris

Greetings David
userHeadPic sachsd87
2018-01-11 23:44:29 Did you check the wiring? could you attach a picture about how you connect the sensor to your UNO, the TX pin of the sensor should connect to D10, and RX pin to D11. userHeadPic robert.chen