Cov txheej txheem:

Cov Txheej Txheem Saib Xyuas Huab Cua Zoo rau Cov Kab Mob Phem: 4 Kauj Ruam
Cov Txheej Txheem Saib Xyuas Huab Cua Zoo rau Cov Kab Mob Phem: 4 Kauj Ruam

Video: Cov Txheej Txheem Saib Xyuas Huab Cua Zoo rau Cov Kab Mob Phem: 4 Kauj Ruam

Video: Cov Txheej Txheem Saib Xyuas Huab Cua Zoo rau Cov Kab Mob Phem: 4 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Cov Txheej Txheem Saib Xyuas Huab Cua Zoo rau Cov Kab Mob Phem
Cov Txheej Txheem Saib Xyuas Huab Cua Zoo rau Cov Kab Mob Phem
Cov Txheej Txheem Saib Xyuas Huab Cua Zoo rau Cov Kab Mob Phem
Cov Txheej Txheem Saib Xyuas Huab Cua Zoo rau Cov Kab Mob Phem

NTAU:

1 Hauv qhov haujlwm no kuv qhia yuav ua li cas txhawm rau tsim lub tshuab ntsuas qhov me me nrog cov ntaub ntawv tso tawm, cov ntaub ntawv thaub qab ntawm SD daim npav thiab IOT. Pom qhov muag neopixels ntiv nplhaib qhia pom huab cua zoo.

2 Huab cua zoo yog qhov kev txhawj xeeb tseem ceeb ntxiv niaj hnub no. muaj cov kab ke los ntsuas cov hmoov av tab sis lawv kim heev. Muaj tus nqi qis, ntsuas tau zoo hauv lub khw, raws li qhia los ntawm qee qhov kev tshawb fawb.

piv txwv:

www.atmos-meas-tech.net/11/4823/2018/amt-1…

3 Kuv thiaj li txiav txim siab tsim lub cuab yeej muaj peev xwm ntsuas tus lej ntawm cov chav kawm me me (0.5µm txog 10 µm), pom qhov muag nrog cov lus yooj yim ntawm qhov tshwm sim (neo pixel ring), ntxaws ntxaws ntxaws ntawm TFT screen thiab lub sij hawm-thwj thaub qab ntawm SD daim npav.

4 Tsis tas li ntawd kuv tau ntxiv qhov kev sib tham bluetooth kom muaj peev xwm sib txuas lus nrog Android daim ntawv thov thiab yog li tshaj tawm cov txiaj ntsig ntawm IOT server.

5 Tus nqi tag nrho ntawm tag nrho tsis tshaj 60 €

Khoom siv

-Arduino ib R3

-Arduino tiv thaiv daim thaiv

-TFT npo ST7735

-Neopixel nplhaib 24 coj

-Plantower PMS5003

-HC-06 bluetooth module

Kauj Ruam 1: Txuas Cov Khoom Siv

Txuas Cov Cheeb Tsam
Txuas Cov Cheeb Tsam

cov khoom sib txawv tau txuas nrog raws li daim duab saum toj no

Kauj Ruam 2: Lub Tsev Qiv Ntawv thiab Arduino Program

1 lub tsev qiv ntawv

rau TFT npo

github.com/adafruit/Adafruit-GFX-Library

rau lub nplhaib neo pixel

github.com/adafruit/Adafruit_NeoPixel

rau sd card

github.com/arduino-libraries/SD

2 daim duab arduino

#include #include // Bibliothèque pour l'I2C #include "RTClib.h" // Bibliothèque pour le module RTC RTC_DS1307 RTC; #suav nrog

// Tus pin twg ntawm Arduino txuas nrog NeoPixels?

#define PIN 6 // Ntawm Trinket lossis Gemma, qhia hloov qhov no mus rau 1

// Muaj pes tsawg NeoPixels txuas rau Arduino?

#define NUMPIXELS 24 // Nrov NeoPixel lub nplhaib loj Adafruit_NeoPixel pixels (NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); uint32_t vert = pixels. Color (0, 250, 0); uint32_t txiv kab ntxwv = pixels. Color (250, 250, 0); uint32_t rouge = pixels. Color (255, 0, 0);

SoftwareSerial pmsSerial (2, 3);

#define cs 10 #define dc 9 #define rst 8 // koj tseem tuaj yeem txuas qhov no rau Arduino pib dua

#suav nrog // Lub tsev qiv ntawv duab nraaj

#include // Tsev qiv ntawv kho vajtse tshwj xeeb #include #include const int cs_sd = 4; koj temps; // temps d'acquisition ob zaug tempsInit; // initialisation du timer au démarrage du loop ()

#if txhais (_ SAM3X8E_)

#undef _FlashStringHelper:: F (string_literal) #define F (string_literal) string_literal #endif

// Qhov Xaiv 1: siv txhua tus pin tab sis qeeb me ntsis

// Adafruit_ST7735 tft = Adafruit_ST7735 (cs, dc, mosi, sclk, rst);

// Qhov Xaiv 2: yuav tsum siv lub khoos phis tawj SPI

// (rau UNO uas yog sclk = 13 thiab sid = 11) thiab tus pin 10 yuav tsum yog // qhov tso tawm. Qhov no sai dua - tseem xav tau yog tias koj xav tau // siv daim npav microSD (saib cov duab piv txwv) Adafruit_ST7735 tft = Adafruit_ST7735 (cs, dc, rst); ntab nombre_leds = 0; teeb tsa tsis muaj dab tsi () {Serial.begin (9600); // Initialise la liaison I2C Wire.begin (); // Initialise le module RTC RTC.begin (); Serial.print ("init SD"); ncua (1000); yog (! SD.begin (cs_sd)) // Qhov xwm txheej vérifiant si la carte SD yog présente dans l'appareil {Serial.print ("Defaut SD"); rov qab; } Serial.print ("Carte SD OK");

Cov ntaub ntawv cov ntaub ntawv = SD.open ("donnees.txt", FILE_WRITE); // Ouvre le fichier "donnees.txt"

data.println (""); cov. data.println ("Yuav tsum tau txais khoom plig"); // Ecrit dans ce fichier data.close (); tft.initR (INITR_GREENTAB); // pib ua ST7735S nti, tab dub Serial.println ("init"); // peb qhov debugging tso tawm tft.fillScreen (ST7735_BLACK); // sensor baud tus nqi yog 9600 pmsSerial.begin (9600);

pixels.begin (); // INITIALIZE NeoPixel strip khoom (YUAV TSUM)

pixels.setBrightness (2);

}

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 tsis siv; uint16_t checksum; };

cov ntaub ntawv pms5003data cov ntaub ntawv; lub voj void () {pixels.clear (); // Teeb tsa txhua lub xim pixel rau 'tawm' DateTime tam sim no = RTC.now (); // Récupère l'heure et le courante hnub tim // affiche_date_heure (tam sim no);

temps = ((millis () - tempsInit))/1000; // Démarrage du chrono

yog (readPMSdata (& pmsSerial)) {// tft.fillScreen (ST7735_BLACK); tft.setCursor (10, 5); tft.setTextColor (ST7735_WHITE); tft.println ("nbre qhov/ 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_BLACK); tft.print (" microg/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 ("microg/m3");

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 ("microg/m3");

tft.setCursor (10, 5);

tft.setTextColor (ST7735_WHITE, ST7735_BLACK); tft.setTextSize (1); tft.println ("nbre qhov/ 0.1 l");

// Serial.print (sijhawm);

// 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µm"); Serial.print (data.particles_10um); Serial.print (""); Serial.print ("25µm"); Serial.print (data.particles_25um); Serial.print (""); Serial.print ("50µm"); Serial.print (data.particles_50um); Serial.print (""); Serial.print ("100µm"); Serial.print (data.particles_100um); Serial.println (""); nombre_leds = int (((ntab (data.particles_03um)/65535)*24))); // nombre_leds = (8); Serial.println (nombre_leds);

yog ((nombre_leds = 1)) {

pixels.fill (ntsug, 0, nombre_leds); } lwm yog ((nombre_leds = 8)) {pixels.fill (vert, 0, 8); pixels.fill (txiv kab ntxwv, 8, ((nombre_leds) -8))); } lwm yog (nombre_leds> 16) {

pixels.fill (ntsug, 0, 8); pixels.fill (txiv kab ntxwv, 8, 8); pixels.fill (rouge, 16, ((nombre_leds) -16))); } lwm yog (nombre_leds <= 1) {pixels.fill (vert, 0, 1); } pixels.show (); // Xa cov xim pixel tshiab hloov kho rau kho vajtse.

// Définition données Txoj hlua PM03 = Txoj hlua (data.particles_03um); Txoj hlua PM05 = Txoj hlua (data.particles_05um); Txoj hlua PM10 = Txoj hlua (data.particles_10um); Txoj hlua PM25 = Txoj hlua (data.particles_25um); Txoj hlua PM50 = Txoj hlua (data.particles_50um); Txoj hlua PM100 = Txoj hlua (data.particles_100um); Txoj hlua PMS10 = Txoj hlua (data.pm10_standard); Txoj hlua PMS25 = Txoj hlua (data.pm25_standard); Txoj hlua PMS100 = Txoj hlua (data.pm100_standard); String Temps = Txoj hlua (temps);

// Ecriture des données dans le fichier texte

Cov ntaub ntawv cov ntaub ntawv = SD.open ("donnees.txt", FILE_WRITE); data.println (Temps+""+PM03+""+PM05+""+PM10+""+PM25+""+PM50+""+PM100+""+PMS10+""+PMS25+""+PMS100+""); cov ntaub ntawv.close (); }

}

boolean readPMSdata (Stream *s) {

yog (! s-> muaj ()) {rov tsis tseeb; } // Nyeem ib byte ntawm lub sijhawm kom txog thaum peb mus rau qhov tshwj xeeb '0x42' pib-byte yog (s-> peek ()! = 0x42) {s-> nyeem (); rov dag; }

// Tam sim no nyeem tag nrho 32 bytes

yog (s-> muaj () readBytes (tsis, 32);

// tau txais checksum npaj

rau (uint8_t i = 0; i <30; i ++) {sum+= buffer ; }

/* debugging

rau (uint8_t i = 2; i <32; i ++) {Serial.print ("0x"); Serial.print (tsis , HEX); Serial.print (","); } Serial.println (); */ // Cov ntaub ntawv los hauv endian'd, qhov no daws nws kom nws ua haujlwm ntawm txhua lub platform uint16_t buffer_u16 [15]; rau (uint8_t i = 0; i <15; i ++) {buff_u16 = tsis [2 + i*2 + 1]; buffer_u16 + = (tsis [2 + i*2] << 8); }

// muab nws tso rau hauv tus qauv zoo:)

memcpy ((void *) & cov ntaub ntawv, (void *) buffer_u16, 30);

yog (sum! = data.checksum) {

Serial.println ("Checksum tsis ua hauj lwm"); rov dag; } // ua tiav! rov muaj tseeb; }

// Converti le numéro de jour en jour /! / La semaine commence un dimanche

Txoj hlua donne_jour_semaine (uint8_t j) {hloov (j) {rooj plaub 0: rov qab "DIM"; rooj plaub 1: rov qab "LUN"; rooj plaub 2: rov qab "MAR"; rooj plaub 3: rov qab "MER"; rooj plaub 4: rov qab "JEU"; rooj plaub 5: rov qab "VEN"; rooj plaub 6: rov qab "SAM"; default: rov qab ""; }}

// affiche la date et l'heure sur l'écran

void affiche_date_heure (DateTime datetime) {// Date String jour = donne_jour_semaine (datetime.dayOfTheWeek ()) + "" + Vers2Chiffres (datetime.day ()) + "/" + Vers2Chiffres (datetime.month ()) + "/" + Txoj hlua (datetime.year (), DEC); // heure Txoj hlua heure = ""; heure = Vers2Chiffres (datetime.hour ()) + ":" + Vers2Chiffres (datetime.minute ()) + ":" + Vers2Chiffres (datetime.second ());

Serial.print (taug kev); Serial.print (""); Serial.print (kho kom raug); //Serial.print (""); Cov ntaub ntawv cov ntaub ntawv = SD.open ("donnees.txt", FILE_WRITE); data.print (Jour + "" + heure + ""); cov ntaub ntawv.close ();

tft.setCursor (2, 120);

tft.setTextColor (ST7735_GREEN); tft.setTextSize (1); tft.print ("hnub tim"); tft.setTextColor (ST7735_YELLOW); tft.print (jour); tft.setTextColor (ST7735_GREEN); tft.setCursor (2, 130); tft.print ("heure"); tft. setTextColor (ST7735_YELLOW); tft.print (kho kom raug);

ncua (500);

}

// permet d'afficher les nombres sur deux chiffres

Txoj hlua Vers2Chiffres (byte nombre) {Txoj hlua resultat = ""; yog (nombre <10) resultat = "0"; return resultat = = Txoj hlua (lub npe, DEC); }

Kauj Ruam 3: MIT App Inventor 2 Program

MIT App Inventor 2 Program
MIT App Inventor 2 Program

qhov no yog MIT app tus tsim cov cai thaiv

Kauj Ruam 4: QHOV TSEEB

nov yog daim vis dis aus ntawm qhov tshwm sim

Pom zoo: