Running a Telegram Photo Bot on the ESP32-CAM


Setting up an ESP32-CAM to send photos on request to Telegram

This tutorial explains how to set up a Telegram Bot and use the Universal Arduino Telegram Bot Library with an ESP32 to take and send photos.

If you don’t have a Telegram account you need to create one first Telegram is similar to WhatsApp but also works in browsers.

After logging in to the web interface go to and click ‘OPEN IN WEB’

BotFather Open In Web

Click ‘START’ and you will see the available commands. You can also type /start in the Telegram web interface to see these commands again.

Type /newbot to create a new bot. The username has to follow these conventions: Usernames are 5-32 characters long and are case insensitive, but may only include Latin characters, numbers, and underscores. Your bot’s username must end in ‘bot’, e.g. ‘tetris_bot’ or ‘TetrisBot’.

Create BotFather Sequence

Copy the token highlighted in red somewhere safe.

Click the link in the message to go to your bot page. Click ‘START’.

ESP32 Arduino IDE Setup

You might need to install or update the ArduinoJson library in the IDE Library Manager to version 6+.

ArduinoJson Arduino IDE

The Arduino Telegram Bot library used for this tutorial isn’t the release version so it has to either be downloaded from the v1.2 branch and renamed to not conflict with the release version or you can just download the UniversalTelegramBotRZO .h and .cpp files from here: and save them all to a new directory in your Arduino folder.

Before running a more complicated sketch it’s better to test everything is working. Copy the ‘EchoBot’ sketch into the new directory, change the #include to match the .h and .cpp file names in the folder and upload it. Open the serial monitor in the IDE and then type something into the message box in the chat with your bot on Telegram and click send.

You should see ‘got response’ in the serial monitor and then the message you entered echoed back to your phone by the ESP32.

Telegram Send Response Echo

Above you can see I sent the message Hello World to the bot (RobotZeroOne) and it replied with the same message.

Uploading a Photo to Telegram

I found sending anything larger than an QVGA size file in one go would crash so to send larger images they have to be sent byte by byte.

Copy the TelegramSendPhotoChunked1_2.ino file into a new Sketch, change the Wi-Fi connection details and save it. Copy the .h and .cpp files above to the new folder. Upload the sketch to the ESP32-CAM and reset it.

Now when you send a message to your bot, the ESP32-CAM will take a photo and send it back to your phone.

Image Sent to Bot

If you go back to the BotFather and run the following commands: /setabouttext and /setdescription you can add more information. If you want to add your bot to a group. Also if you are stuck you can see all the commands by typing /help when you are talking to the BotFather.


Universal Arduino Telegram Bot Library:
Telegram Bots Help Page:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

scroll to top