Cov txheej txheem:

Khaub Ncaws Ntxhua Khaub Ncaws/Tshuab Ziab Khaub Ncaws Nrog ESP8266 & Kev Ceev Ceev: 6 Kauj Ruam
Khaub Ncaws Ntxhua Khaub Ncaws/Tshuab Ziab Khaub Ncaws Nrog ESP8266 & Kev Ceev Ceev: 6 Kauj Ruam

Video: Khaub Ncaws Ntxhua Khaub Ncaws/Tshuab Ziab Khaub Ncaws Nrog ESP8266 & Kev Ceev Ceev: 6 Kauj Ruam

Video: Khaub Ncaws Ntxhua Khaub Ncaws/Tshuab Ziab Khaub Ncaws Nrog ESP8266 & Kev Ceev Ceev: 6 Kauj Ruam
Video: txhais zaj npau suav pom ris tsho thiab khaub ncaws 2024, Hlis ntuj nqeg
Anonim
Khaub Ncaws Ntxhua Khaub Ncaws/Tshuab Ziab Khaub Ncaws Nrog ESP8266 & Kev Ceev Ceev Sensor
Khaub Ncaws Ntxhua Khaub Ncaws/Tshuab Ziab Khaub Ncaws Nrog ESP8266 & Kev Ceev Ceev Sensor

Cov khaub ncaws ntxhua khaub ncaws/tshuab ziab khaub ncaws nyob hauv qab daus, thiab koj, raws li txoj cai, muab cov khaub ncaws tso rau hauv thiab tom qab ntawd, koj dhau los ua haujlwm hauv koj lwm lub tsev ua haujlwm. Koj tsis quav ntsej cov khaub ncaws uas tau tawm hws thiab nqus hauv qab daus ntawm koj lub tshuab. Zoo dua, ib zaug ib zaug koj tsuas yog khiav qis qis cia siab tias lub tshuab tau ua tiav txoj haujlwm thiab tom qab ntawd koj pom lub tshuab tseem ua haujlwm. Kuv paub, nws ua rau khaus.

Xav txog qhov xwm txheej uas koj tuaj yeem saib cov xwm txheej ntawm lub tshuab ntxhua khaub ncaws/tshuab ziab khaub ncaws ntawm koj lub xov tooj ntawm tes lossis ntsiav tshuaj. Ib yam nkaus, qhov twg koj tuaj yeem tau txais cov lus ntawm koj lub xov tooj hais tias lub tshuab tau ua tiav nws txoj haujlwm. Suab zoo li ntxim nyiam thiab haum, txoj cai!

Qhov tseeb, nrog kev pab ntawm ESP8266 thiab lub ntsuas cua nrawm koj tuaj yeem saib xyuas qhov xwm txheej ntawm koj cov khaub ncaws ntxhua khaub ncaws/tshuab ziab khaub ncaws. Koj tuaj yeem ua qhov kev nqis peev no ntawm koj tus kheej lub tsev hauv qhov yooj yim yog tias koj tsuas yog ua raws cov lus qhia thiab theej cov cai.

Kauj Ruam 1: Cov Khoom Peb Xav Tau

Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau

1. Adafruit Huzzah ESP8266

Thawj kauj ruam tau txais Adafruit Huzzah ESP8266 pawg thawj coj. Adafruit Huzzah ESP8266 yog tus nqi qis Wi-nkaus nti nrog rau tag nrho TCP/IP pawg thiab microcontroller muaj peev xwm. ESP8266 tus qauv yog lub rooj tsav xwm muaj txiaj ntsig zoo nrog rau cov zej zog loj, thiab tau nce zuj zus.

2. Adafruit Huzzah ESP8266 Host Adapter (USB Programmer)

Qhov ESP8266 tus tswv tsev adapter tau tsim tshwj xeeb rau Adafruit Huzzah version ntawm ESP8266, muab I²C interface. Kev koom ua ke USB chaw nres nkoj muab lub zog thiab cov phiaj xwm rau ESP8266.

3. H3LIS331DL Acceleration Sensor

H3LIS331DL yog lub zog qis ua tau zoo 3-axis linear accelerometer nrog digital I²C serial interface. Nws tau nruab rau ntsuas qhov nrawm nrog cov ntaub ntawv tso tawm tus nqi los ntawm 0.5 Hz txog 1 kHz. Txhua yam no ua rau lub ntsuas ntsuas no yog qhov kev xaiv zoo tshaj plaws rau txoj haujlwm no.

4. Txuas Cable

Kuv siv I²C txuas cable muaj nyob ntawm qhov txuas saum toj no.

5. Mini USB cable

Lub mini USB cable Lub hwj chim muab yog qhov kev xaiv zoo tshaj rau kev txhawb nqa Adafruit Huzzah ESP8266.

Kauj Ruam 2: Kev Sib Txuas Kho Vajtse

Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas

Feem ntau, kev sib txuas yog yooj yim heev. Ua raws cov lus qhia thiab cov duab hauv qab no, thiab koj yuav tsum tsis muaj teeb meem.

Kev sib txuas ntawm Adafruit Huzzah ESP8266 thiab USB Programmer

Ua ntej tshaj plaws coj Adafruit Huzzah ESP8266 thiab tso USB Programmer (nrog Sab Hauv Lub ntsej muag I²C Port) rau nws. Nias tus USB Programmer maj mam muab tso rau hauv qhov chaw thiab peb tau ua tiav nrog cov kauj ruam no. Yooj yim ua ncuav qab zib (Saib daim duab #1).

Kev sib txuas ntawm Sensor thiab Adafruit Huzzah ESP8266

Coj lub sensor thiab txuas I²C Cable rau nws. Kom ua haujlwm tau zoo ntawm cov kab no, thov nco ntsoov I²C Cov Tawm Ib Leeg txuas rau I²C Cov Tswv Yim. Ib yam yuav tsum ua tiav rau Adafruit Huzzah ESP8266 nrog USB Programmer tau teeb tsa nws (Saib daim duab #2).

Nrog kev pab los ntawm ESP8266 USB Programmer, nws yooj yim heev rau program ESP8266. Txhua yam koj yuav tsum ua yog ntsaws lub sensor rau hauv USB Programmer thiab koj zoo mus. Kuv nyiam siv lub adapter no vim tias nws ua rau nws yooj yim dua los txuas cov khoom siv. Yog tsis muaj qhov ntsaws thiab ua si USB Programmer, muaj qhov pheej hmoo yuav ua rau kev txuas tsis raug. Ib txoj xov hlau tsis raug tuaj yeem tua koj lub wifi zoo li koj lub sensor.

Nco tseg: Cov xaim xim av yuav tsum ib txwm ua raws hauv av (GND) kev sib txuas ntawm cov khoom siv ntawm ib lub cuab yeej thiab cov tswv yim ntawm lwm lub cuab yeej

Kev ua kom muaj zog ntawm Circuit Court

Txuas lub Mini USB cable rau hauv lub zog txuas ntawm Adafruit Huzzah ESP8266. Teeb nws thiab voila, peb zoo mus!

Kev sib dhos zaum kawg yuav zoo li hauv daim duab #3.

Muab lub sensor tso rau hauv khaub ncaws/tshuab ziab khaub ncaws

Ua ntej ua qhov no, xyuas kom koj npog lub sensor tag nrho nrog yas kom nws muaj sia nyob nrog kev sib cuag nrog dej. Tam sim no, tso lub ntsuas cua thiab muab nws tso rau ntawm lub nruas ntawm lub tshuab ntxhua khaub ncaws/tshuab ziab khaub ncaws. Ua nws txhob txwm tshaj tawm yam tsis ua mob xaim hlau ntawm lub tshuab ntxhua khaub ncaws/tshuab ziab khaub ncaws thiab ua rau koj tus kheej raug mob.

Nrog rau qhov no, peb tau ua tiav nrog txhua txoj haujlwm kho vajtse.

Kauj Ruam 3: Adafruit Huzzah ESP8266 Arduino Code

ESP Code rau Adafruit Huzzah ESP8266 thiab H3LIS331DL Sensor muaj nyob ntawm peb Github chaw cia khoom.

Ua ntej mus rau txoj cai, nco ntsoov koj tau nyeem cov lus qhia muab rau hauv Readme cov ntaub ntawv thiab teeb tsa koj li Adafruit Huzzah ESP8266 raws li nws. Nws yuav tsuas yog siv sijhawm me ntsis los ua qhov ntawd.

Nco tseg: Ua ntej rub tawm, xyuas kom tseeb tias koj nkag mus rau koj li SSID network thiab tus password hauv tus lej

Koj tuaj yeem luam tus lej ESP ua haujlwm rau lub ntsuas no los ntawm no kuj:

// Tshaj tawm nrog daim ntawv tso cai pub dawb.// Siv nws txhua txoj hauv kev koj xav tau, muaj txiaj ntsig lossis pub dawb, muab nws haum rau hauv daim ntawv tso cai ntawm nws cov haujlwm ua haujlwm. // Ntaub Tshuab Ntxhua Khaub Ncaws/Tshuab ziab khaub ncaws nrog ESP8266 // Tus lej no yog tsim los ua haujlwm nrog H3LIS331DL_I2CS I2C Mini Module muaj los ntawm Dcubestore.com. //

#suav nrog

#include #include #include

// H3LIS331DL I2C chaw nyob yog 0x18 (24)

#define Ntxiv 0x18

const char* ssid = "koj lub network ssid";

const char* password = "koj tus password";

ESP8266WebServer server (80);

tsis muaj dab tsi handleroot ()

{unsigned int cov ntaub ntawv [6];

rau (int i = 0; i <6; i ++) {// Pib I2C Kev Xa Cov Hlau.beginTransmission (Addr); // Xaiv cov ntaub ntawv sau npe Wire.write ((40 + i)); // Nres I2C Kis Kab Hlau.endTransmission ();

// Thov 1 byte ntawm cov ntaub ntawv

Wire.requestFrom (Addr, 1); // Nyeem 6 bytes ntawm cov ntaub ntawv // xAccl lsb, xAccl msb, yAccl lsb, yAccl msb, zAccl lsb, zAccl msb yog (Wire.available () == 1) {data = Wire.read (); }} ncua (300);

// Hloov cov ntaub ntawv

int xAccl = ((data [1] * 256) + data [0]); yog (xAccl> 32767) {xAccl -= 65536; } int xAcc = ((100 * 9.8) / 32768) * xAccl;

int yAccl = ((cov ntaub ntawv [3] * 256) + cov ntaub ntawv [2]);

yog (yAccl> 32767) {yAccl -= 65536; } int yAcc = ((100 * 9.8) / 32768) * yAccl;

int zAccl = ((cov ntaub ntawv [5] * 256) + cov ntaub ntawv [4]);

yog (zAccl> 32767) {zAccl -= 65536; } int zAcc = ((100 * 9.8) / 32768) * zAccl;

// Cov ntaub ntawv tso tawm rau tus saib xyuas

Serial.print ("Ua kom nrawm hauv X-Axis:"); Serial.print (xAcc); Serial.println ("m/s"); Serial.print ("Kev nrawm hauv Y-Axis:"); Serial.print (yAcc); Serial.println ("m/s"); Serial.print ("Ua kom nrawm hauv Z-Axis:"); Serial.print (zAcc); Serial.println ("m/s"); ncua (300);

// Tso cov ntaub ntawv rau Web Server

server.sendContent ("<meta http-equiv = 'refresh' cov ntsiab lus = '10 '""

Tswj txhua yam

www.controleverything.com

H3LIS331DL Sensor I2C Mini Module

"); server.sendContent ("

Kev nrawm hauv X-Axis = " + String (xAcc) +" m/s/s "); server.sendContent ("

Kev nrawm hauv Y-Axis = " + String (yAcc) +" m/s/s "); server.sendContent ("

Kev nrawm hauv Z-Axis = " + String (zAcc) +" m/s/s ");

yog (xAcc> 2)

{// Cov ntaub ntawv tso tawm rau tus saib xyuas Serial.println ("Cloths Washer/Dryer: Working");

// Tso cov ntaub ntawv rau Web Server

server.sendContent ("

Cov Khaub Ncaws Ntxhua Khaub Ncaws/Tshuab ziab khaub ncaws: Ua haujlwm ");} lwm yam {// Cov ntaub ntawv tso tawm mus rau saib xyuas Serial.println (" Cov Khaub Ncaws Khaub Ncaws/Tshuab Khaub Ncaws: Ua tiav ");

// Tso cov ntaub ntawv rau Web Server

server.sendContent ("

Cov Khaub Ncaws Khaub Ncaws/Khaub Ncaws: Ua tiav ");}}

void teeb tsa ()

{// Initialise I2C kev sib txuas lus li MASTER Wire.begin (2, 14); // Initialise serial communication, set baud rate = 115200 Serial.begin (115200);

// Txuas rau WiFi network

WiFi.begin (ssid, password);

// Tos rau kev txuas

thaum (WiFi.status ()! = WL_CONNECTED) {ncua (500); Serial.print ("."); } Serial.println (""); Serial.print ("Txuas nrog"); Serial.println (ssid);

// Tau txais IP chaw nyob ntawm ESP8266

Serial.print ("IP chaw nyob:"); Serial.println (WiFi.localIP ());

// Pib server

server.on ("/", tus tuav tes); server.begin (); Serial.println ("HTTP server tau pib");

// Pib I2C Kev Kis

Wire.beginTransmission (Addr); // Xaiv tswj npe 1 Wire.write (0x20); // Pab kom X, Y, Z axis, lub zog rau hom, cov ntaub ntawv tso tawm tus nqi 50Hz Wire.write (0x27); // Nres I2C Kis Kab Hlau.endTransmission ();

// Pib I2C Kev Kis

Wire.beginTransmission (Addr); // Xaiv tswj npe 4 Wire.write (0x23); // Teeb tsa qhov ntsuas tag nrho, +/- 100g, hloov tshiab tas li Wire.write (0x00); // Nres I2C Kis Kab Hlau.endTransmission (); ncua (300); }

void lub voj ()

{server.handleClient (); }

Kauj Ruam 4: Kev Ua Tau Zoo ntawm Txoj Cai

Xyaum Ua Haujlwm ntawm Txoj Cai
Xyaum Ua Haujlwm ntawm Txoj Cai

Tam sim no, rub tawm (rub tawm git) lossis luam cov cai thiab qhib nws hauv Arduino IDE.

Ua ke thiab Tshaj tawm cov cai thiab pom cov txiaj ntsig ntawm koj li Serial Monitor. Tom qab ob peb feeb, nws yuav tso tawm txhua qhov ntsuas.

Luam tus IP chaw nyob ntawm ESP8266 los ntawm Serial Monitor thiab muab tso rau hauv koj lub vev xaib. Koj yuav pom lub vev xaib nrog kev nyeem nrawm hauv 3-axis thiab xwm txheej ntawm Lub Tshuab Ntxhua Khaub Ncaws/tshuab ziab khaub ncaws. Ua ntej txav mus rau qhov kev sim zaum kawg, koj yuav tsum hloov kho tus nqi nrawm raws li lub tshuab ntxhua khaub ncaws txoj haujlwm thiab ntsuas qhov ntsuas qhov ntsuas hauv qhov xwm txheej yog tias yog lwm qhov hauv cov cai.

Cov txiaj ntsig ntawm lub ntsuas ntawm Serial Monitor thiab Web Server tau qhia hauv daim duab saum toj no.

Kauj Ruam 5: Cov ntawv thov thiab kho dua tshiab

Nrog kev pab ntawm txoj haujlwm no, koj tuaj yeem saib xyuas qhov xwm txheej ntawm koj lub tshuab ntxhua khaub ncaws/tshuab ziab khaub ncaws ntawm koj lub xov tooj thiab khoos phis tawj. Tsis tas yuav mus dhau thiab tuav/mloog rau nws kom ua tiav txoj haujlwm.

Koj kuj tseem tuaj yeem tau txais cov lus ntawm koj lub xov tooj qhia tias lub tshuab tau ua tiav nws txoj haujlwm. Nrog rau qhov no, koj yuav nco ntsoov cov khaub ncaws hauv lub tshuab ntxhua khaub ncaws. Txog qhov no, koj tuaj yeem yooj yim txhim kho txoj haujlwm no los ntawm kev ntxiv qee qhov hauv cov cai tau hais los saum no.

Kuv vam tias koj nyiam txoj haujlwm no thiab nws txhawb nqa kev sim ntxiv. Adafruit Huzzah ESP8266 pawg thawj coj saib yog qhov tsis txaus ntseeg, pheej yig thiab siv tau rau txhua tus nyiam ua haujlwm. Nov tsuas yog ib ntawm ntau qhov haujlwm yooj yim uas tuaj yeem tsim kho siv ESP8266.

Kauj Ruam 6: Cov peev txheej mus ntxiv

Yog xav paub ntxiv txog H3LIS331DL thiab ESP8266, txheeb xyuas qhov txuas hauv qab no:

  • H3LIS331DL Sensor Cov Ntaub Ntawv
  • Cov Ntaub Ntawv Keeb Kwm Dav Hlau rau ESP8266 los ntawm Kev Tshawb Dav Dav Dav

Koj tseem tuaj yeem saib peb cov ntawv ntxiv ntawm Tsev Automation & ESP8266 cov haujlwm:

  • Tsev Automation nrog ESP8266 thiab Relay Controller
  • Tswj Teeb nrog ESP8266 thiab Siab Sensor

Pom zoo: