Introduction: IoT Based P10 LED Display Controller

About: Love making Electronic Projects

Control a P10 Display Using Arduino & ESP8266 via Telegram Bot


Introduction:


In this project, we will control a P10 LED display using an Arduino Nano and an ESP8266 module. The text displayed on the P10 module is sent via a Telegram bot, making it easy to update remotely. The ESP8266 receives messages from Telegram, forwards them to the Arduino Nano via serial communication, and the Nano then displays the text on the P10 module. The text will scroll automatically for better visibility.


Full video of the project https://youtu.be/WQDSzZuawzE


visit my YouTube channel for more such projects www.youtube.com/@N08labs


visit my Instagram

Supplies

Components Required:


  1. Arduino Nano
  2. ESP8266 (ESP-01 or NodeMCU)
  3. P10 LED Display Module
  4. 5V Power Supply (2A or more)
  5. Male Header Pins
  6. Jumper Wires
  7. Soldering Equipment

Step 1: Circuit Diagram & Connections:

ESP8266 to Arduino Nano:

  1. ESP8266 TX → Arduino Nano RX (Pin 0)
  2. ESP8266 GND → Arduino Nano GND
  3. ESP8266 VCC → 3.3V Power Supply
  4. ESP8266 CH_PD → 3.3V (Enable Pin)

P10 Display to Arduino Nano:

  1. P10 Module CLK → Arduino Nano Pin X
  2. P10 Module DATA → Arduino Nano Pin Y
  3. P10 Module OE → Arduino Nano Pin Z
  4. P10 Module A/B → Arduino Nano Pin W
  5. P10 Module GND → Common GND


Step 2: How It Works:

  1. The Telegram bot is set up to receive text messages.
  2. The ESP8266 connects to Wi-Fi and listens for new messages.
  3. When a message is received, the ESP8266 prints it on the serial monitor.
  4. The Arduino Nano reads the serial data and sends it to the P10 display.
  5. The text automatically scrolls across the display.

Step 3: Code:

Libraries Used:

  1. UniversalTelegramBot.h – For Telegram bot integration
  2. DMD.h – For controlling the P10 LED display
  3. TimerOne.h – For timer-based operations
  4. SystemFont5x7.h & Arial_black_16.h – For text fonts



Code for ESO8266

Enter your own Wi-Fi and Teligram credentials

#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>

const char* ssid = "N-08 LABS "; //your wifi id
const char* password = "n08labs"; //your wifi password

const int nw = 2;



#define CHAT_ID1 "685XXXXXXXX" //your Telegarm chat ID
#define BOTtoken "752XXXXXXXXXXXXXXXXXXXxXXXXXXXX" //your bot token


//#define CHAT_ID1 "1231230123" //your Telegarm chat ID
//#define BOTtoken "6330218641:AAEds1kjfGaeA-7oX48ghCfNdFM-9joOEvY" // your Bot Token (Get from Botfather)

#ifdef ESP8266
X509List cert(TELEGRAM_CERTIFICATE_ROOT);
#endif


WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);

int botRequestDelay = 1000;
unsigned long lastTimeBotRan;

void handleNewMessages(int numNewMessages) {
for (int i = 0; i < numNewMessages; i++) {
String chat_id = String(bot.messages[i].chat_id);
if (chat_id != CHAT_ID1) {
bot.sendMessage(chat_id, "Unauthorized user", "");
continue;
}
String text = bot.messages[i].text;
Serial.println(text);
String from_name = bot.messages[i].from_name;
delay(1000);
}
}

void setup() {
Serial.begin(9600);
pinMode(nw, OUTPUT);
digitalWrite(nw, LOW);

#ifdef ESP8266
configTime(0, 0, "pool.ntp.org"); // get UTC time via NTP
client.setTrustAnchors(&cert); // Add root certificate for api.telegram.org
#endif

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(1000);
}
delay(500);
digitalWrite(nw, HIGH);
delay(500);
digitalWrite(nw, LOW);
delay(500);
digitalWrite(nw, HIGH);
delay(500);
digitalWrite(nw, LOW);
delay(1000);
}

void loop() {
if (millis() > lastTimeBotRan + botRequestDelay) {
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);

while (numNewMessages) {
handleNewMessages(numNewMessages);
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
}
lastTimeBotRan = millis();
}
}


Code for Arduino

#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#define ROW_MODULE 1

#define COLUMN_MODULE 1

DMD p10(ROW_MODULE, COLUMN_MODULE);

char message[200];
char char_read;
byte pos_index = 0;
int i;
char welcome_screen[] = "N-08 LABS @n08labs";

void p10scan()
{
p10.scanDisplayBySPI();
}

void setup()
{
Timer1.initialize(1000);
Timer1.attachInterrupt(p10scan);
p10.clearScreen( true );
Serial.begin(9600);
strcpy(message,welcome_screen);
}
void loop()
{

if(Serial.available())
{
for(i=0; i<199; i++)
{
message[i] = '\0';
Serial.print(message[i]);
}
pos_index=0;
}

while(Serial.available() > 0)
{
p10.clearScreen( true );
if(pos_index < (199))
{
char_read = Serial.read();
message[pos_index] = char_read;
pos_index++;
}
}
p10.selectFont(Arial_Black_16);
p10.drawMarquee(message ,200,(32*ROW_MODULE)-1,0);
long start=millis();
long timer_start=start;
boolean flag=false;
while(!flag)
{
if ((timer_start+50) < millis())
{
flag=p10.stepMarquee(-1,0);
timer_start=millis();
}
}
}

Step 4: Setting Up the Telegram Bot:

  1. Open Telegram and search for @BotFather.
  2. Create a new bot using the /newbot command.
  3. Copy the bot token provided.
  4. Use this token in the ESP8266 code for communication.


Step 5: Uploading the Code:

  1. First, upload the ESP8266 code to establish Wi-Fi and Telegram bot communication.
  2. Then, upload the Arduino Nano code to handle the P10 display output.
  3. Ensure both are correctly wired and powered.

NOTE: Programming the ESP8266 after connecting to Arduino nano may not possibe


Step 6: Final Testing

  1. Power on the setup.
  2. Default message will appear.
  3. Send a message to your Telegram bot.
  4. The text should appear on the P10 display and start scrolling.

Watch my full video of this project https://youtu.be/WQDSzZuawzE