Cov txheej txheem:

MAX7219 LED Matrix MQTT Siv Esp8266: 6 Cov Kauj Ruam
MAX7219 LED Matrix MQTT Siv Esp8266: 6 Cov Kauj Ruam

Video: MAX7219 LED Matrix MQTT Siv Esp8266: 6 Cov Kauj Ruam

Video: MAX7219 LED Matrix MQTT Siv Esp8266: 6 Cov Kauj Ruam
Video: Openhab + Wemos + MQTT + MAX7219 LED Dot Matrix 2024, Hlis ntuj nqeg
Anonim
MAX7219 LED Matrix MQTT Siv Esp8266
MAX7219 LED Matrix MQTT Siv Esp8266

Kuv tau sim txuas kuv MAX7219 LED zaub rau MQTT server thiab tau txais cov ntawv los ntawm MQTT kev tso npe kom pom.

tab sis kuv tsis tau txais cov cai tsim nyog hauv is taws nem, yog li kuv pib tsim kuv tus kheej …

thiab qhov tshwm sim los zoo heev …

  • koj tuaj yeem tso saib cov ntawv ntawm cov zaub coj
  • koj tuaj yeem kho qhov siv ntawm cov zaub
  • koj tuaj yeem teeb tsa qhov nrawm

Khoom siv

  1. ESP8266 pawg thawj coj loj. (kuv rooj plaub nws yog NODE MCU v1.0)
  2. MAX7219 LED Matrix Zaub.

Software xav tau:

  1. Arduino IDE Cov.
  2. MQTT neeg rau zaub mov. (kuv kis Mosquitto)

Tsev qiv ntawv yuav tsum tau:

  1. ESP8266WiFi.h
  2. MD_MAX72xx.h
  3. EspMQTTClient.h

Kauj Ruam 1: Teeb Arduino IDE rau Esp8266 Kev Txhim Kho

Teeb Arduino IDE rau Esp8266 Kev Txhim Kho
Teeb Arduino IDE rau Esp8266 Kev Txhim Kho

qhib kev nyiam ntawm Arduino tom qab ntawd muab tshuaj txhuam URL hauv qab no hauv Aditional Boards Manager URLs:

arduino.esp8266.com/stable/package_esp8266com_index.json

ces Cov Cuab Yeej> Boards> Tus Thawj Saib Xyuas Pawg thiab tshawb rau esp8266 thiab nruab nws.

tam sim no koj Arduino lub tswv yim npaj rau esp8266 kev txhim kho.

Kauj ruam 2: Rub tawm Cov Tsev Qiv Ntawv Sab Nraud

tam sim no peb xav tau qee lub tsev qiv ntawv rau MAX7219 thiab MQTT Client.

cia peb rub tawm thiab teeb tsa cov tsev qiv ntawv

mus rau Sketch> suav nrog Tsev Qiv Ntawv> Tswj Tsev Qiv Ntawv ntawm Arduino IDE

thiab tshawb rau EspMQTTClient thiab nyem Nruab

NB: Txhim kho txhua lub tsev qiv ntawv nyob, nws yog qhov tseem ceeb

Rov tshawb nrhiav MD_MAX72xx thiab nyem Nruab

Kauj Ruam 3: Sau Ib co Cai Tam Sim No

Tam sim no muab tshuaj txhuam hauv qab no

#suav nrog

#include #include #include "EspMQTTClient.h" #define MAX_DEVICES 4 // koj ntaus ntawv suav #define CLK_PIN D5 // lossis SCK #define DATA_PIN D7 // lossis MOSI #define CS_PIN D4 // lossis SS // koj tuaj yeem teeb nws rau ib tus pin #define HARDWARE_TYPE MD_MAX72XX:: PAROLA_HW // hloov pauv raws li koj hom zaub MD_MAX72XX mx = MD_MAX72XX (HARDWARE_TYPE, CS_PIN, MAX_DEVICES); const uint8_t MESG_SIZE = 255; const uint8_t CHAR_SPACING = 1; uint8_t SCROLL_DELAY = 75; // default scroll delay uint8_t INTENSITY = 5; // default siv char curMessage [MESG_SIZE]; char newMessage [MESG_SIZE]; bool newMessageAvailable = tsis tseeb; void scrollDataSink (uint8_t dev, MD_MAX72XX:: transformType_t t, uint8_t col) {} uint8_t scrollDataSource (uint8_t dev, MD_MAX72XX:: transformType_t t) {zoo li qub enum {S_IDLE, S_NEXT_CHAR, S_SHOW_SHOW, S_SHOW_SHOW, S_SHOW_SATA_SHOW, zoo li qub char *p; zoo li qub uint16_t curLen, showLen; zoo li qub uint8_t cBuf [8]; uint8_t colData = 0; hloov (xeev) {rooj plaub S_IDLE: p = curMessage; yog (newMessageAvailable) {strcpy (curMessage, newMessage); newMessageAvailable = tsis tseeb; } xeev = S_NEXT_CHAR; tawg; case S_NEXT_CHAR: yog (*p == '\ 0') xeev = S_IDLE; lwm tus {showLen = mx.getChar (*p ++, sizeof (cBuf) / sizeof (cBuf [0]), cBuf); curLen = 0; xeev = S_SHOW_CHAR; } tawg; case S_SHOW_CHAR: colData = cBuf [curLen ++]; yog (curLen = SCROLL_DELAY) {mx.transform (MD_MAX72XX:: TSL); // nqes nrog - qhov kev hu rov qab yuav thauj tag nrho cov ntaub ntawv prevTime = millis (); // pib taw tes rau lub sijhawm tom ntej}} tsis muaj teeb meem teeb tsa () {Serial.begin (115200)); mx.begin (); mx.control (MD_MAX72XX:: INTENSITY, INTENSITY); mx.setShiftDataInCallback (scrollDataSource); mx.setShiftDataOutCallback (scrollDataSink); curMessage [0] = newMessage [0] = '\ 0'; sprintf (curMessage, "Smart Display"); } void onConnectionEstablished () {// MQTT lub npe sau npe rau cov ntawv nyeem cov neeg siv khoom.subscribe ("leddisplay/text", (const String & payload) {sprintf (curMessage, payload.c_str ());});

// MQTT cov ncauj lus sau npe rau tso saib qhov kev tswj hwm

client.subscribe ("leddisplay/siv", (const String & payload) {mx.control (MD_MAX72XX:: INTENSITY, payload.toInt ());}); // MQTT kev sau npe lub ntsiab lus rau cov zaub scroll nrawm tswj client.subscribe ("leddisplay/scroll", (const String & payload) {SCROLL_DELAY = payload.toInt ();}); } tsis muaj dab tsi voj () {client.loop (); scrollText (); }

Yog xav paub ntxiv, xa mus rau qhov chaw cia khoom no

github.com/souravj96/max7219-mqtt-esp8266

Kauj Ruam 4: Daim duab Circuit Court

Daim duab Circuit Court
Daim duab Circuit Court

txuas MAX7219 zaub nrog NODE MCU

Kauj ruam 5: Upload Code rau Esp8266

Upload Code rau Esp8266
Upload Code rau Esp8266

tam sim no xaiv koj hom board raug thiab qhov chaw nres nkoj txuas tom qab ntawd nyem upload.

Kauj Ruam 6: Xeem Txhua Yam

yog tias txhua yam mus tau zoo ces koj esp8266 yuav txuas nrog koj li MQTT server.

tam sim no, yog tias muaj dab tsi yuav tshaj tawm ntawm leddisplay/cov ncauj lus ntsiab lus uas yuav nthuav tawm.

{

ntsiab lus: "leddisplay/text", them: "koj cov lus ntawm no"}

yog tias koj xav teeb tsa qhov siv ntawm cov zaub

{

ntsiab lus: "leddisplay/siv", them nyiaj: "2" // max yog 15 thiab min 0}

yog tias koj xav teeb tsa qhov nrawm ntawm cov zaub

{

ntsiab lus: "leddisplay/scroll", payload: "100" // max yog 255 thiab min 0}

Zoo siab coding

Pom zoo: