can I write another function in my sketch while a digital button is pressed on the app.i wanted to write a ir hex code to turn on the device
Yes you can do that easily:
http://docs.blynk.cc/#blynk-main-operations-send-data-from-app-to-hardware
Easy peasy, I personally use the IRLib with the following piece of code:
BLYNK_WRITE(1)
{
for(int i=0;i<4;i++)
{
irsend.send(RC5,0x140F, 13); // AMP off
irsend.send(SONY,0xA90, 12); // TV off
}
}
what to write inside BLYNK WRITE(1);what refers to 1
That is the Virtual Pin attached to a button on the dashboard
Can you share full sketch? I could not figured out, sitting hours no luck
What is it you need help with? Can you explain what is not working? My full sketch is several hundred lines, so I’d like to paste just the relevant part for you, but I need to know what is not working for you
Thank u for fast reply :).
I want to controll TV with D1 mini via blynk app. I obtained TV remote RAW data also HEX, sketch is compiling but not working.
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <IRremoteESP8266.h>
char auth[] = "3cbb7cbbxxxxxxxxx3c64";
char ssid[] = "Axxx";
char pass[] = "90xxxx";
int khz = 38; // 38kHz carrier frequency for both NEC and Samsung
IRsend irsend(4); //an IR led is connected to GPIO4 (pin D2 on NodeMCU)
// Insert RAW IR signal for "TV Power"
unsigned int irTVpwr[67] = {9200,4300, 750,350, 800,300, 800,350, 800,300, 800,350, 750,1500, 750,350, 800,350, 750,1500, 750,1500, 750,1450, 800,1450, 800,1450, 800,1450, 800,1450, 800,1450, 800,1450, 800,1450, 750,1500, 750,350, 800,350, 750,350, 800,350, 800,300, 800,350, 750,350, 800,350, 750,1450, 800,1450, 800,1450, 800,1450, 800,1450, 800};// NEC 4FFE01F
void setup() {
Serial.begin(9600);
delay(5000);
Blynk.begin(auth, ssid, pass);
irsend.begin();
}
void loop()
{
Blynk.run();
}
BLYNK_WRITE(V2)
{
if (param.asInt()){
irsend.sendRaw(irTVpwr, sizeof(irTVpwr) / sizeof(irTVpwr[0]), khz);
//delay(40);
}
}
/*BLYNK_WRITE(V1)
{
if (param.asInt() == 1) {
irsend.sendRaw(irTVpwr, sizeof(irTVpwr) / sizeof(irTVpwr[0]), khz);
Blynk.virtualWrite(V17,"ON");
}
if (param.asInt() == 0) {
irsend.sendRaw(irTVpwr, sizeof(irTVpwr) / sizeof(irTVpwr[0]), khz);
Blynk.virtualWrite(V17,"OFF");
}
}
Match the request
if (req.indexOf("/irTVpwr") != -1){
irsend.sendRaw(irTVpwr, sizeof(irTVpwr) / sizeof(irTVpwr[0]), khz);
Serial.println("IRreq irTVpwr sent");
}*/
Your code looks OK from here. Does your TV support RC5 or RC6 standards? That would make things a lot easier.
First, try to see if your code works without blynk. E.g. just send the power on in the Loop without Blynk and see if that works. I’ve tend to notice that the IR led doesn’t always do it’s job, especially with the cheap chinese ones. What I do is make a loop and send a command about 4 times. With poweron/poweroff this is no problem, it could be with volume control or something similar.
BLYNK_WRITE(1)
{
for(int i=0;i<4;i++)
{
irsend.send(RC5,0x140F, 13); // AMP off
irsend.send(SONY,0xA90, 12); // TV off
}
}
One more thing, I use IRLib.h and not the one you included. Maybe it makes a difference? Also, did you include a resistor with your IR Led?
How do I know that my TV supports RC5/6 it is written on remote control or on TV?
I did not include a resistor and it is also Chinese IR leds maybe that is why? I already tried your code but couldn’t figured it out.
There are several types of standard infrared remote codes. You are gonna have to figure that out using the make and model of your TV or remote. If you are using a LED, always use a resistor! LED’s run on current so you have to add a resistor.
Are you sure you have the correct pin? Did you try without the Blynk part?
Got it, resistor.
I connected receiver LED on arduino uno pin 11, but did not tried send(er) LED on UNO just on D1 mini. Guess I rushed little bit I will try both on UNO.
At least on the UNO you know what pin it is with the IDE. I always find the Wemos pins a bit confusing
Thanks for sharing, I will try to apply in my project, control pellets stove
Its code has worked for me, the infrared led, I connected it to pin D4 of wemosd1
how do you use the IRLib library with the wemos mini?
i can’t compile if i set the board to wemos.
I think you need to use the IRremoteESP8266.h library.
Pete.