Air Quality Monitor (SEN0233) not working?
Dear DFRobot community,
so recently I bought the SEN0233 Air Quality Monitor. My hardware in this setup is: Arduino Uno R3, Gravity LCD1602 Module V1.1, Gravity IO Expansion Shield V7.1
When uploading the sample code provided
#include <Wire.h>
#include <SoftwareSerial.h>
#include "DFRobot_RGBLCD1602.h"
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 bufferRTT[32] = {}; //serial receive data
char tempStr[15];
SoftwareSerial mySerial(10, 11); // RX, TX
DFRobot_RGBLCD1602 lcd(/*RGBAddr*/0x6B ,/*lcdCols*/16,/*lcdRows*/2); //16 characters and 2 lines of show
void setup()
{
Serial.begin(115200);
mySerial.begin(9600);
lcd.init();//Initialize LCD1602 RGB display
lcd.setRGB(0, 255, 0); //Set the initial backlight color of the display
lcd.setCursor(0, 0 ); //Set displaying from (0, 0)
lcd.print("T:");//Display T:
lcd.setCursor(9, 0 );
lcd.print("H:");
lcd.setCursor(0, 1 );
lcd.print("PM2.5:");
lcd.setCursor(9, 1 );
lcd.print("ug/m3");
}
void loop()
{
while (mySerial.available() > 0) //Check whether there is any serial data
{
for (int i = 0; i < 32; i++) //Read serial data
{
col = mySerial.read();
bufferRTT[i] = (char)col;
delay(2);
}
mySerial.flush();
CR1 = (bufferRTT[30] << 8) + bufferRTT[31];
CR2 = 0;
for (int i = 0; i < 30; i++)
CR2 += bufferRTT[i];
if (CR1 == CR2) //Check
{
PMSa = bufferRTT[12]; //Read PM2.5 high 8-bit data
PMSb = bufferRTT[13]; //Read PM2.5 low 8-bit data
PMS = (PMSa << 8) + PMSb; //PM2.5 data
TPSa = bufferRTT[24]; //Read temperature high 8-bit data
TPSb = bufferRTT[25]; //Read temperature low 8-bit data
TPS = (TPSa << 8) + TPSb; //Temperature data
HDSa = bufferRTT[26]; //Read humidity high 8-bit data
HDSb = bufferRTT[27]; //Read humidity low 8-bit data
HDS = (HDSa << 8) + HDSb; //Humidity data
}
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); //Display temperature
lcd.print(tempStr);
lcd.write(0xdf); //Display °
lcd.print('C'); //Display C
lcd.setCursor(11, 0 );
sprintf(tempStr, "%d%d.%d", HDS / 100, (HDS / 10) % 10, HDS % 10); //Display humidity
lcd.print(tempStr);
lcd.print('%'); //Display %
lcd.setCursor(6, 1 );
sprintf(tempStr, "%d%d%d", PMS / 100, (PMS / 10) % 10, PMS % 10); //Display PM2.5 ones, tens, hundreds unit ug/m³
lcd.print(tempStr);
}
nothing appears on the LCD. Before programming, I set the switch to “Prog”, after the successful upload I set it to “Run”. Nothing happens, not even after resetting the Arduino.
After sending the sensor data to the Arduino IDE's serial monitor, it just displays a lot of 0s.
The sensor itself should be working, I hear a little fan inside. Also I wired everything accordingly to the documentation:
https://wiki.dfrobot.com/Air_Quality_Monitor__PM_2.5_Temperature_and_Humidity_Sensor__SKU__SEN0233
Did somebody experience the same problems? Do I overlook something? Any help is appreciated!