Motion detector with light, esp32 and telegram notifications
In this tutorial we will see how to make a motion detector system, with a PIR sensor, a relay module, to connect a 110V/220V focus, an esp32 that will connect to our Wifi network and send alert notifications, by messages through the telegram messaging service, when the PIR sensor detects a movement.
Circuit
Electronic components
Cables dupont
ESP32
Features of the ESP32-T module
Connectivity
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.
A focus
Sensor PIR
Electric pyro devices such as pir have elements made of a crystalline material that generates an electrical charge when exposed to infrared radiation. Changes in the amount of radiation produce voltage changes which are measured by an amplifier. The sensor contains special filters called Fresnel lenses that focus infrared signals on the sensor element. When infrared signals from the environment where the sensor is located change rapidly, the amplifier activates the output to indicate movement. This output remains active for a few seconds allowing the micro controller to know if there was movement.
Calibration When the pir sensor is energized requires a preparation time to start operating properly. This is because adaptation to the conditions of operation of the environment where it was installed has to occur. During this moment the sensor learns to recognize the state of rest or non-movement of the environment. The duration of this calibration can be between 10 and 60 seconds and the absence of people in the sensor neighborhood while calibrating is highly recommended.
Features:
- Infrared sensor with control circuit board.
- Sensitivity and retention time can be adjusted.
- Small and light, it is easy to use.
- Detection distance is up to 6 meters.
- Suitable for security field, toy, control automation, etc.
PIR ROBOX IR sensor features
MarchRoboxModelRTHWColorWhite + GreenMaterialPCB + Plastic boardFeaturesStatic power: 50uA; Detection distance: 7m; Detection angle: 110 degrees; Wide voltage range: DC 4.5 20VApplicationDetect motion
Dimensions: 1.26 x 0.94 in x 0.94 in (3.2 cm x 2.4 cm x 2.4 cm)Weight: 0.25 oz (7 g)
PinOut PIR ROBOX AND
Pines macho
Socket
Relay Module
TECHNICAL SPECIFICATIONS
- Operating Voltage: 5V DC
- Control Signal: TTL (3.3V or 5V)
- Number of Relays (channels): 1 CH
- Max capacity: 10A/250VAC, 10A/30VDC
- Max current: 10A (NO), 5A (NC)
- Action time: 10 ms / 5 ms
- To activate output NO: 0 Volts
Printed Circuit
Gerber file
Source
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>
// Reemplazar con los datos de tu red wifi
const char* ssid = "Tu_red_wifi";
const char* password = "Tu_clave";
//Token de Telegram BOT se obtenienen desde Botfather en telegram
#define token_Bot "Tu_token"
// El ID se obtiene de (IDBot) en telegram no olvidar hacer click en iniciar
#define ID_Chat "Tu_chat_ID"
WiFiClientSecure client;
UniversalTelegramBot bot(token_Bot, client);
const int sensorPIR = 23; // Pin donde está conectada la entrada del sensor PIR
const int luz = 13;// Pin para luz de 110 o 220 V( Con módulo relay)
int conteo = 0;
String mensaje = "";
String conteoString = "";
int PIR = 0;
////Setup////
void setup() {
Serial.begin(115200);
// Activamos el resistor de PULLUP para la entrada sensor PIR
pinMode(sensorPIR, INPUT_PULLUP);
pinMode(luz, OUTPUT);
// Intenta conectarse a la red Wifi:
Serial.print("Conectando a la red wifi... ");
Serial.println(ssid);
//Seteo de la red Wifi
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("Conectado a la red wifi!!!");
Serial.print("Dirección ip: ");
Serial.println(WiFi.localIP());//Imprimimos la direción ip local
bot.sendMessage(ID_Chat, "Sistema preparado!!!", "");//Enviamos un mensaje a telegram para informar que el sistema está listo
}
/////loop//////
void loop() {
PIR = digitalRead(sensorPIR);//Leemos el estado del del sensor PIR
//Si es igual a "1" se cumple la condición
if(PIR == 1){
digitalWrite(luz, HIGH);//Encendemos la luz
Serial.println("Luz Encendida!");
conteo = conteo + 1;//Incremento en el contador de movimientos detectados
conteoString = String(conteo);//Lo convertimos a una cadena
mensaje = "Movimiento detectados: " + conteoString;//Concatenamos ambas cadenas
bot.sendMessage(ID_Chat, mensaje, "");//Enviamos el mensaje a Telegram
delay(5000);//mantensmos la luz encendida este tiempo
digitalWrite(luz, LOW);//Luego la apagamos
Serial.println("Luz apagada!");
PIR = 0;//Asignamos el valor "0" a la variable PIR para que deje de cumplirse la condición
}
}
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
You may be interested in projects in Arduino, pic, robotics, telecommunications, subscribe http://www.youtube.com/user/carlosvolt?sub_confirmation=1 videos with full source code and diagrams
Motion detector with light, esp32 and telegram notifications
*PCBWay community is a shared platform and we are not responsible for any design issues.
- Comments(0)
- Likes(1)
- (DIY) C64iSTANBUL Feb 01,2021
- 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
- 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...
- Emular mouse y teclado con arduino muy fácil En este tutorial, aprenderemos cómo utilizar un Arduino para emular tanto un mouse como un teclado e...
- Control of apc220 modules with smartphone and app Controlling APC220 modules using a smartphone and an app involves connecting via a serial USB adapte...
- Exploring the potential of the SI5351 module in electronic projects In this tutorial, you will dive into the depths of this amazing device and discover its limitless po...
- Gas leak detector alarm system with arduino nano In this tutorial we will see how to assemble a gas leak detector alarm system with arduino nano. We ...
- Build your own long-range weather station with Lora GPS anemometer module In this tutorial we will see how to create a weather station, for places where there is no internet ...
- Dual Synchronized Radio Frequency Control for Motor Lights and more In this tutorial we will see how to do a synchronized radio frequency control, since one control can...
- Object lifter with servo and Arduino Nano Does your waist or back hurt when you bend down? So this invention, it's for you and it can help you...
- 8-channel dual light ignition system, infrared and pushbuttons In this tutorial we will put together a dual light ignition system, since we can control the ignitio...
- 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, fr...
- Motion detector with light, esp32 and telegram notifications In this tutorial we will see how to make a motion detector system, with a PIR sensor, a relay module...
- Alcoholimeter with MQ3 sensor and arduino nano (Includes printed circuit) In this tutorial we will see how to make a breathalyzer, simple economical and easy to make. We’ll s...
- GPS tracker without cellular network with LORA module In this tutorial we will see how to make a tracker to GPS tracker, with LORA and Arduino module. We ...
- Build a meter with integrated circuit KA2284 KA2284 integrated circuit featuresHigh gain rectifier amplifier included (Gv = 26dB)Low radiation no...
-
IoT Indoor system with ESP32 to monitor Temperature, Humidity, Pressure, and Air Quality
338 0 2 -
Naruto Multi-color PCB printed with UV technology
136 2 1 -
-
-
-
-