Cov txheej txheem:
- Kauj Ruam 1: Tsim thiab nkag mus rau THINGSIO Platform
- Kauj Ruam 2: Tsim Txoj Haujlwm Tshiab
- Kauj Ruam 3: Tsim Tus Ntaus Tshiab
- Kauj Ruam 4: Txheeb Cov Khoom Parameter
- Kauj Ruam 5: Hloov Kho Tus Ntaus
- Kauj ruam 6: Coding
- Kauj Ruam 7: Xaiv Pawg Thawj Coj thiab Com Port
- Kauj Ruam 8: Kev Sib Txuas Circuit
- Kauj ruam 9: Sau thiab xa tawm
- Kauj ruam 10: Serial Monitor
- Kauj ruam 11: Nyeem ntawv
- Kauj Ruam 12: Cov Duab Sawv Cev
- Kauj ruam 13:
Video: LDR Siv Thingsai Cloud: 13 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
HNUB….. hnub no peb yuav kawm txog kev ntsuas qhov hnyav ntawm lub teeb thiab tshaj tawm qhov txiaj ntsig rau hauv THINGSAI IOT huab platform los ntawm kev siv ESP32.
Cov tseev kom ua qhov haujlwm no yog
1. ESP32 Development Board (Kuv tau siv ESP32 DEVKIT V1)
2. LDR sensor
3. Jumper Wires
4. Account hauv THINGSAI IOT PLATFORM
Kauj Ruam 1: Tsim thiab nkag mus rau THINGSIO Platform
Nkag mus rau THINGS AI tus account. Yog tias koj yog tus tshiab ces sau npe rau tus as khauj los ntawm nias lub pob sau npe thiab sau tag nrho cov ntawv pov thawj. Koj tus lej nyiaj yuav raug tsim thiab txij thaum ntawd los koj yuav tuaj yeem ua haujlwm ntawm huab platform thiab tsim koj txoj haujlwm tshwj xeeb
Kauj Ruam 2: Tsim Txoj Haujlwm Tshiab
Tom qab nkag mus rau hauv tus as khauj, los tsim qhov project tsuas yog nyem rau ntawm qhov haujlwm tshiab thiab tom qab ntawd muab lub npe project.
Kauj Ruam 3: Tsim Tus Ntaus Tshiab
tom qab tsim qhov project yam tom ntej uas koj yuav tsum tau ua yog tsim lub cuab yeej tshiab. Qhia lub npe ntaus ntawv thiab nkag mus rau tus lej ntaus ntawv txawm yog tus kheej lossis lub tshuab tsim.
Kauj Ruam 4: Txheeb Cov Khoom Parameter
Muab cov cuab yeej ntsuas thiab tom qab ntawd xaiv hom kev ntsuas
Kauj Ruam 5: Hloov Kho Tus Ntaus
Xaiv qhov ntsuas thiab tom qab hloov kho lub cuab yeej
Kauj ruam 6: Coding
Los ntawm cov qauv piv txwv xaiv cov cai ntawm esp32 luam nws thiab tom qab ntawd muab lo rau hauv arduino IDE thiab hloov qhov tsim nyog raws li qhov xav tau. Kuv tau muab cov cai hauv qab no
#ncig #ncig
#suav nrog
int suav = 0, i, m, j, k;
tus t; int outputpin = A0; // ds18b20
tus nqi sensor;
//////////////////////////////////////// Txhua qhov kev txiav txim rau CLOUD ////// //////////////////////////
const char* tus tswv = "api.thingsai.io"; // LUB
host = devapi2.thethingscloud.com
const char* post_url = "/devices/deviceData"; // LOS YOG/api/v2/thingscloud2/_table/data_ac
const char* time_server = "baas.thethingscloud.com"; // qhov no yog los hloov lub sijhawm
const int httpPort = 80;
ua int httpsPort = 443;
const char* neeg rau zaub mov = "api.thingsai.io"; // Neeg rau zaub mov URL
timestamp char [10];
WiFiMulti WiFiMulti;
// Siv chav kawm WiFiClient los tsim kev sib txuas TCP
WiFiClient tus thov kev pab;
/////////////////////////////////////// TIMESTAMP CALCULATION muaj nuj nqi //////// ///////////////////////////////// int GiveMeTimestamp () {unsigned ntev timeout = millis (); // WiFiClient tus thov kev pab;
thaum (client.available () == 0)
{
yog tias (millis () - sijhawm>> 50000)
{
client.stop (); cov. rov 0;
}
}
thaum (client.available ())
{
Txoj hlua kab = client.readStringUntil ('\ r'); // indexOf () yog qhov ua haujlwm los tshawb rau smthng, nws rov qab -1 yog tias tsis pom
int pos = line.indexOf ("\" timestamp / ""); // tshawb rau "\" timestamp / "" txij thaum pib teb tau txais thiab theej tag nrho cov ntaub ntawv tom qab ntawd, nws yuav yog koj lub sijhawm
yog (pos> = 0)
{
int j = 0;
rau (j = 0; j <10; j ++)
{
timestamp [j] = kab [pos + 12 + j];
}
}
}
} ////////////////////////////////////////////////////////////////////////////////////////////////////////
void teeb tsa ()
{
Serial.begin (115200);
ncua (10);
// Peb pib los ntawm kev txuas mus rau WiFi network
WiFiMulti.addAP ("wifi", "pswrd");
Serial.println ();
Serial.println ();
Serial.print ("Tos WiFi …");
thaum (WiFiMulti.run ()! = WL_CONNECTED)
{
Serial.print (".");
ncua (500);
}
Serial.println ("");
Serial.println ("Txuas nrog WiFi");
Serial.println ("IP chaw nyob:"); Serial.println (WiFi.localIP ());
ncua (500);
}
void lub voj ()
{
int analogValue = analogRead (tus pin);
{/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Xa tsuas yog lus nug thiab tau txais cov lus teb /// //////////////////////
sensorvalue = analogRead (A0); // nyeem analog input tus pin 0
sensorvalue = tus nqi sensor/100;
Serial.print (sensorvalue, DEC); // luam tawm tus nqi nyeem
Serial.print ("\ n"); // luam qhov chaw nruab nrab ntawm cov lej
ncua (1000); // tos 100ms rau kev nyeem ntawv tom ntej
Serial.print ("txuas rau"); Serial.println (tus tswv tsev); // txhais tau ib sab:- host = devapi2.thethingscloud.com lossis 139.59.26.117
///////////////////////////////////// TIMESTAMP CODE SNIPPET ////////// /////////////////
Serial.println ("sab hauv tau txais timestamp / n");
yog (! client.connect (time_server, {rov qab; //*-*-*-*-*-*-*-*-**
client.println ("Tau txais/api/timestamp HTTP/1.1"); // Qhov haujlwm no ua dab tsi, kuv tsis tau txais client.println ("Host: baas.thethingscloud.com");
client.println ("Cache-Control: tsis-cache");
client.println ("Postman-Token: ea3c18c6-09ba-d049-ccf3-369a22a284b8");
client.println (); cov.
GiveMeTimestamp (); // nws yuav hu lub luag haujlwm uas yuav tau txais lub sijhawm timestamp teb los ntawm server Serial.println ("timestamp tau txais");
Serial.println (timestamp);
Serial.println ("hauv ThingsCloudPost");
Txoj hlua PostValue = "{" device_id / ": 61121695844, \" slave_id / ": 2";
PostValue = PostValue + ", \" dts / ":" + timestamp;
PostValue = PostValue +", \" data / ": {" INTENSITY / ":" +\ sensorvalue +"}" +"}";
Serial.println (PostValue);
/ * tsim qhov piv txwv ntawm WiFiClientSecure */ WiFiClientSecure tus thov kev pab;
Serial.println ("Txuas rau server ntawm chaw nres nkoj 443");
yog (! client.connect (server, 443))
{
Serial.println ("Kev sib txuas tsis tau ua tiav!");
}
lwm tus
{Serial.println ("Txuas rau server!"); / * tsim kev thov HTTP */
client.println ( POST/pab kiag li lawm/deviceData
client.println ("Tus tswv: api.thingsai.io"); //client.println("Connection: kaw "); cl
ient.println ("Cov ntsiab lus-Hom: thov/json");
client.println ("cache-control: tsis-cache");
client.println ("Kev Tso Cai: BearereyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9. IjVhMzBkZDFkN2QwYjNhNGQzODkwYzQ4OSI.kaY6OMj5cYlWNqC2PNTkXs9Jy9j9" client.print ("Cov ntsiab lus-Ntev:");
client.println (PostValue.length ());
client.println (); cov.
client.println (PostValue); ////////////////////////////////// POSTING cov ntaub ntawv rau ntawm huab tau ua tiav thiab tam sim no tau txais daim ntawv teb huab neeg rau zaub mov ////////////////////
Serial.print ("Tos kom teb");
thaum (! client.available ()) {
ncua (50); //
Serial.print (".");
} / * yog tias muaj cov ntaub ntawv ces txais thiab luam tawm rau Terminal * /
thaum (client.available ())
{
char c = client.read (); cov.
Serial.write (c);
}
/ * yog tias tus neeg rau zaub mov raug txuas, nres tus neeg siv khoom */
yog (! client.connected ())
{
Serial.println ();
Serial.println ("Cov neeg rau zaub mov raug txuas");
client.stop (); cov.
}
} Serial.println ("////////////////////// END ////////////////////// /");
ncua (3000); }}
Kauj Ruam 7: Xaiv Pawg Thawj Coj thiab Com Port
Los ntawm cov cuab yeej xaiv lub rooj tsavxwm thiab tom qab ntawd xaiv lub com chaw nres nkoj
Kauj Ruam 8: Kev Sib Txuas Circuit
Coding yog ua tiav ces ua cov kev sib txuas hauv qab no raws li tau hais hauv qab no
Kev sib txuas:
GND ntawm esp32 rau GND ntawm LDR sensor
3V3 0f esp32 rau Vcc ntawm LDR
VP ntawm esp32 rau A0 ntawm LDR
Kauj ruam 9: Sau thiab xa tawm
suav sau thiab xa cov cai rau hauv esp32 thiab tom qab ntawd nyeem cov ntawv nyeem los ntawm tus saib xyuas. Qhov ntawd yuav qhia qhov tshwm sim zoo li no
Kauj ruam 10: Serial Monitor
Qhov muaj txiaj ntsig tau txais ntawm cov ntawv saib xyuas tom qab ntawd lawv raug xa mus rau THINGSAI IOT Cloud platform.
Kauj ruam 11: Nyeem ntawv
Qhov no qhia pom qhov txiaj ntsig tau los ntawm pawg thawj coj esp32.
Kauj Ruam 12: Cov Duab Sawv Cev
Nov yog cov duab sawv cev ntawm cov txiaj ntsig tau txais. Ntawd yog qhov kawg ntawm kev qhia. Vam tias koj nkag siab. Ua Tsaug
Pom zoo:
Cov Khoom Siv Teeb Meem Siv Chaw Taws Teeb Siv Arduino: 7 Kauj Ruam
Cov Khoom Siv Teeb Meem Siv Khoom Siv Hluav Taws Xob Siv Arduino: Tam sim no, Cov Tsim, Cov tsim tawm tau nyiam Arduino rau kev txhim kho sai ntawm cov qauv ntawm cov phiaj xwm. Arduino yog lub platform siv hluav taws xob qhib raws qhov yooj yim-rau-siv-kho vajtse thiab software. Arduino muaj zej zog cov neeg siv zoo heev. Hauv qhov no
Saib Xyuas Kev Siv Sijhawm Siv Raspberry Pi thiab AIS328DQTR Siv Python: 6 Cov Kauj Ruam
Saib Xyuas Kev Siv Sijhawm Siv Raspberry Pi thiab AIS328DQTR Siv Python: Kev nrawm yog qhov kawg, Kuv xav raws li qee txoj cai ntawm Physics.- Terry Riley Tus cheetah siv qhov nrawm nrawm thiab hloov pauv sai thaum caum. Tus tsiaj nrawm tshaj plaws nyob ntawm ntug hiav txwv ib zaug hauv ib lub sijhawm siv nws qhov nrawm tshaj plaws kom ntes tau cov tsiaj txhu. Qhov
Tsis Siv Neeg Kab Hlau Rhuav/Qhov Muag Qhov Muag Siv Arduino thiab LDR: 3 Cov Kauj Ruam
Tsis Siv Neeg Kab Hlau Rhuav/Qhov Muag Qhov Muag Qhov Muag Siv Arduino thiab LDR: Hauv qhov kev qhia no peb yuav los qhia yuav ua li cas thiaj ua lub qhov muag tsis pom qhov muag tsis siv Arduino thiab LDR Module. Thaum nruab hnub daim ntaub/Qhov muag dig qhov muag yuav ntog thiab thaum hmo ntuj nws yuav dov tawm
Motion Detector Siv Thingsai.io Iot Cloud Platform: 6 Kauj Ruam
Motion Detector Siv Thingsai.io Iot Cloud Platform: Hauv qhov kev qhia no kuv yuav piav qhia txog kev txav mus los los ntawm kev siv lub PIR sensor thiab Esp32 nrog rau IOT huab platform Thingai.io
Yuav Ua Li Cas Kom Yooj Yim Tsis Siv Neeg Hmo Hmo Teeb Pom Kev Siv LDR: 4 Kauj Ruam
Yuav Ua Li Cas Ua Kom Yooj Yim Tsis Siv Neeg Hmo Hmo Teeb Siv LDR: Nyob zoo cov phooj ywg hnub no kuv yuav qhia koj yuav ua li cas thiaj ua lub teeb pom kev hmo ntuj tsis siv neeg yooj yim siv LDR (Lub teeb nyob ntawm tus tiv thaiv) thiab mosfet yog li ua raws thiab hauv cov kauj ruam tom ntej, koj yuav nrhiav lub teeb pom kev zoo hmo ntuj tsis siv neeg nrog rau t