|
|
ESP01 |
x 1 | |
|
|
Generic IR Leds |
x 4 | |
|
|
2N2222AON Semiconductor
|
x 1 | |
|
|
Step down converter 5v to 3.3v |
x 1 |
|
Blynk App |
|
|
fritzing |
|
|
arduino IDEArduino
|
IRRemote ESP01 v0.1
Home automation project to create IR Remote pcb compatibile with ESP01 board and Blynk legacy.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include "ircodes.h"
#include <EEPROM.h>
#include <JeVe_EasyOTA.h>
EasyOTA OTA("IRremoteBlynk");
char auth[] = "ah6bhKeHC6S4UWzYmfO_UqJIkC9EX2Vz";
char ssid[] = "Vodafone-uaa2.4";
char pass[] = "asdfasdf";
int eeprom_addr = 0; int eeprom_flag = 0; int flashingmode = 0;
int stepvolume = 10;
int timeoutOTA = 120; // timeout OTA in sec
int old;
IRsend irsend(3); // Pin gpio4 -> D2 (IR LED)
WidgetTerminal terminal(V8);
BLYNK_WRITE(V0) { // tasto accensione/spegnimento
if (param.asInt()) {
terminal.println("Invio segnale Power on/off"); terminal.flush();
irsend.sendRaw(power, 68, 38);
Blynk.virtualWrite(V0, 0);
}
}
BLYNK_WRITE(V1) { // tasto volume +
if (param.asInt() == 1) {
terminal.println("Invio segnale Volume +"); terminal.flush();
irsend.sendRaw(volumesu, 68, 38);
}
else if (param.asInt() == -1) {
terminal.println("Invio segnale Volume -"); terminal.flush();
irsend.sendRaw(volumegiu, 68, 38);
}
Blynk.virtualWrite(V1, 0);
}
BLYNK_WRITE(V3) { // tasto canale +
if (param.asInt() == 1) {
terminal.println("Invio segnale Canale +"); terminal.flush();
irsend.sendRaw(canalesu, 68, 38);
}
else if (param.asInt() == -1) {
terminal.println("Invio segnale Canale -"); terminal.flush();
irsend.sendRaw(canalegiu, 68, 38);
}
Blynk.virtualWrite(V3, 0);
}
BLYNK_WRITE(V5) { // tasto input
if (param.asInt()) {
terminal.println("Invio segnale input"); terminal.flush();
irsend.sendRaw(input, 68, 38);
Blynk.virtualWrite(V5, 0);
}
}
BLYNK_WRITE(V6) { // Volume MUTO
if (param.asInt()) {
terminal.println("Invio segnale Volume muto"); terminal.flush();
irsend.sendRaw(volumemuto, 68, 38);
Blynk.virtualWrite(V6, 0);
}
}
BLYNK_WRITE(V7) { // ALEXA volume +- 10
if (param.asInt() == 1) {
terminal.println("Invio segnale Volume + 10");
for (int i = 0; i < stepvolume; i++) {
irsend.sendRaw(volumesu, 68, 38);
terminal.print(String(i) + " ");
Blynk_Delay(150);
}
}
else if (param.asInt() == -1) {
terminal.println("Invio segnale Volume - 10");
for (int i = 0; i < stepvolume; i++) {
irsend.sendRaw(volumegiu, 68, 38);
terminal.print(String(i) + " ");
Blynk_Delay(150);
}
}
terminal.println(); terminal.flush();
Blynk.virtualWrite(V7, 0);
}
BLYNK_WRITE(V2) { // Reboot in OTA mode
if (param.asInt()) {
terminal.println("Reboot in OTA mode");
// impostazione eeprom_flag a 1
EEPROM.write(eeprom_addr, 1);
EEPROM.write(eeprom_addr + 1, timeoutOTA);
EEPROM.commit();
if (EEPROM.commit()) {
terminal.println("EEPROM successfully committed");
} else {
terminal.println("ERROR! EEPROM commit failed");
}
terminal.flush();
EEPROM.end();
Blynk.virtualWrite(V2, 0);
Blynk.notify("Entering in OTA mode, timeout " + String(timeoutOTA) + " s");
delay(500);
ESP.restart(); // al riavvio viene eseguita la funzione OTASETUP
}
}
BLYNK_WRITE(V12) {
timeoutOTA = param.asInt();
terminal.println("Timeout OTA set to " + String(timeoutOTA) + " seconds");
terminal.flush();
}
BLYNK_WRITE(V11) {
stepvolume = param.asInt();
terminal.println("Volume step set to " + String(stepvolume));
terminal.flush();
}
BLYNK_CONNECTED() {
for (int i = 0; i <= 10; i++) { // reset tasti a stato 0
Blynk.virtualWrite(i, 0);
}
Blynk.syncVirtual(V11, V12); // sync data from app (step volume, ota timeout)
}
void setup()
{
// Debug console
Serial.begin(9600);
EEPROM.begin(512);
eeprom_flag = EEPROM.read(eeprom_addr);
terminal.println("eeprom_flag: " + String(eeprom_flag)); terminal.flush();
if (eeprom_flag == 1) {
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
otasetup();
} else {
Blynk.begin(auth, ssid, pass);
irsend.begin();
Blynk.notify("Started IRremoteBlynk!");
terminal.clear();
}
}
void loop()
{
if (flashingmode == 1) { // ESECUZIONE CODICE LOOP PER OTA
static unsigned long last_m = millis();
static unsigned long last_2 = millis();
unsigned long now = millis();
OTA.loop(now);
if (now - last_m > 1000) {
last_m = now;
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
if (now - last_2 > timeoutOTA) { // TIMEOUT dopo x secondi (definiti nell'app)
ESP.restart();
} else{
float restante = (timeoutOTA - (now - last_2)) /float(1000);
if (restante == int(restante) && restante != old){
Serial.println("riavvio fra " + String(int(restante)) + " secondi" );
old = restante;
}
}
} else { // in qualunque altro caso esegui BLYNK
Blynk.run();
}
}
void restartButton() {
// funzione da chiamare con interrupt su tasto su nodemcu
ESP.restart();
}
void Blynk_Delay(int milli) {
int end_time = millis() + milli;
while (millis() < end_time) {
Blynk.run();
yield();
}
}
uint16_t power[68] = {4400,4650,500,1750,550,1750,500,1750,500,600,500,600,550,600,500,600,500,600,500,1800,500,1750,500,1750,550,550,550,600,500,600,500,600,550,550,550,600,500,1750,500,600,550,600,500,600,500,600,500,600,550,600,500,1750,500,600,550,1750,500,1750,500,1750,550,1750,500,1750,500,1750,500,};
uint16_t volumesu[68] = {4400,4650,450,1750,500,1750,500,1750,500,550,500,600,500,600,450,600,500,600,500,1750,450,1750,500,1750,600,500,500,550,500,600,500,600,450,600,500,1750,500,1750,500,1700,500,600,500,600,500,550,500,600,500,600,500,550,500,600,500,600,450,1750,500,1750,500,1750,500,1700,550,1700,500,};
uint16_t volumegiu[68] = {4400,4650,500,1750,450,1750,500,1750,500,600,450,600,500,600,500,600,450,600,500,1750,500,1750,450,1750,500,600,500,600,450,600,500,600,500,600,450,1750,500,1750,500,600,450,1750,500,600,500,600,450,600,500,600,500,550,500,600,500,1750,500,550,500,1750,500,1750,500,1750,450,1750,500,};
uint16_t volumemuto[68] = {4400,4650,450,1800,450,1750,500,1750,450,650,450,600,500,600,450,650,450,600,450,1800,450,1800,450,1750,500,600,500,600,450,600,500,600,500,600,450,1750,500,1750,450,1800,450,1750,500,600,500,600,500,550,500,600,500,600,450,600,500,600,500,600,450,1750,500,1750,500,1750,500,1700,550,};
uint16_t canalesu[68] = {4400,4650,450,1750,500,1750,450,1800,450,600,500,600,450,650,450,600,500,600,450,1800,450,1750,500,1750,450,650,450,600,500,600,450,650,450,600,500,600,450,1800,450,600,500,600,450,1800,450,600,500,600,450,650,450,1750,500,600,500,1750,450,1750,500,600,450,1800,450,1750,500,1750,500,};
uint16_t canalegiu[68] = {4400,4600,500,1750,500,1750,450,1800,450,600,500,600,450,650,450,600,500,600,450,1800,450,1750,500,1750,500,600,450,600,500,600,450,650,450,600,500,600,450,600,500,600,450,650,450,1750,500,600,500,600,450,600,500,1750,500,1750,500,1750,450,1750,500,600,450,1800,450,1750,500,1750,500,};
uint16_t input[68] = {4400,4650,450,1750,500,1750,450,1800,500,550,500,600,450,650,450,600,500,600,450,1800,450,1750,500,1750,500,600,450,650,450,600,450,650,450,600,500,1750,450,650,500,550,500,600,500,600,450,600,500,600,450,650,450,600,500,1750,500,1750,500,1700,550,1700,550,1700,500,1700,550,1700,550,};
void otasetup(){ // OTA SETUP (run only if EEPROM flag is 1)
Serial.println("ENTERED IN OTA SETUP");
// resetting eeprom flag to reboot in MAIN program
EEPROM.write(eeprom_addr, 0);
EEPROM.commit();
if (EEPROM.commit()) {
Serial.println("EEPROM successfully committed");
} else {
Serial.println("ERROR! EEPROM commit failed");
}
timeoutOTA = EEPROM.read(eeprom_addr+1);
timeoutOTA = timeoutOTA * 1000;
Serial.println("get TIMEMOUT from eeprom: " + String(timeoutOTA) + "ms");
EEPROM.end();
OTA.onMessage([](const String& message, int line) {
Serial.println(message);
});
// Add networks you wish to connect to
OTA.addAP("Vodafone-uaa2.4", "asdfasdf");
OTA.allowOpen(true);
// setting flashingmode variable to 1 (to execute OTA.loop)
flashingmode = 1;
}
IRRemote ESP01 v0.1
Project images are for reference only. Actual production is based on the manufacturing files on the project page.
Please review the designer's notes (e.g., PCB thickness) and select the appropriate options.
PCBWay is not responsible
for issues caused by unsuitable parameter selections.
For more important ordering information, please refer to
Read More
Raspberry Pi 5 7 Inch Touch Screen IPS 1024x600 HD LCD HDMI-compatible Display for RPI 4B 3B+ OPI 5 AIDA64 PC Secondary Screen(Without Speaker)
BUY NOW- Comments(0)
- Likes(0)
- 1 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
-
10design
-
10usability
-
10creativity
-
10content
More by Engineer
-
Programmable Mist Maker - XIAO / QT PY Extension
1074 2 1 -
RadioHAT - Raspberry Pi radio development platform
891 0 2 -
QWIIC-VL53L4CD Time-of-Flight Distance Sensor Module
1098 0 1 -
-
-
-
ARPS-2 – Arduino-Compatible Robot Project Shield for Arduino UNO
3334 0 6 -
-
A Compact Charging Breakout Board For Waveshare ESP32-C3
3945 3 8 -
AI-driven LoRa & LLM-enabled Kiosk & Food Delivery System
4335 2 2







