Cov txheej txheem:

Hue Magic: 4 Kauj Ruam (nrog Duab)
Hue Magic: 4 Kauj Ruam (nrog Duab)

Video: Hue Magic: 4 Kauj Ruam (nrog Duab)

Video: Hue Magic: 4 Kauj Ruam (nrog Duab)
Video: CheeNou & Kong Chue -Puas Tshav Ntuj Nrig (Official Video) 2024, Hlis ntuj nqeg
Anonim
Image
Image

Txais tos cov neeg txawj ntse!

Ob peb lub hlis dhau los Kuv tau tsim lub thawv me me nrog tus pas rau kuv tus tub hnub nyoog 3 xyoos. Thaum nws kov lub thawv nrog tus pas nrig, lub teeb hloov xim yuav pib tawm los ntawm lub thawv. Thaum nws pom cov xim nws tshwj xeeb tshaj yog nyiam, nws tuaj yeem taw tus pas nrig mus rau lub teeb rooj (nrog lub teeb Philips Hawj teeb sab hauv), pov cov ntawv thiab xim los ntawm lub npov yuav dhia mus rau lub teeb! Teeb thiab lub teeb los ntawm lub thawv tam sim muaj xim zoo ib yam …

Tom qab ob peb feeb, cov xim ploj mus thiab lub teeb rooj rov qab los rau nws lub xeev ua ntej qhov kev sau ntawv. Kom txog rau thaum sau ntawv tshiab …

Kauj Ruam 1: Koj Yuav Tsum Ua Dab Tsi Los Tsim Txoj Haujlwm no

Yam Koj Yuav Tsum Tau Tsim Txoj Haujlwm no
Yam Koj Yuav Tsum Tau Tsim Txoj Haujlwm no
Yam Koj Yuav Tsum Tau Tsim Txoj Haujlwm no
Yam Koj Yuav Tsum Tau Tsim Txoj Haujlwm no
Yam Koj Yuav Tsum Tau Tsim Txoj Haujlwm no
Yam Koj Yuav Tsum Tau Tsim Txoj Haujlwm no

Txhawm rau tsim txoj haujlwm no, koj yuav xav tau cov ntaub ntawv hauv qab no:

    • 1 (lossis ntau dua) Philips Hawj raj xim xim thiab Hue Choj
    • 1 Wemos D1 mini lossis zoo li esp8266-based microcontroller
    • 1 (Arduino) kov sensor (piv txwv li TTP223R)
    • 1 (Arduino) khawm ib ntus
    • 1 10uF capacitor
    • 1 RGB coj (hom hom anode)
    • 5 resistors (10, 22 thiab 47 Ohm, 2x 10K Ohm)
    • 2 cov qauv me me PCBs (2x3 nti lossis li 5x7 cm yuav tsum loj txaus)
    • qee cov (jumper) xov hlau
    • ib qho hlau txuas
    • tus pas nrig khawv koob (tuaj yeem yuav ua khoom npaj ua hauv khw muag khoom ua si, lossis koj tuaj yeem ua nws tus kheej)
    • ib lub thawv me me uas ua los ntawm cov duab los qhia los yog ntoo (tuaj yeem yog lub thawv uas twb muaj lawm, tab sis koj kuj tuaj yeem tsim lub thawv los ntawm kos tau kawg)
    • ib co kab xev
    • qee cov kua nplaum thiab/lossis txiv ntseej thiab ntsia hlau txhawm rau txhawm rau PCBs hauv lub thawv.
    • yeem: qhwv ntawv rau lub thawv

NB: Kev paub me ntsis hauv kev nyeem kab duab kab lus yog pab tau thaum mus dhau qhov kev qhia no. Kuv daim duab tsis nyuaj dhau: yog tias koj tuaj yeem sib txawv ntawm lub capacitor los ntawm tus tiv thaiv, koj yuav zaum zoo.

Qee qhov kev paub nrog Arduino cov phiaj xwm siv Arduino IDE kuj tseem pab tau. Qhov yooj yim kev paub yuav tsum txaus, raws li kuv yuav muab tus lej ua tiav rau koj theej/luam tawm. Koj yuav tsum tau hloov kho qee yam txawm hais tias, txhawm rau ua kom nws ua haujlwm tshwj xeeb teeb tsa (piv txwv li koj lub network teeb tsa thiab qee cov ntsiab lus los ntawm koj li Hue teeb tsa). Yog tias lub suab no txaus ntshai me ntsis, tsis txhob txhawj xeeb, Kuv yuav pab koj khaws txhua cov ntaub ntawv koj xav tau.

Kauj Ruam 2: Lub Thawv & Tus Kheej

Lub thawv & Wand
Lub thawv & Wand
Lub thawv & Wand
Lub thawv & Wand

Thawj kauj ruam feem ntau yog qhov nyuaj tshaj plaws, tab sis tsis yog hauv cov lus qhia no! Txhawm rau pib qhov yooj yim, koj tuaj yeem tsuas yog yuav cov khawv koob khawv koob los ntawm lub khw muag khoom ua si thiab rau lub thawv koj tuaj yeem rov siv lub thawv me me uas twb muaj lawm uas koj twb tau dag ib ncig lawm. Tsuas yog xyuas kom lub thawv tsis ua los ntawm cov hlau, vim qhov no yuav thaiv cov cim wifi thiab peb xav tau cov ntawd rau cov khawv koob;-).

Thaum koj rov npaj lub thawv uas twb muaj lawm, qhov tsuas yog koj yuav tsum ua yog ua ob lub qhov nyob rau sab saum toj ntawm lub npov: 1 lub qhov me (qhov loj 5mm = 0.2 ") rau RGB coj thiab lub qhov loj (ib ncig 12- 14mm lossis kwv yees li 0.5 ") rau qhov kov lub ntsuas.

Kev tso qhov tseeb ntawm qhov tsis yog qhov tseem ceeb, tsuas yog tso lawv raws li koj qhov kev xav ntawm kev zoo nkauj tab sis khaws qee yam hauv siab:

  • Khaws qee qhov nrug nruab nrab ntawm ob lub qhov kom ntseeg tau tias cov khoom siv uas yuav teeb tsa hauv qab lub qhov (RGB coj thiab kov lub ntsej muag) ob leeg tau tso cai kom muaj chaw txaus rau kev teeb tsa thiab thaiv kab.
  • Qhov loj tshaj yog rau qhov kov sensor. Qhov ntsuas no yuav raug teeb tsa hauv qab lub qhov, hauv txoj hauv kev uas nws tuaj yeem kov tau (thiab txawm tias nias me ntsis) los ntawm tus pas nrig. Yog li xyuas kom tus pas nrig koj yuav tsis tuab heev!

Xaiv tau koj tuaj yeem siv (tshuaj tsuag) pleev xim lossis qhwv ntawv thiab npog yas kom ua rau koj lub thawv me me kom zoo dua thiab tiv thaiv nws los ntawm cov zaub mov nchuav thiab txhais tes qias neeg.

Yog tias thawj kauj ruam no me ntsis tsis txaus ntseeg rau koj nyiam, thov mus tom ntej thiab tsim ib lub thawv thiab hla tag nrho los ntawm kos! Muaj ntau cov lus qhia tawm uas yuav pab koj tsim tus pas zoo nkauj

Xijpeem txoj kev koj xaiv, nws yog lub sijhawm tam sim no los tshawb hauv lub thawv.

Kauj Ruam 3: Kho Vajtse Sab Hauv

Cov Khoom Sab Hauv
Cov Khoom Sab Hauv
Cov Khoom Sab Hauv
Cov Khoom Sab Hauv
Cov Khoom Sab Hauv
Cov Khoom Sab Hauv

Siv cov hlau txuas los txuas cov khoom siv hluav taws xob raws li daim duab qhia hluav taws xob saum toj no. Muaj ob peb yam uas yuav tau them nyiaj tshwj xeeb rau:

  • Cov xov hlau ntawm Wemos D1 Mini thiab RGB coj yuav tsum ntev txaus yog li RGB coj tuaj yeem ntsia tau rau hauv lub qhov uas koj tau ua hauv lub hau ntawm lub thawv.
  • Tib yam suav rau cov xov hlau txuas rau qhov hloov pauv ib ntus thiab kov lub sensor raws li cov no yuav tsum nkag mus tau los ntawm lwm lub qhov hauv lub hau.
  • Lub pob ntawm qhov hloov pauv tam sim yuav tsum tau glued mus rau sab hauv qab (sab tsis nkag siab) ntawm qhov kov lub ntsej muag, hauv txoj hauv kev uas koj tuaj yeem tso lub pob rov qab rau ntawm qhov hloov pauv tam sim nrog kov lub ntsej muag lo rau saum (saib daim duab). Qhov ntsuas qhov ntsuas tau teeb tsa nyob rau sab saum toj ntawm lub sijhawm hloov pauv kom pom lub pob nyem ua los ntawm tus ntiv tes, nyob rau hauv rooj plaub twg lub pob nyem yuav tsis quav ntsej. Tsuas yog thaum lub pob nyem los ntawm cov khawv koob khawv koob (uas yuav tsum tsis siv neeg, yog li cov yas thiab ntoo zoo), lub voj voog khawv koob yuav pib.
  • Mount lub sijhawm tam sim no nrog lub ntsuas ntsuas nyob rau sab saum toj tsis tob dhau hauv qab lub qhov hauv lub hau, vim tias nws xav tau kom ncav cuag los ntawm cov khawv koob los teeb lub khawv koob hauv kev txav.
  • Nco ntsoov xyuas qhov polarity ntawm lub capacitor thaum siv nws. Yog tias koj thim rov qab qhov ua tau zoo thiab tsis zoo, lub tshuab hluav taws xob yuav zoo li tso tawm qee cov pa luam yeeb thiab ua rau koj lub voj voog pw tsaug zog mus ib txhis.
  • Kua nplaum, kab xev thiab lossis ntsia hlau tuav lub roj teeb thiab PCB (hauv) qhov chaw. Nws tsis tas yuav zoo li nws yuav tsis pom. Nws yuav tsum yog pov thawj pov tseg.

Nyem rau ntawm qhov software!

Kauj ruam 4: Software

Nco ntsoov tias koj muaj qhov hloov tshiab kawg (pub dawb) Arduino software editor, uas tuaj yeem rub tawm ntawm https://www.arduino.cc/en/Main/Software. Txhawm rau ntxiv kev txhawb nqa rau Wemos D1 mini thiab lwm yam ESP8266-raws cov laug cam, ua cov hauv qab no:

  • Tom qab kev teeb tsa, pib Arduino software thiab qhib qhov Preferences window.
  • Nkag mus https://arduino.esp8266.com/stable/package_esp8266com_index.json rau hauv "Tus Thawj Saib Xyuas Haujlwm Ntxiv URLs" teb. Koj tuaj yeem ntxiv ntau qhov URLs, cais lawv nrog tus lej.
  • Qhib Tus Thawj Saib Xyuas Haujlwm los ntawm Cov Cuab Yeej> Cov ntawv qhia zaub mov thiab teeb tsa esp8266 lub platform (thiab tsis txhob hnov qab xaiv koj li ESP8266 lub rooj tsavxwm los ntawm Cov Cuab Yeej> Cov ntawv qhia zaub mov tom qab teeb tsa. "LOLIN (WEMOS) D1 R2 & mini" ua haujlwm zoo tshaj plaws rau Wemos D1 mini v2 thiab v3 cov laug cam.

Yog tias koj xav tau kev pab ntxiv txhim kho Arduino thiab teeb tsa cov tsav tsheb koj tuaj yeem saib ntawm

Hauv Arduino editor, qhib ib daim ntawv tshiab (Cov Ntaub Ntawv> Tshiab) thiab luam/muab cov cai hauv qab no hauv lub qhov rai uas nyuam qhuav qhib. Tsuas yog rov sau dua cov kab uas twb muaj tam sim no hauv lub qhov rai tshiab (tsis muaj teeb tsa thiab lub voj void).

Tam sim no koj yuav luag npaj txhij, tab sis koj yuav tsum hloov kho ob peb daim ntawm cov cai rau koj teeb tsa tshwj xeeb.

Thawj qhov uas yuav tsum ua yog hloov tus IP chaw nyob ntawm kab 34 (hauv Arduino tus kws kho kab ntawv kab ntawm cov lej tau suav) rau hauv tus IP chaw nyob ntawm koj tus Hue choj. Yog tias koj tsis paub koj tus Hue Bridge IP chaw nyob, mus ntsib https://discovery.meethue.com/ thiab tus IP chaw nyob yog nws yuav tshwm sim tam sim hauv koj tus browser. Tus IP chaw nyob yog tus lej tus lej uas ua ntej los ntawm "internalipaddress".

Txhawm rau sib txuas lus nrog Hue teeb, koj yuav tsum tsim Hue API tus neeg siv rau Wemos D1 mini, yog li Wemos tuaj yeem sib txuas lus mus rau Hue teeb ntawm Hue API. Txhawm rau ua qhov ntawd, ua raws cov lus qhia ntawm https://developers.meethue.com/develop/get-started-2/ thiab luam/paste qhov tsim tawm (zoo nkauj ntev) lub npe siv hauv Arduino code window. Tsuas yog hloov txhua qhov "KOJ HUE API USERNAME" nrog cov tsim API lub npe siv.

Tom qab ntawd koj yuav tsum xaiv txoj cai Hawj txawm kom hloov xim. Hauv Hue API txhua lub teeb muaj tus lej, yog li koj yuav tsum nrhiav tus lej uas sib haum nrog lub teeb uas koj xav siv rau txoj haujlwm no. Ib qho ntawm txoj hauv kev yooj yim tshaj plaws kom paub tus lej twg yog lub teeb tshwj xeeb, yog rub tawm Hue Viewer App rau Android lossis iOS. Hloov cov ntawv "Koj tus lej teeb" nrog tus lej raug nyob txhua qhov chaw hauv Arduino code window.

Qhov kawg ua yog teeb Wemos txuas rau koj lub network wifi. Qhov no ua tiav los ntawm kev xa cov cai mus rau Wemos thiab ntawm koj lub khoos phis tawj hloov mus rau lwm lub network wifi: mus rau "AutoConnectAP". Koj tus browser yuav tso tawm nplooj ntawv uas koj tuaj yeem ntxiv SSID (lub npe) thiab tus password ntawm koj lub network wifi uas tus tswj hwm Wemos yuav siv los txuas rau koj lub network wifi (thiab rau Hue choj).

NB: Yog tias xa cov cai rau peb Wemos D1 mini ntawm USB tsis ua haujlwm, koj yuav xav tau rub tus tsav tsheb rau USB nti ntawm Wemos. Tus tsav tsheb rau koj lub platform (Windows, Mac) tuaj yeem rub tawm ntawm

Tam sim no koj tau npaj los sim koj qhov kev tsim!

// ESP8266 Hue Magic Wand // Richard van Kampen - 2018 // Cov cai no tau sim ntawm Wemos D1 mini, tab sis tej zaum kuj tseem yuav ua haujlwm rau lwm ESP8266 -based development boards // Txhawm rau ntxiv kev txhawb nqa rau Wemos D1 mini thiab lwm ESP8266 boards rau Arduino editor, ua raws cov theem hauv qab no: // - Pib Arduino thiab qhib Qhov Nyiam Qhov rai. // - Nkag mus https://arduino.esp8266.com/stable/package_esp8266com_index.json rau hauv Pawg Thawj Saib Xyuas Haujlwm Ntxiv URLs teb. Koj tuaj yeem ntxiv ntau qhov URLs, cais lawv nrog tus lej. // - Qhib Tus Thawj Saib Xyuas Haujlwm los ntawm Cov Cuab Yeej> Pawg ntawv qhia zaub mov thiab teeb tsa esp8266 platform (thiab tsis txhob hnov qab xaiv koj li ESP8266 pawg thawj coj los ntawm Cov Cuab Yeej> Pawg ntawv qhia zaub mov tom qab teeb tsa). // siv cov tsev qiv ntawv: #include "ESP8266WiFi.h" // ESP8266 Core WiFi Library #include "DNSServer.h" // Local DNS Server siv rau kev xa rov qab txhua qhov kev thov mus rau WiFiManager teeb tsa portal yog tias tsis muaj WIFI teeb tsa (SSID, password) muaj tseem tsis tau teeb tsa. #include "ESP8266WebServer.h" // Local WebServer siv los ua haujlwm WiFiManager teeb tsa lub portal #include "WiFiManager.h" // WiFi Configuration Magic library, yog tias tsis tau teeb tsa tseem thov xa mus rau https://github.com/tzapu/WiFiManager #install-through-library-manager #include "RestClient.h" // https://github.com/fabianofranca/ESP8266RestClient, xav tau kev siv Philips Hue API (saib https://developers.meethue.com/develop/ hue-api/) cov. #suav nrog "ArduinoJson.h" // https://github.com/bblanchon/ArduinoJson, xav tau los tshuaj xyuas Hue API cov lus teb, thov teeb tsa version 5.x ntawm tus thawj tswj tsev qiv ntawv hauv Arduino (Ntawv qhia zaub mov "Sketch"> suav nrog Tsev qiv ntawv> Tswj Cov tsev qiv ntawv> tshawb rau ArduinoJson thiab hloov pauv mus rau qhov tseeb 5.x). Version 6 (tam sim no hauv beta) cuam tshuam qhov yuam kev. // hloov pauv thiab pib: Txoj kab lus teb; const int redPin = 13; // ntawm Wemos qhov no yog d7 const int greenPin = 12; // ntawm Wemos qhov no yog d6 const int bluePin = 14; // ntawm Wemos qhov no yog d5 const int touchSensor = 5; // ntawm Wemos qhov no yog d1 const int activationPin = 4; // ntawm Wemos qhov no yog d2 bool ua kom = HIGH; bool kov = LOW; const char* aan_restore; koj bri_restore; ob npaug x_restore; ob y_restore; ob npaug x_magic; ob y_magic; bool thawj = muaj tseeb; unsigned ntev startMillis; tsis tau kos npe ntev tam sim no Millis; unsigned ntev ntevMillis; RestClient tus neeg siv = RestClient ("192.168.178.23"); // "koj Hue Bridge IP chaw nyob" // Yog tias koj tsis paub koj tus Hue Bridge IP chaw nyob, mus ntsib https://discovery.meethue.com thiab nws yuav tshwm sim tam sim ntawd hauv koj tus browser. Tus IP chaw nyob yog tus lej tus lej ua ntej los ntawm "internalipaddress" qhov tsis muaj teeb tsa () {analogWriteRange (255); Serial.begin (9600); // Pib nrog LED tawm. pinMode (activationPin, INPUT_PULLUP); pinMode (touchSensor, INPUT); startMillis = millis (); checkWand (); } tsis muaj dab tsi voj () {// tsis muaj dab tsi los ua ntawm no, tawm khoob …} tsis muaj dab tsi checkWand () {int rgbColour [3]; // RGB xim xim los ntawm James Harton, https://gist.github.com/jamesotron/766994 // Pib nrog liab. rgbColour [0] = 255; rgbColour [1] = 0; rgbColour [2] = 0; ua kom = digitalRead (activationPin); // LOW txhais tau hais tias wand tau siv. kov = digitalRead (touchSensor); // HIGH txhais tau tias siv ntiv tes siv tus pas, uas yuav tsum tsis yog qhov no. thaum (ua kom == LOW && kov == LOW) {// Xaiv cov xim kom nce thiab nqis. rau (int decColour = 0; decColour <3; decColour += 1) {int incColour = decColour == 2? 0: decColour + 1; // = tus neeg teb xov tooj ternary, txhais tau tias: int incColour; yog (decColour == 2) {incColour = 0;} lwm yam {incColour = decColour +1;} // hla-fade ob xim. rau (int i = 0; i <255; i += 1) {rgbColour [decColour] -= 1; rgbColour [incColour] += 1; // raws li peb RGB coj muaj qhov sib thooj hloov pauv ntawm cathode (yog li peb xav tau txuas mus rau +3.3V hloov chaw hauv av), peb xav tau cov txiaj ntsig rov qab rau RGB: int liab = 255 - rgbColour [0]; ntsuab ntsuab = 255 - rgbColour [1]; int xiav = 255 - rgbColour [2]; analogWrite (redPin, liab); analogWrite (greenPin, ntsuab); analogWrite (bluePin, xiav); ncua (8); ua kom = digitalRead (activationPin); yog (ua kom == HIGH) {// HIGH txhais tau hais tias wand tau nqa. tau txais stopColorCycling; }}}} stopColorCycling: currentMillis = millis (); durationMillis = (currentMillis - startMillis); yog (durationMillis> 1000) {RGBtoxy (rgbColour [0], rgbColour [1], rgbColour [2]); } lwm tus {// tso Wemos rau hauv hom pw: ESP.deepSleep (0); }} void RGBtoxy (int liab, int ntsuab, int xiav) {// saib https://developers.meethue.com/documentation/color-conversions-rgb-xy ob npaug R = daim ntawv qhia (liab, 0, 255, 0, 1000); R /= 1000; ob npaug G = daim ntawv qhia (ntsuab, 0, 255, 0, 1000); G /= 1000; ob npaug B = daim ntawv qhia (xiav, 0, 255, 0, 1000); B /= 1000; R = (R> 0.04045f)? pow ((R + 0.055f) / (1.0f + 0.055f), 2.4f): (R / 12.92f); G = (G> 0.04045f)? pow ((G + 0.055f) / (1.0f + 0.055f), 2.4f): (G / 12.92f); B = (B> 0.04045f)? pow ((B + 0.055f) / (1.0f + 0.055f), 2.4f): (B / 12.92f); ob npaug X = R * 0.649926f + G * 0.103455f + B * 0.197109f; ob Y = R * 0.234327f + G * 0.743075f + B * 0.022598f; ob Z = R * 0.0000000f + G * 0.053077f + B * 1.035763f; ob npaug x = X / (X + Y + Z); ob y = Y / (X + Y + Z); // hloov pauv tsis tiav, tab sis tej zaum zoo txaus rau qhov peb xav ua kom tiav, yog li tso nws ntawm qhov no thiab xa XY qhov tseem ceeb rau teeb: sendtoHue (x, y); } void sendtoHue (ob npaug a, ob b) {// qhov tseeb hloov xim ntawm wand khawv koob yog (thawj) {// thawj kis: tau txais lub teeb pom kev zoo tam sim no getCurrentValues (); } // ces xa cov khawv koob wand xim: // tos rau sau ntawv: tos ntev; x_magic = ua; y_magic = b; // teeb rau hauv cov khawv koob wand xim: teb = ""; int temp = random (2, 9); const char* state = "tseeb"; rau (int i = 1; i <= temp; i ++) {// tsim char array xa mus rau choj: String temp_body1 = "{" on / ":" + String (state) + ", \" bri / ": 220, / "xy \": [" + String (x_magic) +", " + String (y_magic) +"], / "transitiontime \": 1} "; int str_len1 = temp_body1.length () + 1; char post_body1 [str_len1]; temp_body1.toCharArray (post_body1, str_len1); // tam sim no peb muaj post_body1 li char array; // ua kom txaus hu: int statusCodePut1 = client.put ("/api/KOJ HUE API USERNAME/teeb/Koj LUB LEEJ TWG/xeev", post_body1, & teb); tos = random (100, 600); ncua (tos); yog (xeev == "tseeb") {xeev = "tsis tseeb"; } lwm {xeev = "tseeb"; }} // txo qhov ci ci …: teb = ""; temp = random (4, 17); // tsim char array xa mus rau tus choj: Txoj hlua temp_body2 = "{" ntawm / ": tseeb, \" bri / ": 154," "sijhawm hloov pauv": " + String (temp) +"} "; int str_len2 = temp_body2.length () + 1; char post_body2 [str_len2]; temp_body2.toCharArray (post_body2, str_len2); // tam sim no peb muaj post_body2 raws li char array; // ua kom so hu: int statusCodePut2 = client.put ("/api/KOJ HUE API USERNAME/teeb/Koj LUB LEEJ TWG/xeev", post_body2, & teb); tos = random (1000, 2500); ncua (tos); //..thiab rov ci dua: teb = ""; temp = random (4, 17); // tsim char array xa mus rau tus choj: Txoj hlua temp_body3 = "{" "bri_inc \": 100, / "transitiontime \":} "; int str_len3 = temp_body3.length () + 1; char post_body3 [str_len3]; temp_body3.toCharArray (post_body3, str_len3); // tam sim no peb muaj post_body3 li char array; // ua kom txaus hu: int statusCodePut3 = client.put ("/api/KOJ HUE API USERNAME/teeb/Koj LUB LEEJ TWG/xeev", post_body3, & teb); tos = random (2500, 5000); // tos 2-5 vib nas this ncua (tos); // thiab ploj mus rau tus nqi qub: teb = ""; // tsim char array xa mus rau choj: Txoj hlua temp_body4 = "{" on / ":" + String (aan_restore) + ", \" bri / ":" + String (bri_restore) + ", \" xy / ": [" + String (x_restore) +", " + String (y_restore) +"], / "transitiontime \": " + String (20) +"} "; int str_len4 = temp_body4.length () + 1; char post_body4 [str_len4]; temp_body4.toCharArray (post_body4, str_len4); // tam sim no peb muaj post_body4 li char array; // ua kom txaus hu: int statusCodePut4 = client.put ("/api/KOJ HUE API USERNAME/teeb/Koj LUB LEEJ TWG/xeev", post_body4, & teb); ESP.deepSleep (0); // mus pw dua…. } unsigned int getCurrentValues () {connectWifi (); // xub txuas rau Wifi teb = ""; // hu so so: int statusCodeGet = client.get ("/api/KOJ HUE API USERNAME/teeb/Koj LUS ZOO ZOO", & teb) Serial.print ("Cov cai xwm txheej los ntawm server tom qab tau txais:"); Serial.println (statusCodeGet); Serial.print ("Lub cev teb los ntawm server:"); Serial.println (teb); StaticJsonBuffer jsonBuffer; // Parsing Json teb // Lub hauv paus ntawm tsob ntoo. // // Nws yog qhov siv rau JsonObject, qhov tseeb bytes yog sab hauv // jsonBuffer nrog rau txhua lwm qhov ntawm cov khoom ntoo. // Nco tau tso tawm thaum jsonBuffer tawm ntawm qhov muaj. JsonObject & hauv paus = jsonBuffer.parseObject (teb); JsonObject & xeev = hauv paus ["xeev"]; // Kuaj yog tias kev cais ua tiav. yog (! root.success ()) {Serial.println ("parseObject () ua tsis tau tejyam"); } // Nqis qhov tseem ceeb. aan_restore = xeev ["rau"]; Serial.println (aan_restore); bri_restore = xeev ["bri"]; x_restore = state ["xy"] [0]; y_restore = state ["xy"] [1]; thawj = cuav;} tsis muaj dabtsis connectWifi () {// Local intialization. Thaum nws ua lag luam tiav, tsis tas yuav khaws nws ib puag ncig WiFiManager wifiManager; // rov pib teeb tsa - rau kev sim: //wifiManager.resetSettings (); // teeb tsa kev hu rov qab uas tau hu thaum txuas mus rau WiFi yav dhau los tsis ua, thiab nkag mus rau Access Point hom wifiManager.setAPCallback (configModeCallback); // nqa ssid thiab dhau thiab sim txuas // yog tias nws tsis txuas nws pib qhov nkag mus nrog lub npe tshwj xeeb // ntawm no "AutoConnectAP" // thiab nkag mus rau hauv lub voj voos tos tos teeb tsa yog (! wifiManager.autoConnect ()) {Serial.println ("ua tsis tiav txuas thiab ntaus sijhawm"); // rov pib dua thiab sim dua, lossis tej zaum muab tso rau pw tsaug zog ESP.reset (); ncua (1000); } // yog tias koj tuaj txog ntawm no koj tau txuas nrog WiFi Serial.println ("txuas nrog … yeey:)"); Serial.print ("Txuas nrog:"); Serial.println (WiFi. SSID ()); Serial.print ("IP chaw nyob:"); Serial.println (WiFi.localIP ()); // IP chaw nyob muab rau koj ESP (Wemos) // luam tawm lub teeb liab tau txais lub zog: ntev rssi = WiFi. RSSI (); Serial.print ("teeb liab lub zog (RSSI):"); Serial.println (rssi); } void configModeCallback (WiFiManager * myWiFiManager) {Serial.println ("Nkag mus rau hom teeb tsa"); Serial.println (WiFi.softAPIP ()); // yog tias koj siv nws pib tsim SSID, luam nws Serial.println (myWiFiManager-> getConfigPortalSSID ()); }

Pom zoo: