Mini proiect (27) - Sonerie fara fir folosind ESP32 wroom

 Sonerie fara fir folosind ESP32 wroom

Astăzi m-am jucat cu un emițător RF 433 MHz , pe care l-am programat să trimită codul pentru activarea soneriei mele fără fir. Practic am făcut încă un emițător pentru sonerie. Micul meu proiect mai conține un buton șmecher cu LED RGB încorporat , care se aprinde cu diferite culori atunci când este apăsat și care are un switch mecanic cu revenire (practic nu rămâne activat din punct de vedere mecanic). Emițătorul și butonul sunt legate la un ESP32 Wroom, care face toată magia. 

Deci merge în felul următor :

  1. Se apasă butonul cel șmecher
  2. ESP32-ul detectează apăsarea 
  3. Emițătorul este activat și trimite codul către sonerie
  4. Soneria o să sune doar după ce se eliberează butonul (vezi filmulețul de mai jos)

 

 

Sketchul de test:

/*
Florin Simedru
Complete project details at https://automatic-house.blogspot.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*/
#include "RCSwitch.h"
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 23; // the number of the pushbutton pin
const int ledPin = 2; // the number of the LED pin
const int BellPin = 22; // the number of the doorbell pin
RCSwitch mySwitch = RCSwitch();
#define CODE_BT1 0xC10208 // doorbell activation code
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
Serial.begin(115200);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
pinMode(12, INPUT_PULLUP);
mySwitch.enableTransmit(BellPin);
mySwitch.setProtocol(1, 208);
}
void loop() {// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH)
{
Serial.print("buton = ");
Serial.println(buttonState);
// turn LED on:
digitalWrite(ledPin, HIGH);
mySwitch.send(CODE_BT1 , 24);
delay(50);
mySwitch.send(CODE_BT1 , 24);
delay(50);
mySwitch.send(CODE_BT1 , 24);
delay(50);
mySwitch.send(CODE_BT1 , 24);
delay(50);
mySwitch.send(CODE_BT1 , 24);
delay(50);
mySwitch.send(CODE_BT1 , 24);
delay(50);
mySwitch.send(CODE_BT1 , 24);
}
else
{
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
Documentatie proiect:

 Pentru întrebari și/sau consultanță tehnică vă stau la dispozitie pe blog sau pe email simedruflorin@automatic-house.ro. O seară/zi plăcută tuturor !

Etichete

Afișați mai multe

Arhiva

Afișați mai multe