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. Troubleshooting
  3. Multiple Dallas Temperatuur sensors at one sensor node

Multiple Dallas Temperatuur sensors at one sensor node

Scheduled Pinned Locked Moved Troubleshooting
36 Posts 9 Posters 3.7k Views 9 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.
  • dzjrD dzjr

    @zboblamont

    Tomorrow I'm going to make a decent connection strip for the sensors, I had done it with some wires, but that does not work ideal of course.

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

    @dzjr If you cannot daisy chain them because there is no sequential route between locations, use a separate pin for each data line (powered via resistor) and communicate with each line in turn.
    The line here is using 3 cores in 20-30m of Cat5e cable to ensure each chip is physically sequential on the line.
    When I added a further sensor location, a loop had to be spliced in to keep the line a daisy chain. It is a small house, the length is purely down to the route, and cable is cheap.

    skywatchS dzjrD 2 Replies Last reply
    0
    • zboblamontZ zboblamont

      @dzjr If you cannot daisy chain them because there is no sequential route between locations, use a separate pin for each data line (powered via resistor) and communicate with each line in turn.
      The line here is using 3 cores in 20-30m of Cat5e cable to ensure each chip is physically sequential on the line.
      When I added a further sensor location, a loop had to be spliced in to keep the line a daisy chain. It is a small house, the length is purely down to the route, and cable is cheap.

      skywatchS Offline
      skywatchS Offline
      skywatch
      wrote on last edited by
      #13

      @dzjr What value pull-up resistor are you using?

      dzjrD 1 Reply Last reply
      0
      • skywatchS skywatch

        @dzjr What value pull-up resistor are you using?

        dzjrD Offline
        dzjrD Offline
        dzjr
        wrote on last edited by
        #14

        @skywatch i use a 4K7 resistor

        1 Reply Last reply
        0
        • zboblamontZ zboblamont

          @dzjr If you cannot daisy chain them because there is no sequential route between locations, use a separate pin for each data line (powered via resistor) and communicate with each line in turn.
          The line here is using 3 cores in 20-30m of Cat5e cable to ensure each chip is physically sequential on the line.
          When I added a further sensor location, a loop had to be spliced in to keep the line a daisy chain. It is a small house, the length is purely down to the route, and cable is cheap.

          dzjrD Offline
          dzjrD Offline
          dzjr
          wrote on last edited by
          #15

          @zboblamont

          Thank you for your tips, at least I now have more knowledge about onewire.

          Last night there was something else in between, but now I have put the sensors in a daisy chain (see photo).

          0_1541622115400_IMG_20181107_204038 2e.jpg

          First I tested it with the "standard" Arduino dallas temperature sketch "oneWireSearch", I got up to 7 sensors in this one.

          0_1541622085409_Knipsel.PNG

          I connected the cable of the waterproof sensors to the three wires (GND, 5V and the onewire pin (pin7)), threaded and twisted together.

          When I connect an 8th sensor, the search sketch says that no sensors can be found, it does not matter which sensor is the 8th.

          If I connect the 7 sensors to the gateway node, I see the 7 sensors in domoticz, so that's where it is.
          it is then 6 wired sensors and a sensor on the PCB.

          does anyone know if the onewire bus might be a twisted pair?
          or is the distance between the branches too short?
          If the problem remains, I just make extra oneWire bus for the 4 ground temperature sensors as you already suggested ...

          zboblamontZ 1 Reply Last reply
          0
          • dzjrD dzjr

            @zboblamont

            Thank you for your tips, at least I now have more knowledge about onewire.

            Last night there was something else in between, but now I have put the sensors in a daisy chain (see photo).

            0_1541622115400_IMG_20181107_204038 2e.jpg

            First I tested it with the "standard" Arduino dallas temperature sketch "oneWireSearch", I got up to 7 sensors in this one.

            0_1541622085409_Knipsel.PNG

            I connected the cable of the waterproof sensors to the three wires (GND, 5V and the onewire pin (pin7)), threaded and twisted together.

            When I connect an 8th sensor, the search sketch says that no sensors can be found, it does not matter which sensor is the 8th.

            If I connect the 7 sensors to the gateway node, I see the 7 sensors in domoticz, so that's where it is.
            it is then 6 wired sensors and a sensor on the PCB.

            does anyone know if the onewire bus might be a twisted pair?
            or is the distance between the branches too short?
            If the problem remains, I just make extra oneWire bus for the 4 ground temperature sensors as you already suggested ...

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

            @dzjr Now you have to figure out why only #8 did not work, so progress ;) even if a digital device on One-Wire has not yet sunk in...
            There is no physical loop 8 I can see, so how is#8 connected in the chain?

            dzjrD 1 Reply Last reply
            0
            • zboblamontZ zboblamont

              @dzjr Now you have to figure out why only #8 did not work, so progress ;) even if a digital device on One-Wire has not yet sunk in...
              There is no physical loop 8 I can see, so how is#8 connected in the chain?

              dzjrD Offline
              dzjrD Offline
              dzjr
              wrote on last edited by
              #17

              @zboblamont

              No, the 8th sensor is not connected because the search sketch does not find any sensor.
              Even with a 9th sensor, the sketch unfortunately does not find anything.

              and indeed there is no loop, on the other side of the wires I connected a multimeter to measure the 5V / GND voltage.
              The yellow bus wire has an open end.
              I also tried to connect a sensor at the end of the line as the 8th sensor.
              and I have used several sensors as "8th", so it is very likely that the sensors are okay

              1 Reply Last reply
              0
              • zboblamontZ Offline
                zboblamontZ Offline
                zboblamont
                wrote on last edited by
                #18

                @dzjr Sorry for any misunderstanding, the loops I was referring to are the sensor cable loops in your photo.
                I did read somewhere that different pullup resistors were recommended by different suppliers of the waterproof versions, values from 10k to 2k2, rather than the usual 4k7, some said the pullup should be on the Arduino end, others on the last sensor on the line, so worth experimenting, perhaps even a sacrificial length of additional cable to alter or extend spacing ?
                What is crucial to these devices is digital signal timing, hence constraints on layout architecture and cable capacitance, the pullup resistor only alters the circuit's speed of High/Low transitions.
                Here bare DS18B20s on Cat5 cable (low capacitance) works fine on a 3v Arduino for 12 sensors, so it can be done.

                dzjrD 1 Reply Last reply
                1
                • mfalkviddM Offline
                  mfalkviddM Offline
                  mfalkvidd
                  Mod
                  wrote on last edited by
                  #19

                  If you have access to an oscilloscope, see what the signal looks like at the end. I had a problem a while ago with too long cable for i2c. See https://forum.mysensors.org/post/92967 for pictures.

                  Stronger pullup at the end of the cable might help.

                  dzjrD 1 Reply Last reply
                  0
                  • wallyllamaW Offline
                    wallyllamaW Offline
                    wallyllama
                    wrote on last edited by
                    #20

                    https://www.maximintegrated.com/en/app-notes/index.mvp/id/148

                    Here is maxim's guide on wiring for 1-wire. There are a few things to note, one is the "weight" of each sensor's cable. Read that section closely. Another is hubs. Hubs are basically a 1 wire switch that connects each segement of the network 1 at a time, so you can essentially walk though each ray of your star. The third is the suggestion above to use multiple pins on the arduino and just make several simpler networks.

                    G dzjrD 2 Replies Last reply
                    2
                    • wallyllamaW wallyllama

                      https://www.maximintegrated.com/en/app-notes/index.mvp/id/148

                      Here is maxim's guide on wiring for 1-wire. There are a few things to note, one is the "weight" of each sensor's cable. Read that section closely. Another is hubs. Hubs are basically a 1 wire switch that connects each segement of the network 1 at a time, so you can essentially walk though each ray of your star. The third is the suggestion above to use multiple pins on the arduino and just make several simpler networks.

                      G Offline
                      G Offline
                      Grubstake
                      wrote on last edited by Grubstake
                      #21

                      @wallyllama

                      I have had good luck with 1 wire but only after careful attention to the wiring itself. Star topology can work fine for several sensors, but daisy chain is important for less trouble, as mentioned.

                      Wiring comments: wiring is the most important thing.

                      1. Use a twisted pair cable (or twist your single conductor wires). Cat5 or telephone wire or similar works well. Solder all connections in the daisy chains or use wire nuts or terminal blocks, or other connectors. Do not just hand twist.

                      2. Your ground and + wires to the sensors should be connected directly to the board terminal closest to the power supply. Don't use skinny jumper wires or connect to a different convenient spot on the board, or to some other ground or +5 device connected to the board. (Yes, all +5 and ground terminals are not 'the same' when it comes to analog circuits.)

                      3. Don't run the wires in a bundle or nearby other wiring.

                      4. A lower value pull-up resistor is easy to try and may help. Another trick is adding a 100 ohm resistor in series where the 1-wire signal line connects to the board. (Disconnect wire from board, connect resistor to board, connect wire to resistor.)

                      Tim

                      dzjrD 1 Reply Last reply
                      1
                      • zboblamontZ zboblamont

                        @dzjr Sorry for any misunderstanding, the loops I was referring to are the sensor cable loops in your photo.
                        I did read somewhere that different pullup resistors were recommended by different suppliers of the waterproof versions, values from 10k to 2k2, rather than the usual 4k7, some said the pullup should be on the Arduino end, others on the last sensor on the line, so worth experimenting, perhaps even a sacrificial length of additional cable to alter or extend spacing ?
                        What is crucial to these devices is digital signal timing, hence constraints on layout architecture and cable capacitance, the pullup resistor only alters the circuit's speed of High/Low transitions.
                        Here bare DS18B20s on Cat5 cable (low capacitance) works fine on a 3v Arduino for 12 sensors, so it can be done.

                        dzjrD Offline
                        dzjrD Offline
                        dzjr
                        wrote on last edited by
                        #22

                        @zboblamont

                        I replaced the resistor an 2K2 resistor, and now see all nine sensors, 2K2 resistor also works with a single sensor.

                        In the sketch I have now given all 9 sensors their own child ID, I only see no data from the 5th sensor, so I have to look at it next week, in the "test sketch" I see a temperature, so just have a look what is wrong.

                        The sensor network of 6 sensors I made in a daisy chain, and two sensors I made separately to the sensor node, and the 9th is fixed on the node's PCB.

                        Next week still good testing and make a small adjustment for sending the (temporary) rain sensor and then I hope to finally install everything.

                        Thank you very much for all the help and tips, I finally solved my "problem"!

                        dzjr

                        1 Reply Last reply
                        1
                        • mfalkviddM mfalkvidd

                          If you have access to an oscilloscope, see what the signal looks like at the end. I had a problem a while ago with too long cable for i2c. See https://forum.mysensors.org/post/92967 for pictures.

                          Stronger pullup at the end of the cable might help.

                          dzjrD Offline
                          dzjrD Offline
                          dzjr
                          wrote on last edited by
                          #23

                          @mfalkvidd I have a oscilloscope but it is a old analog scope so i can't use it to analyse the 1wire singal.

                          But i have orderd a very simple logic analyzer for the next time i need one!.

                          The problem is now solved by using a 2K2 resistor istead of te regulear 4K7 resistor.

                          1 Reply Last reply
                          0
                          • wallyllamaW wallyllama

                            https://www.maximintegrated.com/en/app-notes/index.mvp/id/148

                            Here is maxim's guide on wiring for 1-wire. There are a few things to note, one is the "weight" of each sensor's cable. Read that section closely. Another is hubs. Hubs are basically a 1 wire switch that connects each segement of the network 1 at a time, so you can essentially walk though each ray of your star. The third is the suggestion above to use multiple pins on the arduino and just make several simpler networks.

                            dzjrD Offline
                            dzjrD Offline
                            dzjr
                            wrote on last edited by
                            #24

                            @wallyllama

                            Thank you for the link, i allready find that on a coffe break, but on the smartphone it is nog easy to read, so i read it this weekend on the laptop.

                            All the nine sensors are now working, i rearrenged the sensor network en used a 2K2 resistor in stead of a 4K7 resistor and that turned out to be the problem.

                            Thank you for helping

                            1 Reply Last reply
                            0
                            • G Grubstake

                              @wallyllama

                              I have had good luck with 1 wire but only after careful attention to the wiring itself. Star topology can work fine for several sensors, but daisy chain is important for less trouble, as mentioned.

                              Wiring comments: wiring is the most important thing.

                              1. Use a twisted pair cable (or twist your single conductor wires). Cat5 or telephone wire or similar works well. Solder all connections in the daisy chains or use wire nuts or terminal blocks, or other connectors. Do not just hand twist.

                              2. Your ground and + wires to the sensors should be connected directly to the board terminal closest to the power supply. Don't use skinny jumper wires or connect to a different convenient spot on the board, or to some other ground or +5 device connected to the board. (Yes, all +5 and ground terminals are not 'the same' when it comes to analog circuits.)

                              3. Don't run the wires in a bundle or nearby other wiring.

                              4. A lower value pull-up resistor is easy to try and may help. Another trick is adding a 100 ohm resistor in series where the 1-wire signal line connects to the board. (Disconnect wire from board, connect resistor to board, connect wire to resistor.)

                              Tim

                              dzjrD Offline
                              dzjrD Offline
                              dzjr
                              wrote on last edited by dzjr
                              #25

                              @grubstake I now have used a 4 wire YCY (screened signal cable), and that also is working ( 9 sensors on one pin).
                              Ultimately, the use of a 2K2 resistor was a good solution

                              Do you recommend to use the 5 volt of the arduino, or is it better to use the 5 volts which I use as power supply of the arduino?

                              And can I or should I put the ground of the sensors on the arduino?

                              zboblamontZ 1 Reply Last reply
                              0
                              • dzjrD dzjr

                                @grubstake I now have used a 4 wire YCY (screened signal cable), and that also is working ( 9 sensors on one pin).
                                Ultimately, the use of a 2K2 resistor was a good solution

                                Do you recommend to use the 5 volt of the arduino, or is it better to use the 5 volts which I use as power supply of the arduino?

                                And can I or should I put the ground of the sensors on the arduino?

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

                                @dzjr I believe the point @Grubstake was making is to ensure solid and stable connection for voltage and ground to the board itself, not elsewhere, the issue is to ensure stability.
                                Glad the stronger pullup solved your problem but would caution on choice of cable. Telephone wire or Cat5 as also stated is known to work well and reliably for One-Wire, is cheap and readily available. Screening or grounding unused cores does affect capacitance, which may lead to problems in final layout.

                                1 Reply Last reply
                                0
                                • dzjrD Offline
                                  dzjrD Offline
                                  dzjr
                                  wrote on last edited by dzjr
                                  #27

                                  Thanks again for your help, last weekend I installed everything outside, and everything remains stable!

                                  The only "problem" I still have is that the resolution of the sensors is 9 Bit, while I prefer to have an 11 or 12 bit resolution.

                                  now I have made a second setup with two sensors and the same sketch (only name and IP address are different) and that gives a 12 bit resolution.
                                  Is this because I have connected 9 sensors, or is there possibly something wrong with the reading time in the sketch?
                                  Or is it just a programming error?

                                  the whole sketch is a bit big to post, so I cut it into pieces.

                                  before:

                                  
                                  // Dallas temp stukje
                                  #define COMPARE_TEMP 1 // 1= zenden alleen bij verandering 0= direct zenden
                                  #define ONE_WIRE_BUS 6 
                                  #define TEMPERATURE_PRECISION 12
                                  #define MAX_ATTACHED_DS18B20 13
                                  unsigned long SLEEP_TIME = 300; //slaaptijd tussen twee metingen in ms
                                  OneWire oneWire(ONE_WIRE_BUS); //Een oneWire-exemplaar instellen om te communiceren met alle OneWire-apparaten
                                  DallasTemperature sensors(&oneWire); //OneWire naar Dallas
                                  float lastTemperature[MAX_ATTACHED_DS18B20];
                                  int numSensors=0;
                                  bool receivedConfig = false;
                                  bool metric = true;
                                  
                                  DeviceAddress Probe01 = { 0x28, 0xFF, 0x64, 0x1D, 0xF8, 0x4F, 0x3A, 0x08 }; // op print
                                  DeviceAddress Probe02 = { 0x28, 0xFF, 0x64, 0x1D, 0xF9, 0x9D, 0xDC, 0x5E  }; // temp op -100 cm
                                  DeviceAddress Probe03 = { 0x28, 0xED, 0x25, 0x77, 0x91, 0x13, 0x02, 0xFF }; // temp op -50 mtr
                                  DeviceAddress Probe04 = { 0x28, 0xC5, 0x51, 0x77, 0x91, 0x0B, 0x02, 0x00 }; // temp op -20 cm
                                  DeviceAddress Probe05 = { 0x28, 0xDC, 0x25, 0x77, 0x91, 0x13, 0x02, 0x25 }; // temp op -10 cm
                                  DeviceAddress Probe06 = { 0x28, 0x54, 0x96, 0x77, 0x91, 0x08, 0x02, 0xA0 }; // temp op 10 cm
                                  DeviceAddress Probe07 = { 0x28, 0x1F, 0x11, 0x43, 0x98, 0x25, 0x00, 0x8B }; // temp op 150 cm
                                  DeviceAddress Probe08 = { 0x28, 0xFF, 0x0A, 0x63, 0x73, 0x16, 0x05, 0x9F }; // temp van water in put
                                  DeviceAddress Probe09 = { 0x28, 0x98, 0x9C, 0x77, 0x91, 0x19, 0x02, 0xD7 }; // temp in border
                                  
                                  
                                  // Initialiseer temperatuurbericht
                                  MyMessage msg(0, V_TEMP);
                                  
                                  

                                  Void Loop:

                                  void loop()
                                  
                                  {
                                  {     
                                    // Fetch temperatures from Dallas sensors
                                    sensors.requestTemperatures();
                                  
                                    // query conversion time and sleep until conversion completed
                                    int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
                                   
                                    wait(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.;
                                    float temperature;
                                      // voor geadreseerde sensoren
                                      switch (i)  {
                                        case 0:
                                          temperature = sensors.getTempC(Probe01);
                                          break;
                                        case 1:
                                          temperature = sensors.getTempC(Probe02);
                                          break;
                                        case 2:
                                          temperature = sensors.getTempC(Probe03);
                                          break;
                                        case 3:
                                          temperature = sensors.getTempC(Probe04);
                                          break;
                                        case 4:
                                          temperature = sensors.getTempC(Probe05);
                                          break;
                                        case 5:
                                          temperature = sensors.getTempC(Probe06);
                                          break;
                                        case 6:
                                          temperature = sensors.getTempC(Probe07);
                                          break;
                                        case 7:
                                          temperature = sensors.getTempC(Probe08);
                                          break;
                                        case 8:
                                          temperature = sensors.getTempC(Probe09);
                                          break; 
                                        default:
                                          temperature = sensors.getTempCByIndex(Probe09);
                                          break;
                                      }
                                   
                                      // 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+21).set(temperature,1));
                                        // Save new temperatures for next compare
                                        lastTemperature[i]=temperature;
                                      }
                                      }
                                      }
                                  

                                  The complete code you can find here; sorry the comments are in dutch...
                                  https://github.com/dzjr/MySensors-Put-Node

                                  This was my first real MySensor and second Arduino sketch / project, so if you have some comments or tips, I am open to that!

                                  Thank you for the help!

                                  dzjr

                                  zboblamontZ H 2 Replies Last reply
                                  0
                                  • dzjrD dzjr

                                    Thanks again for your help, last weekend I installed everything outside, and everything remains stable!

                                    The only "problem" I still have is that the resolution of the sensors is 9 Bit, while I prefer to have an 11 or 12 bit resolution.

                                    now I have made a second setup with two sensors and the same sketch (only name and IP address are different) and that gives a 12 bit resolution.
                                    Is this because I have connected 9 sensors, or is there possibly something wrong with the reading time in the sketch?
                                    Or is it just a programming error?

                                    the whole sketch is a bit big to post, so I cut it into pieces.

                                    before:

                                    
                                    // Dallas temp stukje
                                    #define COMPARE_TEMP 1 // 1= zenden alleen bij verandering 0= direct zenden
                                    #define ONE_WIRE_BUS 6 
                                    #define TEMPERATURE_PRECISION 12
                                    #define MAX_ATTACHED_DS18B20 13
                                    unsigned long SLEEP_TIME = 300; //slaaptijd tussen twee metingen in ms
                                    OneWire oneWire(ONE_WIRE_BUS); //Een oneWire-exemplaar instellen om te communiceren met alle OneWire-apparaten
                                    DallasTemperature sensors(&oneWire); //OneWire naar Dallas
                                    float lastTemperature[MAX_ATTACHED_DS18B20];
                                    int numSensors=0;
                                    bool receivedConfig = false;
                                    bool metric = true;
                                    
                                    DeviceAddress Probe01 = { 0x28, 0xFF, 0x64, 0x1D, 0xF8, 0x4F, 0x3A, 0x08 }; // op print
                                    DeviceAddress Probe02 = { 0x28, 0xFF, 0x64, 0x1D, 0xF9, 0x9D, 0xDC, 0x5E  }; // temp op -100 cm
                                    DeviceAddress Probe03 = { 0x28, 0xED, 0x25, 0x77, 0x91, 0x13, 0x02, 0xFF }; // temp op -50 mtr
                                    DeviceAddress Probe04 = { 0x28, 0xC5, 0x51, 0x77, 0x91, 0x0B, 0x02, 0x00 }; // temp op -20 cm
                                    DeviceAddress Probe05 = { 0x28, 0xDC, 0x25, 0x77, 0x91, 0x13, 0x02, 0x25 }; // temp op -10 cm
                                    DeviceAddress Probe06 = { 0x28, 0x54, 0x96, 0x77, 0x91, 0x08, 0x02, 0xA0 }; // temp op 10 cm
                                    DeviceAddress Probe07 = { 0x28, 0x1F, 0x11, 0x43, 0x98, 0x25, 0x00, 0x8B }; // temp op 150 cm
                                    DeviceAddress Probe08 = { 0x28, 0xFF, 0x0A, 0x63, 0x73, 0x16, 0x05, 0x9F }; // temp van water in put
                                    DeviceAddress Probe09 = { 0x28, 0x98, 0x9C, 0x77, 0x91, 0x19, 0x02, 0xD7 }; // temp in border
                                    
                                    
                                    // Initialiseer temperatuurbericht
                                    MyMessage msg(0, V_TEMP);
                                    
                                    

                                    Void Loop:

                                    void loop()
                                    
                                    {
                                    {     
                                      // Fetch temperatures from Dallas sensors
                                      sensors.requestTemperatures();
                                    
                                      // query conversion time and sleep until conversion completed
                                      int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
                                     
                                      wait(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.;
                                      float temperature;
                                        // voor geadreseerde sensoren
                                        switch (i)  {
                                          case 0:
                                            temperature = sensors.getTempC(Probe01);
                                            break;
                                          case 1:
                                            temperature = sensors.getTempC(Probe02);
                                            break;
                                          case 2:
                                            temperature = sensors.getTempC(Probe03);
                                            break;
                                          case 3:
                                            temperature = sensors.getTempC(Probe04);
                                            break;
                                          case 4:
                                            temperature = sensors.getTempC(Probe05);
                                            break;
                                          case 5:
                                            temperature = sensors.getTempC(Probe06);
                                            break;
                                          case 6:
                                            temperature = sensors.getTempC(Probe07);
                                            break;
                                          case 7:
                                            temperature = sensors.getTempC(Probe08);
                                            break;
                                          case 8:
                                            temperature = sensors.getTempC(Probe09);
                                            break; 
                                          default:
                                            temperature = sensors.getTempCByIndex(Probe09);
                                            break;
                                        }
                                     
                                        // 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+21).set(temperature,1));
                                          // Save new temperatures for next compare
                                          lastTemperature[i]=temperature;
                                        }
                                        }
                                        }
                                    

                                    The complete code you can find here; sorry the comments are in dutch...
                                    https://github.com/dzjr/MySensors-Put-Node

                                    This was my first real MySensor and second Arduino sketch / project, so if you have some comments or tips, I am open to that!

                                    Thank you for the help!

                                    dzjr

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

                                    @dzjr Check out the read times on the Dallas specs, from memory it increases markedly with higher resolutions....

                                    1 Reply Last reply
                                    0
                                    • dzjrD dzjr

                                      Thanks again for your help, last weekend I installed everything outside, and everything remains stable!

                                      The only "problem" I still have is that the resolution of the sensors is 9 Bit, while I prefer to have an 11 or 12 bit resolution.

                                      now I have made a second setup with two sensors and the same sketch (only name and IP address are different) and that gives a 12 bit resolution.
                                      Is this because I have connected 9 sensors, or is there possibly something wrong with the reading time in the sketch?
                                      Or is it just a programming error?

                                      the whole sketch is a bit big to post, so I cut it into pieces.

                                      before:

                                      
                                      // Dallas temp stukje
                                      #define COMPARE_TEMP 1 // 1= zenden alleen bij verandering 0= direct zenden
                                      #define ONE_WIRE_BUS 6 
                                      #define TEMPERATURE_PRECISION 12
                                      #define MAX_ATTACHED_DS18B20 13
                                      unsigned long SLEEP_TIME = 300; //slaaptijd tussen twee metingen in ms
                                      OneWire oneWire(ONE_WIRE_BUS); //Een oneWire-exemplaar instellen om te communiceren met alle OneWire-apparaten
                                      DallasTemperature sensors(&oneWire); //OneWire naar Dallas
                                      float lastTemperature[MAX_ATTACHED_DS18B20];
                                      int numSensors=0;
                                      bool receivedConfig = false;
                                      bool metric = true;
                                      
                                      DeviceAddress Probe01 = { 0x28, 0xFF, 0x64, 0x1D, 0xF8, 0x4F, 0x3A, 0x08 }; // op print
                                      DeviceAddress Probe02 = { 0x28, 0xFF, 0x64, 0x1D, 0xF9, 0x9D, 0xDC, 0x5E  }; // temp op -100 cm
                                      DeviceAddress Probe03 = { 0x28, 0xED, 0x25, 0x77, 0x91, 0x13, 0x02, 0xFF }; // temp op -50 mtr
                                      DeviceAddress Probe04 = { 0x28, 0xC5, 0x51, 0x77, 0x91, 0x0B, 0x02, 0x00 }; // temp op -20 cm
                                      DeviceAddress Probe05 = { 0x28, 0xDC, 0x25, 0x77, 0x91, 0x13, 0x02, 0x25 }; // temp op -10 cm
                                      DeviceAddress Probe06 = { 0x28, 0x54, 0x96, 0x77, 0x91, 0x08, 0x02, 0xA0 }; // temp op 10 cm
                                      DeviceAddress Probe07 = { 0x28, 0x1F, 0x11, 0x43, 0x98, 0x25, 0x00, 0x8B }; // temp op 150 cm
                                      DeviceAddress Probe08 = { 0x28, 0xFF, 0x0A, 0x63, 0x73, 0x16, 0x05, 0x9F }; // temp van water in put
                                      DeviceAddress Probe09 = { 0x28, 0x98, 0x9C, 0x77, 0x91, 0x19, 0x02, 0xD7 }; // temp in border
                                      
                                      
                                      // Initialiseer temperatuurbericht
                                      MyMessage msg(0, V_TEMP);
                                      
                                      

                                      Void Loop:

                                      void loop()
                                      
                                      {
                                      {     
                                        // Fetch temperatures from Dallas sensors
                                        sensors.requestTemperatures();
                                      
                                        // query conversion time and sleep until conversion completed
                                        int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
                                       
                                        wait(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.;
                                        float temperature;
                                          // voor geadreseerde sensoren
                                          switch (i)  {
                                            case 0:
                                              temperature = sensors.getTempC(Probe01);
                                              break;
                                            case 1:
                                              temperature = sensors.getTempC(Probe02);
                                              break;
                                            case 2:
                                              temperature = sensors.getTempC(Probe03);
                                              break;
                                            case 3:
                                              temperature = sensors.getTempC(Probe04);
                                              break;
                                            case 4:
                                              temperature = sensors.getTempC(Probe05);
                                              break;
                                            case 5:
                                              temperature = sensors.getTempC(Probe06);
                                              break;
                                            case 6:
                                              temperature = sensors.getTempC(Probe07);
                                              break;
                                            case 7:
                                              temperature = sensors.getTempC(Probe08);
                                              break;
                                            case 8:
                                              temperature = sensors.getTempC(Probe09);
                                              break; 
                                            default:
                                              temperature = sensors.getTempCByIndex(Probe09);
                                              break;
                                          }
                                       
                                          // 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+21).set(temperature,1));
                                            // Save new temperatures for next compare
                                            lastTemperature[i]=temperature;
                                          }
                                          }
                                          }
                                      

                                      The complete code you can find here; sorry the comments are in dutch...
                                      https://github.com/dzjr/MySensors-Put-Node

                                      This was my first real MySensor and second Arduino sketch / project, so if you have some comments or tips, I am open to that!

                                      Thank you for the help!

                                      dzjr

                                      H Offline
                                      H Offline
                                      hard-shovel
                                      wrote on last edited by
                                      #29

                                      @dzjr you have the define

                                      #define TEMPERATURE_PRECISION 12
                                      

                                      In the github code this is not utilized, so the sensors are operating in 9 bit resolution.

                                      You need to add the following in the before or setup

                                      sensors.setResolution(TEMPERATURE_PRECISION);
                                      
                                      dzjrD 1 Reply Last reply
                                      1
                                      • H hard-shovel

                                        @dzjr you have the define

                                        #define TEMPERATURE_PRECISION 12
                                        

                                        In the github code this is not utilized, so the sensors are operating in 9 bit resolution.

                                        You need to add the following in the before or setup

                                        sensors.setResolution(TEMPERATURE_PRECISION);
                                        
                                        dzjrD Offline
                                        dzjrD Offline
                                        dzjr
                                        wrote on last edited by
                                        #30

                                        @hard-shovel

                                        Thanks for the reply, i have tryed to load the new sketch into the Arduino, only i cant make USB connection, do i have look at that first 😕.

                                        You will hear from me.

                                        Dzjr

                                        1 Reply Last reply
                                        1
                                        • dzjrD Offline
                                          dzjrD Offline
                                          dzjr
                                          wrote on last edited by
                                          #31

                                          after replacing the arduino (I could not connect the board) I was able to load the sketch again.

                                          I now have a better resolution, I do not think I have 12 bits but maybe that's because of the link with domoticz.

                                          0_1543091621505_4d1fcb8e-a9db-4b02-a46c-61b211146652-image.png

                                          As I wrote the node is installed, but still think that I must adapt to the sketch.

                                          I now only have a dallas sensor that does not work anymore, but that will be okay.

                                          mfalkviddM H 2 Replies Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          15

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 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