I'm working on an Air quality monitoring project using an Arduino nano 33 IoT and 4 sensors (an MQ7, MQ135, DHT22, MP503). I'm also using an HC-05 bluetooth module to send the sensor data from all of the sensors to my MIT App. The app runs smoothly for some time and then a few errors pop-up.I found that a few of the sensor readings appear at the wrong labels in the app. I have attached the screenshots of the errors. Also attaching my arduino code and MIT aia file.
AEROSENSE.aia (760.3 KB)
Arduino Code:
#include "DHT.h"
#define PIN_MQ135 A0
#define DHTPIN A2
#define MQ7_PIN A6
#define MP503_PIN A4
#define DHTTYPE DHT22
//MQ135 mq135_sensor(PIN_MQ135);
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial1.begin(9600);
dht.begin();
}
void loop() {
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
int MQ135PPM = analogRead(PIN_MQ135);
int MQ7OP = analogRead(MQ7_PIN);
int MP503OP = analogRead(MP503_PIN);
String airQuality;
if (MQ135PPM <=200 && MQ7OP <=100 && MP503OP<=300){
airQuality = "Good";
} else if (MQ135PPM<=400 && MQ7OP<=350 && MP503OP<=600){
airQuality = "Moderate";
} else {
airQuality = "Bad";
}
Serial.print(F("Temperature: "));
Serial.print(temperature);
Serial.print(F("°C"));
Serial.print(" Humidity: ");
Serial.print(humidity);
Serial.print(F("%"));
Serial.print(" MQ135 Analog value: ");
Serial.print(MQ135PPM);
Serial.print(" MQ7 Analog value: ");
Serial.print(MQ7OP);
Serial.print(" MP503 Analog value: ");
Serial.print(MP503OP);
Serial.print(" AIR QUALITY: ");
Serial.println(airQuality);
//Bluetooth send part
Serial1.print(temperature);
Serial1.print(";");
Serial1.print(humidity);
Serial1.print(";");
Serial1.print(MQ135PPM);
Serial1.print(";");
Serial1.print(MQ7OP);
Serial1.print(";");
Serial1.print(MP503OP);
Serial1.print(";");
Serial1.print(airQuality);
Serial1.print(";");
delay(1000);
}