Orodha ya maudhui:

PInt @ t10n: Mfumo wa Ufuatiliaji wa mimea mahiri: Hatua 9
PInt @ t10n: Mfumo wa Ufuatiliaji wa mimea mahiri: Hatua 9

Video: PInt @ t10n: Mfumo wa Ufuatiliaji wa mimea mahiri: Hatua 9

Video: PInt @ t10n: Mfumo wa Ufuatiliaji wa mimea mahiri: Hatua 9
Video: Укладка плитки на бетонное крыльцо быстро и качественно! Дешёвая плитка, но КРАСИВО! 2024, Novemba
Anonim
PInt @ t10n: Mfumo wa Ufuatiliaji wa mimea mahiri
PInt @ t10n: Mfumo wa Ufuatiliaji wa mimea mahiri

PI @ nt @ t10n

Mradi huu uliundwa kama jaribio la wingu la ibm iot. Tunatumia esp-8266 kutuma na kupokea data kwenda na kutoka kwa wingu la ibm. Mawasiliano kati ya esp na wingu la ibm hufanyika kupitia MQTT.

Kushughulikia data zote na kuwasilisha mtumiaji kiolesura cha mtumiaji tunatumia node-nyekundu. Ni rafiki wa Kompyuta.

Ili kuanza unahitaji:

  • Esp-8266
  • dht 11/22 temp / sensor ya unyevu
  • diode ya kupendeza (kipimo nyepesi)
  • buzzer
  • sensorer ya unyevu wa ardhi
  • akaunti ya wingu la ibm

Hatua ya 1: Unganisha Sensorer zako

Unganisha Sensorer Zako
Unganisha Sensorer Zako
Unganisha Sensorer Zako
Unganisha Sensorer Zako
Unganisha Sensorer Zako
Unganisha Sensorer Zako

Kama tulivyosema hapo awali tutatumia esp8266 kusoma na kutuma data ya sensorer. Kwa mafunzo haya tutadhani unajua jinsi ya kuunganisha sensorer zako kwa mdhibiti wako mdogo. Pia unahitaji kujua jinsi ya kupakia nambari kwa esp8266.

Mfano wetu wa esp una bandari moja ya analogi kwa hivyo tulichagua kupokea habari ya analog kutoka kwa sensa yetu ya taa kwa sababu basi tunaweza kufuatilia ni kiasi gani taa hupata.

Sensorer nyingine zote zimeunganishwa kidijitali. Sensorer yetu ya DHT11 hutuma data kwa dijiti na tunatumia maktaba ya dht kutafsiri data ya sensorer.

Hapo juu unaweza kupata mchoro wa mzunguko wa sensorer tulizotumia. Lakini tafadhali kumbuka kuwa sensorer tulizotumia mara nyingi huja na moduli ili uweze kuiunganisha kwa urahisi na mdhibiti wako mdogo bila vipinga vyote vya ziada ambavyo tulijumuisha kwenye mchoro.

Hatua ya 2: Kanuni

Huu ndio mchoro wa arduino tuliotumia. Unaweza kujifunza juu ya jinsi nambari inavyofanya kazi ikiwa utasoma maoni.

#jumuisha ArduinoJson.h # ni pamoja na DHT_U.h # pamoja na DHT.h # pamoja na ESP8266WiFi.h # pamoja na ESP8266WiFiMulti.h # pamoja na PubSubClient.h

#fafanua STASSID "ucll-projectweek-IoT" #fafanua STAPSK "Foo4aiHa" #fafanua DHTPin 5 #fafanua unyevuPini 4 #fafanua DHTType DHT11 DHT dht (DHTPin, DHTType); ESP8266WiFiMulti WiFiMulti; kuelea temp = 0; unyevu wa kuelea = 0; unyevu wa boolean = uwongo; mwanga = 0; const char * ssid = STASSID; const char * nywila = STAPSK; const char * mqtt_server = "cmfwqk.messaging.internetofthings.ibmcloud.com"; Mteja wa WiFi espClient; Mteja wa PubSubClient (espClient); mwisho mrefuMsg = 0; char msg [50]; thamani ya int = 0; #fafanua MQTT_HOST "cmfwqk.messaging.internetofthings.ibmcloud.com" #fafanua MQTT_PORT 1883 #fafanua MQTT_DEVICEID "d: cmfwqk: ESP8266: ESP" #fafanua MQTT_USER "tumia-ishara" ATH "MTTOK" iot-2 / evt / status / fmt / json "#fafanua MQTT_TOPIC_DISPLAY" iot-2 / cmd / update / fmt / json "#include" pitches.h "// notes in the melody: // note durations: 4 = quarter kumbuka, 8 = noti ya nane, nk. int shortTone = 80; muda mrefuTone = 200; kiwango standardDelay = 50; kuchelewesha intBearBars = 50; batili setup_wifi () {kuchelewesha (10); // Tunaanza kwa kuungana na mtandao wa WiFi Serial.println (); Serial.print ("Kuunganisha kwa"); Serial.println (ssid); Kuanza kwa WiFi (ssid, password); wakati (WiFi.status ()! = WL_CONNECTED) {kuchelewa (500); Printa ya serial ("."); } Serial.println (""); Serial.println ("WiFi imeunganishwa"); Serial.println ("Anwani ya IP:"); Serial.println (WiFi.localIP ()); } kupigwa tena batili (mada ya char *, baiti * upakiaji wa malipo, urefu usiowekwa saini) {Serial.print ("Ujumbe umefika ["); Printa ya serial (mada); Serial.print ("]"); kwa (int i = 0; i <urefu; i ++) {Serial.print ((char) malipo ya malipo ); } Serial.println (); Hati ya StaticJsonJsonBuffer; des desizeizeJson (jsonBuffer, malipo ya malipo); Mzizi wa JsonObject = jsonBuffer.as (); ikiwa (mzizi ["wimbo"] == "darude") {darude (); } ikiwa (mzizi ["wimbo"] == "nyota za nyota") {starwars (); } ikiwa (mzizi ["wimbo"] == "jacques") {Serial.println ("jakakakakakkakaka"); jacques (); }} batili unganisha tena () {// Kitanzi mpaka tuunganishwe tena wakati (! mteja.meunganishwa ()) {Serial.print ("Kujaribu unganisho la MQTT…"); // Jaribio la kuunganisha ikiwa (client.connect (MQTT_DEVICEID, MQTT_USER, MQTT_TOKEN)) {Serial.println ("imeunganishwa"); mteja.jisajili (MQTT_TOPIC_DISPLAY); } mwingine {Serial.print ("alishindwa, rc ="); Serial.print (mteja.state ()); Serial.println ("jaribu tena kwa sekunde 5"); // Subiri sekunde 5 kabla ya kujaribu kuchelewesha tena (5000); }}} usanidi batili () {Serial.begin (9600); pinMode (unyevuPini, INPUT); kuanza (); pinMode (0, OUTPUT); kuanzisha_wifi (); mteja.setServer (mqtt_server, MQTT_PORT); mteja.setCallback (kupiga simu tena); kuchelewesha (20); } kitanzi batili () {if (! client.connected ()) {reconnect (); } mteja. kitanzi (); unyevu = dijitiSoma (unyevuPini); mwanga = AnalogSoma (A0); temp = dht. soma Joto (); unyevu = dht. soma Unyenyekevu (); Serial.); Mshahara wa malipo = "{" ts / ": {" t / ":" + Kamba (temp, 1) + ", \" h / ":" + Kamba (unyevu, 1) + "}, \" ms / ": {" m / ":" + Kamba (unyevu) + "}, \" ls / ": {" l / ":" + Kamba (taa) + "}}"; Serial.println (malipo ya malipo); ikiwa (mteja.chapisha (MQTT_TOPIC, (char *) payload.c_str ()) {Serial.println ("chapisha sawa"); } mwingine {Serial.println ("kuchapisha imeshindwa"); } kuchelewa (2000); } batili darude () {toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti ndefu); kuchelewesha (LongTone); hakuna Sauti (0); kuchelewesha (kuchelewesha Kati ya Baa); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti ndefu); kuchelewesha (LongTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_E4, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_E4, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_E4, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_E4, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_E4, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_E4, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_E4, Sauti ndefu); kuchelewesha (LongTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_D4, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_D4, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_D4, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_D4, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_D4, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_D4, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_D4, Sauti ndefu); kuchelewesha (LongTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_A3, Sauti ndefu); kuchelewesha (LongTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti ndefu); kuchelewesha (LongTone); hakuna Sauti (0); kuchelewesha (kuchelewesha Kati ya Baa); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti ndefu); kuchelewesha (LongTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_E4, Sauti ndefu); kuchelewesha (LongTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti ndefu); kuchelewesha (LongTone); hakuna Sauti (0); kuchelewesha (kuchelewesha Kati ya Baa); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti fupi); kuchelewesha (ShortTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_B3, Sauti ndefu); kuchelewesha (LongTone); hakuna Sauti (0); kuchelewesha (standardDelay); toni (0, NOTE_E4, Sauti ndefu); kuchelewesha (LongTone); hakuna Sauti (0); kuchelewesha (standardDelay); } nyota za nyota za utupu () {beep (NOTE_A4, 500); beep (NOTE_A4, 500); beep (NOTE_A4, 500); beep (NOTE_F4, 350); beep (NOTE_C5, 150); beep (NOTE_A4, 500); beep (NOTE_F4, 350); beep (NOTE_C5, 150); beep (NOTE_A4, 650); kuchelewesha (500); beep (NOTE_E5, 500); beep (NOTE_E5, 500); beep (NOTE_E5, 500); beep (NOTE_F5, 350); beep (NOTE_C5, 150); beep (NOTE_GS4, 500); beep (NOTE_F4, 350); beep (NOTE_C5, 150); beep (NOTE_A4, 650); } beep batili (int note, int int) {// Cheza toni kwenye buzzerPin tone (0, kumbuka, muda); kuchelewesha (muda); hakuna Sauti (0); kuchelewesha (standardDelay); } utupu wa moyoOfCourage () {} utupu jacques () {beep (NOTE_C4, 500); beep (NOTE_D4, 500); beep (NOTE_E4, 500); beep (NOTE_C4, 500); beep (NOTE_C4, 500); beep (NOTE_D4, 500); beep (NOTE_E4, 500); beep (NOTE_C4, 500); beep (NOTE_E4, 500); beep (NOTE_F4, 500); beep (NOTE_G4, 500); beep (NOTE_E4, 500); beep (NOTE_F4, 500); beep (NOTE_G4, 500); beep (NOTE_G4, 500); beep (NOTE_A4, 500); beep (NOTE_G4, 500); beep (NOTE_F4, 500); beep (NOTE_E4, 500); beep (NOTE_C4, 500); beep (NOTE_G4, 500); beep (NOTE_A4, 500); beep (NOTE_G4, 500); beep (NOTE_F4, 500); beep (NOTE_E4, 500); beep (NOTE_C4, 500); beep (NOTE_C4, 500); beep (NOTE_G4, 500); beep (NOTE_C4, 500); beep (NOTE_C4, 500); beep (NOTE_G4, 500); beep (NOTE_C4, 500); }

Hatua ya 3: Ibm Cloud

Wingu la Ibm
Wingu la Ibm

Unahitaji kuanzisha mfano wa IBM-wingu. Unaweza kupata habari juu ya hii kupitia kiunga hiki: github.

Hatua ya 4: Node-RED

Tunatumia node nyekundu kwa kushughulikia mantiki yetu ya jumla ya biashara na kuibua data hii katika kiolesura cha mtumiaji angavu.

Hatua ya 5: Usanidi wa Node-RED: Nuru

Usanidi wa RED-RED: Mwanga
Usanidi wa RED-RED: Mwanga

Ingiza nambari ifuatayo kwenye mradi wako.

[{"id": "deb0d57.1c46528", "type": "tab", "label": "Light", "disabled": false, "info": ""}, {"id": "8a0fcaac. 4e54 "," type ":" ibmiot in "," z ":" deb0d57.1c46528 "," uthibitishaji ":" boundService "," apiKey ":" "," inputType ":" evt "," logicalInterface ":" "," ruleId ":" "," deviceId ":" ESP "," applicationId ":" "," TypeType ":" ESP8266 "," eventType ":" + "," commandType ":" "," format ": "json", "name": "Pata data kutoka ESP", "huduma": "iliyosajiliwa", "allDevices": uwongo, "allApplications": "", "allDeviceTypes": false, "allLogicalInterfaces": "", "AllEvents": true, "allCommands": "", "allFormats": "", "qos": 0, "x": 120, "y": 62, "waya":

Hatua ya 6: Usanidi wa Node-RED: Joto

Usanidi wa RED-RED: Joto
Usanidi wa RED-RED: Joto

Ingiza nambari ifuatayo kwenye mradi wako.

[{"id": "fbad3799.f0e0e", "type": "tab", "lebo": "Joto", "walemavu": uongo, "info": ""}, {"id": "b8618eb9. 1c9288 "," aina ":" ibmiot katika "," z ":" fbad3799.f0e0e "," uthibitishaji ":" Huduma iliyofungwa "," apiKey ":" "," Aina ya kuingiza ":" evt "," logicalInterface ":" "," ruleId ":" "," deviceId ":" ESP "," applicationId ":" "," TypeType ":" ESP8266 "," eventType ":" + "," commandType ":" "," format ": "json", "jina": "Pata data kutoka ESP", "huduma": "iliyosajiliwa", "vifaa vyote": uwongo, "AllApplications": "", "allDeviceTypes": uongo, "allLogicalInterfaces": "", "AllEvents": kweli, "All Command": "", "AllFormats": "", "qos": 0, "x": 145.5, "y": 49, "waya":

Hatua ya 7: Usanidi wa Node-RED: Unyevu

Usanidi wa RED-RED: Unyevu
Usanidi wa RED-RED: Unyevu

Ingiza nambari ifuatayo kwenye mradi wako.

[{"id": "144cd53b.c00473", "type": "tab", "label": "Humidity", "disabled": uongo, "info": ""}, {"id": "d958f58b. 2678e "," aina ":" ibmiot in "," z ":" 144cd53b.c00473 "," uthibitishaji ":" Huduma iliyofungwa "," apiKey ":" "," TypeType ":" evt "," logicalInterface ":" "," ruleId ":" "," deviceId ":" ESP "," applicationId ":" "," typeType ":" ESP8266 "," eventType ":" + "," commandType ":" "," format ": "json", "name": "Pata data kutoka ESP", "huduma": "iliyosajiliwa", "allDevices": uwongo, "AllApplications": "", "allDeviceTypes": false, "allLogicalInterfaces": "", "AllEvents": true, "allCommands": "", "allFormats": "", "qos": 0, "x": 142, "y": 87, "waya":

Hatua ya 8: Usanidi wa Node-RED: Unyevu

Usanidi wa RED-RED: Unyevu
Usanidi wa RED-RED: Unyevu

Ingiza nambari ifuatayo kwenye mradi wako.

[{"id": "4ee73536.ec6fc4", "type": "tab", "label": "Unyevu", "walemavu": uongo, "info": ""}, {"id": "a6daac3e. 2d5268 "," aina ":" ibmiot nje "," z ":" 4ee73536.ec6fc4 "," uthibitishaji ":" ServiceService "," apiKey ":" "," outputType ":" cmd "," kifaaId ":" ESP "," Aina ya kifaa ":" ESP8266 "," tukioCommandType ":" sasisha "," fomati ":" json "," data ":" msg "," qos ": 0," name ":" Tuma amri kwa ESP "," huduma ":" iliyosajiliwa "," x ": 804.1944580078125," y ": 383.0000305175781," waya ": }, {" id ":" 4134fdb7.18e9b4 "," type ":" ibmiot in ", "z" ": "ESP", "applicationId": "", "Aina ya kifaa": "ESP8266", "eventType": "update", "commandType": "", "format": "json", "name": "Pata data kutoka ESP "," huduma ":" iliyosajiliwa "," Vifaa vyote ": uwongo," AllApplications ":" "," allDeviceTypes ": uongo," allLogicalInterfaces ":" "," AllEvents ": kweli," AllCommands ":" ", "AllFormats": uongo, "qos": 0, "x": 115, "y": 76, "waya":

Hatua ya 9: Umemaliza

Hongera! sasa una mfumo wa uchunguzi wa mmea unaofanya kazi.

Ikiwa una swali lolote, usisite kuwasiliana nasi!