Skip to content

Error while receiving IR remote signal #2296

@scropion86

Description

@scropion86

Basic Infos

My Hardware is based on ESP-12F and Three Relays and RGB LED MOSFET Drive , but in that case i am not using the MOSFETS here.
i connected my Hardware to WIFI using WIFI Manager library , and controlling it using Blynk library and App, also i use a IR receiver to manully control the Relays and send back the status to Blynk server/App using Virtual pin.

Hardware

Hardware: ESP-12F
Core Version: 2.3.0

Description

the problem is sometimes when the Remote sent IR to the Receiver connected to my Board GPIO0 the device is resetted.

Settings in IDE

Module: ?Generic ESP8266 Module?
Flash Size: ?4MB/1MB?
CPU Frequency: ?80Mhz?
Flash Mode: ?qio?
Flash Frequency: ?40Mhz?
Upload Using: ?OTA / SERIAL?
Reset Method: ?ck / nodemcu?

i am using Platformio and select the board as esp12e

Sketch

//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@ intialazing librarys @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

//ESP8266 library
#include <ESP8266WiFi.h>          //https://github.com/esp8266/Arduino
//For OTA
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

//####needed for WIFI Manager library###########
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>         //https://github.com/tzapu/WiFiManager
//WiFiManager
//Local intialization. Once its business is done, there is no need to keep it around
WiFiManager wifiManager;

//###### Blynk Library ################
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <BlynkSimpleEsp8266.h>
char auth[] = "2d831d5f05eb4c809a22db721945ba7e";
WidgetTerminal terminal(V1); // V Pin For Blynk Terminal
//########IR Part ####################
#include <IRremoteESP8266.h>
int RECV_PIN = 0; //an IR detector/demodulatord is connected to GPIO pin 2
IRsend irsend(14); //@@@@@@@@@@@@@@@@@an IR led is connected to GPIO pin 0
IRrecv irrecv(RECV_PIN);
decode_results results;

//##### Simpletimer ######
#include <SimpleTimer.h>
SimpleTimer timer;


//Relay Status to be Synced with Blynk Buttons
int  Relay1 = 0 ; //GPIO 16
int  Relay2 = 0; //GPIO 4
int  Relay3 = 0; //GPIO 13

// IR Remote Emulator Multi Function buttons alternating Value
int _Red = 0; // 4 Functions
int _Green = 0; // 4 Functions
int _Blue = 0; // 4 Functions
int _Mode = 0; // 4 Functions

// Mills to prevent debounce of IR received signals
unsigned long last = millis();


// function to be called repeatedly by simple timer
void RepeatTask()
{
 last = millis();
}





//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@       Setup Void                        @@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@




void setup() {

    // put your setup code here, to run once:
    Serial.begin(115200);
    irrecv.enableIRIn(); // Start the IR receiver
    irsend.begin(); // Start The IR Sender

    pinMode(16 , OUTPUT); //Relay1
    pinMode(4 , OUTPUT);  //Relay2
    pinMode(13 , OUTPUT); //Relay3

    // timed actions setup
    timer.setInterval(10000, RepeatTask); //used to rest mills every 10 second to not overload



    //WiFiManager
    //Local intialization. Once its business is done, there is no need to keep it around
    //WiFiManager wifiManager;
    //reset saved settings
    //wifiManager.resetSettings();

    //set custom ip for portal
    //wifiManager.setAPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));

    //fetches ssid and pass from eeprom and tries to connect
    //if it does not connect it starts an access point with the specified name
    //here  "AutoConnectAP"
    //and goes into a blocking loop awaiting configuration
    wifiManager.setTimeout(180);
    wifiManager.autoConnect("EgyIOT-Reception" , "password");
    //or use this for auto generated name ESP + ChipID
    //wifiManager.autoConnect();


    //if you get here you have connected to the WiFi
   Serial.println("connected...yeey :)");
   Blynk.config(auth);


   while (Blynk.connect() == false) {
      // Wait until connected
    }
    // This will print Blynk Software version to the Terminal Widget when
    // your hardware gets connected to Blynk Server
    terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
    terminal.println("-------------");
    terminal.println("IP address: ");
    terminal.println(WiFi.localIP());
    terminal.println("Wifi Signal strength : ");
    terminal.println(WiFi.RSSI());
    terminal.flush();




     // Port defaults to 8266
          // ArduinoOTA.setPort(8266);

          // Hostname defaults to esp8266-[ChipID]
          // ArduinoOTA.setHostname("myesp8266");

          // No authentication by default
          // ArduinoOTA.setPassword((const char *)"123");
          // Hostname defaults to esp8266-[ChipID]
           ArduinoOTA.setHostname("EgyIOT-Reception");
          // No authentication by default
           //ArduinoOTA.setPassword((const char *)"password");


          ArduinoOTA.onStart([]() {
            Serial.println("Start");
          });
          ArduinoOTA.onEnd([]() {
            Serial.println("\nEnd");
          });
          ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
            Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
          });
          ArduinoOTA.onError([](ota_error_t error) {
            Serial.printf("Error[%u]: ", error);
            if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
            else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
            else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
            else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
            else if (error == OTA_END_ERROR) Serial.println("End Failed");
          });
          ArduinoOTA.begin();
          Serial.println("Ready");
          Serial.print("IP address: ");
          Serial.println(WiFi.localIP());


}

// Send Data to Terminal Widget
BLYNK_WRITE(V1) {

}


//Relay 1 Status sync with IR and Blynk Dashboard
BLYNK_WRITE(V2) {
  int stste;
  stste = param.asInt();
  Relay1 = stste;
  digitalWrite(16, stste);
}
//Relay 2 Status sync with IR and Blynk Dashboard
BLYNK_WRITE(V3) {
  int stste;
  stste = param.asInt();
  Relay2 = stste;
  digitalWrite(4, stste);
}
//Relay 3 Status sync with IR and Blynk Dashboard
BLYNK_WRITE(V4) {
  int stste ;
  stste = param.asInt();
  Relay3 = stste;
  digitalWrite(13, stste);
}

///////////////////////////////////////////////////
//////// /////////// //     /// LED Remote Emulator
//////////////////////////////////////////////////

//power on
BLYNK_WRITE(V5) {
  irsend.sendNEC(0xFFB04F, 67);
}

//power off
BLYNK_WRITE(V6) {
  irsend.sendNEC(0xFFF807, 67);
}

//up
BLYNK_WRITE(V7) {
  irsend.sendNEC(0xFF906F, 67);
}

//down
BLYNK_WRITE(V8) {
  irsend.sendNEC(0xFFB847, 67);
}

//white
BLYNK_WRITE(V9) {
  irsend.sendNEC(0xFFA857, 67);
}

//Mode
//####
BLYNK_WRITE(V10) {
if ( param.asInt()== 1 ){

// increase _Mode value to change the IR code acordengly
if (_Mode < 4) {
 _Mode = _Mode +1;
}
else {

}



if (_Mode == 1)
{
  irsend.sendNEC(0xFFB24D, 67); //Flash mode
  Blynk.virtualWrite(V0, "Flash mode");
}

if (_Mode == 2)
{
  irsend.sendNEC(0xFF00FF, 67); //Strobe mode
  Blynk.virtualWrite(V0, "Strobe mode");
}

if (_Mode == 3)
{
  irsend.sendNEC(0xFF58A7, 67); //Fade mode
  Blynk.virtualWrite(V0, "Fade mode");
}

if (_Mode == 4)
{
  irsend.sendNEC(0xFF30CF, 67); //smooth
  Blynk.virtualWrite(V0, "smooth mode");
  _Mode = 0;
}
}
//  irsend.sendNEC(0xFFB24D, 67); //Flash mode
//  irsend.sendNEC(0xFF00FF, 67); //Strobe mode
//  irsend.sendNEC(0xFF58A7, 67); //Fade mode
//  irsend.sendNEC(0xFF30CF, 67); //smooth
}


//RED toggle
//##########

BLYNK_WRITE(V11) {

if ( param.asInt()== 1 ){

// increase _Red value to change the IR code acordengly
if (_Red < 4) {
 _Red = _Red +1;
}
else {
}



if (_Red == 1)
{
  irsend.sendNEC(0xFFE817, 67); //Red1
  Blynk.virtualWrite(V0, "Red1");
}

if (_Red == 2)
{
 irsend.sendNEC(0xFF02FD, 67); //red2
 Blynk.virtualWrite(V0, "Red2");
}

if (_Red == 3)
{
 irsend.sendNEC(0xFF50AF, 67); //Red3
 Blynk.virtualWrite(V0, "Red3");
}

if (_Red == 4)
{
  irsend.sendNEC(0xFF38C7, 67); //Red4
  Blynk.virtualWrite(V0, "Red4");
_Red = 0;
}

//  irsend.sendNEC(0xFF9867, 67); //Red0 - same color
//  irsend.sendNEC(0xFFE817, 67); //Red1  - same  color
//  irsend.sendNEC(0xFF02FD, 67); //red2
//  irsend.sendNEC(0xFF50AF, 67); //Red3
//  irsend.sendNEC(0xFF38C7, 67); //Red4
}
}

//green toggle
//############
BLYNK_WRITE(V13) {

if ( param.asInt()== 1 ){

// increase _green value to change the IR code acordengly
if (_Green < 4) {
 _Green = _Green +1;
}
else {
}



if (_Green == 1)
{
 irsend.sendNEC(0xFF48B7, 67); //green1
 Blynk.virtualWrite(V0, "green1");
}

if (_Green == 2)
{
  irsend.sendNEC(0xFF32CD, 67); //green2
  Blynk.virtualWrite(V0, "green2");
}

if (_Green == 3)
{
  irsend.sendNEC(0xFF7887, 67); //green3
  Blynk.virtualWrite(V0, "green3");
}

if (_Green == 4)
{
  irsend.sendNEC(0xFF28D7, 67); //green4
  Blynk.virtualWrite(V0, "green4");
  _Green = 0;
}

//  irsend.sendNEC(0xFFD827, 67); //green0-same color
//  irsend.sendNEC(0xFF48B7, 67); //green1-same color
//  irsend.sendNEC(0xFF32CD, 67); //green2
//  irsend.sendNEC(0xFF7887, 67); //green3
//  irsend.sendNEC(0xFF28D7, 67); //green4
}
}

//Blue Toggle
BLYNK_WRITE(V12) {

if ( param.asInt()== 1 ){

// increase _Blue value to change the IR code acordengly
if (_Blue < 4) {
 _Blue = _Blue +1;
}
else {
}



if (_Blue == 1)
{
 irsend.sendNEC(0xFF6897, 67); //blue1
 Blynk.virtualWrite(V0, "blue1");
}

if (_Blue == 2)
{
 irsend.sendNEC(0xFF20DF, 67); //blue2
 Blynk.virtualWrite(V0, "blue2");
}

if (_Blue == 3)
{
  irsend.sendNEC(0xFF708F, 67); //blue3
  Blynk.virtualWrite(V0, "blue3");
}

if (_Blue == 4)
{
  irsend.sendNEC(0xFFF00F, 67); //blue4
  Blynk.virtualWrite(V0, "blue4");
  _Blue = 0;
}

//  irsend.sendNEC(0xFF8877, 67); //blue0-same color
//  irsend.sendNEC(0xFF6897, 67); //blue1-same color
//  irsend.sendNEC(0xFF20DF, 67); //blue2
//  irsend.sendNEC(0xFF708F, 67); //blue3
//  irsend.sendNEC(0xFFF00F, 67); //blue4
}
}


// to remove saved WIFI credintials and reset the Board
BLYNK_WRITE(V127)
{
  if (param.asInt() == 1)
  {
    wifiManager.resetSettings();
    delay(3000);
    ESP.restart();
  }
}


///////////////////////////////////////////////////
//   to auto Sync all values of Pins once connected to server
//////////////////////////////////////////////////

// Keep this flag not to re-sync on every reconnection
bool isFirstConnect = true;

// This function will run every time Blynk connection is established
BLYNK_CONNECTED() {
  if (isFirstConnect) {
    // Request Blynk server to re-send latest values for all pins
    Blynk.syncAll();

    // You can also update an individual Virtual pin like this:
    //Blynk.syncVirtual(V0);

    isFirstConnect = false;
  }
}

//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@       loop                              @@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@



void loop() {

   // put your main code here, to run repeatedly:
 ArduinoOTA.handle();
 Blynk.run();
 timer.run();



// trigger the relays and Sync the status with Blynk App and Cloud
 if (irrecv.decode(&results)) {
Serial.println(results.value);
    switch(results.value) {    // Used Value not incoded Hex as that was lead to ESP8266 reset.
          case 16508951:
                if (millis() - last > 700) {  // for debounce
                          if(Relay1 == 1) {        // if first led is on then
                            digitalWrite(16, LOW);   // turn it off when button is pressed
                            Blynk.virtualWrite(V2,LOW);
                            Relay1  = 0;           // and set its state as off
                } else {                      // else if first led is off
                            digitalWrite(16, HIGH); // turn it on when the button is pressed
                            Blynk.virtualWrite(V2,HIGH);
                            Relay1 = 1;          // and set its state as on
                        }
                                  break;
                                          }

        case 16476311:
                if (millis() - last > 700) {
                         if(Relay2 == 1) {
                          Blynk.virtualWrite(V3,LOW);
                          digitalWrite(4, LOW);
                          Relay2 = 0;
                } else {
                          Blynk.virtualWrite(V3,HIGH);
                          digitalWrite(4, HIGH);
                          Relay2 = 1;
                       }
                                 break;
                                           }

       case 16492631:
               if (millis() - last > 700) {
                      if(Relay3 == 1) {
                         Blynk.virtualWrite(V4,LOW);
                         digitalWrite(13, LOW);
                         Relay3 = 0;
                } else {
                          Blynk.virtualWrite(V4,HIGH);
                          digitalWrite(13, HIGH);
                          Relay3 = 1;
                        }
                                break;
                                          }
                      }
       irrecv.resume(); // Receive the next value
  }


}

Debug Messages

Exception (0):
epc1=0x40235ce0 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: sys 
sp: 3ffffc50 end: 3fffffb0 offset: 01a0

>>>stack>>>
3ffffdf0:  00000006 00000006 42d60000 42d60000  
3ffffe00:  400043c8 00000030 00000016 ffffffff  
3ffffe10:  400044ab 3fffc718 3fffff00 003fc2f4  
3ffffe20:  000002f4 fffffeff 3fff3214 00e8a101  
3ffffe30:  fffdffff 3fffc6fc 3ffee2fc 3fff3214  
3ffffe40:  000002f4 003fc000 60000600 00000030  
3ffffe50:  40104a3c 0080911c 3fff16f8 00000000  
3ffffe60:  3ffee320 3fff16f8 3ffea784 00000001  
3ffffe70:  00000000 00807ecd 40235d98 3fff16f8  
3ffffe80:  3fff1558 019ba1c2 00000043 fffff000  
3ffffe90:  00000000 00000000 0000001f 401048f9  
3ffffea0:  4000050c 40235ce0 3fffc258 4000050c  
3ffffeb0:  40000f68 00000030 0000001b ffffffff  
3ffffec0:  40000f58 00000000 00000020 00000000  
3ffffed0:  00000012 40212e20 3ffee2fc 00000001  
3ffffee0:  ffffffff 3ffe9d14 3ffee2fc 3fffdab0  
3ffffef0:  00000000 3fffdcb0 3ffee330 00000030  
3fffff00:  3fff1edc 400042db 00000598 60000600  
3fffff10:  40004b31 3fff3214 000002f4 003fc000  
3fffff20:  40104e5e 3ffee320 3ffee180 401079bc  
3fffff30:  402128e9 3ffee180 3ffee320 019c6e6a  
3fffff40:  3fff3214 00001000 40212d86 00000008  
3fffff50:  4020f6d8 3ffe9d14 40212e33 3ffee234  
3fffff60:  3ffee320 0080bebe 3ffee2fc 3ffee320  
3fffff70:  40215b09 3ffee234 3ffee320 019c3073  
3fffff80:  40215b4e 3fffdab0 00000000 3fffdcb0  
3fffff90:  3ffee338 00000000 40000f65 3fffdab0  
3fffffa0:  40000f49 0001821a 3fffdab0 40000f49  
<<<stack<<<

 ets Jan  8 2013,rst cause:1, boot mode:(3,6)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld

and decoded message is

Decoding 26 results
0x40104a3c: RC_GetBlockAckTime at ?? line ?
0x401048f9: ppCalFrameTimes at ?? line ?
0x40212e20: readvdd33 at ?? line ?
0x40104e5e: rcGetRate at ?? line ?
0x402128e9: ram_pbus_debugmode at ?? line ?
0x40212d86: readvdd33 at ?? line ?
0x4020f6d8: igmp_timeout at /Users/igrokhotkov/espressif/arduino/tools/sdk/lwip/src/core/ipv4/igmp.c line 685
:  (inlined by) igmp_tmr at /Users/igrokhotkov/espressif/arduino/tools/sdk/lwip/src/core/ipv4/igmp.c line 668
0x40212e33: readvdd33 at ?? line ?
0x40215b09: phy_dig_spur_set at ?? line ?
0x40215b4e: phy_dig_spur_set at ?? line ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions