Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Mysensors ESP8266 GW with relay - Presentation relay not working why?

Mysensors ESP8266 GW with relay - Presentation relay not working why?

Scheduled Pinned Locked Moved Development
4 Posts 4 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fernando coelho
    wrote on last edited by sundberg84
    #1

    Dear all,

    I am trying to use the ESP8266 with a local attached relay , but it is not recognized by domoticz.
    Can someone help on that ?

    Here the information log and the ino code:

    DOMOTICZ LOG

    2016-01-17 13:49:54.731 MySensors: connected to: 192.168.1.111:5003 
    2016-01-17 13:49:54.731 MySensors: Gateway Ready... 
    2016-01-17 13:49:55.781 MySensors: Gateway Version: 1.6.0-beta 
    2016-01-17 13:49:55.781 MySensors: Gateway Version: 1.6.0-beta 
    

    ESP LOG

    connected with FCSSID, channel 1
    ip:192.168.1.111,mask:255.255.255.0,gw:192.168.1.1
    .IP: 192.168.1.111
    start call Setup
    Start wait
    End wait
    End call Setup
    start call presentation
    Start wait
    End wait
    End call presentation
    0;0;3;0;9;Init complete, id=0, parent=0, distance=0
    0;0;3;0;9;Client 0 connected
    0;0;3;0;9;Client 0: 0;0;3;0;2;
    0;0;3;0;9;Client 0: 0;0;3;0;2;Get Version
    0;0;3;0;9;Client 0: 0;0;3;0;18;PING
    0;0;3;0;9;Client 0: 0;0;3;0;18;PING
    0;0;3;0;9;Client 0: 0;0;3;0;18;PING
    0;0;3;0;9;Client 0: 0;0;3;0;18;PING
    0;0;3;0;9;Client 0: 0;0;3;0;18;PING
    

    INO code:

    #include <EEPROM.h>
    #include <SPI.h>
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    //#define MY_REPEATER_FEATURE
    #define MY_DEBUG_VERBOSE
    
    // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
    #define MY_BAUD_RATE 9600
    
    // Enables and select radio type (if attached)
    // #define MY_RADIO_NRF24
    // #define MY_RADIO_RFM69
    
    // Gateway mode always enabled for ESP8266. But we add this anyway ;)
    #define MY_GATEWAY_ESP8266
    
    #define MY_ESP8266_SSID "FCSSID"
    #define MY_ESP8266_PASSWORD "jfsc20100930*"
    
    // Enable UDP communication
    //#define MY_USE_UDP
    
    // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
    #define MY_IP_ADDRESS 192,168,1,111
    
    // If using static ip you need to define Gateway and Subnet address as well
    #define MY_IP_GATEWAY_ADDRESS 192,168,1,1
    #define MY_IP_SUBNET_ADDRESS 255,255,255,0
    
    // The port to keep open on node server mode 
    #define MY_PORT 5003      
    
    // How many clients should be able to connect to this gateway (default 1)
    #define MY_GATEWAY_MAX_CLIENTS 2
    
    // Controller ip address. Enables client mode (default is "server" mode). 
    // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. 
    //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68
    
    /*
    // Flash leds on rx/tx/err
    #define MY_LEDS_BLINKING_FEATURE
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Enable inclusion mode
    #define MY_INCLUSION_MODE_FEATURE
    // Enable Inclusion mode button on gateway
    #define MY_INCLUSION_BUTTON_FEATURE
    // Set inclusion mode duration (in seconds)
    #define MY_INCLUSION_MODE_DURATION 60 
    // Digital pin used for inclusion mode button
    #define MY_INCLUSION_MODE_BUTTON_PIN  3 
    
    #define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
    #define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
    #define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
    
    */
    
    #if defined(MY_USE_UDP)
      #include <WiFiUDP.h>
    #else
      #include <ESP8266WiFi.h>
    #endif
    
    // Enable repeater functionality for this node
    //#define MY_REPEATER_FEATURE
    
    #include <SPI.h>
    #include <MySensor.h>
    
    #define RELAY_1  4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 1 // Total number of attached relays
    #define RELAY_ON 1  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
    
    void setup()  
    { 
    
    
      Serial.println("start call Setup");
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);   
        // Set relay to last known state (using eeprom storage) 
        digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
      }
        Serial.println("Start wait");  
        //delay(60000);  
        Serial.println("End wait");  
        Serial.println("End call Setup");
    }
    
    void presentation()  
    {   
    
        Serial.println("start call presentation");
        Serial.println("Start wait");  
        //delay(60000);  
        Serial.println("End wait");  
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Relay2", "2.0");
    
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_LIGHT);
      }
    
          Serial.println("End call presentation");
    }
    
    
    void loop() 
    {
          //Serial.println("start call loop");
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_LIGHT) {
         // Change relay state
         digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
         // Store state in eeprom
         saveState(message.sensor, message.getBool());
         // Write some debug info
         Serial.print("Incoming change for sensor:");
         Serial.print(message.sensor);
         Serial.print(", New status: ");
         Serial.println(message.getBool());
       } 
    }
    
    1 Reply Last reply
    0
    • E Offline
      E Offline
      ericvdb
      wrote on last edited by ericvdb
      #2

      please indent your code with 4 spaces to keep it readable.
      And in the arduino gui press CTRL-T to tabify your code correctly ;)

      1 Reply Last reply
      1
      • W Offline
        W Offline
        wxws
        wrote on last edited by
        #3

        yes ,i find this bug too.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hek
          Admin
          wrote on last edited by
          #4

          Hmm.. Looks like it could it be that the connection to controller hasn't been initialised when node/gw sends the presentations.

          Please create an issue on github and create a link to it here.

          1 Reply Last reply
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          14

          Online

          12.0k

          Users

          11.2k

          Topics

          113.4k

          Posts


          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular