Mundarija:

MAX7219 LED Matrix MQTT Esp8266 yordamida: 6 qadam
MAX7219 LED Matrix MQTT Esp8266 yordamida: 6 qadam

Video: MAX7219 LED Matrix MQTT Esp8266 yordamida: 6 qadam

Video: MAX7219 LED Matrix MQTT Esp8266 yordamida: 6 qadam
Video: Using HT16K33 4 digit seven segment display with ESP8266 NodeMCU and D1 Mini 2024, Noyabr
Anonim
MAX7219 LED Matrix MQTT Esp8266 yordamida
MAX7219 LED Matrix MQTT Esp8266 yordamida

Men MAX7219 LED displeyimni MQTT serveriga ulashga va MQTT obunasidan matnni ko'rsatishga harakat qilardim.

lekin men Internetda mos kodni olmadim, shuning uchun men o'z kodimni yaratishni boshladim …

va natija juda yaxshi …

  • har qanday matnni LED displeyda ko'rsatish mumkin
  • Siz ekranning intensivligini sozlashingiz mumkin
  • aylantirish tezligini belgilashingiz mumkin

Ta'minotlar

  1. Esp8266 ishlab chiqish paneli. (mening ishim bu NODE MCU v1.0)
  2. MAX7219 LED matritsali displey.

Kerakli dasturiy ta'minot:

  1. Arduino IDE.
  2. MQTT serveri. (Mening ishim chivin)

Kutubxona kerak:

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

1 -qadam: Esp8266 ishlab chiqish uchun Arduino IDE -ni o'rnating

Esp8266 ishlab chiqish uchun Arduino IDE -ni o'rnating
Esp8266 ishlab chiqish uchun Arduino IDE -ni o'rnating

Arduino -ning afzalliklarini oching, so'ng quyidagi URL -ni qo'shimcha taxtalar menejeri URL -lariga joylashtiring:

arduino.esp8266.com/stable/package_esp8266com_index.json

keyin asboblar> taxtalar> taxtalar menejeri va esp8266 ni qidiring va o'rnating.

Endi sizning Arduino ideangiz esp8266 ishlab chiqishga tayyor.

2 -qadam: Tashqi kutubxonalarni yuklab oling

endi bizga MAX7219 va MQTT Client uchun kutubxonalar kerak.

kutubxonalarni yuklab olamiz va o'rnatamiz

Sketch> Kutubxonani qo'shish> Arduino IDE -dagi kutubxonalarni boshqarish -ga o'ting

va EspMQTTClient -ni qidiring va O'rnatish -ni bosing

Eslatma: Barcha qaram kutubxonalarni o'rnating, bu juda muhim

Yana MD_MAX72xx -ni qidiring va O'rnatish -ni bosing

3 -qadam: Endi kod yozing

Endi quyidagi kodni joylashtiring

#qo'shing

#include #include #include "EspMQTTClient.h" #MAX_DEVICES 4 ni aniqlang // qurilmangiz sonini aniqlang #CLK_PIN D5 ni belgilang // yoki SCK #DATA_PIN D7 ni belgilang // yoki MOSIni belgilang #CS_PIN D4 ni belgilang // yoki SS // uni sozlashingiz mumkin. har qanday pinga #define HARDWARE_TYPE MD_MAX72XX:: PAROLA_HW // displey turiga qarab o'zgartirish 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; // standart aylantirish kechikishi uint8_t INTENSITY = 5; // standart intensivlik char curMessage [MESG_SIZE]; char newMessage [MESG_SIZE]; bool newMessageAvailable = noto'g'ri; void scrollDataSink (uint8_t dev, MD_MAX72XX:: transformType_t t, uint8_t col) {} uint8_t scrollDataSource (uint8_t dev, MD_MAX72XX:: transformType_t t) {static enum {S_IDLE, S_NEX_CHOW_, S_NEX_CHOW_, S_NEX_CHOW_ statik char *p; statik uint16_t curLen, showLen; statik uint8_t cBuf [8]; uint8_t colData = 0; switch (holat) {case S_IDLE: p = curMessage; if (newMessageAvailable) {strcpy (curMessage, newMessage); newMessageAvailable = noto'g'ri; } holat = S_NEXT_CHAR; tanaffus; holat S_NEXT_CHAR: agar (*p == '\ 0') holat = S_IDLE; boshqa {showLen = mx.getChar (*p ++, sizeof (cBuf) / sizeof (cBuf [0]), cBuf); curLen = 0; davlat = S_SHOW_CHAR; } tanaffus; holat S_SHOW_CHAR: colData = cBuf [curLen ++]; agar (curLen = SCROLL_DELAY) {mx.transform (MD_MAX72XX:: TSL); // oldinga siljiting - qayta qo'ng'iroq barcha ma'lumotlarni yuklaydi prevTime = millis (); // keyingi safar boshlanish nuqtasi}} void setup () {Serial.begin (115200); mx.begin (); mx.control (MD_MAX72XX:: INTENSITY, INTENSITY); mx.setShiftDataInCallback (scrollDataSource); mx.setShiftDataOutCallback (scrollDataSink); curMessage [0] = newMessage [0] = '\ 0'; sprintf (curMessage, "Aqlli displey"); } void onConnectionEstablished () {// MQTT obunasi mavzusi matnli mijozni ko'rsatish uchun.subscribe ("leddisplay/text", (const String & payload) {sprintf (curMessage, payload.c_str ());});

// Displey intensivligini nazorat qilish uchun MQTT obunasi mavzusi

client.subscribe ("leddisplay/intensivligi", (const String & payload) {mx.control (MD_MAX72XX:: INTENSITY, payload.toInt ());}); // MQTT obunasi mavzusi displeyda aylantirish tezligini boshqarish client.subscribe ("leddisplay/scroll", (const String & payload) {SCROLL_DELAY = payload.toInt ();}); } void loop () {client.loop (); scrollText (); }

Batafsil ma'lumot uchun ushbu omborga qarang

github.com/souravj96/max7219-mqtt-esp8266

4 -qadam: O'chirish diagrammasi

O'chirish diagrammasi
O'chirish diagrammasi

MAX7219 displeyini NODE MCU bilan ulang

5 -qadam: Kodni Esp8266 -ga yuklang

Kodni Esp8266 -ga yuklang
Kodni Esp8266 -ga yuklang

Endi to'g'ri taxta turini va ketma -ket portni tanlang, so'ngra yuklashni bosing.

6 -qadam: Hammasini sinab ko'ring

agar hamma narsa to'g'ri bo'lsa, sizning esp8266 sizning MQTT serveringizga ulanadi.

endi, agar biror narsa ko'rsatiladigan LEDdisplay/matn mavzusida e'lon qilinsa.

{

mavzu: "leddisplay/text", foydali yuk: "bu erda sizning xabaringiz"}

agar siz ekranning intensivligini sozlamoqchi bo'lsangiz

{

mavzu: "leddisplay/intensivligi", yuk: "2" // maksimal 15 va min 0}

Agar siz ekranning aylanish tezligini o'rnatmoqchi bo'lsangiz

{

mavzu: "leddisplay/scroll", yuk: "100" // maksimal 255 va min 0}

Baxtli kodlash

Tavsiya: