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. Troubleshooting
  3. relay statue doesn't change

relay statue doesn't change

Scheduled Pinned Locked Moved Troubleshooting
22 Posts 3 Posters 2.3k Views 3 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.
  • Boots33B Boots33

    1.5.4 is a few versions back now so it will help if you post the code you are using, even if it is the standard version. That will give us a starting point to work from.
    Also what controller are you using.

    L Offline
    L Offline
    ludoarchi
    wrote on last edited by gohan
    #13

    @boots33 that s the code V1

    // Example sketch showing how to control physical relays. 
    // This example will remember relay state even after power failure.
    
    #include <MySensor.h>
    #include <SPI.h>
    
    #define RELAY_1  3  // 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
    
    MySensor gw;
    
    void setup()  
    {   
      // Initialize library and add callback for incoming messages
      gw.begin(incomingMessage, AUTO, true);
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Relay", "1.0");
    
      // Fetch relay status
      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)
        gw.present(sensor, S_LIGHT);
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);   
        // Set relay to last known state (using eeprom storage) 
        digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
      }
    }
    
    
    void loop() 
    {
      // Alway process incoming messages whenever possible
      gw.process();
    }
    
    void incomingMessage(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
         gw.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
    • Boots33B Boots33

      1.5.4 is a few versions back now so it will help if you post the code you are using, even if it is the standard version. That will give us a starting point to work from.
      Also what controller are you using.

      L Offline
      L Offline
      ludoarchi
      wrote on last edited by gohan
      #14

      @boots33 that s the code V2

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0 - Henrik Ekblad
       *
       * DESCRIPTION
       * Example sketch showing how to control physical relays.
       * This example will remember relay state after power failure.
       * http://www.mysensors.org/build/relay
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      // Enable repeater functionality for this node
      #define MY_REPEATER_FEATURE
      
      #include <MySensors.h>
      
      #define RELAY_1  3  // 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 before()
      {
      	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);
      	}
      }
      
      void setup()
      {
      
      }
      
      void presentation()
      {
      	// Send the sketch version information to the gateway and Controller
      	sendSketchInfo("Relay", "1.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_BINARY);
      	}
      }
      
      
      void loop()
      {
      
      }
      
      void receive(const MyMessage &message)
      {
      	// We only expect one type of message from controller. But we better check anyway.
      	if (message.type==V_STATUS) {
      		// 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
      • Boots33B Boots33

        1.5.4 is a few versions back now so it will help if you post the code you are using, even if it is the standard version. That will give us a starting point to work from.
        Also what controller are you using.

        L Offline
        L Offline
        ludoarchi
        wrote on last edited by
        #15

        @boots33 i m using mysensor 2.2 with jeedom last version on rpi3 (serial gateway and node with 4.7uf condo).
        i also used my old rpi2 with Mysensors 1.5.4 for test

        1 Reply Last reply
        0
        • gohanG Offline
          gohanG Offline
          gohan
          Mod
          wrote on last edited by
          #16

          are you checking the right relay pin? Pls post a v2 node log

          L 1 Reply Last reply
          0
          • gohanG gohan

            are you checking the right relay pin? Pls post a v2 node log

            L Offline
            L Offline
            ludoarchi
            wrote on last edited by
            #17

            @gohan 16 MCO:BGN:INIT REPEATER,CP=RNNRA---,VER=2.2.0
            26 MCO:BGN:BFR
            27 TSM:INIT
            28 TSF:WUR:MS=0
            35 TSM:INIT:TSP OK
            37 TSF:SID:OK,ID=136
            39 TSM:FPAR
            75 TSF:MSG:SEND,136-136-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
            2083 !TSM:FPAR:NO REPLY
            2085 TSM:FPAR
            2121 TSF:MSG:SEND,136-136-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
            2568 TSF:MSG:READ,0-0-136,s=255,c=3,t=8,pt=1,l=1,sg=0:0
            2573 TSF:MSG:FPAR OK,ID=0,D=1
            2842 TSF:MSG:READ,5-5-136,s=255,c=3,t=8,pt=1,l=1,sg=0:2
            2851 TSF:MSG:READ,45-45-136,s=255,c=3,t=8,pt=1,l=1,sg=0:1
            4129 TSM:FPAR:OK
            4130 TSM:ID
            4131 TSM:ID:OK
            4133 TSM:UPL
            4136 TSF:MSG:SEND,136-136-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
            4148 TSF:MSG:READ,0-0-136,s=255,c=3,t=25,pt=1,l=1,sg=0:1
            4153 TSF:MSG:PONG RECV,HP=1
            4156 TSM:UPL:OK
            4157 TSM:READY:ID=136,PAR=0,DIS=1
            4162 TSF:MSG:SEND,136-136-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
            4169 TSF:MSG:READ,0-0-136,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
            4179 TSF:MSG:SEND,136-136-0-0,s=255,c=0,t=18,pt=0,l=5,sg=0,ft=0,st=OK:2.2.0
            4195 TSF:MSG:SEND,136-136-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
            4220 TSF:MSG:READ,0-0-136,s=255,c=3,t=6,pt=0,l=1,sg=0:M
            4228 TSF:MSG:SEND,136-136-0-0,s=255,c=3,t=11,pt=0,l=5,sg=0,ft=0,st=OK:Relay
            4236 TSF:MSG:SEND,136-136-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
            4244 TSF:MSG:SEND,136-136-0-0,s=1,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
            4251 MCO:REG:REQ
            4254 TSF:MSG:SEND,136-136-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
            4261 TSF:MSG:READ,0-0-136,s=255,c=3,t=27,pt=1,l=1,sg=0:1
            4267 MCO:PIM:NODE REG=1
            4269 MCO:BGN:STP
            4271 MCO:BGN:INIT OK,TSP=1
            22720 TSF:MSG:READ,0-0-136,s=1,c=1,t=2,pt=0,l=1,sg=0:0
            22724 TSF:MSG:ACK REQ
            22737 TSF:MSG:SEND,136-136-0-0,s=1,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=OK:0
            Incoming change for sensor:1, New status: 0
            31295 TSF:MSG:READ,0-0-136,s=1,c=1,t=2,pt=0,l=1,sg=0:0
            31299 TSF:MSG:ACK REQ
            31337 !TSF:MSG:SEND,136-136-0-0,s=1,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=NACK:0
            Incoming change for sensor:1, New status: 0

            1 Reply Last reply
            0
            • gohanG Offline
              gohanG Offline
              gohan
              Mod
              wrote on last edited by
              #18

              The last you got was a NACK btw. Have you tried a different controller like domoticz or MyController? Also remember to check your logs on https://www.mysensors.org/build/parser if you meed help decoding it

              L 1 Reply Last reply
              0
              • gohanG gohan

                The last you got was a NACK btw. Have you tried a different controller like domoticz or MyController? Also remember to check your logs on https://www.mysensors.org/build/parser if you meed help decoding it

                L Offline
                L Offline
                ludoarchi
                wrote on last edited by
                #19

                @gohan i think the nack came when i unplleged the node but i will try again.
                there is no nack in the V1log
                i would like to try myscontroler but i m not able to start with it ... i ve configured the COM but nothing happened ... i don't find How To for it 😕

                i also try Double State Relay code V2 and it s the same think ... no statue change

                1 Reply Last reply
                0
                • gohanG Offline
                  gohanG Offline
                  gohan
                  Mod
                  wrote on last edited by
                  #20

                  I am talking about MyController, not MySController

                  L 1 Reply Last reply
                  0
                  • gohanG gohan

                    I am talking about MyController, not MySController

                    L Offline
                    L Offline
                    ludoarchi
                    wrote on last edited by
                    #21

                    @gohan oups ! sorry no i don't have try another controller yet

                    1 Reply Last reply
                    0
                    • gohanG Offline
                      gohanG Offline
                      gohan
                      Mod
                      wrote on last edited by
                      #22

                      try it, it is quite simple to run

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      8

                      Online

                      11.7k

                      Users

                      11.2k

                      Topics

                      113.1k

                      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