Air conditioning on/off control via telegram and esp32
In this tutorial we will see how to control an air conditioner, with an esp32 and the telegram application, from anywhere in the world, where we have access to the internet. The device can capture the commands of an air conditioner with an infrared receiver module, and in this project we will control the on and off with the telegram application, but we will also be able to monitor the change in temperature, to see if it has actually been turned on.
Female pins
ky-022 infrared receiver module
Size: 6.4*7.4*5.1MM, acceptance angle 90°, working voltage 2.7-5.5V.
Frequency 37.9KHZ, receiving distance 18m.
Daylight rejection up to 500LUX, electromagnetic interference capability, built-in infrared dedicated IC.
Widely used: stereo, TV, VCR, CD, set-top boxes, digital photo frame, car audio, remote control toys, satellite receivers, hard disk, air conditioning, heating, fans, lighting and other household appliances.
Pinout:
1 …. GND (-)
2 …. + 5V
3 …. Output (S)
Un transistor 2n3904
Description
SMALL SIGNAL BIPOLAR TRANSISTOR
Detailed description
Transistors – Bipolar (BJT) – Single NPN 40 V 200 mA 300 MHz 625 mW Through Hole TO-92-3
Data sheet
2n3904
Pinout
A 100 Ohm resistor
A 470 Ohm resistor
A DHT11 Temperature and Humidity Sensor
This module consists of a DHT11 digital humidity and temperature sensor and a 1 kΩ resistor. The DHT11 uses an internal thermistor and a capacitive humidity sensor to determine environmental conditions, an internal chip is responsible for converting the readings to a serial digital signal.
Cables Dupont
An infrared emitter
A PCB
Gerber file —> Gerber_Air conditioning control by telegram
Circuit
Source code
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include "PinDefinitionsAndMore.h"//Configuración y definición de pines
#include <IRremote.hpp>
#include "DHT.h"
// Reemplazar con los datos de tu red wifi
#define WIFI_SSID "Tu_red_wifi"
#define WIFI_PASSWORD "tu_clave_wifi"
//Token de Telegram BOT se obtenienen desde Botfather en telegram
#define BOT_TOKEN "tu_token_de_telegram"
const unsigned long tiempo = 1000; //tiempo medio entre mensajes de escaneo
WiFiClientSecure secured_client;
UniversalTelegramBot bot(BOT_TOKEN, secured_client);
unsigned long tiempoAnterior; //última vez que se realizó el análisis de mensajes
int inicio = 1;
String datos;
String stringT;
String stringH;
int aireEstado = 0;
// Descomenta la linea dependiendo del sensor que vas a usar
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT21 // DHT 21
//#define DHTTYPE DHT22 // DHT 22
#define DHTPin 23 //Pin del sensor DHT;
DHT dht(DHTPin, DHTTYPE);
float t;
float h;
String chat_id;
#define ID_Chat "id_chat_telegram"//ID_Chat se obtiene de telegram
void mensajesNuevos(int numerosMensajes)
{
for (int i = 0; i < numerosMensajes; i++)
{
String chat_id = bot.messages[i].chat_id;
String text = bot.messages[i].text;
if (text == "/TyH")
{
h = dht.readHumidity();//Lectura de la humedad
t = dht.readTemperature();//Lectura de la temperatura
stringT = String(t);
stringH = String(h);
Serial.print("T:" );
Serial.println(t);
Serial.print("H:" );
Serial.println(h);
datos = "Temperatura: "+ stringT + " Humedad: " +stringH;
bot.sendMessage(chat_id, datos, "");//Enviamos la temperatura y humedad
}
//////////Comando para encender el aire acondicionado//////
if (text == "/Aireon")
{
const uint16_t irSignal[227] = {
//Código para encendido de aire acondicionado marca Electra
3100, 1600 , 500, 1100 , 450, 1100 , 450, 300
, 500, 350 , 450, 350 , 450, 1100 , 450, 350
, 450, 350 , 450, 1150 , 400, 1150 , 400, 400
, 400, 1150 , 450, 350 , 450, 350 , 450, 1100
, 450, 1150 , 400, 400 , 400, 1150 , 400, 1150
, 400, 400 , 400, 400 , 400, 1150 , 450, 350
, 450, 350 , 450, 1100 , 450, 350 , 450, 350
, 450, 350 , 450, 350 , 450, 350 , 450, 350
, 450, 350 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 1150
, 400, 400 , 400, 400 , 400, 1150 , 450, 350
, 450, 350 , 400, 400 , 400, 1150 , 450, 350
, 450, 350 , 450, 350 , 450, 350 , 450, 350
, 450, 350 , 450, 350 , 400, 400 , 400, 400
, 400, 1150 , 450, 350 , 450, 350 , 450, 350
, 450, 350 , 450, 350 , 450, 350 , 450, 350
, 400, 400 , 400, 400 , 400, 400 , 400, 1150
, 400, 400 , 450, 350 , 450, 350 , 450, 350
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 350, 450 , 400, 400
, 350, 450 , 400, 400 , 400, 400 , 400, 400
, 350, 450 , 350, 450 , 350, 450 , 350, 450
, 350, 1200 , 400, 1150 , 400, 1150 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400
};
IrSender.sendRaw(irSignal, 227, 38);
bot.sendMessage(chat_id, "Comando encendido ejecutado", "");
aireEstado = 1;
}
//////////Comando para apagar el aire acondicionado////////
if (text == "/Aireoff")
{
const uint16_t irSignal2[227] = {
//Código para apagado de aire acondicionado marca Electra
3100, 1600 , 450, 1100 , 500, 1100 , 450, 350
, 450, 350 , 450, 350 , 450, 1100 , 450, 400
, 400, 350 , 450, 1150 , 400, 1150 , 400, 400
, 400, 1150 , 400, 400 , 400, 400 , 400, 1150
, 400, 1150 , 400, 400 , 450, 1150 , 400, 1150
, 400, 400 , 400, 400 , 400, 1150 , 400, 400
, 400, 400 , 400, 1150 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 350 , 400, 1200 , 400, 400
, 400, 400 , 400, 1150 , 400, 1150 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 1150 , 400, 450 , 350, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 1150
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 350, 450 , 350, 450 , 350, 450
, 350, 450 , 350, 450 , 350, 450 , 350, 450
, 350, 450 , 350, 450 , 350, 450 , 350, 450
, 350, 450 , 350, 450 , 350, 450 , 350, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 400, 400
, 400, 1150 , 400, 400 , 400, 400 , 400, 400
, 400, 400 , 400, 400 , 400, 400 , 350, 500
, 300, 450 , 400
};
IrSender.sendRaw(irSignal2, 227, 38);
bot.sendMessage(chat_id, "Comando apagado ejecutado", "");
aireEstado = 2;
}
////////Último comando enviado ///////
if (text == "/Estado")
{
////Ultimo comando enviado////
if (aireEstado == 0)
{
bot.sendMessage(chat_id, "No definido", "");
}
if (aireEstado == 1)
{
bot.sendMessage(chat_id, "Último comando: Encendido", "");
}
if (aireEstado == 2)
{
bot.sendMessage(chat_id, "Último comando: Apagado", "");
}
}
if (text == "/Ayuda")
{
String ayuda = "Bienvenido al sistema de control luces con Esp32, " ".\n";
ayuda += "Estas son tus opciones.\n\n";
ayuda += "/Aireon: para encender el aire \n";
ayuda += "/Aireoff: para apagar el aire \n";
ayuda += "/TyH : Muestra la Temperatura y Humedad \n";
ayuda += "/Ayuda: Imprime este menú \n";
ayuda += "Recuerda el sistema distingue entre mayuculas y minusculas \n";
bot.sendMessage(chat_id, ayuda, "");
}
}
}
void setup()
{
Serial.begin(115200);
dht.begin();//Inicializar el sensor DHT
// Intenta conectarse a la red wifi
Serial.print("Conectando a la red ");
Serial.print(WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
secured_client.setCACert(TELEGRAM_CERTIFICATE_ROOT); //Agregar certificado raíz para api.telegram.org
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(500);
}
Serial.print("\nConectado a la red wifi. Dirección IP: ");
Serial.println(WiFi.localIP());
if(inicio == 1){
Serial.println("Sistema preparado");
bot.sendMessage(ID_Chat, "Sistema preparado!!!, escribe /Ayuda para ver las opciones", "");//Enviamos un mensaje a telegram para informar que el sistema está listo
inicio = 0;
}
}
void loop()
{
//Verifica si hay datos nuevos en telegram cada 1 segundo
if (millis() - tiempoAnterior > tiempo)
{
int numerosMensajes = bot.getUpdates(bot.last_message_received + 1);
while (numerosMensajes)
{
Serial.println("Comando recibido");
mensajesNuevos(numerosMensajes);
numerosMensajes = bot.getUpdates(bot.last_message_received + 1);
}
tiempoAnterior = millis();
}
}
Air conditioning on/off control via telegram and esp32
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(0)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by CarlosVolt Tutoriales
- Infrared stepper motor control with speed control More info and updates https://rogerbit.com/wprb/2024/09/motor-paso-a-paso-x-infrarrojo/In this proje...
- Uploading BME280 Sensor Data to ThingSpeak Using ESP32 In this tutorial, we will show you how to connect a BME280 sensor to an ESP32 to read temperature, h...
- Water pump control for irrigation via telegram and esp32 Water Pump Control by Telegram and ESP32 is an automated system that allows you to remotely control ...
- Air conditioning on/off control via telegram and esp32 In this tutorial we will see how to control an air conditioner, with an esp32 and the telegram appli...
- 35 watt stereo amplifier In this video we will see how to build an audio amplifier, with the TDA7377 integrated circuit, and ...
- Laser alarm with RFID module More info and updates in https://rogerbit.com/wprb/2024/08/alarma-laser-rfid/In this project, we bui...
- Control lights by voice commands and keys In this tutorial we will see how to create a device to control lights by voice commands, with a modu...
- Stepper motor control x bluetooth and app In this tutorial we will see a circuit, which controls a stepper motor, with an application made in ...
- DFplayermini x bluetooth mp3 player control More info and updates in https://rogerbit.com/wprb/2022/12/dfplayermini-x-bluetooth/In this tutorial...
- Robot with WiFi control and servos driven by ESP32 More info and updates in https://rogerbit.com/wprb/2023/07/robot-wifi/A robot controlled by Wi-Fi, s...
- How to make a water level meter with uln2803 In this tutorial we will see how to make a water level meter circuit with the built-in uln2803.The p...
- DTMF decoder for handy with arduino, control over several kilometers In this tutorial we will see how to make a circuit to connect to our handy, in this case a Baofeng U...
- Turn on light from thindspeak with esp32 In this tutorial, we will show you how to control lights over the Internet using an ESP32 and the Th...
- MP3 player control with webserver using ESP32 WIFI In this tutorial, you will learn how to build a web server using the ESP32 to control the YX5300 mod...
- Time clock with fingerprint IoT module, uploading data to thingspeak More info in and updates in https://rogerbit.com/wprb/2022/07/reloj-de-control-fingerprint/In this t...
- Make your own logic tip (includes printed circuit board) In this video tutorial we will see how to make a logic tip, on a printed circuit, with the integrate...
- Coil or inductor meter with Arduino and OLED display More info and updates in https://rogerbit.com/wprb/2022/06/medidor-inductores/In this tutorial we wi...
- Turn on Light with Reyax RYLR896 LoRa Modules with Acknowledgement In this tutorial, you will learn how to use the Reyax RYLR896 LoRa modules to wirelessly and reliabl...
-
-
-
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
154 1 1 -
-