Cov txheej txheem:

PhotonLamp - WS2812b Nruab Tus Tsim Teeb nrog MQTT Tswj: 5 Kauj Ruam (nrog Duab)
PhotonLamp - WS2812b Nruab Tus Tsim Teeb nrog MQTT Tswj: 5 Kauj Ruam (nrog Duab)

Video: PhotonLamp - WS2812b Nruab Tus Tsim Teeb nrog MQTT Tswj: 5 Kauj Ruam (nrog Duab)

Video: PhotonLamp - WS2812b Nruab Tus Tsim Teeb nrog MQTT Tswj: 5 Kauj Ruam (nrog Duab)
Video: TOP 10 neopixel ws2812b projects (2018) 2024, Kaum ib hlis
Anonim
Image
Image
Tus Tshiab Innards ntawm Teeb - Partlist
Tus Tshiab Innards ntawm Teeb - Partlist

Ntau xyoo dhau los peb tau yuav lub teeb tsim qauv uas muaj lub teeb pom kev zoo li cov luam yeeb thiab tau ua los ntawm cov kua mis. Peb nyiam qhov tsim tshwj xeeb ntawm qhov ntxoov ntxoo thiab qhov pom ntawm lub teeb. Tab sis kuv tsis tau txaus siab tiag tiag nrog lub teeb uas los ntawm tsib tus qauv me me qhov muag teeb. Txij li qhov ntxoov ntxoo muaj lub vojvoog me me, koj tsis tau txais lub teeb pom kev tsis tu ncua tab sis koj tuaj yeem pom tib lub qhov muag teev los ntawm qhov ntxoov ntxoo. Thaum kuv dawm hla WS2812b LED kab txaij ib lub tswv yim tau yug: Kuv xav hloov/hloov dua tshiab lub teeb thiab hloov cov qauv teeb pom kev zoo los ntawm RGB LEDs. Tsis txhob hais tias lub teeb "tshiab" yuav tsum tswj tau los ntawm Wifi kom tau txais WAF siab dua 8-).

Kauj Ruam 1: Tus Tshiab Innards of the Lamp - Partlist

Tus Tshiab Innards ntawm Teeb - Partlist
Tus Tshiab Innards ntawm Teeb - Partlist

Txij li thaum kuv twb tau ua qee qhov haujlwm nrog Particle Photons (https://particle.io) kuv xaiv qhov no zoo li tus tswj hwm zoo raws li lub hauv paus ntawm kuv txoj haujlwm. Cov ntsiab lus kuv xav tau cov cuab yeej no los tsim kuv lub teeb hloov pauv:

  • 1x 90cm yeeb nkab nrog M6 metric xov ntawm ib kawg
  • 1 x Particle Photon
  • 1x HC-SR04 ultrasonic sensor (rau qhov tshwj xeeb twist)
  • qee cov xov hlau los txuas rau ntu
  • 1 x AC/DC 5V/2A fais fab mov
  • fais fab txuas rau lub hauv paus ntawm lub teeb kom ntsaws rau hauv lub hwj chim
  • 1x WS2812b LED kab txaij nrog 30 LEDs ib 'meter' (3m ntev)
  • Lub teeb tsim

Kauj Ruam 2: Kev Txuas Hluav Taws Xob

Qhov thaiv
Qhov thaiv

Kev teeb tsa txoj hlua yog yooj yim heev: Raws li tau qhia hauv daim duab fritzing koj yuav tsum txuas lub zog txuas nrog Photon ntawm tus pin VIN thiab GND thiab nrog + thiab - ntawm ib kawg ntawm thawj LED kab txaij. HC-SR04 txuas nrog ob txoj hlua ntev nrog tus pin D2 (TRIGGER ntawm HC-SR04) thiab D3 (ECHO ntawm HC-SR04) ntawm Photon. Tus pin D4 ntawm Photon txuas rau DI ntawm thawj LED kab txaij.

Kauj Ruam 3: Qhov Nyuaj - Sib Sau Cov Khoom

Qhov Nyuaj - Sib sau ua tej daim
Qhov Nyuaj - Sib sau ua tej daim
Qhov Nyuaj - Sib sau ua tej daim
Qhov Nyuaj - Sib sau ua tej daim
Qhov Nyuaj - Sib sau ua tej daim
Qhov Nyuaj - Sib sau ua tej daim
Qhov Nyuaj - Sib sau ua tej daim
Qhov Nyuaj - Sib sau ua tej daim

Cov kab txaij LED yog tus kheej-nplaum, tab sis kuv ruaj ntseg lawv nrog qee qhov txuas txuas ntxiv (saib cov duab nthuav dav). Txhawm rau khaws cov xov hlau kom luv li sai tau Kuv txiav txim siab xaim plaub kab coj hauv zigzag - tus pin D4 ntawm Photon txuas nrog DI ntawm thawj kab txaij, ua ntawm thawj kab ntawv txuas nrog rau qhov kawg ntawm cov yeeb nkab mus rau DI ntawm qhov kab thib ob. DO ntawm kab thib ob txuas nrog DI ntawm kab thib peb nyob hauv qab ntawm cov yeeb nkab. DO ntawm kab thib peb txuas nrog DI ntawm kab plaub kab saum toj ntawm cov yeeb nkab. VCC thiab GND kab ntawm txhua kab txaij tau txuas nrog tib txoj hauv kev. Cov xov hlau rau lub ntsuas hluav taws xob ultrasonic yog qhov ntev tshaj plaws thiab khiav los ntawm sab hauv ntawm cov yeeb nkab.

Lub hwj chim tau txuas nrog lub qhov (socket) uas kuv tau muab tso rau hauv lub qhov hauv qab ntawm lub teeb uas nyob hauv qhov qub version 220V fais fab cable tau hla mus. Cov hlua hluav taws xob mus los ntawm cov txuas no mus rau VIN/GND ntawm Photon, mus rau VCC/GND ntawm cov kab txaij coj mus rau lub ntsuas hluav taws xob.

Kauj Ruam 4: Cov Khoom Muag - Firmware Muaj nyob ntawm Github

Cov Khoom Muag - Firmware Muaj nyob ntawm Github
Cov Khoom Muag - Firmware Muaj nyob ntawm Github

Lub khoos phis tawj muaj nyob hauv no git chaw cia khoom ntawm Github:

github.com/happenpappen/PhotonLamp

Yog tias koj siv tus pin zoo tib yam los txuas cov kab hluav taws xob LED thiab HC-SR04, qhov tsuas yog qhov koj yuav tsum tau hloov ua ntej sau cov cai yog los tsim cov ntaub ntawv "MQTT_credentials.h" hauv "src" subdirectory uas muaj peb kab:

#define MQTT_HOST "" #define MQTT_USER "" #define MQTT_PASSWORD ""

Muaj ntau cov lus qhia zoo yuav teeb tsa lub mositto server li cas uas koj tuaj yeem nrhiav tau yooj yim los ntawm kev siv koj lub tshuab tshawb fawb uas koj nyiam …

Kauj Ruam 5: Lub Firmware - Yuav Siv Li Cas MQTT Kev Sib Txuas

Image
Image

Kuv siv Rasperry Pi 3 nrog mosquitto (https://www.mosquitto.org) ua MQTT server, thov xa mus rau nws cov ntaub ntawv yuav ua li cas teeb tsa nws. Koj tuaj yeem sau npe mus rau lub ncauj lus ([ntaus cim] = ID ntawm koj li Particle Photon):

/[ntaus cim]/#

kom pom tias nws tau ua tiav txuas rau lub server thiab yog nws muaj peev xwm tshaj tawm nws li xwm txheej:

Cov zis yuav tsum zoo li qhov no ([device id] = ID ntawm koj li Particle Photon):

/[ntaus cim]/xeev/DisplayMode 8

/[device id]/state/Brightness 250/[device id]/state/ForgroundColor 100, 023, 014/[device id]/state/BackgroundColor 034, 006, 034/[device id]/state/MaxDistance 92/[device id]/state/LastDistance 92/[device id]/state/CurrentDistance 92/[device id]/state/FirmwareVersion 0.6.3

Qhov tseeb tso tawm yuav nyob ntawm qhov version ntawm firmware uas koj siv.

Tab sis muaj kev lom zem ntau hauv nws: Los ntawm kev tshaj tawm rau:

/[ntaus cim]/teeb/[parameter] [tus nqi]

koj tuaj yeem hloov tus qauv uas tau nthuav tawm nrog rau qee yam xim.

Kom hloov xim xa:

/[device id of Particle Photon]/set/ForgroundColor/[liab], [ntsuab], [xiav]

/[ntaus cim ntawm Particle Photon]/setBackgroundColor/[liab], [ntsuab], [xiav]

Rau [liab], [ntsuab] thiab [xiav] ntxig cov zauv zauv ntawm qhov xim sib txawv.

Txhawm rau hloov cov qauv duab xa:

/[ntaus cim ntawm Particle Photon]/teeb/DisplayMode [tus nqi nruab nrab ntawm 1 thiab 11]

Tam sim no siv cov qauv zaub yog:

  1. Suab nrov
  2. Zaj sawv
  3. NoisePlusPalette
  4. Tib Xim
  5. Lub tog raj kheej
  6. Los nag
  7. Hluav Taws
  8. Kab rov tav
  9. Kab rov tav
  10. NtsugSplit
  11. Muab kauv (hauv kev txhim kho)

Ib txhia ntawm lawv yog los ntawm ntu piv txwv ntawm FastLED.

Txhawm rau hloov qhov ci ci xa:

/[device id]/set/Brightness [tus nqi ntawm 1 txog 100]

Pom zoo: