Cov txheej txheem:

Cov Lus Qhia: 17 Cov Kauj Ruam
Cov Lus Qhia: 17 Cov Kauj Ruam

Video: Cov Lus Qhia: 17 Cov Kauj Ruam

Video: Cov Lus Qhia: 17 Cov Kauj Ruam
Video: Lus Qhuab Qhia Cov kauj ruam uas qhia ze ze Tswv Yexus yuav los lawm tiag 2024, Kaum ib hlis
Anonim
Cov ntawv ceeb toom
Cov ntawv ceeb toom

Cov cuab yeej tuaj yeem txuas nrog piv txwv rau IFTTT system thiab ua haujlwm thaum muaj ntawv xa tawm tshiab. Ntawm app.remoteme.org peb yuav tsim qhov txuas tom qab hu xov tooj twg yuav xa mus rau Arduino, thiab Arduino yuav tso saib qee qhov pom kev thiab ua qee qhov mp3 los ntawm SDcard

Kauj Ruam 1: Yam Yuav Tsum Tau Ua

Dab Tsi Xav Tau
Dab Tsi Xav Tau
Dab Tsi Xav Tau
Dab Tsi Xav Tau
  • NodeMCU, WemOS lossis qee yam zoo sib xws
  • Ob lub nplhaib LED nrog WS2812B diodes (Kuv tau siv lub teeb ci 16 qhov)
  • DFRobotDFPlayerMini - qhov no yog mp3 player. Nws ua si mp3 los ntawm SDcard, thiab sib tham nrog Arduino los ntawm RX/TX
  • Hais lus
  • SDcard
  • Logic converter -Kuv tau siv qhov no, lub mp3 player siv 5V thiab Arduino 3.3 yog vim li cas peb thiaj xav tau qhov hloov pauv no
  • Kev paub thiab kev txawj ua kom yooj yim PCB los ntawm peb tus kheej

Tus pej thuam:

  • cardboard - ob qhov sib txawv tuab
  • Luam ntawv
  • txhuas ntawv ci

Kauj Ruam 2: Lub Tsev Ntauwd

Ntauwd Tsev
Ntauwd Tsev
Ntauwd Tsev
Ntauwd Tsev
Ntauwd Tsev
Ntauwd Tsev
Ntauwd Tsev
Ntauwd Tsev

Saum toj no txoj kev npaj ntawm tus pej thuam nyob rau sab saib (kuv taug txuj kev nyuaj nrog kev kos duab tas hauv tsev kawm ntawv theem pib), txhua qhov ntev hauv millimeters.

Lub hauv paus ntsiab lus ntawm kev ua haujlwm

  1. lub nplhaib ntawm LEDs tso lub teeb rau
  2. Luam ntawv
  3. Lub khob hliav qab txiav, ua los ntawm cov duab los qhia thiab npog nrog ntawv ci txhuas, yog li nws cuam tshuam lub teeb los ntawm cov hlua coj, hauv daim duab 3 '= qhov txiav tawm
  4. thawv raj - tuav lub yees ntsug, sab hauv lub raj yog cov hlua rau coj
  5. Qhov siab nyob ntawm koj kuv muaj 85mm
  6. Sawv hauv txhua qhov khoom siv hluav taws xob

Txhua kab rov tav yuav tsum ua los ntawm cov ntawv tuab.

Kauj Ruam 3: Daim Kab Xev

Daim duab thaiv
Daim duab thaiv
Daim duab thaiv
Daim duab thaiv
Daim duab thaiv
Daim duab thaiv
Daim duab thaiv
Daim duab thaiv

Lub mp3 player tau muab nrog 5V qhov hluav taws xob thiab sib txuas lus nrog Arduino ntawm TX / RX, xav tau kev hloov pauv vim tias Arduino nws tus kheej ua haujlwm ntawm 3.3V qhov hluav taws xob. Kev tswj ntawm lub nplhaib tseem txuas nrog Arduino (D5, D6) los ntawm kev hloov pauv logic.

Ntawm qhov chaw cia khoom, Koj yuav pom cov ntaub ntawv dav dav nrog PCB cov phiaj xwm

Kuv hais kom tsis txhob siv cov khoom txuas mus tas li Arduino thiab lub mp3 player tsuas yog siv cov poj niam goldpins

Kauj Ruam 4: Lub hauv paus ntsiab lus ntawm Kev Ua Haujlwm

Peb Arduino txuas rau app.remoteme.org system siv WebSockets (muaj cov tsev qiv ntawv npaj tau) los ntawm qhov txuas no 5-byte cov lus tau xa:

  • thawj byte ntawm lub teeb pom kev zoo rau lub nplhaib LED sab saud
  • thib ob byte lub teeb pom kev rau hauv qab LED lub nplhaib
  • tus naj npawb ntawm cov ntawv mp3 uas yuav tsum tau ua
  • tus naj npawb ntawm vib nas this ntev npaum li cas lub teeb pom kev zoo thiab lub mp3 yuav tau ua si
  • seb mp3 yuav tsum tau ua si ib zaug lossis hauv lub voj

qhov chaws

Txhua qhov chaws Koj tuaj yeem pom ntawm no

hauv cov ntaub ntawv SingleRing.cpp thiab SingleRing.h muaj chav kawm los tswj qhov cuam tshuam ntawm LED rings. Kuv qhia koj pib los ntawm saib setMode (int m) muaj nuj nqi:

void SingleRing:: setMode (int m) {hloov (m) {rooj plaub 0: setConfiguration (0, 0, 50, 0, 5, 1); so; // tawm = 0 rooj plaub 1: setConfiguration (6, 0, 50, 0, 0, 20); tawg; // txheej txheem txheej txheem ntsuab 2: setConfiguration (6, 0, 0, 50, 0, 20); tawg; // txheej txheem txheej txheem xiav 3: setConfiguration (6, 50, 0, 0, 0, 0, 20); tawg; // txheej txheem txheej txheem liab 4: setConfiguration (6, 50, 10, 0, 0, 20); tawg; // txheej txheem txiv kab ntxwv txheej 5: setConfiguration (1, 0, 100, 0, 5, 2); tawg; // tub ceev xwm clockwise rooj plaub ntsuab 6: setConfiguration (1, 0, 100, 0, 5, -2); tawg; // tub ceev xwm rov qab rooj plaub ntsuab 7: setConfiguration (1, 0, 0, 100, 5, 2); tawg; // tub ceev xwm lub moos xiav rooj plaub 8: teeb tsa (1, 0, 0, 100, 5, -2); tawg; // tub ceev xwm rov qab rooj plaub 9: setConfiguration (1, 100, 0, 0, 5, 2); tawg; // tub ceev xwm txheej txheem rooj plaub liab 10: setConfiguration (1, 100, 0, 0, 5, -2); tawg; // tub ceev xwm rov qab rooj plaub liab 11: setConfiguration (1, 100, 20, 0, 5, 2); ua txhaum; // tub ceev xwm tus txheej txheem txiv kab ntxwv 12: setConfiguration (1, 100, 20, 0, 5, -2); tawg; // tub ceev xwm rov qab cov ntaub ntawv txiv kab ntxwv 13: setConfiguration (2, 0, 0, 50, 8, 10); tawg; // hla tus txheej txheem xiav 14: setConfiguration (2, 0, 0, 50, 8, -10); tawg; // hla rov qab rooj plaub 15: setConfiguration (5, 0, 50, 0, 0, 20); tawg; // ntsais muag tus qauv ntsuab rooj plaub 16: setConfiguration (5, 0, 50, 0, 0, -20); so; // ntsais muag odwyrtka ntsuab rooj plaub 17: setConfiguration (5, 0, 0, 50, 0, 20); tawg; // ntsais muag tus qauv xiav rooj plaub 18: setConfiguration (5, 0, 0, 50, 0, -20); tawg; // ntsais ntsais rov qab rooj plaub 19: setConfiguration (5, 50, 0, 0, 0, 0, 20); tawg; // ntsais muag tus qauv liab rooj plaub 20: setConfiguration (5, 50, 0, 0, 0, -20); so; // ntsais ntsais rov qab rooj plaub liab 21: setConfiguration (5, 50, 10, 0, 0, 20); tawg; // ntsais muag tus qauv txiv kab ntxwv 22: setConfiguration (5, 50, 10, 0, 0, -20); tawg; // ntsais ntsais rov qab txiv kab ntxwv lub neej qub: setConfiguration (0, 0, 50, 0, 5, 1); tawg; // tawm = 0}}

nyob ntawm qhov ntsuas uas tau muab, lub nplhaib yuav tso saib cov nyhuv. Koj tuaj yeem ntxiv koj tus kheej cov txiaj ntsig los ntawm kev hu xov tooj teeb tsa teeb tsa nrog cov ntsuas tshiab (hloov xim, tso saib nrawm) los ntawm kev ntxiv hom tshiab, lossis ntxiv cov txiaj ntsig tshiab tag - lossis qhia rau kuv paub hauv cov lus yog tias kuv nyiam nws Kuv yuav ntxiv cov nyhuv tshiab

arduino.ino:

#include "Arduino.h" #include "SoftwareSerial.h" #include "DFRobotDFPlayerMini.h"

#suav nrog

#include #include #include "SingleRing.h"

#suav nrog

#ncig #ncig

#suav nrog

#Txhais WIFI_NAME ""

#define WIFI_PASSWORD "" #define DEVICE_ID 205 #define DEVICE_NAME "siren" #define TOKEN ""

#define DIODES_COUNT 16

SingleRing saum = SingleRing (DIODES_COUNT, D5);

SingleRing hauv qab = SingleRing (DIODES_COUNT, D6);

SoftwareSerial mySoftwareSerial (D4, D3); // RX, TX

DFRobotDFPlayerMini myDFPlayer; RemoteMe & remoteMe = RemoteMe:: getInstance (TOKEN, DEVICE_ID);

ESP8266WiFiMulti WiFiMulti;

teeb tsa tsis muaj dab tsi () {mySoftwareSerial.begin (9600); Serial.begin (115200);

yog (! myDFPlayer.begin (mySoftwareSerial)) {// Siv softwareSerial los tham nrog mp3.

Serial.println (F ("Tsis tuaj yeem pib:")); Serial.println (F ("1. Please check the connection!")); Serial.println (F ("2. Please insert the SD card!")); thaum (muaj tseeb); } Serial.println (F ("DFPlayer Mini online."));

myDFPlayer.setTimeOut (500); // Teeb tsa lub sijhawm sib tham tsis sib xws tawm 500ms

myDFPlayer.volume (30);

myDFPlayer. EQ (DFPLAYER_EQ_NORMAL);

myDFPlayer.outputDevice (DFPLAYER_DEVICE_SD); WiFiMulti.addAP (WIFI_NAME, WIFI_PASSWORD); thaum (WiFiMulti.run ()! = WL_CONNECTED) {ncua (100); }

remoteMe.setUserMessageListener (onUserMessage);

remoteMe.setupTwoWayCommunication ();

remoteMe.sendRegisterDeviceMessage (DEVICE_NAME);

top.setup ();

hauv qab.setup (); saum.clear (); hauv qab.clear (); }

boolean turnsOff = muaj tseeb;

tsis tau kos npe ntev turnOffMillis = 0;

void onUserMessage (uint16_t senderDeviceId, uint16_t dataSize, uint8_t *cov ntaub ntawv) {

uint16_t pos = 0; uint8_t bottomMode = RemoteMeMessagesUtils:: getUint8 (cov ntaub ntawv, pos); uint8_t topMode = RemoteMeMessagesUtils:: getUint8 (cov ntaub ntawv, pos); uint8_t trackNumber = RemoteMeMessagesUtils:: getUint8 (cov ntaub ntawv, pos); uint8_t sijhawm = RemoteMeMessagesUtils:: getUint8 (cov ntaub ntawv, pos); uint8_t hom = RemoteMeMessagesUtils:: getUint8 (cov ntaub ntawv, pos);

bottom.setMode (bottomMode);

top.setMode (topMode); yog (hom == 1) {myDFPlayer.loop (trackNumber); } lwm {myDFPlayer.play (trackNumber); } tig tawm = tsis tseeb; turnOffMillis = millis () + 1000 * sijhawm; }

void lub voj ()

{remoteMe.loop (); top.loop (); hauv qab.loop (); yog (turnOffMillis

}

piav qhia:

#define WIFI_NAME "" #define WIFI_PASSWORD "" #define DEVICE_ID 205 #define DEVICE_NAME "notificator" #define TOKEN ""

Peb xav tau muab cov ntaub ntawv saum toj no, cov lus qhia ntxaws ntawm no ntawm qhov txuas thiab kuv tau qhia yuav ua li cas rau npe hauv remoteme.org thiab tsim cov cim, void onUserMessage (uint16_t senderDeviceId, uint16_t dataSize, uint8_t *cov ntaub ntawv) {uint16_t pos = 0; uint8_t bottomMode = RemoteMeMessagesUtils:: getUint8 (cov ntaub ntawv, pos); uint8_t topMode = RemoteMeMessagesUtils:: getUint8 (cov ntaub ntawv, pos); uint8_t trackNumber = RemoteMeMessagesUtils:: getUint8 (cov ntaub ntawv, pos); uint8_t sijhawm = RemoteMeMessagesUtils:: getUint8 (cov ntaub ntawv, pos); uint8_t hom = RemoteMeMessagesUtils:: getUint8 (cov ntaub ntawv, pos);

bottom.setMode (bottomMode);

top.setMode (topMode); yog (hom == 1) {myDFPlayer.loop (trackNumber); } lwm {myDFPlayer.play (trackNumber); } tig tawm = tsis tseeb; turnOffMillis = millis () + 1000 * sijhawm; }

Lub luag haujlwm no yuav raug hu thaum cov lus tuaj rau Arduino thiab nthuav qhia qhov kev ceeb toom. Cov cai yog qhov tseeb uas nws piav qhia nws tus kheej. Kuv xa mus rau cov ntsiab lus ntawm cov chav kawm rau cov ntaub ntawv ntawm no thiab ntawm no

lub voj void () {remoteMe.loop (); top.loop (); hauv qab.loop (); yog (turnOffMillis <millis ()) {

yog (! turnsOff) {

saum.clear ();

hauv qab.clear (); myDFPlayer.stop (); turnsOff = muaj tseeb; }}

Hauv lub voj, peb hu lub voj ua haujlwm ntawm cov khoom, thiab tseem yog lub sijhawm tso saib cov ntawv ceeb toom tau dhau mus, peb tua lub diodes thiab lub suab.

Kauj ruam 5: Mp3 Player

Mp3 Player
Mp3 Player

Nws sib txuas lus nrog Arduino ntawm TX / RX - Cov ntsiab lus ntawm tus neeg ua si nws tus kheej ntawm no, thiab tsev qiv ntawv ntawm no

Peb tso cov ntawv mp3 rau SD daim npav. Cov ntaub ntawv ntawm daim npav raug txheeb raws tus tsiaj ntawv thiab tom qab ntawd hu rau:

myDFPlayer.play (5);

Peb ua cov ntaub ntawv thib tsib los ntawm daim npav SD los ntawm cov hauv paus hauv paus. Tias yog vim li cas nws yog qhov zoo los muab cov ntaub ntawv ntawm SD daim npav ua ntej 01, 02 thiab lwm yam Hauv kuv cov ntaub ntawv nws zoo li ntawm cov ntawv sau saum toj no

Txhawm rau tsim cov lus txib Koj tuaj yeem siv nplooj ntawv no.

Kauj Ruam 6: Tshaj Tawm Txoj Haujlwm rau Arduino

Rub tawm Txoj Haujlwm rau Arduino
Rub tawm Txoj Haujlwm rau Arduino
Rub tawm Txoj Haujlwm rau Arduino
Rub tawm Txoj Haujlwm rau Arduino

Ua ntej xa cov duab kos rau Arduino, Koj yuav tsum rub tawm cov tsev qiv ntawv xav tau ntawm no koj yuav pom cov lus qhia ntxaws

ntxiv rau, peb yuav tsum teeb tsa DFRobotDFPlayerMini lub tsev qiv ntawv thiab Adafruit_NeoPixel

Kauj Ruam 7: Tswj

Tswj
Tswj
Tswj
Tswj

Peb xa mus rau peb Arduino tsib bytes

  • thawj byte ntawm lub teeb pom kev zoo rau lub nplhaib LED sab saud
  • thib ob byte lub teeb pom kev rau hauv qab LED lub nplhaib
  • tus naj npawb ntawm cov ntawv mp3 uas yuav tsum tau ua
  • tus naj npawb ntawm vib nas this ntev npaum li cas lub teeb pom kev zoo thiab lub mp3 yuav tau ua si
  • seb mp3 yuav tsum tau ua si ib zaug lossis hauv lub voj (1 yog tias nws yuav tsum tau ua hauv lub voj)

Los ntawm xa bytes

07 0F 01 05 01

Lub nplhaib sab saum toj yuav qhia cov tub ceev xwm teeb (hom 6) hauv qab ib qho ntsais ntsuab (hom 15) (txheeb xyuas qhov teeb tsa teeb tsa ntawm homRing.cpp thiab cov lus nyob ib sab ntawm nws). Thawj daim ntawv SDcard yuav ua si rau 5 vib nas this. Thiab cov ntawv yuav raug ua nyob rau hauv lub voj (kos ua haujlwm ntawmUserMessage ntawm arduino.ino)

Cia peb xa cov bytes no. Saib ntawm lub vijtsam saum toj no, thiab nyem lub cim nyob rau hauv kev sau los ntawm 1, 2, 3. Lub qhov rai tshwm

Tom qab ntawd saib ntawm lub vijtsam thib ob - thiab sau qhov rai zoo li ntawm lub vijtsam thib ob

Lub qhov rai uas tshwm sim yog siv los xa xov mus rau lub cuab yeej. Hauv daim teb 1, xaiv tus xa khoom - vim tias peb tsuas muaj ib lub cuab yeej, peb xaiv nws (qhov no yog qhov yuav tsum tau ua thiab nws tsis muaj teeb meem tias nws yog tib lub cuab yeej uas peb xa lus) Hauv kab 2 peb muab bytes rau xa (liab liab tus nqi peb nkag mus rau hauv 2 yuav raug sawv cev ua ib txoj hlua) tom qab ntawd nyem lub pob Xa.

Tom qab xa cov lus, peb tus neeg ceeb toom yuav tsum hnov mob los ntawm kev tso tawm cov teeb pom kev zoo tsim nyog thiab ua si xaiv mp3. Kuv txhawb koj kom sim cov teebmeem sib txawv los ntawm muab thawj ob bytes ntawm tus lej ntawm 0 thiab 22 (saib cov lus piav qhia hauv setMode muaj nuj nqi).

Kauj Ruam 8: Xa Cov Lus Siv URLs

Xa Cov Lus Siv URLs
Xa Cov Lus Siv URLs
Xa Cov Lus Siv URLs
Xa Cov Lus Siv URLs
Xa Cov Lus Siv URLs
Xa Cov Lus Siv URLs
Xa Cov Lus Siv URLs
Xa Cov Lus Siv URLs

Yog tias peb xav pom cov ntawv ceeb toom los ntawm daim ntawv thov sab nraud xws li IFTTT, peb yuav tsum muaj URL uas yuav ua tau zoo ib yam nkaus li peb tau ua hauv lub qhov rais hauv cov kauj ruam dhau los. remoteme.org muab REST APi. Mus rau nws los ntawm nyem rau ntawm swagger tab nyob rau sab laug (qhov kawg). Ib nplooj ntawv yuav tshwm sim, ntawm nplooj ntawv no peb tseem tuaj yeem sim peb qhov URLs.

Ntawm thawj lub vijtsam Koj muaj txoj haujlwm Koj xav tau nthuav dav, tom qab ntawd sau cov ntaub ntawv zoo li ntawm lub vijtsam thib ob.

sau cov ntaub ntawv raws li cov duab saum toj no. Tom qab nyem qhov ua tiav peb yuav xa lus

070F010501

Tus txais yog lub cuab yeej nrog 205 id, tib lub cuab yeej tseem yog tus xa. MessageId nrog "No_RENEVAL" teeb tsa tsis cuam tshuam Thiab tom qab ntawd nyem Execute. Notificator yuav hnov zoo ib yam li thaum xa xov los ntawm daim ntawv thov. Tom qab hu REST hauv qab no yog qhov URL uas tau hu - saib ntawm lub vijtsam thib peb. Thiab theej thiab paste rau browser URL tau cim nrog ciam teb ntsuab. Ntawm qhov tshuaj ntsuam thib plaub kuv lub chrome browser tom qab URL tau muab tso rau

Hauv kuv qhov xwm txheej, qhov URL yog:

app.remoteme.org/api/*/rest/v1/message/sendUserMessageHexString/205/1/NO_RENEWAL/1/070F010501/

Kauj Ruam 9: Anymous URL Kom Xa Xov

Anymous URL Kom Xa Xov
Anymous URL Kom Xa Xov

Hauv cov kauj ruam dhau los Koj muaj qhov URL uas xa cov ntaub ntawv rau koj lub cuab yeej. Hmoov tsis zoo, tom qab txiav tawm ntawm app.remoteme.org, nws tsis ua haujlwm. Qhov no yog vim peb tsis tau muab cov cim cim pov thawj, thiab peb tsis nkag mus ntxiv lawm.

Saib ntawm lub vijtsam thiab hloov * hauv URL nrog koj tus cim

hauv kuv qhov token yog:

~ 267_ZxoWtJ) 0ph & 2c

yog li kuv qhov kawg URL zoo li:

app.remoteme.org/api/~267_ZxoWtJ)0ph&2c/rest/v1/message/sendUserMessageHexString/205/1/NO_RENEWAL/1/070F010501/

Tam sim no peb tuaj yeem hu nws txawm hais tias peb tsis nkag rau hauv. Thiab thaum nws raug hu, cov lus yuav xa mus rau peb lub cuab yeej 205

Kauj Ruam 10: Kev Sib Koom Nrog IFTTT 1/7

Kev koom ua ke nrog IFTTT 1/7
Kev koom ua ke nrog IFTTT 1/7

Url tsim nyob rau theem saum toj no yog qhov tsim nyog rau kev ua tiav los ntawm daim ntawv thov sab nraud. Yuav siv nws li cas Kuv yuav qhia rau ntawm IFTTT. Kuv yuav teeb tsa nws kom tus ceeb toom qhib thaum tus email tuaj rau tus email (Gmail account).

Nkag mus rau IFTTT. Then mus rau My Applets tab thiab tom qab ntawv "Applet tshiab"- thawj lub vijtsam

Kauj Ruam 11: Kev Sib Koom Nrog IFTTT 2/7

Kev koom ua ke nrog IFTTT 2/7
Kev koom ua ke nrog IFTTT 2/7

Tom ntej no nyem "+qhov no"

Kauj Ruam 12: Kev Sib Koom Nrog IFTTT 3/7

Kev koom ua ke nrog IFTTT 3/7
Kev koom ua ke nrog IFTTT 3/7

Tom qab ntawd hauv daim teb "Tshawb nrhiav kev pabcuam" sau "Gmail"

Tom qab ntawd "email tshiab hauv inbox" (Qee qhov kev teeb tsa yuav xav tau).

Kauj Ruam 13: Kev Sib Koom Nrog IFTTT 4/7

Kev koom ua ke nrog IFTTT 4/7
Kev koom ua ke nrog IFTTT 4/7

tam sim no peb nyem rau "+ ntawd"

Kauj Ruam 14: Kev Sib Koom Nrog IFTTT 5/7

Kev koom ua ke nrog IFTTT 5/7
Kev koom ua ke nrog IFTTT 5/7

nrhiav "Webhooks" thiab nyem rau nws

Kauj Ruam 15: Kev Sib Koom Nrog IFTTT 6/7

Kev koom ua ke nrog IFTTT 6/7
Kev koom ua ke nrog IFTTT 6/7

tom qab ntawd "Ua lub vev xaib thov"

Kauj Ruam 16: Kev Sib Koom Nrog IFTTT 7/7

Kev koom ua ke nrog IFTTT 7/7
Kev koom ua ke nrog IFTTT 7/7

peb ua tiav qhov URL ntawm peb qhov url nrog cov cim. Cov ntsiab lus hom rau daim ntawv thov / json thiab nyem "tsim ua" thiab Ua tiav. Tam sim no peb muaj peb applet:

Kauj Ruam 17: Cov ntsiab lus

Hauv qhov kev qhia no, kuv tau qhia yuav xa li cas rau peb cov lus Arduino los ntawm cov txheej txheem sab nraud. Peb kuj sib koom ua ke qee qhov system tom qab ntawd IFTTT zoo ib yam. Nws tsis tas yuav tsum yog "tus tshaj tawm" Kuv xav qhia hauv qhov piv txwv no yuav xa xov li cas los ntawm cov txheej txheem sab nraud rau peb Arduino.

sourcecodesFanPage ntawm Facebook

Ua tsaug, Maciek

Pom zoo: