How to turn on lights with telegram and esp32 from anywhere in the world

In this tutorial we will see how to make a system that allows us to turn on lights with telegram, from anywhere in the world, just by typing a command. To do this a dual channel relay module will turn on two 110V/220V bulbs, the esp32 will connect to our Wifi network and by means of commands, to control the on or off of lights. We will send messages through the telegram messaging service, where the bot will respond to us when the light is turned on or off and we will also be able to know the status of each of them.

You may be interested in projects in Arduino, pic, robotics, telecommunications, subscribe videos with full source code and diagrams



Electronic components

Cables dupont

An ESP32

Features of the ESP32-T module


The ESP32 module has all the wiFi variants:

  • 802.11 b/g/n/e/i/n
  • Wi-Fi Direct (P2P), P2P Discovery, P2P Group Owner mode and P2P Power Management

This new version includes low-power Bluethoot connectivity

  • Bluetooth v4.2 BR/EDR and BLE
  • BLE Beacon

In addition, you can communicate using SPI, I2C, UART, MAC Ethernet, Host SD protocols

Microcontroller features

The CPU consists of a Tensilica LX6 Model SoC with the following features and memory

  • Dual 32-bit core with 160MHz speed
  • 448 kBytes ROM
  • 520kByteS SRAM

Have 48 Pins

  • 18 12-bit ADC
  • 2 8-bit DAC
  • 10 pin contact sensors
  • 16 PWM
  • 20 Digital inputs/outputs

Power and consumption modes

For proper operation of the ESP32 it is necessary to supply a voltage between 2.8V and 3.6V. The energy you consume depends on the mode of operation. It contains a mode, the Ultra Low Power Solution (ULP),in which basic tasks (ADC, PSTN…) continue to be performed in Sleep mode.

Two spotlights

A pcb

Gerber file


Pines macho

Dual-channel relay module


  • Card with 2-5V and 2-channel relays
  • Tical current: 4mA
  • Activation current: 2mA
  • Working current: 65mA
  • High Current Relay: AC250V 10A; DC30V 10A.
  • Standard interface for microcontroller: Arduino, AVR, PIC, DSP, ARM, etc.
  • PC817 on-board optocoupler with anti-jamming optical isolation capability
  • Independent contact wiring, safe and reliable
  • With screw holes for easy installation
  • Size: 44.4×32.4mm


Input Part:

  • VCC: connect to positive power (depending on relay voltage range)
  • GND: connect to negative power
  • IN1: channel trigger pin 1 relay module (high level trigger)
  • IN2: channel trigger pin 2 relay module (high level trigger)

Output Part:

  • Normally open (NA): Normally open relay pin. NO pin is not connected to COM pin when relay is off. The pin does NOT connect to the COM pin when the relay is on.
  • Pin común (COM): pin común del relé.
  • Normally closed (NC): normally closed relay pin. The NC pin connects to the COM pin when the relay is off. The NC pin does not connect to the COM pin when the relay is on.

A plinth for the esp32


Download Library –> Universal-Arduino-Telegram-Bot-master

Create Bot on Telegram

In telegram we look for BotFather

We write /start and something similar to this will appear to us

Write /newbot

I will see the name of the bot, and we invent a name for our bot, it must be in the format «usuario_bot»

We’ll get a token that we’re going to use in the source code

Now we’ll look for IDBot, and we’ll start it

We write /getid and it will give us user_id that we should place in the source code


[wysija_form id=”1″]


Deja una respuesta