Arduino-Based Air Quality Monitoring System with Bluetooth Connectivity
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to monitor air quality using a PM2.5 Air Quality Sensor (PMS5003) and an MQ131 ozone sensor. The data is processed by an Arduino UNO and can be transmitted via an HC-05 Bluetooth module. The circuit is powered by a 9V battery and includes a rocker switch for power control.
Component List
PM2.5 Air Quality Sensor and Breadboard Adapter Kit - PMS5003
- Description: Measures particulate matter (PM) concentrations in the air.
- Pins: VCC, GND, SET, RX, TX, RST
MQ131
- Description: Ozone gas sensor.
- Pins: GND, AOUT, DOUT, VCC
Rocker Switch
- Description: Used to control the power supply to the circuit.
- Pins: 1, 2
Arduino UNO
- Description: Microcontroller used to process sensor data and control other components.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
HC-05 Bluetooth Module
- Description: Bluetooth module for wireless communication.
- Pins: Key, VCC, GND, TXD, RXD, State
Resistor (2000 Ohms)
- Description: Limits current in the circuit.
- Pins: pin1, pin2
Resistor (1000 Ohms)
- Description: Limits current in the circuit.
- Pins: pin1, pin2
9V Battery
- Description: Power supply for the circuit.
- Pins: -, +
Wiring Details
PM2.5 Air Quality Sensor and Breadboard Adapter Kit - PMS5003
- VCC connected to 5V on Arduino UNO
- GND connected to GND on Arduino UNO
- RX connected to D3 on Arduino UNO
- TX connected to D2 on Arduino UNO
MQ131
- VCC connected to 5V on Arduino UNO
- GND connected to GND on Arduino UNO
- DOUT connected to D2 on Arduino UNO
- AOUT connected to A1 on Arduino UNO
Rocker Switch
- Pin 1 connected to D7 on Arduino UNO
- Pin 2 connected to GND on Arduino UNO
Arduino UNO
- 5V connected to VCC on PM2.5 Air Quality Sensor, MQ131, and HC-05 Bluetooth Module
- GND connected to GND on PM2.5 Air Quality Sensor, MQ131, and HC-05 Bluetooth Module
- D3 connected to RX on PM2.5 Air Quality Sensor
- D2 connected to TX on PM2.5 Air Quality Sensor and DOUT on MQ131
- A1 connected to AOUT on MQ131
- D7 connected to Pin 1 on Rocker Switch
- Vin connected to + on 9V Battery
- GND connected to - on 9V Battery
HC-05 Bluetooth Module
- VCC connected to 5V on Arduino UNO
- GND connected to GND on Arduino UNO
- TXD connected to D1 on Arduino UNO
- RXD connected to pin1 on 1000 Ohms Resistor
Resistor (2000 Ohms)
- Pin 1 connected to RXD on HC-05 Bluetooth Module
- Pin 2 connected to - on 9V Battery
Resistor (1000 Ohms)
- Pin 1 connected to D0 on Arduino UNO
- Pin 2 connected to pin1 on 2000 Ohms Resistor
9V Battery
- + connected to Vin on Arduino UNO
- - connected to GND on Arduino UNO and pin2 on 2000 Ohms Resistor
Documented Code
Arduino UNO Code
#include <SoftwareSerial.h>
SoftwareSerial pmsSerial(2, 3);
void setup() {
// our debugging output
Serial.begin(115200);
// sensor baud rate is 9600
pmsSerial.begin(9600);
}
struct pms5003data {
uint16_t framelen;
uint16_t pm10_standard, pm25_standard, pm100_standard;
uint16_t pm10_env, pm25_env, pm100_env;
uint16_t particles_03um, particles_05um, particles_10um, particles_25um, particles_50um, particles_100um;
uint16_t unused;
uint16_t checksum;
};
struct pms5003data data;
void loop() {
if (readPMSdata(&pmsSerial)) {
// reading data was successful!
Serial.println();
Serial.println("---------------------------------------");
Serial.println("Concentration Units (standard)");
Serial.print("PM 1.0: "); Serial.print(data.pm10_standard);
Serial.print("\t\tPM 2.5: "); Serial.print(data.pm25_standard);
Serial.print("\t\tPM 10: "); Serial.println(data.pm100_standard);
Serial.println("---------------------------------------");
Serial.println("Concentration Units (environmental)");
Serial.print("PM 1.0: "); Serial.print(data.pm10_env);
Serial.print("\t\tPM 2.5: "); Serial.print(data.pm25_env);
Serial.print("\t\tPM 10: "); Serial.println(data.pm100_env);
Serial.println("---------------------------------------");
Serial.print("Particles > 0.3um / 0.1L air:"); Serial.println(data.particles_03um);
Serial.print("Particles > 0.5um / 0.1L air:"); Serial.println(data.particles_05um);
Serial.print("Particles > 1.0um / 0.1L air:"); Serial.println(data.particles_10um);
Serial.print("Particles > 2.5um / 0.1L air:"); Serial.println(data.particles_25um);
Serial.print("Particles > 5.0um / 0.1L air:"); Serial.println(data.particles_50um);
Serial.print("Particles > 10.0 um / 0.1L air:"); Serial.println(data.particles_100um);
Serial.println("---------------------------------------");
}
}
boolean readPMSdata(Stream *s) {
if (! s->available()) {
return false;
}
// Read a byte at a time until we get to the special '0x42' start-byte
if (s->peek() != 0x42) {
s->read();
return false;
}
// Now read all 32 bytes
if (s->available() < 32) {
return false;
}
uint8_t buffer[32];
uint16_t sum = 0;
s->readBytes(buffer, 32);
// get checksum ready
for (uint8_t i=0; i<30; i++) {
sum += buffer[i];
}
/* debugging
for (uint8_t i=2; i<32; i++) {
Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", ");
}
Serial.println();
*/
// The data comes in endian'd, this solves it so it works on all platforms
uint16_t buffer_u16[15];
for (uint8_t i=0; i<15; i++) {
buffer_u16[i] = buffer[2 + i*2 + 1];
buffer_u16[i] += (buffer[2 + i*2] << 8);
}
// put it into a nice struct :)
memcpy((void *)&data, (void *)buffer_u16, 30);
if (sum != data.checksum) {
Serial.println("Checksum failure");
return false;
}
// success!
return true;
}
This documentation provides a comprehensive overview of the circuit, including a summary, detailed component list, wiring details, and the code used in the Arduino UNO.