Navigation

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

    adamp237

    @adamp237

    0
    Reputation
    7
    Posts
    360
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    adamp237 Follow

    Best posts made by adamp237

    This user hasn't posted anything yet.

    Latest posts made by adamp237

    • First time sending message from HA to MySensors

      Hi,

      I have been using MySensors with Home Assistant successfully for a few months now. I feel like I have a pretty good grasp on how to get the sensor (Arduino) to report a value to Home Assistant (RPi) over MQTT.

      The next step I'm trying to do is getting the sensor to do something based on a switch in Home Assistant.

      Basically what I want to do is use the Arduino to transmit a code via RF to control a Watts Clever RF power relay. I've already got the Arduino doing this based on a motion sensor but the only MySensor integration is reporting to HA what the status of the relay is.

      I've tried re purposing the relay actuator code for my use but the code is a bit beyond my Arduino coding knowledge. I just want to send a message from Home Assistant which is read by the Arduino and code is then run based on what that message says (eg on, off).

      Is there a tutorial or similar that anyone can link me to? My googling only results in complicated examples for particular things. I just need the bare bones so I can add what I want.

      I know this would not work because I made most of it up, but this is the type of thing I think I'm looking for:

      void receive(const MyMessage &message) {
          if (message.type == V_STATUS) {   // check for switch status
      status=message;    // This is where I start making up stuff to convey my intent
      if status == 'on'
      {
       mySwitch.send("110011110011000101010101");    \\Send RF code
       digitalWrite(13,HIGH);
       delay(500);
       digitalWrite(13,LOW);
       delay(1000);
        Serial.println("on");
        }
      else {
      mySwitch.send("110011110011000101011101");   \\Send RF code
       digitalWrite(13,HIGH);
       delay(500);
       digitalWrite(13,LOW);
       delay(1000);
        Serial.println("off");
      }
      }
      

      Also, what would I actually add to Home Assistant to make a switch (or button) send a line of MQTT to the sensor, and what would that line be?

      Sorry if this is a difficult and vague question to answer. I'm not expecting someone to explain how the whole thing works or write my code for me but any similar examples or links to tutorials would be very helpful.

      Thanks.

      Ps, just for reference here is my working code as it currently stands:

      
      // Enable debug prints
      //#define MY_DEBUG
      #define MY_CONTROLLER_IP_ADDRESS 192, 168, 1, 141
      #define MY_PORT 1883
      #define MY_MQTT_CLIENT_ID "mysensors-1"
      #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
      #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      
      //RF Codes here
      //Shed Lights attached to WATTS CLEVER 13578589
      #define shedlighton "110011110011000101011101"
      #define shedlightoff "110011110011000101010101"
      
      #include <MySensors.h>
      #include <RCSwitch.h>
      #include <SPI.h>
      unsigned long SLEEP_TIME = 12000; // 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
      
      // Initialize motion message
      MyMessage msgtrip(CHILD_ID, V_TRIPPED);
      MyMessage msglight(CHILD_ID, V_LIGHT);
      MyMessage msgrain(CHILD_ID, V_TEXT);
      
      RCSwitch mySwitch = RCSwitch();
      
      long previousTime = 0;        
      long interval = 5000;   
      int recentmotion = 0;
      unsigned long currentTime = 0;
      unsigned long differentTime = 0;
      
      const int sensorMin = 0;     // sensor minimum
      const int sensorMax = 1024;  // sensor maximum
      
      void setup()
      {
      	pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
      	// Transmitter is connected to Arduino Pin #10 
      	mySwitch.enableTransmit(4);
      
       // Optional set pulse length.
       mySwitch.setPulseLength(321);
      }
      
      void presentation()
      {
      	// Send the sketch version information to the gateway and Controller
      	sendSketchInfo("Motion Sensor Plus", "1.0");
      
      	// Register all sensors to gw (they will be created as child devices)
      	present(1, S_MOTION);
      }
      
      void loop()
      {
                Serial.println(millis());
      if(millis() > 20000 && digitalRead(DIGITAL_INPUT_SENSOR) == LOW){
        if(millis() > differentTime){
          recentmotion = 0;
                 send(msglight.set("Off"));
              previousTime = currentTime; 
                Serial.print("recentmotion=");
                Serial.println(recentmotion);
        }
      }
        if(recentmotion == 0) {
         
       mySwitch.send(shedlightoff);
       digitalWrite(13,HIGH);
       delay(500);
       digitalWrite(13,LOW);
       delay(1000);
        Serial.println("off");
        }
      	// Read digital motion value
      	bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
      
      	Serial.println(tripped);
      	send(msgtrip.set(tripped?"1":"0"));  // Send tripped value to gw
        if(digitalRead(DIGITAL_INPUT_SENSOR) == HIGH){
            Serial.println("on");
         mySwitch.send(shedlighton);
       digitalWrite(13,HIGH);
       delay(500);
       digitalWrite(13,LOW);
       delay(2000); 
             recentmotion = 1;
             send(msglight.set("On"));
              differentTime = millis() + 20;
              Serial.print("differentTime=");
                      Serial.println(differentTime);
            Serial.print("recentmotion=");
                      Serial.println(recentmotion);
        }
      // rain sensor
      
      
      // read the sensor on analog A0:
        int sensorReading = analogRead(A0);
        // map the sensor range (four options):
        // ex: 'long int map(long int, long int, long int, long int, long int)'
        int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
        
        // range value:
        switch (range) {
       case 0:    // Sensor getting wet
          Serial.println("Flood");
          send(msgrain.set("Yes, heavy rain"));
          break;
       case 1:    // Sensor getting wet
          Serial.println("Rain Warning");
          send(msgrain.set("Light rain detected"));
          break;
       case 2:    // Sensor dry - To shut this up delete the " Serial.println("Not Raining"); " below.
          Serial.println("Not Raining");
          send(msgrain.set("No, it's not raining"));
          break;
        }
      
      
      	// 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
      adamp237
      adamp237
    • RE: Payload always 0 when using Arduino Pro Mini

      You are all actually amazing and I appreciate your time. Thanks.

      posted in Troubleshooting
      adamp237
      adamp237
    • RE: Payload always 0 when using Arduino Pro Mini

      Reinstalled. It all went smoothly. Still sending 0 bytes of data.

      posted in Troubleshooting
      adamp237
      adamp237
    • RE: Payload always 0 when using Arduino Pro Mini

      You're onto something I reckon, but I'm still not sure what! This might make more sense to you:

      So my MQTT shows this:

      Client mosqsub/2384-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/0/255/0/0/18', ... (5 bytes))
      2.1.1
      Client mosqsub/2384-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/255/255/3/0/3', ... (0 bytes))
      Client mosqsub/2384-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/255/255/3/0/3', ... (0 bytes))
      Client mosqsub/2384-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/255/255/3/0/3', ... (0 bytes))
      Client mosqsub/2384-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/255/255/3/0/3', ... (0 bytes))
      Client mosqsub/2384-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/255/255/3/0/3', ... (0 bytes))
      Client mosqsub/2384-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/255/255/3/0/3', ... (0 bytes))
      Client mosqsub/2384-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/255/255/3/0/3', ... (0 bytes))
      

      My Sensors did this:

      pi@raspberrypi:~/MySensors $ sudo ./bin/mysgw -d
      mysgw: Starting gateway...
      mysgw: Protocol version - 2.1.1
      mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.1
      mysgw: TSF:LRT:OK
      mysgw: TSM:INIT
      mysgw: TSF:WUR:MS=0
      mysgw: TSM:INIT:TSP OK
      mysgw: TSM:INIT:GW MODE
      mysgw: TSM:READY:ID=0,PAR=0,DIS=0
      mysgw: MCO:REG:NOT NEEDED
      mysgw: MCO:BGN:STP
      mysgw: MCO:BGN:INIT OK,TSP=1
      mysgw: Attempting MQTT connection...
      mysgw: connected to 127.0.0.1
      mysgw: MQTT connected
      mysgw: Sending message on topic: mysensors-out/0/255/0/0/18
      mysgw: TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0:
      mysgw: Sending message on topic: mysensors-out/255/255/3/0/3
      mysgw: TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0:
      mysgw: Sending message on topic: mysensors-out/255/255/3/0/3
      mysgw: send: Broken pipe
      mysgw: Attempting MQTT connection...
      mysgw: connected to 127.0.0.1
      mysgw: MQTT connected
      mysgw: Sending message on topic: mysensors-out/0/255/0/0/18
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,7!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      mysgw: TSF:MSG:READ,7-7-7,s=7,c=7,t=7,pt=0,l=0,sg=1:
      mysgw: !TSF:MSG:LEN,0!=32
      

      Then the Arduino Serial shows a fail to connect and nothing happens:

      0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
      3 MCO:BGN:BFR
      5 TSM:INIT
      6 TSF:WUR:MS=0
      13 TSM:INIT:TSP OK
      15 TSM:FPAR
      17 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      2024 !TSM:FPAR:NO REPLY
      2026 TSM:FPAR
      2028 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      4036 !TSM:FPAR:NO REPLY
      4038 TSM:FPAR
      4040 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      6048 !TSM:FPAR:NO REPLY
      6050 TSM:FPAR
      6052 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      8061 !TSM:FPAR:FAIL
      8062 TSM:FAIL:CNT=1
      8065 TSM:FAIL:PDT
      18068 TSM:FAIL:RE-INIT
      18070 TSM:INIT
      18077 TSM:INIT:TSP OK
      18079 TSM:FPAR
      18081 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      20089 !TSM:FPAR:NO REPLY
      20091 TSM:FPAR
      20093 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      22102 !TSM:FPAR:NO REPLY
      22104 TSM:FPAR
      22106 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      24114 !TSM:FPAR:NO REPLY
      24116 TSM:FPAR
      24118 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      26126 !TSM:FPAR:FAIL
      26127 TSM:FAIL:CNT=2
      26129 TSM:FAIL:PDT
      36132 TSM:FAIL:RE-INIT
      36134 TSM:INIT
      36142 TSM:INIT:TSP OK
      36144 TSM:FPAR
      36146 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      38154 !TSM:FPAR:NO REPLY
      38156 TSM:FPAR
      38158 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      40166 !TSM:FPAR:NO REPLY
      40168 TSM:FPAR
      40170 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      42178 !TSM:FPAR:NO REPLY
      42180 TSM:FPAR
      42182 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      44190 !TSM:FPAR:FAIL
      44191 TSM:FAIL:CNT=3
      44193 TSM:FAIL:PDT
      54196 TSM:FAIL:RE-INIT
      54198 TSM:INIT
      54205 TSM:INIT:TSP OK
      54207 TSM:FPAR
      54209 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      56217 !TSM:FPAR:NO REPLY
      56219 TSM:FPAR
      56221 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      58229 !TSM:FPAR:NO REPLY
      58231 TSM:FPAR
      58233 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      60242 !TSM:FPAR:NO REPLY
      60244 TSM:FPAR
      60247 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      62255 !TSM:FPAR:FAIL
      62256 TSM:FAIL:CNT=4
      62258 TSM:FAIL:PDT
      72261 TSM:FAIL:RE-INIT
      72263 TSM:INIT
      72270 TSM:INIT:TSP OK
      72272 TSM:FPAR
      72274 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      72290 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      72295 TSF:MSG:FPAR OK,ID=0,D=1
      74283 TSM:FPAR:OK
      74284 TSM:ID
      74285 TSM:ID:REQ
      74288 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      76296 TSM:ID
      76297 TSM:ID:REQ
      76300 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      78307 TSM:ID
      78308 TSM:ID:REQ
      78311 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      80318 TSM:ID
      80319 TSM:ID:REQ
      80322 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      82329 !TSM:ID:FAIL
      82330 TSM:FAIL:CNT=5
      82332 TSM:FAIL:PDT
      92335 TSM:FAIL:RE-INIT
      92337 TSM:INIT
      92344 TSM:INIT:TSP OK
      92346 TSM:FPAR
      92348 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      92983 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      92988 TSF:MSG:FPAR OK,ID=0,D=1
      94356 TSM:FPAR:OK
      94357 TSM:ID
      94359 TSM:ID:REQ
      94361 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      96369 TSM:ID
      96370 TSM:ID:REQ
      96373 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      98380 TSM:ID
      98381 TSM:ID:REQ
      98384 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      100392 TSM:ID
      100393 TSM:ID:REQ
      100397 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      102404 !TSM:ID:FAIL
      102405 TSM:FAIL:CNT=6
      102408 TSM:FAIL:PDT
      112410 TSM:FAIL:RE-INIT
      112412 TSM:INIT
      112419 TSM:INIT:TSP OK
      112421 TSM:FPAR
      112424 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      112640 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      112645 TSF:MSG:FPAR OK,ID=0,D=1
      114432 TSM:FPAR:OK
      114433 TSM:ID
      114435 TSM:ID:REQ
      114438 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      116445 TSM:ID
      116446 TSM:ID:REQ
      116449 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      118456 TSM:ID
      118457 TSM:ID:REQ
      118460 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      120467 TSM:ID
      120468 TSM:ID:REQ
      120471 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      122478 !TSM:ID:FAIL
      122479 TSM:FAIL:CNT=7
      122482 TSM:FAIL:PDT
      182484 TSM:FAIL:RE-INIT
      182487 TSM:INIT
      182494 TSM:INIT:TSP OK
      182496 TSM:FPAR
      182499 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      184506 !TSM:FPAR:NO REPLY
      184508 TSM:FPAR
      184511 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      186518 !TSM:FPAR:NO REPLY
      186520 TSM:FPAR
      186523 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      188530 !TSM:FPAR:NO REPLY
      188532 TSM:FPAR
      188535 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      190542 !TSM:FPAR:FAIL
      190544 TSM:FAIL:CNT=7
      190546 TSM:FAIL:PDT
      250549 TSM:FAIL:RE-INIT
      250551 TSM:INIT
      250558 TSM:INIT:TSP OK
      250560 TSM:FPAR
      250563 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      252570 !TSM:FPAR:NO REPLY
      252572 TSM:FPAR
      252575 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      254582 !TSM:FPAR:NO REPLY
      254584 TSM:FPAR
      254587 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      256595 !TSM:FPAR:NO REPLY
      256598 TSM:FPAR
      256601 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      258608 !TSM:FPAR:FAIL
      258610 TSM:FAIL:CNT=7
      258612 TSM:FAIL:PDT
      318615 TSM:FAIL:RE-INIT
      318617 TSM:INIT
      318624 TSM:INIT:TSP OK
      318626 TSM:FPAR
      318629 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      320637 !TSM:FPAR:NO REPLY
      320640 TSM:FPAR
      320643 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      322650 !TSM:FPAR:NO REPLY
      322652 TSM:FPAR
      322655 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      324662 !TSM:FPAR:NO REPLY
      324664 TSM:FPAR
      324667 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      326674 !TSM:FPAR:FAIL
      326676 TSM:FAIL:CNT=7
      326678 TSM:FAIL:PDT
      

      Unless you can work out anything specific, I'll try reinstalling MySensors on my Pi. The initial installation did not go smoothly. I just figured that if it was working fine with the Uno, it was working fine full stop.

      posted in Troubleshooting
      adamp237
      adamp237
    • RE: Payload always 0 when using Arduino Pro Mini

      I did try this. It is sending 4 messages before failing. I'm not really sure what this means though?

      posted in Troubleshooting
      adamp237
      adamp237
    • Payload always 0 when using Arduino Pro Mini

      Hi,

      I've been using MySensors with HomeAssistant fairly successfully, testing on my Arduino Uno (Genuine).

      Everything works fine with the UNO, so I purchased some no so genuine Arduino Nanos and Pro Mini (5v and 3.3v version). With all of these boards I've had an issue of never being able to receive any usable data from the sensors.

      I will explain with my most current example which I have poured hours into with no luck:

      I have set up my UNO with the temperature sketch which works a treat using the waterproof DS18B20. I copied the exact same sketch with the exact same connections to an Arduino Pro Mini 3.3v and it seems to work through MQTT but I'm always receiving no actual data. Where it should show "13.2" for example, it shows "".

      I changed to the Arduino Pro Mini 5v with a 3.3v regulator and it does the exact same thing.

      When I warm the sensor up with my hand it shoots off lots of messages as if the code has recognised the change in temp but all of those messages have "".

      This happened on a previous project when I tried a Nano. Everything seems to work, but no data!

      I've tried different radios etc but it doesn't seem to make a difference.

      I will admit I don't really understand it all, I'm more of a copy paste type guy but all of my debugging has got me nowhere. I am guessing there's nothing wrong with the code, I'm not changing it at all, I'm just changing the board in the Arduino software.

      Using: Arduino 1.6.12 on Windows, powering by USB (FTD1232 for Pro Minis). I've tried different power supplies also.

      Serial output:

      0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
      3 MCO:BGN:BFR
      63 TSM:INIT
      64 TSF:WUR:MS=0
      71 TSM:INIT:TSP OK
      73 TSM:FPAR
      75 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      712 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      717 TSF:MSG:FPAR OK,ID=0,D=1
      2082 TSM:FPAR:OK
      2083 TSM:ID
      2084 TSM:ID:REQ
      2087 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      4096 TSM:ID
      4097 TSM:ID:REQ
      4099 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      6107 TSM:ID
      6108 TSM:ID:REQ
      6110 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      8118 TSM:ID
      8119 TSM:ID:REQ
      8121 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      10129 !TSM:ID:FAIL
      10130 TSM:FAIL:CNT=1
      10132 TSM:FAIL:PDT
      20135 TSM:FAIL:RE-INIT
      20137 TSM:INIT
      20145 TSM:INIT:TSP OK
      20147 TSM:FPAR
      20149 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      20369 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      20374 TSF:MSG:FPAR OK,ID=0,D=1
      22157 TSM:FPAR:OK
      22158 TSM:ID
      22160 TSM:ID:REQ
      22162 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      24170 TSM:ID
      24171 TSM:ID:REQ
      24174 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      26181 TSM:ID
      26182 TSM:ID:REQ
      26185 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      28192 TSM:ID
      28193 TSM:ID:REQ
      28196 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      30204 !TSM:ID:FAIL
      30205 TSM:FAIL:CNT=2
      30208 TSM:FAIL:PDT
      40211 TSM:FAIL:RE-INIT
      40213 TSM:INIT
      40220 TSM:INIT:TSP OK
      40222 TSM:FPAR
      40224 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      41061 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      41066 TSF:MSG:FPAR OK,ID=0,D=1
      42232 TSM:FPAR:OK
      42233 TSM:ID
      42235 TSM:ID:REQ
      42237 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      44246 TSM:ID
      44247 TSM:ID:REQ
      44250 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      46257 TSM:ID
      46258 TSM:ID:REQ
      46261 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      48268 TSM:ID
      48269 TSM:ID:REQ
      48272 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      50279 !TSM:ID:FAIL
      50280 TSM:FAIL:CNT=3
      50282 TSM:FAIL:PDT
      60285 TSM:FAIL:RE-INIT
      60288 TSM:INIT
      60295 TSM:INIT:TSP OK
      60297 TSM:FPAR
      60299 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      60737 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      60742 TSF:MSG:FPAR OK,ID=0,D=1
      62307 TSM:FPAR:OK
      62308 TSM:ID
      62310 TSM:ID:REQ
      62312 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      64320 TSM:ID
      64321 TSM:ID:REQ
      64324 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      66331 TSM:ID
      66332 TSM:ID:REQ
      66335 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      68342 TSM:ID
      68343 TSM:ID:REQ
      68346 TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      70354 !TSM:ID:FAIL
      70355 TSM:FAIL:CNT=4
      70358 TSM:FAIL:PDT
      

      Arduino sketch:

      /**
       * 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.
       *
       *******************************
       *
       * DESCRIPTION
       *
       * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
       * http://www.mysensors.org/build/temp
       */
      
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      #define MY_MQTT_USER "pi"
      #define MY_MQTT_PASSWORD "masked"
      #define MY_CONTROLLER_IP_ADDRESS 192, 168, 1, 141
      #define MY_PORT 1883
      
      #include <SPI.h>
      #include <MySensors.h>  
      #include <DallasTemperature.h>
      #include <OneWire.h>
      
      #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
      
      #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
      #define MAX_ATTACHED_DS18B20 16
      unsigned long SLEEP_TIME = 300; // Sleep time between reads (in milliseconds)
      OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
      DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
      float lastTemperature[MAX_ATTACHED_DS18B20];
      int numSensors=0;
      bool receivedConfig = false;
      bool metric = true;
      // Initialize temperature message
      MyMessage msg(0,V_TEMP);
      
      void before()
      {
        // Startup up the OneWire library
        sensors.begin();
      }
      
      void setup()  
      { 
        // requestTemperatures() will not block current thread
        sensors.setWaitForConversion(false);
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Temperature Sensor", "1.1");
      
        // Fetch the number of attached temperature sensors  
        numSensors = sensors.getDeviceCount();
      
        // Present all sensors to controller
        for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {   
           present(i, S_TEMP);
        }
      }
      
      void loop()     
      {     
        // Fetch temperatures from Dallas sensors
        sensors.requestTemperatures();
      Serial.println("Start");
        // query conversion time and sleep until conversion completed
        int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
        // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
        sleep(conversionTime);
      
        // Read temperatures and send them to controller 
        for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
      
          // Fetch and round temperature to one decimal
          float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
      
          // Only send data if temperature has changed and no error
          #if COMPARE_TEMP == 1
          if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
          #else
          if (temperature != -127.00 && temperature != 85.00) {
          #endif
      
            // Send in the new temperature
            Serial.println(temperature);
            send(msg.setSensor(i).set(temperature,1));
            // Save new temperatures for next compare
            lastTemperature[i]=temperature;
          }
        }
        sleep(SLEEP_TIME);
      }
      
      posted in Troubleshooting
      adamp237
      adamp237
    • RE: 💬 Connecting the Radio

      I had this working perfectly on my Arduino Uno. I soldered it up to my Arduino Nano and it seems to work ok, but I'm not getting any data sent. The serial says it's connected OK but never sends any motion 1s or 0s. My MQTT server shows the following: Client mosqsub/3449-raspberryp received PUBLISH (d0, q0, r0, m0, 'mygateway1-out/255/255/3/0/3', ... (0 bytes))

      Any idea what is going on? I've tested the motion sensor separately and that is sending a high value to pin 3 no worries.

      posted in Announcements
      adamp237
      adamp237