Navigation

    • Register
    • Login
    • Search
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. Steve Parsons
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Steve Parsons

    @Steve Parsons

    2
    Reputation
    6
    Posts
    4
    Profile views
    1
    Followers
    0
    Following
    Joined Last Online

    Steve Parsons Follow

    Best posts made by Steve Parsons

    • Sensors won't connect to Gateway after adding Controller

      Hello,

      I've posted this in the HA Forums too but hoping someone here might be able to help too

      I am stuck setting up MySensors and if anyone could help me I would be very grateful. I am completely new to Arduino's and the syntax (and I'm not a programmer anyway!) so I am aware I'm on a steep learning curve here!

      I have followed the tutorials to set up an Ethernet Gateway and a basic motion sensor. I then assigned static ID's to these as at this point I wasn't using a controller and I could get the two to talk successfully. I used the serial monitor to check both devices and when I wave my hand in front of the sensor I get the following:

      Sensor:

      42401 MCO:SLP:WUP=1
      42403 TSF:TRI:TSB
      1
      42414 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:1
      42420 MCO:SLP:MS=120000,SMS=0,I1=1,M1=1,I2=255,M2=255
      42425 TSF:TDI:TSL
      42427 MCO:SLP:WUP=1
      42429 TSF:TRI:TSB
      0
      42439 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
      42445 MCO:SLP:MS=120000,SMS=0,I1=1,M1=1,I2=255,M2=255
      42450 TSF:TDI:TSL
      
      

      Gateway:

      18749588 TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:1
      18752809 TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      

      If I've misinterpreted this then please let me know, but it appears to me that the 1 (motion) and 0 (reset) on both devices almost simultaneously would suggest that they are communicating.

      I also set up a repeater and had communication between these, and could even pass the sensor data through it (we have thick walls so I took the sensor out of range and put the repeater in the middle).

      At this point I was thinking, this is all pretty easy, just need to hook it up to HA and I'll be away! However, I cannot get it to work. My understanding is that the controller - HA in this case - hands out the ID's to the nodes and therefore I don't want to define these in the sketch. I believe I am also right in saying that the gateway always has an ID of 0.

      I added the following to my HA configuration.yaml

      mysensors:
        gateways:
          - device: '192.168.86.19'
        version: '2.3.2'
      
      

      I restarted HA, and it appeared to be communicating as I was getting the following in the serial monitor for the gateway:

      19548847 GWT:RFC:MSG=0;255;3;0;2;
      19548853 GWT:RFC:MSG=255;255;3;0;20;
      19548859 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=1,l=1,sg=0,ft=0,st=OK:0
      19558932 GWT:RFC:MSG=0;255;3;0;2;
      19569021 GWT:RFC:MSG=0;255;3;0;2;
      19579111 GWT:RFC:MSG=0;255;3;0;2;
      19589199 GWT:RFC:MSG=0;255;3;0;2;
      19600464 GWT:RFC:MSG=0;255;3;0;2;
      19610560 GWT:RFC:MSG=0;255;3;0;2;
      19620649 GWT:RFC:MSG=0;255;3;0;2;
      19630739 GWT:RFC:MSG=0;255;3;0;2;
      19640828 GWT:RFC:MSG=0;255;3;0;2;
      19650917 GWT:RFC:MSG=0;255;3;0;2;
      19661007 GWT:RFC:MSG=0;255;3;0;2;
      19671098 GWT:RFC:MSG=0;255;3;0;2;
      19681187 GWT:RFC:MSG=0;255;3;0;2;
      19691277 GWT:RFC:MSG=0;255;3;0;2;
      19701367 GWT:RFC:MSG=0;255;3;0;2;
      19711457 GWT:RFC:MSG=0;255;3;0;2;
      19721546 GWT:RFC:MSG=0;255;3;0;2;
      19731637 GWT:RFC:MSG=0;255;3;0;2;
      19741726 GWT:RFC:MSG=0;255;3;0;2;
      
      

      Again, please correct me if I'm wrong but I believe this is telling me that the gateway and HA are communicating?

      The issue, and where I am currently stuck is that my sensor won't connect to the gateway. I have cleared the EEPROM from the board (using the MySensors clear eeprom sketch) and removed the ID from the sketch before uploading it again. I've done the same on the repeater and switched the boards for brand new ones but get the same issue each time.

       __  __       ____
      |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
      | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
      | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
      |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
              |___/                      2.3.2
      
      16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2
      26 TSM:INIT
      28 TSF:WUR:MS=0
      34 TSM:INIT:TSP OK
      36 TSM:FPAR
      38 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      2048 !TSM:FPAR:NO REPLY
      2050 TSM:FPAR
      2052 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      4060 !TSM:FPAR:NO REPLY
      4062 TSM:FPAR
      4064 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      6072 !TSM:FPAR:NO REPLY
      6074 TSM:FPAR
      6076 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      8084 !TSM:FPAR:FAIL
      8085 TSM:FAIL:CNT=1
      8087 TSM:FAIL:DIS
      8089 TSF:TDI:TSL
      

      This just loops with the count incrementing by one each time. There is nothing on the gateway serial monitor beyond the messages in the log above. It doesn't even seem to be aware anything is trying to communicate with it.

      I have looked through the Debug info on the MySensors website and I think I have an understanding of what is happening based on the values for s,c,t. (I'm assuming s=255 is like a broadcast message rather than a defined value for the sensor). The line TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK is the sensor looking for the gateway and the next line !TSM:FPAR:NO REPLY is saying there is no response.

      I'm sure I have missed something blindingly obvious but no amount of reading or research has helped me, so I'd be very grateful if someone could point a newbie in the right direction!

      The sketch for Gateway is:

      
      // 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 below
      
      
      
      // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
      
      #define MY_IP_ADDRESS 192,168,86,19
      
      
      
      // If using static ip you can define Gateway and Subnet address as well
      
      #define MY_IP_GATEWAY_ADDRESS 192,168,86,1
      
      #define MY_IP_SUBNET_ADDRESS 255,255,254,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, 178, 254
      
      
      
      // 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 0xBE, 0x93, 0x51, 0x91, 0xF0, 0x22
      
      
      
      // 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>
      
      
      
      void setup()
      
      {
      
        // Setup locally attached sensors
      
      }
      
      
      
      void presentation()
      
      {
      
        // Present locally attached sensors here
      
      }
      
      
      
      void loop()
      
      {
      
        // Send locally attached sensors data here
      
      }
      

      The sketch for the sensor is:

      
      // Enable debug prints
      #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
      
      //define ID
      //#define MY_NODE_ID 1
      
      #include <MySensors.h>
      
      uint32_t SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
      #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      #define CHILD_ID 1   // Id of the sensor child
      
      
      
      // Initialize motion message
      MyMessage msg(CHILD_ID, V_TRIPPED);
      
      void setup()
      {
          pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
      }
      
      void presentation()
      {
          // Send the sketch version information to the gateway and Controller
          sendSketchInfo("Motion Sensor", "1.0");
      
          // Register all sensors to gw (they will be created as child devices)
          present(CHILD_ID, S_MOTION);
      }
      
      void loop()
      {
          // Read digital motion value
          bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
      
          Serial.println(tripped);
          send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
      
          // Sleep until interrupt comes in on motion sensor. Send update every two minute.
          sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
      }
      
      posted in Home Assistant
      Steve Parsons
      Steve Parsons
    • RE: [SOLVED] BH1750 Light level sensor not reading after sleep

      Ok, so I have managed to get it working. I switched out the BH1750 for a new one and it was reading successfully after sleep and updating the controller, although the level wasn't changing regardless of how light/dark it was.

      I reverted back to my original code (so taking out the 'ONE_TIME_HIGH_RES_MODE') and it all appears to be working as expected, updating the level and the sensor on the controller.

      Thanks for your help, looks like it was a duff sensor in the end! Now just need to get it working with my 'multi sensor' 🙂

      posted in Troubleshooting
      Steve Parsons
      Steve Parsons

    Latest posts made by Steve Parsons

    • RE: [SOLVED] BH1750 Light level sensor not reading after sleep

      Ok, so I have managed to get it working. I switched out the BH1750 for a new one and it was reading successfully after sleep and updating the controller, although the level wasn't changing regardless of how light/dark it was.

      I reverted back to my original code (so taking out the 'ONE_TIME_HIGH_RES_MODE') and it all appears to be working as expected, updating the level and the sensor on the controller.

      Thanks for your help, looks like it was a duff sensor in the end! Now just need to get it working with my 'multi sensor' 🙂

      posted in Troubleshooting
      Steve Parsons
      Steve Parsons
    • RE: [SOLVED] BH1750 Light level sensor not reading after sleep

      @virtualmkr thank you for taking the time to read my post and offering a solution.

      I've amended my setup as follows:

      void setup()  
      { 
        lightSensor.begin(BH1750::ONE_TIME_HIGH_RES_MODE);
      }
      

      I also amended my loop to the following:

      Serial.println("Reading Light Level");
        Serial.println("First Read");
        lightSensor.readLightLevel();
        wait(20);
        Serial.println("Second Read & Variable Set");
        lux = lightSensor.readLightLevel();  // Get Lux value
        wait(20);
      

      But I'm still having the same issue. I added the first and second read serial output lines for debugging so I could see where it stops, and it still hangs on the first read after sleep:

       __  __       ____
      |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
      | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
      | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
      |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
              |___/                      2.3.2
      
      16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2
      26 TSM:INIT
      28 TSF:WUR:MS=0
      34 TSM:INIT:TSP OK
      36 TSM:INIT:STATID=95
      38 TSF:SID:OK,ID=95
      39 TSM:FPAR
      44 ?TSF:MSG:SEND,95-95-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      396 TSF:MSG:READ,0-0-95,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      401 TSF:MSG:FPAR PREF
      403 TSF:MSG:FPAR OK,ID=0,D=1
      405 TSM:FPAR:OK
      407 TSM:ID
      408 TSM:ID:OK
      409 TSM:UPL
      446 !TSF:MSG:SEND,95-95-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1
      698 TSF:MSG:READ,11-11-95,s=255,c=3,t=8,pt=1,l=1,sg=0:1
      703 !TSF:MSG:FPAR INACTIVE
      2453 TSM:UPL
      2456 TSF:MSG:SEND,95-95-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=1,st=OK:1
      2467 TSF:MSG:READ,0-0-95,s=255,c=3,t=25,pt=1,l=1,sg=0:1
      2472 TSF:MSG:PONG RECV,HP=1
      2475 TSM:UPL:OK
      2477 TSM:READY:ID=95,PAR=0,DIS=1
      2482 TSF:MSG:SEND,95-95-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
      2491 TSF:MSG:READ,0-0-95,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
      2498 TSF:MSG:SEND,95-95-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
      2507 TSF:MSG:SEND,95-95-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
      2536 TSF:MSG:READ,0-0-95,s=255,c=3,t=6,pt=0,l=1,sg=0:M
      2543 TSF:MSG:SEND,95-95-0-0,s=255,c=3,t=11,pt=0,l=16,sg=0,ft=0,st=OK:Light Lux Sensor
      2557 TSF:MSG:SEND,95-95-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
      2566 TSF:MSG:SEND,95-95-0-0,s=3,c=0,t=16,pt=0,l=0,sg=0,ft=0,st=OK:
      2572 MCO:REG:REQ
      2575 TSF:MSG:SEND,95-95-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
      2583 TSF:MSG:READ,0-0-95,s=255,c=3,t=27,pt=1,l=1,sg=0:1
      2588 MCO:PIM:NODE REG=1
      2590 MCO:BGN:STP
      2612 MCO:BGN:INIT OK,TSP=1
      Sending initial value
      2617 TSF:MSG:SEND,95-95-0-0,s=3,c=1,t=37,pt=3,l=2,sg=0,ft=0,st=OK:0
      Requesting initial value from controller
      2627 TSF:MSG:SEND,95-95-0-0,s=3,c=2,t=37,pt=0,l=0,sg=0,ft=0,st=OK:
      2652 TSF:MSG:READ,0-0-95,s=3,c=1,t=37,pt=0,l=1,sg=0:0
      Receiving initial value from controller
      Reading Light Level
      First Read
      Second Read & Variable Set
      Value is: 10
      12701 TSF:MSG:SEND,95-95-0-0,s=3,c=1,t=37,pt=3,l=2,sg=0,ft=0,st=OK:10
      12707 MCO:SLP:MS=10000,SMS=0,I1=255,M1=255,I2=255,M2=255
      12712 TSF:TDI:TSL
      12715 MCO:SLP:WUP=-1
      12717 TSF:TRI:TSB
      Reading Light Level
      First Read
      
      

      It just stops here and never goes anywhere.

      I should probably add that I am using a Nano (clone), wired up as per the BH1750 example on the MySensors site. It's powered through USB, and have tried a different Nano, and NRF24L01 without success.

      I took delivery of some more BH1750's today so going to solder one of those up and swap it out to see if that makes any difference!

      posted in Troubleshooting
      Steve Parsons
      Steve Parsons
    • [SOLVED] BH1750 Light level sensor not reading after sleep

      I'm having an issue with a BH1750 light sensor where it only reads once and won't read again if I use sleep. I was initially building a multi sensor for motion, temperature and light level, and got the motion and temperature working fine, but hit this issue when adding the light level sensor. I assumed it was my code so stripped the whole thing back to basics and created a basic sensor with just an Arduino and the BH1750, all worked fine reading the levels.

      I then tried to create just a light level sensor using mysensors and even when using the example code had the issue where it would read once and send the info to the controller, but then just hangs on the second read (after sleeping). Specifically this line:

      lux = lightSensor.readLightLevel();
      

      I can make it work by removing the sleep command and adding a delay, but this is no good if I want to use it with a motion sensor!

      I've searched the forums and stumbled across this thread with a similar issue but the resolution was to use 2.3.1 beta and I am on 2.3.2 already. I also tried adding waits either side of the point where it hangs to give the sensor time to wake up after sleep, but that didn't help either!

      My code (which is derived from the mysensors sample code and the homeassistant sample, which happens to be for this exact sensor!!):

      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_RFM69
      
      //define ID
      #define MY_NODE_ID 95
      #define MY_PARENT_NODE_ID 0
      
      #include <MySensors.h>  
      #include <BH1750.h>
      #include <Wire.h>
      
      #define LIGHT_CHILD_ID 3
      unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) (shortened for testing purposes!)
      
      BH1750 lightSensor;
      
      MyMessage msg(LIGHT_CHILD_ID, V_LEVEL);
      uint16_t lastlux = 0;
      uint16_t lux;
      bool initialValueSent = false;
      
      void setup()  
      { 
        lightSensor.begin();
      }
      
      void presentation()  {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Light Lux Sensor", "1.0");
      
        // Register all sensors to gateway (they will be created as child devices)
        present(LIGHT_CHILD_ID, S_LIGHT_LEVEL);
      }
      
      void loop()
      {
        if (!initialValueSent) {
          Serial.println("Sending initial value");
          send(msg.set(lastlux));
          Serial.println("Requesting initial value from controller");
          request(LIGHT_CHILD_ID, V_LEVEL);
          wait(2000, C_SET, V_LEVEL);
        }
        wait(10000);
        Serial.println("Reading Light Level"); //added for debugging
        lux = lightSensor.readLightLevel();  // Get Lux value
        wait(20);
        Serial.print("Value is: ");
        Serial.println(lux); //added for debugging
        if (lux != lastlux) {
            send(msg.set(lux));
            lastlux = lux;
        }
      
        sleep(SLEEP_TIME);
      }
      
      void receive(const MyMessage &message) {
        if (message.type == V_LEVEL) {
          if (!initialValueSent) {
            Serial.println("Receiving initial value from controller");
            initialValueSent = true;
          }
        }
      }
      

      The serial monitor output is:

       __  __       ____
      |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
      | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
      | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
      |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
              |___/                      2.3.2
      
      16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2
      26 TSM:INIT
      28 TSF:WUR:MS=0
      34 TSM:INIT:TSP OK
      36 TSM:INIT:STATID=95
      38 TSF:SID:OK,ID=95
      39 TSM:FPAR
      44 ?TSF:MSG:SEND,95-95-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      632 TSF:MSG:READ,11-11-95,s=255,c=3,t=8,pt=1,l=1,sg=0:1
      637 TSF:MSG:FPAR OK,ID=11,D=2
      2052 TSM:FPAR:OK
      2053 TSM:ID
      2054 TSM:ID:OK
      2056 TSM:UPL
      2059 TSF:MSG:SEND,95-95-11-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      2081 TSF:MSG:READ,0-11-95,s=255,c=3,t=25,pt=1,l=1,sg=0:2
      2086 TSF:MSG:PONG RECV,HP=2
      2089 TSM:UPL:OK
      2091 TSM:READY:ID=95,PAR=11,DIS=2
      2096 TSF:MSG:SEND,95-95-11-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
      2106 TSF:MSG:READ,0-11-95,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
      2118 TSF:MSG:SEND,95-95-11-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
      2126 TSF:MSG:SEND,95-95-11-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:11
      2163 TSF:MSG:READ,0-11-95,s=255,c=3,t=6,pt=0,l=1,sg=0:M
      2170 TSF:MSG:SEND,95-95-11-0,s=255,c=3,t=11,pt=0,l=16,sg=0,ft=0,st=OK:Light Lux Sensor
      2181 TSF:MSG:SEND,95-95-11-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
      2198 TSF:MSG:SEND,95-95-11-0,s=3,c=0,t=16,pt=0,l=0,sg=0,ft=0,st=OK:
      2204 MCO:REG:REQ
      2211 TSF:MSG:SEND,95-95-11-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
      2225 TSF:MSG:READ,0-11-95,s=255,c=3,t=27,pt=1,l=1,sg=0:1
      2230 MCO:PIM:NODE REG=1
      2233 MCO:BGN:STP
      2254 MCO:BGN:INIT OK,TSP=1
      2257 TSF:MSG:READ,0-11-95,s=255,c=3,t=27,pt=1,l=1,sg=0:1
      2263 MCO:PIM:NODE REG=1
      Sending initial value
      2271 TSF:MSG:SEND,95-95-11-0,s=3,c=1,t=37,pt=3,l=2,sg=0,ft=0,st=OK:0
      Requesting initial value from controller
      2279 TSF:MSG:SEND,95-95-11-0,s=3,c=2,t=37,pt=0,l=0,sg=0,ft=0,st=OK:
      2318 TSF:MSG:READ,0-11-95,s=3,c=1,t=37,pt=0,l=1,sg=0:0
      Receiving initial value from controller
      Reading Light Level
      Value is: 4
      12344 TSF:MSG:SEND,95-95-11-0,s=3,c=1,t=37,pt=3,l=2,sg=0,ft=0,st=OK:4
      12351 MCO:SLP:MS=10000,SMS=0,I1=255,M1=255,I2=255,M2=255
      12356 TSF:TDI:TSL
      12358 MCO:SLP:WUP=-1
      12360 TSF:TRI:TSB
      Reading Light Level
      
      

      My controller is Homeassistant, and it get's the initial read from the sensor fine. If I remove the sleep command it works and the sensor updates in homeassistant when the level changes but clearly it loops without a sleep/delay and therefore sends the data way more frequently than I want/need!

      My ultimate goal is to add the sensor to my 'multi sensor' but I've hit this stumbling block just creating a basic light level sensor. Any help/advice would be gratefully received as I am completely stuck at this point.

      Thanks in advance!

      posted in Troubleshooting
      Steve Parsons
      Steve Parsons
    • RE: Sensors won't connect to Gateway after adding Controller

      Thank you so much @BearWithBeard for this, it's really helpful.

      I decided to try using a serial gateway and have had more success. The sensor is connecting and getting an ID from the controller. Although the gateway drops out when i reboot my Pi and I have to unplug, reconnect and restart HA! Not the end of the world, and certainly better than no connection, but a bit annoying.

      I'd like to use an Ethernet gateway if I can so I'll try your suggestion of static ID's and see what happens. I like the idea of organising things as you suggest, so may well end up doing that anyway. I'll try the static route to the gateway too if still no luck - very useful info.

      I'm using Uno's at the minute while I test/set it up and am powering them via USB from a laptop (sensor) and an NUC (Gateway). Although my serial gateway is connected via USB to the Pi running HA. No capacitors at this point either. They are within a few metres of each other so don't think range is the problem.

      Will amend my HA Config as you suggest, again useful info.

      Only other thing I didn't mention is I'm using a 5100 shield breakout board on the gateway rather than the board in the tutorial, not sure if this affects power or is relevant!

      Again, thank you, really appreciate your advice! I was completely stuck so really nice to have options now.

      posted in Home Assistant
      Steve Parsons
      Steve Parsons
    • RE: Sensors won't connect to Gateway after adding Controller

      @mntlvr thank you for taking the time to read my post and to respond. I have tried swapping out the nrf24l01 board on both the gateway and the sensor with brand new ones and still have the same issue. What I can't understand is why it works with no controller and assigned static ID's, but then not when a controller is connected.

      posted in Home Assistant
      Steve Parsons
      Steve Parsons
    • Sensors won't connect to Gateway after adding Controller

      Hello,

      I've posted this in the HA Forums too but hoping someone here might be able to help too

      I am stuck setting up MySensors and if anyone could help me I would be very grateful. I am completely new to Arduino's and the syntax (and I'm not a programmer anyway!) so I am aware I'm on a steep learning curve here!

      I have followed the tutorials to set up an Ethernet Gateway and a basic motion sensor. I then assigned static ID's to these as at this point I wasn't using a controller and I could get the two to talk successfully. I used the serial monitor to check both devices and when I wave my hand in front of the sensor I get the following:

      Sensor:

      42401 MCO:SLP:WUP=1
      42403 TSF:TRI:TSB
      1
      42414 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:1
      42420 MCO:SLP:MS=120000,SMS=0,I1=1,M1=1,I2=255,M2=255
      42425 TSF:TDI:TSL
      42427 MCO:SLP:WUP=1
      42429 TSF:TRI:TSB
      0
      42439 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
      42445 MCO:SLP:MS=120000,SMS=0,I1=1,M1=1,I2=255,M2=255
      42450 TSF:TDI:TSL
      
      

      Gateway:

      18749588 TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:1
      18752809 TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      

      If I've misinterpreted this then please let me know, but it appears to me that the 1 (motion) and 0 (reset) on both devices almost simultaneously would suggest that they are communicating.

      I also set up a repeater and had communication between these, and could even pass the sensor data through it (we have thick walls so I took the sensor out of range and put the repeater in the middle).

      At this point I was thinking, this is all pretty easy, just need to hook it up to HA and I'll be away! However, I cannot get it to work. My understanding is that the controller - HA in this case - hands out the ID's to the nodes and therefore I don't want to define these in the sketch. I believe I am also right in saying that the gateway always has an ID of 0.

      I added the following to my HA configuration.yaml

      mysensors:
        gateways:
          - device: '192.168.86.19'
        version: '2.3.2'
      
      

      I restarted HA, and it appeared to be communicating as I was getting the following in the serial monitor for the gateway:

      19548847 GWT:RFC:MSG=0;255;3;0;2;
      19548853 GWT:RFC:MSG=255;255;3;0;20;
      19548859 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=1,l=1,sg=0,ft=0,st=OK:0
      19558932 GWT:RFC:MSG=0;255;3;0;2;
      19569021 GWT:RFC:MSG=0;255;3;0;2;
      19579111 GWT:RFC:MSG=0;255;3;0;2;
      19589199 GWT:RFC:MSG=0;255;3;0;2;
      19600464 GWT:RFC:MSG=0;255;3;0;2;
      19610560 GWT:RFC:MSG=0;255;3;0;2;
      19620649 GWT:RFC:MSG=0;255;3;0;2;
      19630739 GWT:RFC:MSG=0;255;3;0;2;
      19640828 GWT:RFC:MSG=0;255;3;0;2;
      19650917 GWT:RFC:MSG=0;255;3;0;2;
      19661007 GWT:RFC:MSG=0;255;3;0;2;
      19671098 GWT:RFC:MSG=0;255;3;0;2;
      19681187 GWT:RFC:MSG=0;255;3;0;2;
      19691277 GWT:RFC:MSG=0;255;3;0;2;
      19701367 GWT:RFC:MSG=0;255;3;0;2;
      19711457 GWT:RFC:MSG=0;255;3;0;2;
      19721546 GWT:RFC:MSG=0;255;3;0;2;
      19731637 GWT:RFC:MSG=0;255;3;0;2;
      19741726 GWT:RFC:MSG=0;255;3;0;2;
      
      

      Again, please correct me if I'm wrong but I believe this is telling me that the gateway and HA are communicating?

      The issue, and where I am currently stuck is that my sensor won't connect to the gateway. I have cleared the EEPROM from the board (using the MySensors clear eeprom sketch) and removed the ID from the sketch before uploading it again. I've done the same on the repeater and switched the boards for brand new ones but get the same issue each time.

       __  __       ____
      |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
      | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
      | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
      |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
              |___/                      2.3.2
      
      16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2
      26 TSM:INIT
      28 TSF:WUR:MS=0
      34 TSM:INIT:TSP OK
      36 TSM:FPAR
      38 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      2048 !TSM:FPAR:NO REPLY
      2050 TSM:FPAR
      2052 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      4060 !TSM:FPAR:NO REPLY
      4062 TSM:FPAR
      4064 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      6072 !TSM:FPAR:NO REPLY
      6074 TSM:FPAR
      6076 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      8084 !TSM:FPAR:FAIL
      8085 TSM:FAIL:CNT=1
      8087 TSM:FAIL:DIS
      8089 TSF:TDI:TSL
      

      This just loops with the count incrementing by one each time. There is nothing on the gateway serial monitor beyond the messages in the log above. It doesn't even seem to be aware anything is trying to communicate with it.

      I have looked through the Debug info on the MySensors website and I think I have an understanding of what is happening based on the values for s,c,t. (I'm assuming s=255 is like a broadcast message rather than a defined value for the sensor). The line TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK is the sensor looking for the gateway and the next line !TSM:FPAR:NO REPLY is saying there is no response.

      I'm sure I have missed something blindingly obvious but no amount of reading or research has helped me, so I'd be very grateful if someone could point a newbie in the right direction!

      The sketch for Gateway is:

      
      // 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 below
      
      
      
      // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
      
      #define MY_IP_ADDRESS 192,168,86,19
      
      
      
      // If using static ip you can define Gateway and Subnet address as well
      
      #define MY_IP_GATEWAY_ADDRESS 192,168,86,1
      
      #define MY_IP_SUBNET_ADDRESS 255,255,254,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, 178, 254
      
      
      
      // 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 0xBE, 0x93, 0x51, 0x91, 0xF0, 0x22
      
      
      
      // 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>
      
      
      
      void setup()
      
      {
      
        // Setup locally attached sensors
      
      }
      
      
      
      void presentation()
      
      {
      
        // Present locally attached sensors here
      
      }
      
      
      
      void loop()
      
      {
      
        // Send locally attached sensors data here
      
      }
      

      The sketch for the sensor is:

      
      // Enable debug prints
      #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
      
      //define ID
      //#define MY_NODE_ID 1
      
      #include <MySensors.h>
      
      uint32_t SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
      #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      #define CHILD_ID 1   // Id of the sensor child
      
      
      
      // Initialize motion message
      MyMessage msg(CHILD_ID, V_TRIPPED);
      
      void setup()
      {
          pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
      }
      
      void presentation()
      {
          // Send the sketch version information to the gateway and Controller
          sendSketchInfo("Motion Sensor", "1.0");
      
          // Register all sensors to gw (they will be created as child devices)
          present(CHILD_ID, S_MOTION);
      }
      
      void loop()
      {
          // Read digital motion value
          bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
      
          Serial.println(tripped);
          send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
      
          // Sleep until interrupt comes in on motion sensor. Send update every two minute.
          sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
      }
      
      posted in Home Assistant
      Steve Parsons
      Steve Parsons