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. Announcements
  3. 💬 Temperature Sensor

💬 Temperature Sensor

Scheduled Pinned Locked Moved Announcements
171 Posts 40 Posters 54.8k Views 36 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.
  • nofoxN Offline
    nofoxN Offline
    nofox
    wrote on last edited by
    #145

    Hi, I have few in wall nodes mounted under the light switches. I have two relays and one DS18B20 in each node. When i'm turning light on, switching the relay, the DS18B20 readings jumping about 0.8 degrees celsius up. When I switch off the relay readings back to normal. Anyone have similar problems ? Sensors are away from from node board, relays etc. so it's not about the heat from atmega or relays.

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

      Is the temperature gradually rising after the relay is activated or it is instantly jumping 0.8°?

      1 Reply Last reply
      0
      • nofoxN Offline
        nofoxN Offline
        nofox
        wrote on last edited by
        #147

        Jumping 0.8 immediately after switching the relay and sometimes rising very slow during the time when relay is on.

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

          That makes it quite difficult to figure out the problem. Can you make another node with same setup and see if you get the same results and if you do try unplug the relay and see what happens

          1 Reply Last reply
          0
          • skywatchS Online
            skywatchS Online
            skywatch
            wrote on last edited by skywatch
            #149

            It's probably a voltage drop from the psu when the relay is engaged and drawing current. That will cause the output voltage to dip slightly.

            If it is only momentary you can add a beefy capacitor across the power supply, but if the readings change for the whole time the relay is on, you really need to replace the relay with something that uses less power (triac/mosfet??) - Or get a more stable power supply with good regulation.

            A final thing might be more noise on the power line with the psu sending more current with the relay on. again a smoothing capacitor would help if this were the case.

            You could also try looking into the wiring and see if the relay cables and the ds18b20 cables are far enough apart, some induction might be going on there between the cables. Also, make sure everything goes back to a single ground point. I can't imagine how an earth loop would cause what you describe, but it's always a good thing to do.....

            Another thought to think about is matbe the magnetic field from the relap power cables are inducing into the sensor cables.

            1 Reply Last reply
            0
            • ben999B Offline
              ben999B Offline
              ben999
              wrote on last edited by
              #150

              Hi
              Can we talk about redundancy please? What if one or more sensor fail on a one-wire bus? Would it make the whole line unusable?
              As part of a central heating MySensorization i would like to have groups of 3 sensors and have some sort of redundancy check.
              Would i be allowed to run multiple one-wire busses on a single arduino?
              Thanks a lot foryour help

              mfalkviddM 1 Reply Last reply
              0
              • ben999B ben999

                Hi
                Can we talk about redundancy please? What if one or more sensor fail on a one-wire bus? Would it make the whole line unusable?
                As part of a central heating MySensorization i would like to have groups of 3 sensors and have some sort of redundancy check.
                Would i be allowed to run multiple one-wire busses on a single arduino?
                Thanks a lot foryour help

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

                @ben999 you can have as many onewire buses as you have digital pins. Just add more of these:

                #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
                OneWire oneWire(ONE_WIRE_BUS);
                
                ben999B 1 Reply Last reply
                1
                • mfalkviddM mfalkvidd

                  @ben999 you can have as many onewire buses as you have digital pins. Just add more of these:

                  #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
                  OneWire oneWire(ONE_WIRE_BUS);
                  
                  ben999B Offline
                  ben999B Offline
                  ben999
                  wrote on last edited by
                  #152

                  @mfalkvidd thanks a lot. Yes, that looks good to me. I will have a go.

                  The real big question now is about what happens when one or more sensor fails on the line.
                  I am not talking about removing a sensor, which doesn't produce any fault.
                  My concern is how does a DS18 ends its life under normal operation? Complete shortcut?

                  mfalkviddM zboblamontZ 2 Replies Last reply
                  0
                  • ben999B ben999

                    @mfalkvidd thanks a lot. Yes, that looks good to me. I will have a go.

                    The real big question now is about what happens when one or more sensor fails on the line.
                    I am not talking about removing a sensor, which doesn't produce any fault.
                    My concern is how does a DS18 ends its life under normal operation? Complete shortcut?

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

                    @ben999 I don't think there are any guarantees on how it will fail. If there are, the datasheet should list them.

                    ben999B 1 Reply Last reply
                    0
                    • ben999B ben999

                      @mfalkvidd thanks a lot. Yes, that looks good to me. I will have a go.

                      The real big question now is about what happens when one or more sensor fails on the line.
                      I am not talking about removing a sensor, which doesn't produce any fault.
                      My concern is how does a DS18 ends its life under normal operation? Complete shortcut?

                      zboblamontZ Offline
                      zboblamontZ Offline
                      zboblamont
                      wrote on last edited by
                      #154

                      @ben999 I cannot remember WHERE I read it, but if a DS18B20 fails it will either send impossible results when addressed or fail to be addressed at all as it is digitally addressed. Only cable short circuits can pull the entire chain down, as I found out when two socket pins had crossed over (sensor crimped into telephone plugs).

                      1 Reply Last reply
                      0
                      • mfalkviddM mfalkvidd

                        @ben999 I don't think there are any guarantees on how it will fail. If there are, the datasheet should list them.

                        ben999B Offline
                        ben999B Offline
                        ben999
                        wrote on last edited by
                        #155

                        @mfalkvidd thank you for the idea. Had a look (boooooring reading for me :D ) but no mention to failiure

                        @zboblamont you're right. Seems that a faulty sensor return "85" (top of my head). And a "dead" sensor looses its bus address (next sensor on the chain takes its address and so on)

                        Thanks a lot gentlemen :)

                        rejoe2R 1 Reply Last reply
                        0
                        • ben999B ben999

                          @mfalkvidd thank you for the idea. Had a look (boooooring reading for me :D ) but no mention to failiure

                          @zboblamont you're right. Seems that a faulty sensor return "85" (top of my head). And a "dead" sensor looses its bus address (next sensor on the chain takes its address and so on)

                          Thanks a lot gentlemen :)

                          rejoe2R Offline
                          rejoe2R Offline
                          rejoe2
                          wrote on last edited by
                          #156

                          @ben999 said in 💬 Temperature Sensor:

                          And a "dead" sensor looses its bus address (next sensor on the chain takes its address and so on)

                          That's not exactly right. Each of the 1-wire devices uses a hardcoded, unique address that can not be changed.
                          So if you use the standard sketch with multiple DS18B20, in case of detached or replaced sensors you may get reported the measured temperatures comming from the same physical DS18B20 device under a different ChildID (after node reboot). To avoid effects like that, one has to take additional measures as described here . In short:

                          • Use an array with the physical ID's to address them
                          • Store a hash-array (done automatically) to identify "known" physical ID's that have once been attached to the bus as well as the ChildID used for MySensors.

                          Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                          ben999B 1 Reply Last reply
                          2
                          • rejoe2R rejoe2

                            @ben999 said in 💬 Temperature Sensor:

                            And a "dead" sensor looses its bus address (next sensor on the chain takes its address and so on)

                            That's not exactly right. Each of the 1-wire devices uses a hardcoded, unique address that can not be changed.
                            So if you use the standard sketch with multiple DS18B20, in case of detached or replaced sensors you may get reported the measured temperatures comming from the same physical DS18B20 device under a different ChildID (after node reboot). To avoid effects like that, one has to take additional measures as described here . In short:

                            • Use an array with the physical ID's to address them
                            • Store a hash-array (done automatically) to identify "known" physical ID's that have once been attached to the bus as well as the ChildID used for MySensors.
                            ben999B Offline
                            ben999B Offline
                            ben999
                            wrote on last edited by
                            #157

                            @rejoe2 oooooooooh great! thanks a lot, exactly what i was looking for !!!

                            rejoe2R 1 Reply Last reply
                            0
                            • ben999B ben999

                              @rejoe2 oooooooooh great! thanks a lot, exactly what i was looking for !!!

                              rejoe2R Offline
                              rejoe2R Offline
                              rejoe2
                              wrote on last edited by
                              #158

                              @ben999 You are welcome :grinning:

                              Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                              1 Reply Last reply
                              0
                              • P Offline
                                P Offline
                                pintman
                                wrote on last edited by
                                #159

                                When I try to compile the sketch for an ESP8266 I get an error in DallasTemperature.h which results in an error in OneWire.h

                                OneWire.h:108:2: error: #error "Please define I/O register types here"  #error "Please define I/O register types here"
                                

                                Is it possible to make the sensor run on an ESP?

                                1 Reply Last reply
                                0
                                • cashew75C Offline
                                  cashew75C Offline
                                  cashew75
                                  wrote on last edited by
                                  #160

                                  Hi, I'm having a hard time getting this Temperatursensor to work with Home Assistant. When i start it it doesn't register with the HA. If I use the same hardware and switch out the sensor to a DHT sensor (new sketch of course) then it works out of the box, HA sees the sensor. I've tried changing the Dallas DS18B20, but nothing. If i look at the logs the gateway have no problem with the sensor. Is there something in the code for the sensor that doesn't add up to it being presented to HA in the right way? I'm quite the newbie when it comes to programming.

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

                                    Have you tried another controller like mycontroller?

                                    cashew75C 1 Reply Last reply
                                    0
                                    • gohanG gohan

                                      Have you tried another controller like mycontroller?

                                      cashew75C Offline
                                      cashew75C Offline
                                      cashew75
                                      wrote on last edited by
                                      #162

                                      @gohan No I have not. I have a RF-Link also connected to the HA and it's working great. As I said, if I use the same hardware that I used to control the Dallas sensor and change the sensor to a DHT sensor the DHT sensor is accepted by HA and shows up as a sensor. That's why I was asking if there is something in the code for the Temperature sensor sketch that has to be changed to be able to present it to HA.

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

                                        pls post the code that is not working

                                        cashew75C 1 Reply Last reply
                                        0
                                        • gohanG gohan

                                          pls post the code that is not working

                                          cashew75C Offline
                                          cashew75C Offline
                                          cashew75
                                          wrote on last edited by
                                          #164

                                          @gohan Thanks for the quick reply! Well I've use the standard sketch for this Temperatur sensor. This is the code i've got.

                                          // Enable debug prints to serial monitor
                                          //#define MY_DEBUG 
                                          
                                          // Enable and select radio type attached
                                          #define MY_RADIO_NRF24
                                          //#define MY_RADIO_RFM69
                                          
                                          #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 = 30000; // 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();
                                          
                                            // 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
                                                send(msg.setSensor(i).set(temperature,1));
                                                // Save new temperatures for next compare
                                                lastTemperature[i]=temperature;
                                              }
                                            }
                                            sleep(SLEEP_TIME);
                                          }```
                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          20

                                          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