Cov txheej txheem:

Arduino Powered Dust Particle Monitoring Station: 4 Cov Kauj Ruam (nrog Duab)
Arduino Powered Dust Particle Monitoring Station: 4 Cov Kauj Ruam (nrog Duab)

Video: Arduino Powered Dust Particle Monitoring Station: 4 Cov Kauj Ruam (nrog Duab)

Video: Arduino Powered Dust Particle Monitoring Station: 4 Cov Kauj Ruam (nrog Duab)
Video: Dust Sensor DSM501A with Arduino, PM10 & PM2.5 Air Quality Monitoring, Arduino Project 2024, Kaum ib hlis
Anonim
Arduino Powered Dust Particle Monitoring Station
Arduino Powered Dust Particle Monitoring Station

Koj tuaj yeem tsim tau yooj yim tsim DIY internet ntawm cov khoom siv uas saib xyuas cov pa phem hauv koj lub tsev tsawg dua $ 50 thiab tau txais kev ceeb toom thaum qib hmoov av tau siab dhau yog li koj tuaj yeem tso cua hauv chav, lossis koj tuaj yeem teeb nws sab nraum thiab tau txais kev ceeb toom yog tias nws yog muaj kev nyab xeeb tawm mus sab nraud yog tias koj nyob hauv ib puag ncig muaj kuab paug.

Kuv ua qhov no los ua haujlwm hauv tsev kawm ntawv, yog li kuv tsis muaj sijhawm txaus los nrhiav kev pabcuam uas yuav siv MQTT cov lus thiab xa lawv tuaj rau koj zoo li ceeb toom lossis email.

Tsis tas li nco ntsoov tias ua kom lub ntsuas hluav taws xob siv tau txhua lub sijhawm yuav txo tus kiv cua lub neej.

Kauj Ruam 1: Qhov Yuav Tsum Tau

Qhov Yuav Tsum Tau
Qhov Yuav Tsum Tau

Koj yuav xav tau dab tsi

  • Arduino Ib
  • Arduino Ethernet ntaub thaiv npog
  • Particulate teeb meem laser sensor (feem ntau mus rau $ 10- $ 30 ntawm eBay/aliexpress)
  • DHT11 kub thiab av noo sensor (yeem)
  • Cov qhob cij
  • Jumper cables

Kauj Ruam 2: Sib Sau Ua Ke

Sib Sau Ua Ke
Sib Sau Ua Ke

Ua ntej tshaj, koj yuav tsum ntsaws daim thaiv thaiv ethernet ntawm Arduino

PM sensor muaj ntau lub xov hlau, tab sis qhov peb xav tau yog VCC, GND, TX, RX.

Txuas VCC thiab GND rau + thiab - ntawm lub khob cij feem.

Arduino muaj kho vajtse RX thiab TX pins, tab sis peb yuav siv software emulation ntawm RX thiab TX pins ntawm tus pin 2 thiab 3 feem. Txuas RX ntawm lub sensor mus rau TX ntawm Arduino thiab TX ntawm lub sensor rau RX ntawm Arduino.

Yog tias koj yuav siv lub ntsuas kub, ntsaws VCC thiab GND kab rau + thiab - ntawm Breadboard thiab kab ntawv cov ntaub ntawv rau tus pin 7.

Kauj Ruam 3: Txoj Cai

Koj tuaj yeem nruab MQTT broker ntawm raspberry pi lossis lub khoos phis tawj koj ib txwm nyob hauv tsev, lossis siv huab MQTT kev pabcuam, zoo li Cloud MQTT. Tom qab ntawd koj tuaj yeem sau tsab ntawv uas xa cov ntaub ntawv ua HTTP mus rau IFTT webhook, vim tias lawv tseem tsis tau txhawb nqa MQTT webhooks thiab teeb tsa cov ntawv ceeb toom rau thaum qib hmoov av hauv koj lub tsev tau siab dhau.

Arduino air station chaw

#suav nrog

#suav nrog
#suav nrog
#suav nrog
#suav nrog
#suav nrog

#suav nrog

#suav nrog
#defineDHT11_PIN7
#defineRX_PIN2
#defineTX_PIN3
Tus IP chaw nyob IP (169, 169, 100, 98);
byte mac = {
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};
constchar *mqtt_server = "m23.cloudmqtt.com";
constit mqtt_port = 11895;
constchar *mqtt_user = "jhetjewk";
constchar *mqtt_pass = "QB2p9PiMV6pn";
constchar *mqtt_client_name = "arduinoClient1"; // Cov neeg siv sib txuas tsis tuaj yeem muaj lub npe sib txuas zoo ib yam
EthernetClient ethClient;
PubSubClient tus neeg siv khoom (ethClient);
SoftwareSerial pmSerial (RX_PIN, TX_PIN);
dht DHT;
ua pm1;.
ua pm2_5;
pm10; ua.
unsignedlong id;
// Ua ntaub ntawv myFile;
Txoj hlua s;
StaticJsonBuffer <200> jsonBuffer;
JsonObject & hauv paus = jsonBuffer.createObject ();
voidsetup () {
Serial.begin (57600);
pmSerial.begin (9600);
id = 0;
pm1 = 0;
pm2_5 = 0;
pm10 = 0;
yog (Ethernet.begin (mac) == 0)
{
Serial.println ("Ua tsis tiav los teeb tsa Ethernet siv DHCP");
// sim nrog ip ruaj khov ntxiv
Ethernet.begin (mac, ip);
}
client.setServer (mqtt_server, mqtt_port);
client.setCallback (hu rov qab);
ncua (2000);
Serial.println (Ethernet.localIP ());
client.connect ("arduinoClient", mqtt_user, mqtt_pass);
Serial.print ("rc =");
Serial.print (client.state ());
Serial.print ("\ n");
}
voidloop () {
intindex = 0;
tus nqi;
char yav dhau losValue;
yog (! client.connected ())
{
yog (client.connect ("arduinoClient", mqtt_user, mqtt_pass)) {
Serial.println ("txuas nrog");
}
}
thaum (pmSerial.available ()) {
tus nqi = pmSerial.read ();
yog ((index == 0 && value! = 0x42) || (index == 1 && value! = 0x4d)) {
Serial.println ("Tsis tuaj yeem pom cov ntaub ntawv header.");
rov qab;
}
yog (index == 4 || index == 6 || index == 8 || index == 10 || index == 12 || index == 14) {
yav dhau losValue = tus nqi;
}
elseif (qhov ntsuas == 5) {
pm1 = 256 * yav dhau los Tus nqi + tus nqi;
hauv paus ["pm1"] = abs (pm1);
}
elseif (qhov ntsuas == 7) {
pm2_5 = 256 * yav dhau los Tus nqi + tus nqi;
hauv paus ["pm2_5"] = abs (pm2_5);
}
elseif (qhov ntsuas == 9) {
pm10 = 256 * yav dhau los Tus nqi + tus nqi;
hauv paus ["pm10"] = abs (pm10);
}
elseif (qhov ntsuas> 15) {
tawg;
}
index ++;
}
thaum (pmSerial.available ()) pmSerial.read ();
int chk = DHT.read11 (DHT11_PIN);
yog (DHT.temperature == -999 || DHT.humidity == -999) {
hauv paus ["kub"] = "N/A";
hauv paus ["av noo"] = "N/A";
lwm yam {
hauv paus ["kub"] = DHT.temperature;
hauv paus ["av noo"] = DHT.humidity;
}
xa cov txiaj ntsig ();
id ++; ib.
ncua (5000);
}
voidsendResults () {
// tshaj tawm rau MQTT
char jsonChar [100];
root.printTo (jsonChar);
Serial.println (client.publish ("arduino", jsonChar));
// debug rau serial
root.printTo (Serial);
Serial.print ('\ n');
}
// Kov cov lus tuaj txog ntawm cov ncauj lus sau npe (s)
voidcallback (char* ntsiab lus, byte* payload, unsignedint ntev) {
}

saib rawair_quality.ino tuav nrog ❤ los ntawm GitHub

Kauj Ruam 4: Sib Sau Lub Box

Sib Sau Lub Thawv
Sib Sau Lub Thawv
Sib Sau Lub Thawv
Sib Sau Lub Thawv
Sib Sau Lub Thawv
Sib Sau Lub Thawv

Kuv nyuam qhuav siv lub thawv uas kuv tau pw ib puag ncig thiab drilled lub qhov rau lub ntsuas cua kom tau txais huab cua los ntawm thiab txiav tawm lub qhov rau cov kab hluav taws xob tawm mus (txawm hais tias nws loj me ntsis).

Kuv siv cov kua nplaum los txhawm rau txhawm rau txhawm rau lub thawv, ua kom lub qhov nkag ntawm qhov ntsuas nrog lub qhov drilled ntawm lub thawv.

Thaum kawg, Kuv tau ntsaws rau hauv ethernet thiab cov xov hluav taws xob.

Pom zoo: