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. Controllers
  3. Home Assistant
  4. Arduino+M5100 cannot connect to LAN

Arduino+M5100 cannot connect to LAN

Scheduled Pinned Locked Moved Home Assistant
22 Posts 3 Posters 87 Views 2 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.
  • mfalkviddM Offline
    mfalkviddM Offline
    mfalkvidd
    Mod
    wrote on last edited by
    #4

    Did you read section #2:3 ?

    P 1 Reply Last reply
    0
    • mfalkviddM mfalkvidd

      Did you read section #2:3 ?

      P Offline
      P Offline
      PZDPRO
      wrote on last edited by
      #5

      @mfalkvidd
      Yes. I use this:
      7184fb55-7e58-435d-a789-1d7206684671-obraz.png
      It shouldn't be wired wrong.

      mfalkviddM 1 Reply Last reply
      1
      • P PZDPRO

        @mfalkvidd
        Yes. I use this:
        7184fb55-7e58-435d-a789-1d7206684671-obraz.png
        It shouldn't be wired wrong.

        mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by
        #6

        @PZDPRO I can’t see a nrf24 radio in that photo.

        1 Reply Last reply
        0
        • mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #7

          @PZDPRO said in Arduino+M5100 cannot connect to LAN:

          #define MY_RADIO_RF24

          Comment out this if you don't want to use a nrf24.

          P 1 Reply Last reply
          0
          • mfalkviddM mfalkvidd

            @PZDPRO said in Arduino+M5100 cannot connect to LAN:

            #define MY_RADIO_RF24

            Comment out this if you don't want to use a nrf24.

            P Offline
            P Offline
            PZDPRO
            wrote on last edited by
            #8

            @mfalkvidd Hi,
            I tried this but still cannot connect to my LAN network. Router doesn't give me IP. I cannot see arduino in HA.
            I tried many configurations. Even i put a new sketches from my sensors examples in arduino IDE (GatewayW5100 and GatewayW5100Client).

            Maybe you someone have working sketch for tests?

            Thank you in advance.

            mfalkviddM 1 Reply Last reply
            0
            • P PZDPRO

              @mfalkvidd Hi,
              I tried this but still cannot connect to my LAN network. Router doesn't give me IP. I cannot see arduino in HA.
              I tried many configurations. Even i put a new sketches from my sensors examples in arduino IDE (GatewayW5100 and GatewayW5100Client).

              Maybe you someone have working sketch for tests?

              Thank you in advance.

              mfalkviddM Offline
              mfalkviddM Offline
              mfalkvidd
              Mod
              wrote on last edited by
              #9

              @PZDPRO all the examples in MySensors are known to work. We wouldn’t have them if they were broken.

              What does the debug output say when you have removed the nrf24?

              P 1 Reply Last reply
              0
              • mfalkviddM mfalkvidd

                @PZDPRO all the examples in MySensors are known to work. We wouldn’t have them if they were broken.

                What does the debug output say when you have removed the nrf24?

                P Offline
                P Offline
                PZDPRO
                wrote on last edited by PZDPRO
                #10

                @mfalkvidd
                This is what i have:
                b9642955-10f3-41a5-ad18-c29535f4b71f-obraz.png Przechwytywanie.PNG
                I cant see arduino in my router internal website, but i made a ping wrom Command line and i have this:
                eb2fb8fb-b647-46ac-b713-6d2ab183a531-obraz.png

                Unfortunatelly i cant connect it in HA:
                Przechwsssssytywanie.PNG

                mfalkviddM 1 Reply Last reply
                0
                • P PZDPRO

                  @mfalkvidd
                  This is what i have:
                  b9642955-10f3-41a5-ad18-c29535f4b71f-obraz.png Przechwytywanie.PNG
                  I cant see arduino in my router internal website, but i made a ping wrom Command line and i have this:
                  eb2fb8fb-b647-46ac-b713-6d2ab183a531-obraz.png

                  Unfortunatelly i cant connect it in HA:
                  Przechwsssssytywanie.PNG

                  mfalkviddM Offline
                  mfalkviddM Offline
                  mfalkvidd
                  Mod
                  wrote on last edited by
                  #11

                  @PZDPRO I have never used HA but port 1883 in your configuration hints that HA is expecting a MQTT gateway. Your gateway is configured as an ethernet gateway. Therefore, the gateway does not support MQTT.

                  Either configure HA to use an MySensors ethernet gateway, or reconfigure your gateway to use MQTT. See https://www.mysensors.org/build/mqtt_gateway for instructions.

                  I think you'll need a MQTT broker as well. Instructions are available at https://www.mysensors.org/build/mqtt_gateway#setup-and-test-gateway

                  P 1 Reply Last reply
                  0
                  • mfalkviddM mfalkvidd

                    @PZDPRO I have never used HA but port 1883 in your configuration hints that HA is expecting a MQTT gateway. Your gateway is configured as an ethernet gateway. Therefore, the gateway does not support MQTT.

                    Either configure HA to use an MySensors ethernet gateway, or reconfigure your gateway to use MQTT. See https://www.mysensors.org/build/mqtt_gateway for instructions.

                    I think you'll need a MQTT broker as well. Instructions are available at https://www.mysensors.org/build/mqtt_gateway#setup-and-test-gateway

                    P Offline
                    P Offline
                    PZDPRO
                    wrote on last edited by
                    #12

                    Thank you @mfalkvidd
                    Do i need this radio module even if i use wire system in my home?
                    2d3a1f4c-9ae0-43f6-96f6-2da1fb4f6fcd-obraz.png

                    mfalkviddM 1 Reply Last reply
                    0
                    • P PZDPRO

                      Thank you @mfalkvidd
                      Do i need this radio module even if i use wire system in my home?
                      2d3a1f4c-9ae0-43f6-96f6-2da1fb4f6fcd-obraz.png

                      mfalkviddM Offline
                      mfalkviddM Offline
                      mfalkvidd
                      Mod
                      wrote on last edited by
                      #13

                      @PZDPRO you only need the nrf24 if you want to connect sensor nodes to your gateway. See https://www.mysensors.org/about/network for details on how MySensors works.

                      P 1 Reply Last reply
                      0
                      • mfalkviddM mfalkvidd

                        @PZDPRO you only need the nrf24 if you want to connect sensor nodes to your gateway. See https://www.mysensors.org/about/network for details on how MySensors works.

                        P Offline
                        P Offline
                        PZDPRO
                        wrote on last edited by
                        #14

                        @mfalkvidd OK.
                        I changed my sketch and finally i connect it to HA using integration but still dont have any device in HA.
                        b3dad7bc-0380-4abb-bc09-cd0a0f5385e3-obraz.png

                        code_text
                        
                        // Enable debug prints to serial monitor
                        #define MY_DEBUG
                        
                        // Enable and select radio type attached
                        //#define MY_RADIO_RF24
                        //#define MY_RADIO_NRF5_ESB
                        //#define MY_RADIO_RFM69
                        //#define MY_RADIO_RFM95
                        
                        // Enable gateway ethernet module type
                        #define MY_GATEWAY_W5100
                        
                        // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
                        //#define MY_W5100_SPI_EN 4
                        
                        // Enable Soft SPI for NRF radio (note different radio wiring is required)
                        // The W5100 ethernet module seems to have a hard time co-operate with
                        // radio on the same spi bus.
                        #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
                        #define MY_SOFTSPI
                        #define MY_SOFT_SPI_SCK_PIN 14
                        #define MY_SOFT_SPI_MISO_PIN 16
                        #define MY_SOFT_SPI_MOSI_PIN 15
                        #endif
                        
                        // When W5100 is connected we have to move CE/CSN pins for NRF radio
                        #ifndef MY_RF24_CE_PIN
                        #define MY_RF24_CE_PIN 5
                        #endif
                        #ifndef MY_RF24_CS_PIN
                        #define MY_RF24_CS_PIN 6
                        #endif
                        
                        // Enable UDP communication
                        //#define MY_USE_UDP  // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS or MY_CONTROLLER_URL_ADDRESS below
                        
                        // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
                        #define MY_IP_ADDRESS 192,168,0,207
                        // If using static ip you can define Gateway and Subnet address as well
                        #define MY_IP_GATEWAY_ADDRESS 192,168,0,1
                        #define MY_IP_SUBNET_ADDRESS 255,255,255,0
                        
                        // Renewal period if using DHCP
                        //#define MY_IP_RENEWAL_INTERVAL 60000
                        
                        // The port to keep open on node server mode / or port to contact in client mode
                        #define MY_PORT 5003
                        
                        // 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, 0, 140
                        //#define MY_CONTROLLER_URL_ADDRESS "my.controller.org"
                        
                        // The MAC address can be anything you want but should be unique on your network.
                        // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
                        // Note that most of the Arduino examples use  "DEAD BEEF FEED" for the MAC address.
                        #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
                        
                        
                        // 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
                        
                        // Set blinking period
                        #define MY_DEFAULT_LED_BLINK_PERIOD 300
                        
                        // Flash leds on rx/tx/err
                        // Uncomment to override default HW configurations
                        //#define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
                        //#define MY_DEFAULT_RX_LED_PIN  8  // Receive led pin
                        //#define MY_DEFAULT_TX_LED_PIN  9  // Transmit led pin
                        
                        #if defined(MY_USE_UDP)
                        #include <EthernetUdp.h>
                        #endif
                        #include <Ethernet.h>
                        #include <MySensors.h>
                        #include <Bounce2.h>
                        #define MY_REPEATER_FEATURE
                        #define MY_NODE_ID 1
                        #include <SPI.h>
                        // Enable repeater functionality for this node
                        #define MY_REPEATER_FEATURE
                        
                        #define RELAY_PIN  5
                        #define BUTTON_PIN  3
                        #define CHILD_ID 1
                        #define RELAY_ON 1
                        #define RELAY_OFF 0
                        
                        Bounce debouncer = Bounce();
                        bool state = false;
                        bool initialValueSent = false;
                        
                        MyMessage msg(CHILD_ID, V_STATUS);
                        
                        void setup()
                        {
                          pinMode(BUTTON_PIN, INPUT_PULLUP);
                          debouncer.attach(BUTTON_PIN);
                          debouncer.interval(10);
                        
                          // Make sure relays are off when starting up
                          digitalWrite(RELAY_PIN, RELAY_OFF);
                          pinMode(RELAY_PIN, OUTPUT);
                        }
                        
                        void presentation()  {
                          sendSketchInfo("Relay+button", "1.0");
                          present(CHILD_ID, S_BINARY);
                        }
                        
                        void loop()
                        {
                          if (!initialValueSent) {
                            Serial.println("Sending initial value");
                            send(msg.set(state?RELAY_ON:RELAY_OFF));
                            Serial.println("Requesting initial value from controller");
                            request(CHILD_ID, V_STATUS);
                            wait(2000, C_SET, V_STATUS);
                          }
                          if (debouncer.update()) {
                            if (debouncer.read()==LOW) {
                              state = !state;
                              // Send new state and request ack back
                              send(msg.set(state?RELAY_ON:RELAY_OFF), true);
                            }
                          }
                        }
                        
                        void receive(const MyMessage &message) {
                          if (message.isAck()) {
                             Serial.println("This is an ack from gateway");
                          }
                        
                          if (message.type == V_STATUS) {
                            if (!initialValueSent) {
                              Serial.println("Receiving initial value from controller");
                              initialValueSent = true;
                            }
                            // Change relay state
                            state = (bool)message.getInt();
                            digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
                            send(msg.set(state?RELAY_ON:RELAY_OFF));
                          }
                        }
                        
                        mfalkviddM V 2 Replies Last reply
                        0
                        • P PZDPRO

                          @mfalkvidd OK.
                          I changed my sketch and finally i connect it to HA using integration but still dont have any device in HA.
                          b3dad7bc-0380-4abb-bc09-cd0a0f5385e3-obraz.png

                          code_text
                          
                          // Enable debug prints to serial monitor
                          #define MY_DEBUG
                          
                          // Enable and select radio type attached
                          //#define MY_RADIO_RF24
                          //#define MY_RADIO_NRF5_ESB
                          //#define MY_RADIO_RFM69
                          //#define MY_RADIO_RFM95
                          
                          // Enable gateway ethernet module type
                          #define MY_GATEWAY_W5100
                          
                          // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
                          //#define MY_W5100_SPI_EN 4
                          
                          // Enable Soft SPI for NRF radio (note different radio wiring is required)
                          // The W5100 ethernet module seems to have a hard time co-operate with
                          // radio on the same spi bus.
                          #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
                          #define MY_SOFTSPI
                          #define MY_SOFT_SPI_SCK_PIN 14
                          #define MY_SOFT_SPI_MISO_PIN 16
                          #define MY_SOFT_SPI_MOSI_PIN 15
                          #endif
                          
                          // When W5100 is connected we have to move CE/CSN pins for NRF radio
                          #ifndef MY_RF24_CE_PIN
                          #define MY_RF24_CE_PIN 5
                          #endif
                          #ifndef MY_RF24_CS_PIN
                          #define MY_RF24_CS_PIN 6
                          #endif
                          
                          // Enable UDP communication
                          //#define MY_USE_UDP  // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS or MY_CONTROLLER_URL_ADDRESS below
                          
                          // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
                          #define MY_IP_ADDRESS 192,168,0,207
                          // If using static ip you can define Gateway and Subnet address as well
                          #define MY_IP_GATEWAY_ADDRESS 192,168,0,1
                          #define MY_IP_SUBNET_ADDRESS 255,255,255,0
                          
                          // Renewal period if using DHCP
                          //#define MY_IP_RENEWAL_INTERVAL 60000
                          
                          // The port to keep open on node server mode / or port to contact in client mode
                          #define MY_PORT 5003
                          
                          // 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, 0, 140
                          //#define MY_CONTROLLER_URL_ADDRESS "my.controller.org"
                          
                          // The MAC address can be anything you want but should be unique on your network.
                          // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
                          // Note that most of the Arduino examples use  "DEAD BEEF FEED" for the MAC address.
                          #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
                          
                          
                          // 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
                          
                          // Set blinking period
                          #define MY_DEFAULT_LED_BLINK_PERIOD 300
                          
                          // Flash leds on rx/tx/err
                          // Uncomment to override default HW configurations
                          //#define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
                          //#define MY_DEFAULT_RX_LED_PIN  8  // Receive led pin
                          //#define MY_DEFAULT_TX_LED_PIN  9  // Transmit led pin
                          
                          #if defined(MY_USE_UDP)
                          #include <EthernetUdp.h>
                          #endif
                          #include <Ethernet.h>
                          #include <MySensors.h>
                          #include <Bounce2.h>
                          #define MY_REPEATER_FEATURE
                          #define MY_NODE_ID 1
                          #include <SPI.h>
                          // Enable repeater functionality for this node
                          #define MY_REPEATER_FEATURE
                          
                          #define RELAY_PIN  5
                          #define BUTTON_PIN  3
                          #define CHILD_ID 1
                          #define RELAY_ON 1
                          #define RELAY_OFF 0
                          
                          Bounce debouncer = Bounce();
                          bool state = false;
                          bool initialValueSent = false;
                          
                          MyMessage msg(CHILD_ID, V_STATUS);
                          
                          void setup()
                          {
                            pinMode(BUTTON_PIN, INPUT_PULLUP);
                            debouncer.attach(BUTTON_PIN);
                            debouncer.interval(10);
                          
                            // Make sure relays are off when starting up
                            digitalWrite(RELAY_PIN, RELAY_OFF);
                            pinMode(RELAY_PIN, OUTPUT);
                          }
                          
                          void presentation()  {
                            sendSketchInfo("Relay+button", "1.0");
                            present(CHILD_ID, S_BINARY);
                          }
                          
                          void loop()
                          {
                            if (!initialValueSent) {
                              Serial.println("Sending initial value");
                              send(msg.set(state?RELAY_ON:RELAY_OFF));
                              Serial.println("Requesting initial value from controller");
                              request(CHILD_ID, V_STATUS);
                              wait(2000, C_SET, V_STATUS);
                            }
                            if (debouncer.update()) {
                              if (debouncer.read()==LOW) {
                                state = !state;
                                // Send new state and request ack back
                                send(msg.set(state?RELAY_ON:RELAY_OFF), true);
                              }
                            }
                          }
                          
                          void receive(const MyMessage &message) {
                            if (message.isAck()) {
                               Serial.println("This is an ack from gateway");
                            }
                          
                            if (message.type == V_STATUS) {
                              if (!initialValueSent) {
                                Serial.println("Receiving initial value from controller");
                                initialValueSent = true;
                              }
                              // Change relay state
                              state = (bool)message.getInt();
                              digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
                              send(msg.set(state?RELAY_ON:RELAY_OFF));
                            }
                          }
                          
                          mfalkviddM Offline
                          mfalkviddM Offline
                          mfalkvidd
                          Mod
                          wrote on last edited by
                          #15

                          @PZDPRO since I have never used HA, I don't know what devices in HA are, or how they work.

                          1 Reply Last reply
                          0
                          • P PZDPRO

                            @mfalkvidd OK.
                            I changed my sketch and finally i connect it to HA using integration but still dont have any device in HA.
                            b3dad7bc-0380-4abb-bc09-cd0a0f5385e3-obraz.png

                            code_text
                            
                            // Enable debug prints to serial monitor
                            #define MY_DEBUG
                            
                            // Enable and select radio type attached
                            //#define MY_RADIO_RF24
                            //#define MY_RADIO_NRF5_ESB
                            //#define MY_RADIO_RFM69
                            //#define MY_RADIO_RFM95
                            
                            // Enable gateway ethernet module type
                            #define MY_GATEWAY_W5100
                            
                            // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
                            //#define MY_W5100_SPI_EN 4
                            
                            // Enable Soft SPI for NRF radio (note different radio wiring is required)
                            // The W5100 ethernet module seems to have a hard time co-operate with
                            // radio on the same spi bus.
                            #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
                            #define MY_SOFTSPI
                            #define MY_SOFT_SPI_SCK_PIN 14
                            #define MY_SOFT_SPI_MISO_PIN 16
                            #define MY_SOFT_SPI_MOSI_PIN 15
                            #endif
                            
                            // When W5100 is connected we have to move CE/CSN pins for NRF radio
                            #ifndef MY_RF24_CE_PIN
                            #define MY_RF24_CE_PIN 5
                            #endif
                            #ifndef MY_RF24_CS_PIN
                            #define MY_RF24_CS_PIN 6
                            #endif
                            
                            // Enable UDP communication
                            //#define MY_USE_UDP  // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS or MY_CONTROLLER_URL_ADDRESS below
                            
                            // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
                            #define MY_IP_ADDRESS 192,168,0,207
                            // If using static ip you can define Gateway and Subnet address as well
                            #define MY_IP_GATEWAY_ADDRESS 192,168,0,1
                            #define MY_IP_SUBNET_ADDRESS 255,255,255,0
                            
                            // Renewal period if using DHCP
                            //#define MY_IP_RENEWAL_INTERVAL 60000
                            
                            // The port to keep open on node server mode / or port to contact in client mode
                            #define MY_PORT 5003
                            
                            // 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, 0, 140
                            //#define MY_CONTROLLER_URL_ADDRESS "my.controller.org"
                            
                            // The MAC address can be anything you want but should be unique on your network.
                            // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
                            // Note that most of the Arduino examples use  "DEAD BEEF FEED" for the MAC address.
                            #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
                            
                            
                            // 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
                            
                            // Set blinking period
                            #define MY_DEFAULT_LED_BLINK_PERIOD 300
                            
                            // Flash leds on rx/tx/err
                            // Uncomment to override default HW configurations
                            //#define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
                            //#define MY_DEFAULT_RX_LED_PIN  8  // Receive led pin
                            //#define MY_DEFAULT_TX_LED_PIN  9  // Transmit led pin
                            
                            #if defined(MY_USE_UDP)
                            #include <EthernetUdp.h>
                            #endif
                            #include <Ethernet.h>
                            #include <MySensors.h>
                            #include <Bounce2.h>
                            #define MY_REPEATER_FEATURE
                            #define MY_NODE_ID 1
                            #include <SPI.h>
                            // Enable repeater functionality for this node
                            #define MY_REPEATER_FEATURE
                            
                            #define RELAY_PIN  5
                            #define BUTTON_PIN  3
                            #define CHILD_ID 1
                            #define RELAY_ON 1
                            #define RELAY_OFF 0
                            
                            Bounce debouncer = Bounce();
                            bool state = false;
                            bool initialValueSent = false;
                            
                            MyMessage msg(CHILD_ID, V_STATUS);
                            
                            void setup()
                            {
                              pinMode(BUTTON_PIN, INPUT_PULLUP);
                              debouncer.attach(BUTTON_PIN);
                              debouncer.interval(10);
                            
                              // Make sure relays are off when starting up
                              digitalWrite(RELAY_PIN, RELAY_OFF);
                              pinMode(RELAY_PIN, OUTPUT);
                            }
                            
                            void presentation()  {
                              sendSketchInfo("Relay+button", "1.0");
                              present(CHILD_ID, S_BINARY);
                            }
                            
                            void loop()
                            {
                              if (!initialValueSent) {
                                Serial.println("Sending initial value");
                                send(msg.set(state?RELAY_ON:RELAY_OFF));
                                Serial.println("Requesting initial value from controller");
                                request(CHILD_ID, V_STATUS);
                                wait(2000, C_SET, V_STATUS);
                              }
                              if (debouncer.update()) {
                                if (debouncer.read()==LOW) {
                                  state = !state;
                                  // Send new state and request ack back
                                  send(msg.set(state?RELAY_ON:RELAY_OFF), true);
                                }
                              }
                            }
                            
                            void receive(const MyMessage &message) {
                              if (message.isAck()) {
                                 Serial.println("This is an ack from gateway");
                              }
                            
                              if (message.type == V_STATUS) {
                                if (!initialValueSent) {
                                  Serial.println("Receiving initial value from controller");
                                  initialValueSent = true;
                                }
                                // Change relay state
                                state = (bool)message.getInt();
                                digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
                                send(msg.set(state?RELAY_ON:RELAY_OFF));
                              }
                            }
                            
                            V Offline
                            V Offline
                            virtualmkr
                            wrote on last edited by
                            #16

                            @PZDPRO
                            Hi, have you checked in HA the file /config/mysensors/mysensors.json?
                            Can you provide the content here?

                            I have been using HA with MySensors for some time and it works for me, but sometimes HA behaves strangely for me too.
                            Maybe we can fix your problem here and maybe someone with more HA experience can join the discussion.

                            So far your second Arduino sketch should work with HA.
                            BR Immo

                            P 1 Reply Last reply
                            1
                            • V virtualmkr

                              @PZDPRO
                              Hi, have you checked in HA the file /config/mysensors/mysensors.json?
                              Can you provide the content here?

                              I have been using HA with MySensors for some time and it works for me, but sometimes HA behaves strangely for me too.
                              Maybe we can fix your problem here and maybe someone with more HA experience can join the discussion.

                              So far your second Arduino sketch should work with HA.
                              BR Immo

                              P Offline
                              P Offline
                              PZDPRO
                              wrote on last edited by
                              #17

                              @virtualmkr Hello!
                              I checked and i think i dont have any file from mysensors.
                              e7e6c735-8228-43aa-b072-a0df71525f37-obraz.png
                              I'm not good at programming and i only change ready skatches. Maybe you can be my guide how to start with this?
                              Main thing for me is to have arduino as a light controller. To analogs i have connected monostable switches and on digitals outputs a i had connected relays. In domoticz it works very well via USB.

                              V 1 Reply Last reply
                              0
                              • P PZDPRO

                                @virtualmkr Hello!
                                I checked and i think i dont have any file from mysensors.
                                e7e6c735-8228-43aa-b072-a0df71525f37-obraz.png
                                I'm not good at programming and i only change ready skatches. Maybe you can be my guide how to start with this?
                                Main thing for me is to have arduino as a light controller. To analogs i have connected monostable switches and on digitals outputs a i had connected relays. In domoticz it works very well via USB.

                                V Offline
                                V Offline
                                virtualmkr
                                wrote on last edited by
                                #18

                                @PZDPRO
                                I use the File editor from Add-on Store:
                                2021-09-28 14_01_54-Supervisor - Home Assistant.png

                                Then I can see the MySensors nodes configuration:
                                2021-09-28 14_05_38-File editor - Home Assistant.png

                                P 1 Reply Last reply
                                0
                                • V virtualmkr

                                  @PZDPRO
                                  I use the File editor from Add-on Store:
                                  2021-09-28 14_01_54-Supervisor - Home Assistant.png

                                  Then I can see the MySensors nodes configuration:
                                  2021-09-28 14_05_38-File editor - Home Assistant.png

                                  P Offline
                                  P Offline
                                  PZDPRO
                                  wrote on last edited by
                                  #19

                                  @virtualmkr
                                  I cant connect to arduino again. I ping ip from my laptop and its ok.
                                  Error in HA is "cannot make connection"
                                  6e4be8c6-9c0c-4aa4-8bb7-f21cf755a1cb-obraz.png
                                  I installed file editor and i dont have such a folder and file.

                                  V 3 Replies Last reply
                                  0
                                  • P PZDPRO

                                    @virtualmkr
                                    I cant connect to arduino again. I ping ip from my laptop and its ok.
                                    Error in HA is "cannot make connection"
                                    6e4be8c6-9c0c-4aa4-8bb7-f21cf755a1cb-obraz.png
                                    I installed file editor and i dont have such a folder and file.

                                    V Offline
                                    V Offline
                                    virtualmkr
                                    wrote on last edited by
                                    #20

                                    @PZDPRO It may be you use the automatic config file name. For me I have a second MySensors integration with the configuration file located directly in the config folder:
                                    2021-09-28 15_10_46-File editor - Home Assistant.png

                                    When your MyS gateway is reachable via ping then HA should be able to connect.
                                    How is your HA hosted? Do you use the HA Raspi image?

                                    1 Reply Last reply
                                    0
                                    • P PZDPRO

                                      @virtualmkr
                                      I cant connect to arduino again. I ping ip from my laptop and its ok.
                                      Error in HA is "cannot make connection"
                                      6e4be8c6-9c0c-4aa4-8bb7-f21cf755a1cb-obraz.png
                                      I installed file editor and i dont have such a folder and file.

                                      V Offline
                                      V Offline
                                      virtualmkr
                                      wrote on last edited by
                                      #21

                                      @PZDPRO
                                      Additional I use the MYSController tool, very helpful for debug:
                                      MYSBootloader 1.3 pre-release & MYSController 1.0.0beta

                                      With this you can check if the problem is on HA side or with your gateway.

                                      1 Reply Last reply
                                      0
                                      • P PZDPRO

                                        @virtualmkr
                                        I cant connect to arduino again. I ping ip from my laptop and its ok.
                                        Error in HA is "cannot make connection"
                                        6e4be8c6-9c0c-4aa4-8bb7-f21cf755a1cb-obraz.png
                                        I installed file editor and i dont have such a folder and file.

                                        V Offline
                                        V Offline
                                        virtualmkr
                                        wrote on last edited by
                                        #22

                                        @PZDPRO Also you should activate the logging for the MySensors integration.
                                        See: https://www.home-assistant.io/integrations/mysensors#debug-logging

                                        The log will hopefully provide further insights..

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


                                        33

                                        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