CTBot
CTBot copied to clipboard
why flickered my led matrix at telegram
Hi,
I have a P3 RGB 64x32 l led matrix and the telegram library as soon as I embed a certain part of the telegram library flickers the matrix. Why is that?
` #include "CTBot.h" // Telegramm #include "PxMatrix.h" // LED Matrix / P3 64x32 RGB Display #include <Ticker.h> // Intervall for Display refresh
Ticker display_ticker;
#define P_LAT 16 #define P_A 5 #define P_B 4 #define P_C 15 #define P_D 12 #define P_E 0 #define P_OE 9
PxMATRIX display(64, 32, P_LAT, P_OE, P_A, P_B, P_C, P_D, P_E);
CTBot myBot;
void display_updater() { display.display(10); // Display Refresh }
void setup() {
Serial.begin(9600);
display.begin(16);
myBot.wifiConnect("qwertx", "1234@@5678");
myBot.setTelegramToken("640083020:AAEyK6UhUybfzuPcxYSgg0DXxYPH2FqYgHs");
display_ticker.attach(0.002, display_updater); }
void loop() {
display.setCursor(0, 0); display.print("HI"); // this text flickers
TBMessage msg;
if (myBot.getNewMessage(msg)) {} // if I comment that out, the flickering is gone
} `
Hello Nurries, the RGB Matrixes are bad beast to deal with the ESP8266 hardware. Keep in mind that 2dom (the PxMatrix author) use a clever way to bypass the lack of pin in the ESP8266 by "serializing" all the RGB data (six pin) in only one ESP8266 pin (so a bunch of work for the SOC!). Basically, I guess the problem is related to the Telegram library fetching data (that is not asynchronous) -> they maybe blocks the execution waiting the telegram server response -> some flicker effect appears. You can try overclocking the ESP8266 from 80MHz to 160MHz (you can do that in the "Tools" menu of Arduino IDE and choosing "CPU Frequency -> 160MHz)
In the past, when I did some projects with RGB matrixes and NodeMCUs, doubling the frequency sometimes saves me ;-)
So try and let me know!
Ceers,
Stefano
I forgot, one more thing: download the master branch version, because it have some upgrades not published yet as official release.
Hello, Stefano,
Thanks for the answer. I increased the CPU frequency to 160MHz but the flickering is still there. Do you have a link to the possibility to bypass the pin shortage?
Do you happen to know what happens when a telegram waits for an answer and if you can bypass what is blocked there?
downloaded the new version :)
Thanks for your help!
Greetings from Germany
The RGB matrices needs a lot of pin to work: you need at least:
- six pins for RGB color components
- four/five pins for row addressing
- three pins for signalling (output enable, latch and clock) Total: 13 pins (at least, some matrices needs more) The ESP8266 have only nine I/O pins (D0..D8) so it can't drive a RGB Matrix. 2dom "serialize" the RGB data so use only a pin in spite of six. For that reason you can drive an RGB Matrix with an ESP8266.
Going back to your questions, at this moment I can't work on a "non blocking" member functions that interact with Telegram server.
A possible solution could be using another device (an Arduino Nano) as frame buffer: this device handle the matrix refreshing procedure and the ESP8266 handle all other tasks. Every time the ESP8266 need to change the data on the RGB Matrix, it sends the data (pixels) to the Arduino Nano and the Arduino use the new data for refreshing the RGB Matrix. There is a bit of work to do, but you could reuse some projects already done! Good luck ;-)
Stefano
Hi Stefano, so technically dont use 1 device ie WemosD1 mini with LED Dot Matrix directly with CTBot ?
id saw one sample that use ESP01 & to send text to Uno using blynk serial (connected to LED Dot Matrix)...
i wonder that still the proper method right ? Wemos -> serial link -> Uno -> LED Dot Matrix
regards
Hello CCERocks, exactly! You can:
- gather data with a Telegram Bot running in the Wemos,
- send the data retrieved using a serial connection (or SPI, or I2C - these protocols should be more efficient than UART/SoftwareSerial) to an Arduino Uno
- process and draw the data on a LED dot matrix using the Arduino Uno
Driving LED matrices requires a good timing.
Cheers,
Stefano