Mundarija:
2025 Muallif: John Day | [email protected]. Oxirgi o'zgartirilgan: 2025-01-13 06:58
INTRO:
1 Ushbu loyihada men ma'lumotlarni ko'rsatish, SD -karta va IOT -da ma'lumotlarni zaxiralash bilan zarracha detektorini qanday qurishni ko'rsataman. Vizual ravishda neopikselli halqali displey havo sifatini ko'rsatadi.
2 Havo sifati bugungi kunda tobora muhim ahamiyat kasb etmoqda. chang tezligini o'lchaydigan tizimlar bor, lekin ular juda qimmat. Ba'zi tadqiqotlar ko'rsatganidek, bozorda arzon va yuqori sifatli zarracha detektorlari mavjud.
masalan:
www.atmos-meas-tech.net/11/4823/2018/amt-1…
3 Shuning uchun men zarrachalar sonini o'lchov sinflari bo'yicha o'lchashga qodir bo'lgan qurilmani (0,5 mkm dan 10 mkm gacha), natijani oddiy ko'rsatish (neo pikselli halqa), TFT ekranida va SD-kartadagi vaqt muhri bilan zaxiralash.
4 Bundan tashqari, men bluetooth aloqa modulini qo'shdim, u android ilovasi bilan aloqa o'rnatishi va natijalarni IOT serverida e'lon qilishi mumkin.
5 Umumiy qiymati 60 € dan oshmaydi
Ta'minotlar
-Arduino uno R3
-Arduino proto -qalqoni
-TFT ekranli ST7735
-Neopikselli halqa 24 boshli
-Plantower PMS5003
-HC-06 bluetooth moduli
1 -qadam: Komponentlarni ulash
har xil komponentlar yuqoridagi diagramaga muvofiq ulanadi
2 -qadam: Kutubxona va Arduino dasturi
1 kutubxona
TFT ekrani uchun
github.com/adafruit/Adafruit-GFX-Library
neo pikselli uzuk uchun
github.com/adafruit/Adafruit_NeoPixel
sd karta uchun
github.com/arduino-libraries/SD
2 arduino eskizi
#include #include // Bibliothèque pour l'I2C #include "RTClib.h" // Bibliothèque pour le module RTC RTC_DS1307 RTC; #qo'shing
// Arduino -dagi qaysi pin NeoPixel -ga ulangan?
#define PIN 6 // Trinket yoki Gemma -da buni 1 ga o'zgartirishni taklif qiling
// Arduino -ga nechta NeoPixel biriktirilgan?
#define NUMPIXELS 24 // Mashhur NeoPixel halqa o'lchami Adafruit_NeoPixel piksellari (NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); uint32_t vert = piksel. Rang (0, 250, 0); uint32_t apelsin = piksel. Rang (250, 250, 0); uint32_t rouge = piksel. Rang (255, 0, 0);
SoftwareSerial pmsSerial (2, 3);
#define cs 10 #define dc 9 #define rst 8 // siz ham buni Arduino sozlamalariga ulashingiz mumkin.
#include // Asosiy grafik kutubxona
#include // Uskuna uchun maxsus kutubxona #include #include const int cs_sd = 4; int temps; // temps d'acquisition er -xotin tempsInit; // ishga tushirish taymeri au démarrage du loop ()
#if aniqlangan (_ SAM3X8E_)
#undef _FlashStringHelper:: F (string_literal) #define F (string_literal) string_literal #endif
// 1 -variant: har qanday pinni ishlating, lekin biroz sekinroq
// Adafruit_ST7735 tft = Adafruit_ST7735 (cs, dc, mosi, sclk, rst);
// 2 -variant: apparat SPI pinlaridan foydalanish kerak
// (UNO uchun sclk = 13 va sid = 11) va pin 10 // chiqishi bo'lishi kerak. Bu ancha tezroq - agar siz xohlasangiz // microSD kartasidan foydalanishni xohlasangiz (rasm chizish misolini ko'ring) Adafruit_ST7735 tft = Adafruit_ST7735 (cs, dc, rst); float nombre_leds = 0; void setup () {Serial.begin (9600); // I2C Wire.begin () bilan bog'lanishni boshlang; // RTC RTC.begin () modulini ishga tushirish; Serial.print ("boshlang'ich SD"); kechikish (1000); if (! SD.begin (cs_sd)) // // Vazifa sharti SD -karta SD est présente dans l'appareil {Serial.print ("Defaut SD"); qaytish; } Serial.print ("Carte SD OK");
Fayl ma'lumotlari = SD.open ("donnees.txt", FILE_WRITE); // Ochiq le fichier "donnees.txt"
ma'lumotlar.println (""); data.println ("Démarrage sotib olish"); // Ecrit dans ce fichier data.close (); tft.initR (INITR_GREENTAB); // ST7735S chipini ishga tushirish, qora tab Serial.println ("init"); // bizning disk raskadrovka chiqishimiz tft.fillScreen (ST7735_BLACK); // sensorning uzatilish tezligi 9600 pmsSerial.begin (9600);
piksel.begin (); // NeoPixel tasma ob'ektini INITIALIZE (talab qilinadi)
piksel.setBrightness (2);
}
pms5003data tuzilishi {
uint16_t ramka; uint16_t pm10_standart, pm25_standart, pm100_standart; uint16_t pm10_env, pm25_env, pm100_env; uint16_t zarralar_03um, zarrachalar_05um, zarralar_10um, zarrachalar_25um, zarrachalar_50um, zarralar_100um; uint16_t ishlatilmagan; uint16_t checksum; };
pms5003 ma'lumotlar ma'lumotlarini tuzish; void loop () {piksel.clear (); // Barcha piksel ranglarini "o'chirilgan" qilib qo'ying DateTime now = RTC.now (); // Récupère l'heure et le date courante // affiche_date_heure (hozir);
temps = ((millis () - tempsInit))/1000; // Démarrage du chrono
agar (readPMSdata (& pmsSerial)) {// tft.fillScreen (ST7735_BLACK); tft.setCursor (10, 5); tft.setTextColor (ST7735_WHITE); tft.println ("nbre qismlari/ 0,1 l");
tft.setCursor (10, 17); tft.setTextColor (ST7735_GREEN, ST7735_BLACK); tft.setTextSize (1); tft.setCursor (10, 17); tft.print ("0.3 um"); tft.print (data.particles_03um); tft.print ("");
tft.setCursor (10, 29);
tft.setTextColor (ST7735_GREEN, ST7735_BLACK); tft.setTextSize (1); tft.print ("0,5 um"); tft.print (data.particles_05um); tft.print ("");
tft.setCursor (10, 41);
tft.setTextColor (ST7735_GREEN, ST7735_BLACK); tft.setTextSize (1); tft.print ("1.0 um"); tft.print (data.particles_10um); tft.print ("");
tft.setCursor (10, 53);
tft.setTextColor (ST7735_GREEN, ST7735_BLACK); tft.setTextSize (1); tft.print ("2,5 um"); tft.print (data.particles_25um); tft.print ("");
tft.setCursor (10, 65);
tft.setTextColor (ST7735_GREEN, ST7735_BLACK); tft.setTextSize (1); tft.print ("5.0 um"); tft.print (data.particles_50um); tft.print ("");
tft.setCursor (10, 77);
tft.setTextColor (ST7735_GREEN, ST7735_BLACK); tft.setTextSize (1); tft.print ("10 um"); tft.print (data.particles_100um); tft.print ("");
tft.setCursor (2, 89);
tft.setTextColor (ST7735_GREEN, ST7735_BLACK); tft.setTextSize (1); tft.print ("PM 1.0"); tft.setTextColor (ST7735_YELLOW, ST7735_BLACK); tft.print (data.pm10_standard); tft.print (""); tft.setTextColor (ST7735_GREEN, ST7735_BLint) " mikrog/m3 ");
tft.setCursor (2, 100); tft.setTextColor (ST7735_GREEN, ST7735_BLACK); tft.setTextSize (1); tft.print ("PM 2.5"); tft.setTextColor (ST7735_YELLOW, ST7735_BLACK); tft.print (data.pm25_standard); tft.setTextColor (ST7735_GREEN, ST7735_BLACK); tft.print ("mikrografiya")
tft.setCursor (2, 110);
tft.setTextColor (ST7735_GREEN, ST7735_BLACK); tft.setTextSize (1); tft.print ("PM 10"); tft.setTextColor (ST7735_YELLOW, ST7735_BLACK); tft.print (data.pm100_standard); tft.setTextColor (ST7735_GREEN, ST7735_BLACK); tft.print ("mikrografiya")
tft.setCursor (10, 5);
tft.setTextColor (ST7735_WIT, ST7735_BLACK); tft.setTextSize (1); tft.println ("nbre qismlari/ 0,1 l");
// Serial.print (vaqt);
// Serial.print (""); Serial.print ("#"); Serial.print ("03µm"); Serial.print (data.particles_03um); Serial.print (""); Serial.print ("05µm"); Serial.print (data.particles_05um); Serial.print (""); Serial.print ("1 mkm"); Serial.print (data.particles_10um); Serial.print (""); Serial.print ("25 mkm"); Serial.print (data.particles_25um); Serial.print (""); Serial.print ("50 mkm"); Serial.print (data.particles_50um); Serial.print (""); Serial.print ("100 mkm"); Serial.print (data.particles_100um); Serial.println (""); nombre_leds = int (((float (data.particles_03um)/65535)*24)); // nombre_leds = (8); Serial.println (nombre_leds);
agar ((nombre_leds = 1)) {
pixel.fill (vert, 0, nombre_leds); } if if ((nombre_leds = 8)) {piksel.fill (vert, 0, 8); piksel.fil (to'q sariq, 8, ((nombre_leds) -8))); } agar boshqa (nombre_leds> 16) {
piksel.fill (vert, 0, 8); piksel.fil (to'q sariq, 8, 8); piksel.fill (rouge, 16, ((nombre_leds) -16)); } if if (nombre_leds <= 1) {piksel.fill (vert, 0, 1); } piksel.show (); // Yangilangan piksel ranglarini qo'shimcha qurilmalarga yuborish.
// DNF ta'rifi String PM03 = String (data.particles_03um); String PM05 = String (data.particles_05um); String PM10 = String (data.particles_10um); String PM25 = String (data.particles_25um); String PM50 = String (data.particles_50um); String PM100 = String (data.particles_100um); String PMS10 = String (data.pm10_standard); String PMS25 = String (data.pm25_standard); String PMS100 = String (data.pm100_standard); String temps = String (temps);
// Ecriture des données dans le fichier texte
Fayl ma'lumotlari = SD.open ("donnees.txt", FILE_WRITE); data.println (Temps+""+PM03+""+PM05+""+PM10+""+PM25+""+PM50+""+PM100+""+PMS10+""+PMS25+""+PMS100+""); data.close (); }
}
boolean readPMSdata (oqim *lar) {
if (! s-> available ()) {return false; } // "0x42" maxsus boshlang'ich baytiga kelgunimizcha, bir vaqtning o'zida bir baytni o'qing, agar (s-> peek ()! = 0x42) {s-> o'qish (); noto'g'ri qaytarish; }
// Endi barcha 32 baytni o'qing
if (s-> available () readBytes (bufer, 32);
// nazorat summasini tayyorlang
uchun (uint8_t i = 0; i <30; i ++) {sum+= bufer ; }
/* disk raskadrovka
uchun (uint8_t i = 2; i <32; i ++) {Serial.print ("0x"); Serial.print (bufer , HEX); Serial.print (","); } Serial.println (); */ // Ma'lumot endian'd keladi, bu uni hal qiladi, shuning uchun uint16_t buffer_u16 barcha platformalarida ishlaydi [15]; uchun (uint8_t i = 0; i <15; i ++) {buffer_u16 = bufer [2 + i*2 + 1]; buffer_u16 + = (bufer [2 + i*2] << 8); }
// uni yaxshi tuzilishga joylashtiring:)
memcpy ((void *) & data, (void *) buffer_u16, 30);
agar (sum! = data.checksum) {
Serial.println ("Tekshirish summasining ishlamay qolishi"); noto'g'ri qaytarish; } // muvaffaqiyat! haqiqatga qaytish; }
// Converti le numéro de jour en jour /! / La semaine commence un dimanche
Donne_jour_semaine (uint8_t j) {switch (j) {0 holat: qaytarish "DIM"; 1 -holat: "LUN" ni qaytarish; 2 -holat: "MAR" ni qaytarish; 3 -holat: "MER" ni qaytarish; 4 -holat: "JEU" ni qaytarish; 5 -holat: "VEN" ni qaytarish; 6 -holat: "SAM" ni qaytarish; standart: qaytarish ""; }}
// affiche la date et l'heure sur l'écran
vic affiche_date_heure (DateTime datetime) {// Sana satrining jurnal = donne_jour_semaine (datetime.dayOfTheWeek ()) + "" + Vers2Chiffres (datetime.day ()) + "/" + Vers2Chiffres (datetime.month ()) + "/" + String (datetime.year (), DEC); // heure String heure = ""; heure = Vers2Chiffres (datetime.hour ()) + ":" + Vers2Chiffres (datetime.minute ()) + ":" + Vers2Chiffres (datetime.second ());
Serial.print (jurnal); Serial.print (""); Serial.print (heure); //Serial.print (""); Fayl ma'lumotlari = SD.open ("donnees.txt", FILE_WRITE); data.print (jurnal + "" + heure + ""); data.close ();
tft.setCursor (2, 120);
tft.setTextColor (ST7735_GREEN); tft.setTextSize (1); tft.print ("sana"); tft.setTextColor (ST7735_YELLOW); tft.print (jurnal); tft.setTextColor (ST7735_GREEN); tft.setCursor (2, 130); tft.print ("heure"); tft. setTextColor (ST7735_YELLOW); tft.print (heure);
kechikish (500);
}
// permet d'afficher les nombres sur deux chiffres
String Vers2Chiffres (bayt nom) {String resultat = ""; if (nombre <10) resultat = "0"; return resultat += String (nombre, DEC); }
3 -qadam: MIT App Inventor 2 dasturi
bu MIT ilovasi ixtirochi kod bloki
4 -qadam: natija
mana natija videosi