What settings for ESP8266 Node?



  • Hi,

    I would like to convert the below sketch to a ESP8266 /WeMos D1 Mini compatible sketch. Do I have to change MY RADIO NRF24 to ESP8266 or sth like that? PS I am using MQTT and Openhab 2...

    /*
     * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
     * An IR LED must be connected to Arduino PWM pin 3.
     * Version 0.1 July, 2009
     * Copyright 2009 Ken Shirriff
     * http://arcfn.com
     */
    
    #define MY_RADIO_NRF24 
    // Define Node ID
    #define MY_NODE_ID 5
    //#define MY_PARENT_NODE_ID 50 //Repeater Node 1!
    //#define MY_PARENT_NODE_IS_STATIC
    
    #include <MySensors.h>
    #include <SPI.h>
    #include <IRremote.h>
    
    #define CHILD_ID 1   // Id of the sensor child
    
    IRsend irsend;
    
    // Initialize message
    MyMessage msg(CHILD_ID, V_IR_SEND);
    
    void setup()
    {
      Serial.begin(9600);
    }
    
    void presentation()
    {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("LED Licht TV Steuerung", "1.0");
    
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID, S_IR);
    }
    
    void loop() {
    
    
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
       Serial.println(F("Incoming Message:"));
       Serial.println(message.getString());
      if (message.type == V_IR_RECEIVE) {
        // Send command to Turn LEDs On
        if (message.getString("anaus")) { 
        for (int i = 0; i < 3; i++) {
            irsend.sendNEC(0xFF02FD, 32);
            Serial.println(message.getString());
            Serial.println("Message sent");
            delay(40);
          }
        } 
            // Send command to Turn LEDs Red
        else if (message.getString("rot")) { 
        for (int i = 0; i < 3; i++) {
            irsend.sendNEC(0xFF1AE5, 32);
            Serial.println(message.getString());
            Serial.println("Message sent");
            delay(40);
          }
        }
            // Send command to Turn LEDs green
        else if (message.getString("gruen")) { 
        for (int i = 0; i < 3; i++) {
            irsend.sendNEC(0xFF9A65, 32);
            Serial.println(message.getString());
            Serial.println("Message sent");
            delay(40);
          }
        }
                // Send command to Turn LEDs blue
        else if (message.getString("blau")) { 
        for (int i = 0; i < 3; i++) {
            irsend.sendNEC(0xFFA25D, 32);
            Serial.println(message.getString());
            Serial.println("Message sent");
            delay(40);
          }
        }
                    // Send command to Turn LEDs white
        else if (message.getString("weiss")) { 
        for (int i = 0; i < 3; i++) {
            irsend.sendNEC(0xFF22DD, 32);
            Serial.println(message.getString());
            Serial.println("Message sent");
            delay(40);
          }
        }
                        // Send command to Turn LEDs faster
        else if (message.getString("schneller")) { 
        for (int i = 0; i < 3; i++) {
            irsend.sendNEC(0xFFE817, 32);
            Serial.println(message.getString());
            Serial.println("Message sent");
            delay(40);
          }
        }
                            // Send command to Turn LEDs slower
        else if (message.getString("langsamer")) { 
        for (int i = 0; i < 3; i++) {
            irsend.sendNEC(0xFFC837, 32);
            Serial.println(message.getString());
            Serial.println("Message sent");
            delay(40);
          }
        }
                   // Send command to Turn LEDs brighter
        else if (message.getString("heller")) { 
        for (int i = 0; i < 3; i++) {
            irsend.sendNEC(0xFF3AC5, 32);
            Serial.println(message.getString());
            Serial.println("Message sent");
            delay(40);
          }
        }
            // Send command to Turn LEDs darker
        else if (message.getString("dunkler")) { 
        for (int i = 0; i < 3; i++) {
            irsend.sendNEC(0xFFBA45, 32);
            Serial.println(message.getString());
            Serial.println("Message sent");
            delay(40);
          }
        }
                // Send command to Turn LEDs Fade7
        else if (message.getString("fade7")) { 
        for (int i = 0; i < 3; i++) {
            irsend.sendNEC(0xFFE01F, 32);
            Serial.println(message.getString());
            Serial.println("Message sent");
            delay(40);
          }
        }
                    // Send command to Turn LEDs flash
        else if (message.getString("flash")) { 
        for (int i = 0; i < 3; i++) {
            irsend.sendNEC(0xFFD02F, 32);
            Serial.println(message.getString());
            Serial.println("Message sent");
            delay(40);
          }
        }
        // Send command to Turn LEDs Jump7
        else if (message.getString("jump")) { 
        for (int i = 0; i < 3; i++) {
            irsend.sendNEC(0xFFA05F, 32);
            Serial.println(message.getString());
            Serial.println("Message sent");
            delay(40);
          }
        }
        else{ 
          // if nothing else matches, do the default
          // default is optional
          Serial.println("Nicht belegt");
          }
       }
     }
    

  • Mod

    It depends if you want it connected via wifi or via nrf24, if the second just leave the nrf24 define


 

319
Online

7.7k
Users

8.6k
Topics

92.3k
Posts