Cov txheej txheem:

Kev Tswj Xyuas Khoom Noj Hauv miv (ESP8266 + Servo Motor + 3D Printing): 5 Kauj Ruam (nrog Duab)
Kev Tswj Xyuas Khoom Noj Hauv miv (ESP8266 + Servo Motor + 3D Printing): 5 Kauj Ruam (nrog Duab)

Video: Kev Tswj Xyuas Khoom Noj Hauv miv (ESP8266 + Servo Motor + 3D Printing): 5 Kauj Ruam (nrog Duab)

Video: Kev Tswj Xyuas Khoom Noj Hauv miv (ESP8266 + Servo Motor + 3D Printing): 5 Kauj Ruam (nrog Duab)
Video: Plab Plab Ntswg..(Pluav Pluav Ntswg) Maiv Twm New Song 2023-2024 2024, Hlis ntuj nqeg
Anonim
Image
Image
Kev Tswj Xyuas Khoom Noj Hauv miv (ESP8266 + Servo Tsav + 3D Luam Ntawv)
Kev Tswj Xyuas Khoom Noj Hauv miv (ESP8266 + Servo Tsav + 3D Luam Ntawv)

Txoj haujlwm no mus dhau cov txheej txheem Kuv tau siv los tsim lub tais zaub mov miv tsis siv neeg, rau kuv cov laus muaj ntshav qab zib miv Chaz. Saib, nws xav tau noj tshais ua ntej nws tuaj yeem tau txais nws cov insulin, tab sis kuv feem ntau tsis nco qab khaws nws cov zaub mov ua ntej kuv mus pw, uas ua rau nws qab los noj mov thiab cuam tshuam nws lub sijhawm insulin. Cov tais no siv lub tshuab servo kaw lub hau ntawm cov khoom noj thaum ib tag hmo ib tag hmo thiab 7:30 sawv ntxov. NodeMCU ESP8266 microcontroller's Arduino kos duab siv Network Time Protocol (NTP) los tswj lub sijhawm.

Txoj haujlwm no yuav tsis haum rau cov menyuam yau, ua haujlwm ntau dua. Chaz laus heev thiab tsis muaj zog, nws tsis xav sim txhawm rau qhib lub tais, tab sis nws muaj peev xwm ua tau.

Yog tias koj tshiab rau Arduino lossis ESP8266, koj yuav txaus siab rau cov lus qhia ua ntej hauv qab no:

  • Instructables Arduino Class
  • Instructables Internet of Things Class

Khoom siv

  • 3D tshuab luam ntawv (Kuv siv Creality CR-10s Pro)
  • 3D tshuab luam ntawv ntsiabteeb (Kuv siv kub PLA)
  • NodeMCU ESP8266 wifi microcontroller
  • USB cable (A rau microB)
  • USB zog adapter
  • Micro servo tsav
  • Ntsia taub hau me me thiab ntsia hlau
  • Hookup hlau
  • Header tus pin
  • Perma-proto pawg thawj coj saib

Txhawm rau ua raws qhov kuv tab tom ua haujlwm, ua raws kuv hauv YouTube, Instagram, Twitter, Pinterest, thiab sau npe yuav rau kuv tsab ntawv xov xwm. Raws li Amazon Kev Koom Tes Kuv khwv tau los ntawm kev tsim nyog yuav khoom koj ua siv kuv cov koom nrog txuas.

Kauj Ruam 1: 3D Luam Qhov Chaw

3D Luam Tshooj
3D Luam Tshooj
3D Luam Tshooj
3D Luam Tshooj

Tus tuav lub tais zaub mov miv yog ua raws Ardy Lai tus tsim ntawm Thingiverse. Kuv ua kom nws loj dua kom haum kuv tus miv lub tais, thiab tseem ua rau nws luv dua vim qhov ntsuas nws tau ua rau nws siab dhau. Kuv tau ntxiv tus tuav rau lub micro servo motor, thiab ob peb lub qhov rau cov hlua txuas mus rau sab hauv.

Kuv ua qauv lub hau yooj yim siv Tinkercad, tsim los txuas rau lub suab ntawm lub micro servo. Koj tuaj yeem tuav kuv tus qauv ncaj qha los ntawm Tinkercad, thiab/lossis rub tawm STLs txuas nrog rau theem no.

Kuv tau luam tawm ib feem ntawm kuv Creality CR-10s Pro tshuab luam ntawv nrog kub PLA filament.

Kev nthuav tawm: thaum lub sijhawm sau ntawv no, Kuv yog ib tus neeg ua haujlwm ntawm Autodesk, uas ua rau Tinkercad.

Kauj Ruam 2: Txuas lub hau rau Servo Motor

Txuas lub hau rau Servo Motor
Txuas lub hau rau Servo Motor
Txuas lub hau rau Servo Motor
Txuas lub hau rau Servo Motor

Kuv siv lub qhov me me los txhawm rau kom qhov loj me ntawm lub qhov ntawm servo horn, tom qab ntawd siv cov ntsia hlau los txuas cov servo rau 3D luam tawm lub hau.

Kauj Ruam 3: Tsim NodeMCU ESP8266 Circuit

Tsim NodeMCU ESP8266 Circuit
Tsim NodeMCU ESP8266 Circuit
Tsim NodeMCU ESP8266 Circuit
Tsim NodeMCU ESP8266 Circuit
Tsim NodeMCU ESP8266 Circuit
Tsim NodeMCU ESP8266 Circuit
Tsim NodeMCU ESP8266 Circuit
Tsim NodeMCU ESP8266 Circuit

Lub Circuit Court yog tswj los ntawm NodeMCU ESP8266 wifi microcontroller. Kuv siv tus pin header rau ntawm perma-proto board los ua kom lub micro servo motor yooj yim tshem tawm tau. Qhov servo headers txuas nrog NodeMCU raws li hauv qab no:

Daj servo hlau: NodeMCU D1

Liab servo hlau: NodeMCU zog (3V3 lossis VIN)

Dub servo hlau: NodeMCU hauv av (GND)

Kauj ruam 4: Upload Arduino Code thiab Test

Upload Arduino Code thiab Xeem
Upload Arduino Code thiab Xeem

Txhim kho koj lub cav/lub hau sib dhos rau hauv lub tshuab txiav tawm ntawm lub tais tais 3D luam tawm ib feem. Ntsaws lub taub hau lub cev rau hauv lub microcontroller board's header pins, thiab ntsaws lub Circuit Court rau hauv koj lub computer nrog USB cable.

Daim duab Arduino siv Network Sijhawm raws tu qauv los nqa lub sijhawm tam sim no thiab tom qab ntawd qhib lossis kaw lub hau raws li lub sijhawm nyuaj. Luam theej cov cai hauv qab no, hloov kho koj li ntawv pov thawj wifi thiab UTC lub sijhawm offset, thiab xa nws mus rau koj NodeMCU pawg thawj coj siv Arduino IDE.

#suav nrog

#suav nrog #suav nrog #suav nrog ESP8266WiFiMulti wifiMulti; // Tsim ib qho piv txwv ntawm ESP8266WiFiMulti chav kawm, hu ua 'wifiMulti' WiFiUDP UDP; // Tsim qhov piv txwv ntawm chav kawm WiFiUDP kom xa thiab tau txais IPAddress timeServerIP; // time.nist.gov NTP server chaw nyob const char* NTPServerName = "time.nist.gov"; const int NTP_PACKET_SIZE = 48; // NTP lub sijhawm thwj nyob hauv thawj 48 bytes ntawm cov lus byte NTPBuffer [NTP_PACKET_SIZE]; // tsis tuav cov khoom ntim thiab xa tawm Servo myservo; // tsim cov khoom siv servo los tswj hwm servo // kaum ob cov khoom siv servo tuaj yeem tsim ntawm feem ntau cov laug cam int pos = 0; // sib txawv los khaws qhov chaw ua haujlwm servo void teeb () {myservo.attach (5); // txuas cov servo ntawm tus pin 5 aka D1 rau cov khoom siv servo // qhib lub hau los ntawm lub neej ntawd Serial.println ("qhib lub hau"); rau (pos = 95; pos> = 0; pos -= 1) {// mus los ntawm 95 degrees mus rau 0 degrees myservo.write (pos); // qhia servo mus rau txoj haujlwm hauv qhov sib txawv 'pos' ncua (15); // tos 15ms rau servo kom mus txog txoj haujlwm} Serial.begin (115200); // Pib Serial kev sib txuas lus xa xov mus rau lub khoos phis tawj qeeb (10); Serial.println ("\ r / n"); pibWiFi (); // Sim txuas mus rau qee cov ntsiab lus nkag. Tom qab ntawd tos rau qhov txuas txuas startUDP (); yog (! Serial.flush (); ESP.reset (); } Serial.print ("IP server sijhawm: / t"); Serial.println (timeServerIP); Serial.println ("\ r / n Xa NTP thov …"); xa NTPpacket (timeServerIP); } unsigned ntev intervalNTP = 60000; // Thov NTP lub sijhawm txhua feeb tsis tau kos npe ntev prevNTP = 0; unsigned ntev kawg NTPResponse = millis (); uint32_t timeUNIX = 0; unsigned ntev prevActualTime = 0; void loop () {unsigned ntev currentMillis = millis (); yog (currentMillis - prevNTP> intervalNTP) {// Yog tias ib feeb dhau los txij li NTP thov zaum kawg prevNTP = currentMillis; Serial.println ("\ r / n Xa NTP thov …"); xa NTPpacket (timeServerIP); // Xa daim NTP thov} uint32_t sijhawm = getTime (); // Txheeb xyuas yog tias NTP cov lus teb tau los txog thiab tau txais (UNIX) lub sijhawm yog (sijhawm) {// Yog tias lub sijhawm tshiab tau txais lub sijhawm UNIX = sijhawm; Serial.print ("NTP teb: / t"); Serial.println (timeUNIX); lastNTPResponse = currentMillis; } lwm tus yog ((currentMillis - lastNTPResponse)> 3600000) {Serial.println ("Ntau dua 1 teev txij li NTP teb kawg. Rov pib dua."); Serial.flush (); ESP.reset (); } uint32_t actualTime = timeUNIX + (currentMillis - lastNTPResponse)/1000; uint32_t eastTime = timeUNIX - 18000 + (currentMillis - lastNTPResponse)/1000; yog (realTime! = prevActualTime && timeUNIX! = 0) {// Yog tias ib pliag dhau los txij thaum luam tawm dhau los prevActualTime = actualTime; Serial.printf ("\ rUTC lub sijhawm: / t%d:%d:%d", getHours (lub sijhawm tiag tiag), getMinutes (lub sijhawm tiag tiag), getSeconds (lub sijhawm tiag tiag)); Serial.printf ("\ rEST (-5): / t%d:%d:%d", getHours (EasternTime), getMinutes (EasternTime), getSeconds (EasternTime)); Serial.println (); } // 7:30 sawv ntxov yog (getHours (EasternTime) == 7 && getMinutes (EasternTime) == 30 && getSeconds (eastTime) == 0) {// qhib lub hau Serial.println ("qhib lub hau"); rau (pos = 95; pos> = 0; pos -= 1) {// mus los ntawm 95 degrees mus rau 0 degrees myservo.write (pos); // qhia servo mus rau txoj haujlwm hauv qhov sib txawv 'pos' ncua (15); // tos 15ms rau cov servo kom mus txog txoj haujlwm}} // ib tag hmo yog (getHours (EasternTime) == 0 && getMinutes (EasternTime) == 0 && getSeconds (eastTime) == 0) {// kaw lub hau Serial. println ("kaw lub hau"); rau (pos = 0; pos <= 95; pos += 1) {// mus los ntawm 0 degrees mus rau 95 degrees // hauv cov theem ntawm 1 degree myservo.write (pos); // qhia servo mus rau txoj haujlwm hauv qhov sib txawv 'pos' ncua (15); // tos 15ms rau servo kom mus txog txoj haujlwm}} /* // kuaj yog (getHours (EasternTime) == 12 && getMinutes (EasternTime) == 45 && getSeconds (eastTime) == 0) {// kaw lub hau Serial.println ("kaw lub hau"); rau (pos = 0; pos = 0; pos -= 1) {// mus los ntawm 95 degrees mus rau 0 degrees myservo.write (pos); // qhia servo mus rau txoj haujlwm hauv qhov sib txawv 'pos' ncua (15); // tos 15ms rau servo kom mus txog txoj haujlwm}} */} tsis muaj dab tsi pibWiFi () {// Sim txuas rau qee qhov muab nkag mus. Tom qab ntawd tos rau kev sib txuas wifiMulti.addAP ("ssid_from_AP_1", "your_password_for_AP_1"); // ntxiv Wi-Fi tes hauj lwm koj xav txuas rau //wifiMulti.addAP("ssid_from_AP_2 "," your_password_for_AP_2 "); //wifiMulti.addAP("ssid_from_AP_3 "," koj_password_for_AP_3 "); Serial.println ("Txuas"); thaum (wifiMulti.run ()! = WL_CONNECTED) {// Tos kom Wi-nkaus txuas txuas qeeb (250); Serial.print ('.'); } Serial.println ("\ r / n"); Serial.print ("Txuas nrog"); Serial.println (WiFi. SSID ()); // Qhia rau peb lub network peb txuas nrog Serial.print ("IP chaw nyob: / t"); Serial.print (WiFi.localIP ()); // Xa tus IP chaw nyob ntawm ESP8266 mus rau lub computer Serial.println ("\ r / n"); } void startUDP () {Serial.println ("Pib UDP"); UDP.begin (123); // Pib mloog rau UDP cov lus ntawm chaw nres nkoj 123 Serial.print ("Chaw nres nkoj hauv zos: / t"); Serial.println (UDP.localPort ()); Serial.println (); } uint32_t getTime () {yog (UDP.parsePacket () == 0) {// Yog tias tsis muaj lus teb (tsis tau) rov qab 0; } UDP.read (NTPBuffer, NTP_PACKET_SIZE); // nyeem cov pob ntawv rau hauv qhov tsis sib xws // Muab 4 lub sij hawm tim ntsej tim muag bytes rau hauv ib tus lej 32-ntsis uint32_t NTPTime = (NTPBuffer [40] << 24) | (NTPBuffer [41] << 16) | (NTPBuffer [42] << 8) | NTPBuffer [43]; // Hloov NTP lub sijhawm rau UNIX lub sijhawm: // Lub sijhawm Unix pib rau Lub Ib Hlis 1 1970. Ntawd yog 2208988800 vib nas this hauv NTP lub sijhawm: const uint32_t xya caum xyoo = 2208988800UL; // rho tawm xya caum xyoo: uint32_t UNIXTime = NTPTime - xya caum xyoo; rov qab UNIXTime; } void sendNTPpacket (IPAddress & address) {memset (NTPBuffer, 0, NTP_PACKET_SIZE); // teeb tsa txhua bytes hauv qhov tsis rau 0 // Pib qhov tseem ceeb xav tau los ua NTP thov NTPBuffer [0] = 0b11100011; // LI, Version, Mode // xa pob ntawv thov lub sijhawm: UDP.beginPacket (chaw nyob, 123); // NTP thov yog chaw nres nkoj 123 UDP.write (NTPBuffer, NTP_PACKET_SIZE); UDP.endPacket (); } inline int getSeconds (uint32_t UNIXTime) {rov qab UNIXTime % 60; } inline int getMinutes (uint32_t UNIXTime) {rov qab UNIXTime / 60 % 60; } inline int getHours (uint32_t UNIXTime) {rov qab UNIXTime / 3600 % 24; }

Kauj ruam 5: Siv nws

Siv nws!
Siv nws!
Siv nws!
Siv nws!

Teem koj cov xov hlau mus rau sab hauv ntawm lub tais tais, thiab ntsaws koj tus miv pub rau hauv qhov hluav taws xob siv USB AC adapter. Txoj hauv kev sau cov lej yooj yim, nws lub ntsiab lus yuav tsum tau khau raj hauv lub xeev "qhib", thiab tsuas yog yuav hloov nws txoj haujlwm lub hau thaum lub sijhawm pib tau teev tseg hauv Arduino daim duab.

Tsaug rau ua raws nrog! Yog tias koj ua koj tus kheej version, Kuv xav pom nws hauv I Made It section hauv qab no!

Yog tias koj nyiam txoj haujlwm no, tej zaum koj yuav txaus siab rau qee qhov ntawm kuv:

  • Prism Holder rau Zaj sawv Portraits
  • Plywood Cia Phab Ntsa nrog Cat Ntauwd
  • LED Mason Jar Teeb (3D luam tawm hau)
  • 3D Tshuab Luam Ntawv Filament Qhuav Lub Thawv
  • Thaum Muaj Xwm Ceev USB Lub Hwj Chim (3D Luam Tawm)
  • Glowing LED Gummy Candy
  • 3D Luam Geometric Planter Nrog Dej
  • Glowing 3D Luam Paj
  • Yuav Ua Li Cas Txhim Kho LEDs Hauv Scooter (nrog Bluetooth)

Txhawm rau ua raws qhov kuv tab tom ua haujlwm, ua raws kuv ntawm YouTube, Instagram, Twitter, thiab Pinterest.

Pom zoo: