Engineer
ITALY • + Follow
Edit Project
Components
|
ESP01 |
x 1 | |
|
Generic IR Leds |
x 4 | |
|
2N2222AON Semiconductor
|
x 1 | |
|
Step down converter 5v to 3.3v |
x 1 |
Tools, APP Software Used etc.
|
Blynk App |
|
|
fritzing |
|
|
arduino IDEArduino
|
Description
IRRemote ESP01 v0.1
Home automation project to create IR Remote pcb compatibile with ESP01 board and Blynk legacy.
Code
IRRemoteBlynk.ino
Arduino
#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();
}
}
ircodes.h
Arduino
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,};
ota.ino
Arduino
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;
}
Schematic and Layout
Oct 09,2022
470 views
IRRemote ESP01 v0.1
Universal infrared remote control made by ESP01, 4 recycled IR leds and some others basic components.
470
0
0
10.00 (1)
Published: Oct 09,2022
Download Gerber file 1
Purchase
Donation Received ($)
PCBWay Donate 10% cost To Author
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
Copy this HTML into your page to embed a link to order this shared project
Copy
Under the
Attribution-MIT
License.
Topic
- Comments(0)
- Likes(0)
Upload photo
You can only upload 5 files in total. Each file cannot exceed 2MB. Supports JPG, JPEG, GIF, PNG, BMP
0 / 10000
It looks like you have not written anything. Please add a comment and try again.
You can upload up to 5 images!
Image size should not exceed 2MB!
File format not supported!
View More
View More
VOTING
1 votes
- 1 USER VOTES
10.00
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Design
1/4
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Usability
2/4
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Creativity
3/4
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Content
4/4
-
10design
-
10usability
-
10creativity
-
10content
10.00
More by Engineer
You may also like
-
-
Helium IoT Network Sensor Development board | H2S-Dev V1.2
90 0 0 -
-
-
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
176 1 1