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. Bug Reports
  3. Strange value being sent from controller using mixed temp/relay node

Strange value being sent from controller using mixed temp/relay node

Scheduled Pinned Locked Moved Bug Reports
multiple sensormqtterror
42 Posts 6 Posters 16.9k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • caycoC Offline
    caycoC Offline
    cayco
    wrote on last edited by cayco
    #33

    Hi! I'm starting to play with relay and I experiencing somethings similar. I have 3 sensors (two of them works great, just temperature, volt, light and humidity) one is relay sensor. First of all it just doesn't react to my commands:

    mosquitto_pub -p 1883 -h 10.0.0.11 -t MyMQTT/22/1/V_LIGHT -m "1"
    

    serial shows just this:

    connecting at 115200
    repeater started, id 22
    send: 22-22-0-0 s=255,c=0,t=18,pt=0,l=3,st=ok:1.4
    send: 22-22-0-0 s=255,c=3,t=6,pt=1,l=1,st=fail:0
    send: 22-22-0-0 s=255,c=3,t=11,pt=0,l=12,st=ok:Relay sketch
    send: 22-22-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
    send: 22-22-0-0 s=1,c=0,t=3,pt=0,l=3,st=ok:1.4
    

    I'm using stock http://www.mysensors.org/build/relay code, just setting node_id manually to 22.

    On the controller I have:

    0;0;3;0;9;read: 21-21-0 s=11,c=1,t=0,pt=7,l=5:23.0
    publish: MyMQTT/21/11/V_TEMP 23.0
    0;0;3;0;9;send: 0-0-21-21 s=11,c=1,t=0,pt=0,l=7,st=fail:23.0001
    0;0;3;0;9;send: 0-0-22-22 s=1,c=1,t=2,pt=0,l=7,st=fail:13.0001
    

    It looks like it tries to send '1' with garbage from last sensor read.

    It does this with my humidity sensor:

    publish: MyMQTT/21/12/V_VOLTAGE 5001
    0;0;3;0;9;send: 0-0-21-21 s=12,c=1,t=38,pt=0,l=4,st=ok:5001
    0;0;3;0;9;read: 21-21-0 s=10,c=1,t=1,pt=7,l=5:52.0
    publish: MyMQTT/21/10/V_HUM 52.0
    0;0;3;0;9;send: 0-0-21-21 s=10,c=1,t=1,pt=0,l=8,st=fail:52.05001
    

    I am also using MQTT client gateway which @gadu recommended me.

    I did not understood how does this workaround @Gambituk mention work. Do you know what is going on above? What am I doing wrong?

    P.S. Using standart EthernetGateway code also scrambles messages (please note strange sing after '1'):

    0;0;3;0;9;read: 22-22-0 s=255,c=3,t=11,pt=0,l=12:Relay sketch
    0;0;3;0;9;read: 22-22-0 s=255,c=3,t=12,pt=0,l=3:1.0
    0;0;3;0;9;read: 22-22-0 s=1,c=0,t=3,pt=0,l=3:1.4
    0;0;3;0;9;send: 0-0-22-22 s=1,c=1,t=2,pt=0,l=2,st=ok:1à
    0;0;3;0;9;read: 0-1-22 s=1,c=1,t=2,pt=0,l=2:1à
    0;0;3;0;9;read: 21-21-0 s=12,c=1,t=38,pt=4,l=4:5023
    MyMQTT/21/12/V_VOLTAGE
    
    0;0;3;0;9;send: 0-0-22-22 s=1,c=1,t=2,pt=0,l=2,st=fail:1à
    

    after this relay node does not accept any message (you can see st=fail on the last line - that was me retrying mosquitto_pub -p 1883 -h 10.0.0.34 -t MyMQTT/22/1/V_LIGHT -m "1").

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Gambituk
      wrote on last edited by
      #34

      Sorry, i just saw this, do you still have the issue or is it resolved?

      1 Reply Last reply
      0
      • caycoC Offline
        caycoC Offline
        cayco
        wrote on last edited by
        #35

        I still have it. I need to check how this is (not)working in single sensor environment. I will laso try not to set IT manually. Only if I get some tim to do it...

        1 Reply Last reply
        0
        • caycoC Offline
          caycoC Offline
          cayco
          wrote on last edited by
          #36

          I have reconnected it again and it did just starte to work as it should from the start. I changed nothing. Strange...

          1 Reply Last reply
          0
          • G Offline
            G Offline
            Gambituk
            wrote on last edited by Gambituk
            #37

            What i think happens.. in my own way of thinking!

                                  1 2 3 4 5 6 7 8
                                  B a d v a l u e      something longer than expected
                                1 1 . 4 v a l u e        next value is 11.4 but longer value stays in a register somewhere
                                2 1 . 6 5 7 l u e       and is mixed with the next value -
                                1 2 . 5 5 7 l u e       until restart or overwrite -
            

            So i think there is something that needs to be changed to control the length of expected values or actual values to adapt to whatever data arrives.

            For my workaround, send 1.0 and 0.0 instead of 1 and 0 seems to force the sketch to round the value to 1 or 0 even when there is "1.0dvalue" as the received instruction.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              Gambituk
              wrote on last edited by
              #38

              http://forum.mysensors.org/topic/524/mqtt-client-gateway/29 There is a proposed solution in the following post, i will test and see if it helps, and report back.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                Gambituk
                wrote on last edited by
                #39

                Initial tests seem that it is now resolved with the fixed version of the mqttclient gateway as modified by fotofieber

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tjay4x4
                  wrote on last edited by
                  #40

                  I try this code on pro mini with Vera3 but then I implementing it I have a DOOR Switch instead of Ds18b20. So is it possile to show temperature on vera and what's wrong?

                  repeater started, id 1
                  send: 1-1-0-0 s=255,c=0,t=18,pt=0,l=5,st=ok:1.4.1
                  send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
                  send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=25,st=ok:Liquid warm floore relay 
                  send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
                  send: 1-1-0-0 s=0,c=0,t=0,pt=0,l=5,st=ok:1.4.1
                  send: 1-1-0-0 s=1,c=0,t=0,pt=0,l=5,st=ok:1.4.1
                  send: 1-1-0-0 s=2,c=0,t=0,pt=0,l=5,st=ok:1.4.1
                  send: 1-1-0-0 s=4,c=0,t=3,pt=0,l=5,st=ok:1.4.1
                  send: 1-1-0-0 s=5,c=0,t=3,pt=0,l=5,st=ok:1.4.1
                  send: 1-1-0-0 s=0,c=1,t=0,pt=7,l=5,st=ok:28.6
                  send: 1-1-0-0 s=1,c=1,t=0,pt=7,l=5,st=ok:28.2
                  send: 1-1-0-0 s=2,c=1,t=0,pt=7,l=5,st=ok:28.5
                  
                  hekH 1 Reply Last reply
                  0
                  • T tjay4x4

                    I try this code on pro mini with Vera3 but then I implementing it I have a DOOR Switch instead of Ds18b20. So is it possile to show temperature on vera and what's wrong?

                    repeater started, id 1
                    send: 1-1-0-0 s=255,c=0,t=18,pt=0,l=5,st=ok:1.4.1
                    send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
                    send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=25,st=ok:Liquid warm floore relay 
                    send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
                    send: 1-1-0-0 s=0,c=0,t=0,pt=0,l=5,st=ok:1.4.1
                    send: 1-1-0-0 s=1,c=0,t=0,pt=0,l=5,st=ok:1.4.1
                    send: 1-1-0-0 s=2,c=0,t=0,pt=0,l=5,st=ok:1.4.1
                    send: 1-1-0-0 s=4,c=0,t=3,pt=0,l=5,st=ok:1.4.1
                    send: 1-1-0-0 s=5,c=0,t=3,pt=0,l=5,st=ok:1.4.1
                    send: 1-1-0-0 s=0,c=1,t=0,pt=7,l=5,st=ok:28.6
                    send: 1-1-0-0 s=1,c=1,t=0,pt=7,l=5,st=ok:28.2
                    send: 1-1-0-0 s=2,c=1,t=0,pt=7,l=5,st=ok:28.5
                    
                    hekH Offline
                    hekH Offline
                    hek
                    Admin
                    wrote on last edited by
                    #41

                    @tjay4x4

                    We can't help you much without any code.

                    1 Reply Last reply
                    0
                    • G Gambituk

                      and here is the modified relay/temp sketch

                      // Running DS temperature sensor(s) and relay(s) on one mysensor arduino node
                          // Combines Onewire and Relay code
                          // 2014-10-14 Pego: Tested and Running on Uno/Clone and MQTT gateway
                          
                          // Example sketch showing how to send in OneWire temperature readings
                          // Example sketch showing how to control physical relays. 
                          // This example will remember relay state even after power failure.
                          
                          #include <MySensor.h>  
                          #include <SPI.h>
                          #include <DallasTemperature.h>
                          #include <OneWire.h>presen
                          
                          #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
                          #define MAX_ATTACHED_DS18B20 16
                          
                          #define RELAY_1  4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                          #define NUMBER_OF_RELAYS 2 // Total number of attached relays
                          #define RELAY_ON 1  // GPIO value to write to turn on attached relay
                          #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
                          
                          unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) 30000 orig
                          OneWire oneWire(ONE_WIRE_BUS);
                          DallasTemperature sensors(&oneWire);
                          MySensor gw;
                          float lastTemperature[MAX_ATTACHED_DS18B20];
                          int numSensors=0;
                          boolean receivedConfig = false;
                          boolean metric = true; 
                          // Initialize temperature message
                          MyMessage msg(0,V_TEMP);
                          
                          void setup()  
                          { 
                            // Startup OneWire 
                            sensors.begin();
                          
                            // Startup and initialize MySensors library. Set callback for incoming messages. 
                            //gw.begin(); 
                            gw.begin(incomingMessage, AUTO, true);
                          
                            // Send the sketch version information to the gateway and Controller
                            gw.sendSketchInfo("Temp and Relays", "1.0");
                          
                            // 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++) {   
                               gw.present(i, V_TEMP);
                            }
                          
                            // Fetch relay status
                            for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
                              // Register all sensors to gw (they will be created as child devices)
                              gw.present(sensor, S_LIGHT);
                              // Then set relay pins in output mode
                              pinMode(pin, OUTPUT);   
                              // Set relay to last known state (using eeprom storage) 
                              digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
                            }
                          
                          }
                          
                          
                          void loop()     
                          {     
                            // Process incoming messages (like config from server)
                            gw.process(); 
                          
                            // Fetch temperatures from Dallas sensors
                            sensors.requestTemperatures(); 
                          
                            // 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>((gw.getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
                           
                              // Only send data if temperature has changed more then 1 degC and no error
                              if (int(lastTemperature[i]) != int(temperature) && temperature != -127.00) { //added integer
                           
                                // Send in the new temperature
                                gw.send(msg.setSensor(i).set(temperature,1));
                                lastTemperature[i]=temperature;
                              }
                            }
                            //gw.sleep(SLEEP_TIME); //no sleep for relays!!!!
                          }
                          
                          void incomingMessage(const MyMessage &message) {
                            // We only expect one type of message from controller. But we better check anyway.
                            if (message.type==V_LIGHT) {
                               // Change relay state
                               digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
                               // Store state in eeprom
                               gw.saveState(message.sensor, message.getBool());
                               // Write some debug info
                               Serial.print("Incoming change for sensor:");
                               Serial.print(message.sensor);
                               Serial.print(", New status: ");
                               Serial.println(message.getBool());
                             } 
                          }
                      
                      T Offline
                      T Offline
                      tjay4x4
                      wrote on last edited by
                      #42

                      Sorry. :) Hek, I using this code. Vera3 find relay and it works, but also appears 3 door sensors instead of 3 temp sensors.
                      I try to use the my arduino board only with sd18b20 sketch and it work's and show temperature. Is it sketch suitale for vera?

                      @Gambituk said:

                      and here is the modified relay/temp sketch

                      // Running DS temperature sensor(s) and relay(s) on one mysensor arduino node
                          // Combines Onewire and Relay code
                          // 2014-10-14 Pego: Tested and Running on Uno/Clone and MQTT gateway
                          
                          // Example sketch showing how to send in OneWire temperature readings
                          // Example sketch showing how to control physical relays. 
                          // This example will remember relay state even after power failure.
                          
                          #include <MySensor.h>  
                          #include <SPI.h>
                          #include <DallasTemperature.h>
                          #include <OneWire.h>presen
                          
                          #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
                          #define MAX_ATTACHED_DS18B20 16
                          
                          #define RELAY_1  4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                          #define NUMBER_OF_RELAYS 2 // Total number of attached relays
                          #define RELAY_ON 1  // GPIO value to write to turn on attached relay
                          #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
                          
                          unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) 30000 orig
                          OneWire oneWire(ONE_WIRE_BUS);
                          DallasTemperature sensors(&oneWire);
                          MySensor gw;
                          float lastTemperature[MAX_ATTACHED_DS18B20];
                          int numSensors=0;
                          boolean receivedConfig = false;
                          boolean metric = true; 
                          // Initialize temperature message
                          MyMessage msg(0,V_TEMP);
                          
                          void setup()  
                          { 
                            // Startup OneWire 
                            sensors.begin();
                          
                            // Startup and initialize MySensors library. Set callback for incoming messages. 
                            //gw.begin(); 
                            gw.begin(incomingMessage, AUTO, true);
                          
                            // Send the sketch version information to the gateway and Controller
                            gw.sendSketchInfo("Temp and Relays", "1.0");
                          
                            // 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++) {   
                               gw.present(i, V_TEMP);
                            }
                          
                            // Fetch relay status
                            for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
                              // Register all sensors to gw (they will be created as child devices)
                              gw.present(sensor, S_LIGHT);
                              // Then set relay pins in output mode
                              pinMode(pin, OUTPUT);   
                              // Set relay to last known state (using eeprom storage) 
                              digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
                            }
                          
                          }
                          
                          
                          void loop()     
                          {     
                            // Process incoming messages (like config from server)
                            gw.process(); 
                          
                            // Fetch temperatures from Dallas sensors
                            sensors.requestTemperatures(); 
                          
                            // 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>((gw.getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
                           
                              // Only send data if temperature has changed more then 1 degC and no error
                              if (int(lastTemperature[i]) != int(temperature) && temperature != -127.00) { //added integer
                           
                                // Send in the new temperature
                                gw.send(msg.setSensor(i).set(temperature,1));
                                lastTemperature[i]=temperature;
                              }
                            }
                            //gw.sleep(SLEEP_TIME); //no sleep for relays!!!!
                          }
                          
                          void incomingMessage(const MyMessage &message) {
                            // We only expect one type of message from controller. But we better check anyway.
                            if (message.type==V_LIGHT) {
                               // Change relay state
                               digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
                               // Store state in eeprom
                               gw.saveState(message.sensor, message.getBool());
                               // Write some debug info
                               Serial.print("Incoming change for sensor:");
                               Serial.print(message.sensor);
                               Serial.print(", New status: ");
                               Serial.println(message.getBool());
                             } 
                          }
                      
                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      12

                      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