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. Hardware
  3. About DS18B20 onewire.

About DS18B20 onewire.

Scheduled Pinned Locked Moved Hardware
dallasone wireonewireds18b20
48 Posts 5 Posters 12.4k Views 10 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.
  • F Offline
    F Offline
    flopp
    wrote on last edited by
    #26

    @pepson said in About DS18B20 onewire.:

    byte D[3][8] = {
    { 0x28, 0xFB, 0x8F, 0x77, 0x91, 0x15, 0x02, 0x32 },
    { 0x28, 0xFF, 0x37, 0x77, 0x91, 0x18, 0x02, 0x16 }
    };
    

    D[3] means 3 attached DS18B20, but you only have address for 2

    1 Reply Last reply
    1
    • F Offline
      F Offline
      flopp
      wrote on last edited by
      #27

      I have a sketch where I have attached 40 pcs mixed both DS18B20 and DS18S20, works perfect, except that sometimes I recevied 0 as value for some of them. I am polling every minute, so I don't care if the value is 0 for a couple of minutes, it is not that very important

      pepsonP 1 Reply Last reply
      0
      • F flopp

        I have a sketch where I have attached 40 pcs mixed both DS18B20 and DS18S20, works perfect, except that sometimes I recevied 0 as value for some of them. I am polling every minute, so I don't care if the value is 0 for a couple of minutes, it is not that very important

        pepsonP Offline
        pepsonP Offline
        pepson
        wrote on last edited by
        #28

        @flopp

        But for what is number 8 in this ?
        byte D[3][8] = {

        On what MySensors you use it ?
        Previous sketch your in this thread i can not compile. I convert it as i show. You mean that sketch with 2 pcs dallas should look like this:

        /**
         * The MySensors Arduino library handles the wireless radio link and protocol
         * between your home built sensors/actuators and HA controller of choice.
         * The sensors forms a self healing radio network with optional repeaters. Each
         * repeater and gateway builds a routing tables in EEPROM which keeps track of the
         * network topology allowing messages to be routed to nodes.
         *
         * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
         * Copyright (C) 2013-2015 Sensnology AB
         * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
         *
         * Documentation: http://www.mysensors.org
         * Support Forum: http://forum.mysensors.org
         *
         * This program is free software; you can redistribute it and/or
         * modify it under the terms of the GNU General Public License
         * version 2 as published by the Free Software Foundation.
         *
         *******************************
         *
         * DESCRIPTION
         *
         * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
         * http://www.mysensors.org/build/temp
         */
        
        #define MY_GATEWAY_SERIAL
        
        #include <MySensors.h>  
        #include <SPI.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 = 3000; // 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. 
        
        byte D[2][8] = {
        { 0x28, 0xFB, 0x8F, 0x77, 0x91, 0x15, 0x02, 0x32 },
        { 0x28, 0xC5, 0xBF, 0x77, 0x91, 0x16, 0x02, 0x1D }
        };
        //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 before()  
        { 
          // Startup up the OneWire library
          sensors.begin();
        }
        
        void setup() 
        {
          // requestTemperatures() will not block current thread
          sensors.setWaitForConversion(false);
        
          // Startup and initialize MySensors library. Set callback for incoming messages. 
        //  begin();
        }
        void presentation() {
          // Send the sketch version information to the gateway and Controller
          sendSketchInfo("Temp. Sensor", "1.1");
        
          // Fetch the number of attached temperature sensors  
          numSensors = sensors.getDeviceCount();
        
          // Present all sensors to controller
          for (int i=0; i<3 && i<MAX_ATTACHED_DS18B20; i++) {   
             present(i, S_TEMP);
          }
        }
        
        
        void loop()     
        {     
          
        Serial.println(millis()); 
          // Process incoming messages (like config from server)
          //process(); 
        
          // 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<3 && i<MAX_ATTACHED_DS18B20; i++) {
         
            // Fetch and round temperature to one decimal
            //float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(D[i]):sensors.getTempFByIndex(D[i])) * 10.)) / 10.;
            //float temperature = static_cast<float>(static_cast<int>((sensors.requestTemperaturesByAddress(D[i])) * 10.)) / 10.;
            float temperature = sensors.getTempC(D[i]);
            // 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);
        }
        

        And what command in sketch should be use:

        1. float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(D[i]):sensors.getTempFByIndex(D[i])) * 10.)) / 10.;
        2. float temperature = static_cast<float>(static_cast<int>((sensors.requestTemperaturesByAddress(D[i])) * 10.)) / 10.;
        3. float temperature = sensors.getTempC(D[i]);

        In original sketch from Mysensors he use this :
        float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;

        And please share me sketch which you use with MySensors 2.x and with how system controller you use it ? I want use with Home Assistant.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          flopp
          wrote on last edited by
          #29
          /**
           * The MySensors Arduino library handles the wireless radio link and protocol
           * between your home built sensors/actuators and HA controller of choice.
           * The sensors forms a self healing radio network with optional repeaters. Each
           * repeater and gateway builds a routing tables in EEPROM which keeps track of the
           * network topology allowing messages to be routed to nodes.
           *
           * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
           * Copyright (C) 2013-2015 Sensnology AB
           * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
           *
           * Documentation: http://www.mysensors.org
           * Support Forum: http://forum.mysensors.org
           *
           * This program is free software; you can redistribute it and/or
           * modify it under the terms of the GNU General Public License
           * version 2 as published by the Free Software Foundation.
           *
           *******************************
           *
           * DESCRIPTION
           *
           * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
           * http://www.mysensors.org/build/temp
           */
           
          // Enable and select radio type attached
          #define MY_RADIO_NRF24
          
          // Enable debug prints to serial monitor
          #define MY_DEBUG
          
          #define MY_NODE_ID 14
          
          #include <SPI.h>
          #include <MySensors.h>
          #include <DallasTemperature.h>
          
          #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No
          
          #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
          #define ATTACHED_DS18B20 40
          unsigned long SLEEP_TIME = 60000; // 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. 
          
          byte D[ATTACHED_DS18B20][8] = {
          { 0x10, 0x04, 0xB8, 0x3F, 0x02, 0x08, 0x00, 0xBD }, //KökTbx
          { 0x10, 0xF4, 0xD7, 0x3F, 0x02, 0x08, 0x00, 0xB1 }, //UppTbx
          { 0x10, 0x92, 0x9F, 0x3E, 0x02, 0x08, 0x00, 0x98 }, //KökUt
          { 0x10, 0x4E, 0xE4, 0x3E, 0x02, 0x08, 0x00, 0x3C }, //ToaUt
          { 0x10, 0x1E, 0xE8, 0x3E, 0x02, 0x08, 0x00, 0x33 }, //EfterPump
          { 0x10, 0x09, 0xA1, 0x3E, 0x02, 0x08, 0x00, 0xF7 }, //HallTbx
          { 0x10, 0x59, 0xCB, 0x3F, 0x02, 0x08, 0x00, 0xFA }, //UppUt
          { 0x10, 0x07, 0x1B, 0x3F, 0x02, 0x08, 0x00, 0x99 }, //ToaTbx
          { 0x28, 0xFF, 0xB1, 0xAA, 0x63, 0x15, 0x03, 0xC8 }, //Kök 
          { 0x10, 0x80, 0xB6, 0x3F, 0x02, 0x08, 0x00, 0x29 }, //Panna komp
          { 0x10, 0x3C, 0x9C, 0x3E, 0x02, 0x08, 0x00, 0x99 }, //Hall ut
          { 0x10, 0x42, 0xE0, 0x3F, 0x02, 0x08, 0x00, 0xD1 }, //Tvätt
          { 0x10, 0xCE, 0xE9, 0x3E, 0x02, 0x08, 0x00, 0x3A }, //T12
          { 0x10, 0x99, 0xAC, 0x3F, 0x02, 0x08, 0x00, 0x25 }, //V mellan
          { 0x10, 0x15, 0xDB, 0x3E, 0x02, 0x08, 0x00, 0x01 }, //Hallen
          { 0x10, 0xF3, 0xD7, 0x3F, 0x02, 0x08, 0x00, 0x34 }, //Panna El
          { 0x10, 0xFB, 0xCB, 0x3F, 0x02, 0x08, 0x00, 0xC8 }, //Toa Nere
          { 0x10, 0x97, 0x23, 0x3F, 0x02, 0x08, 0x00, 0x92 }, //Varmvatten
          { 0x10, 0x0F, 0xE6, 0x3E, 0x02, 0x08, 0x00, 0xFD }, //Carport
          { 0x10, 0xF3, 0xC6, 0x3F, 0x02, 0x08, 0x00, 0x85 }, //Förrådet
          { 0x10, 0x9C, 0x3B, 0x52, 0x02, 0x08, 0x00, 0x25 }, //Mark 60
          { 0x10, 0xF2, 0x24, 0x3F, 0x02, 0x08, 0x00, 0xEB }, //Vrum V
          { 0x10, 0x6A, 0x5E, 0x52, 0x02, 0x08, 0x00, 0x26 }, //Mark 30
          { 0x10, 0x76, 0xCE, 0x3F, 0x02, 0x08, 0x00, 0xBA }, //Plattan
          { 0x10, 0x0E, 0x7B, 0x13, 0x02, 0x08, 0x00, 0x7C }, //Utetemp
          { 0x10, 0xEE, 0xEB, 0x3E, 0x02, 0x08, 0x00, 0x0F }, //Uterum
          { 0x28, 0x8C, 0x2D, 0xB4, 0x04, 0x00, 0x00, 0x9C }, //Kyl uppe
          { 0x28, 0xFF, 0xB2, 0x74, 0x63, 0x15, 0x02, 0xCC }, //Kyl mitten
          { 0x28, 0xFF, 0x08, 0x07, 0x52, 0x04, 0x00, 0xFF }, //Kyl nere
          { 0x28, 0xFF, 0xE6, 0x06, 0x52, 0x04, 0x00, 0x08 }, //Frys uppe
          { 0x28, 0xFF, 0xB4, 0x07, 0x55, 0x04, 0x00, 0xEB }, //Kyl bakom
          { 0x10, 0x1C, 0xA8, 0x3F, 0x02, 0x08, 0x00, 0x3B }, //Lucas
          { 0x10, 0x83, 0x3C, 0x3F, 0x02, 0x08, 0x00, 0x06 }, //Allrum
          { 0x10, 0xA3, 0xE8, 0x3E, 0x02, 0x08, 0x00, 0x7E }, //Theo
          { 0x10, 0x33, 0x3C, 0x3F, 0x02, 0x08, 0x00, 0x01 }, //Sovrum
          { 0x28, 0xFF, 0xFB, 0x3D, 0xC3, 0x16, 0x03, 0x58 }, //Panna luft in(varm)
          { 0x28, 0xFF, 0xD4, 0x1C, 0x00, 0x17, 0x03, 0x43 }, //Dränering
          { 0x28, 0xFF, 0x97, 0x11, 0x01, 0x15, 0x04, 0xC0 } // Poolvatten
          
          };
          
          float lastTemperature[ATTACHED_DS18B20];
          // Initialize temperature message
          MyMessage msg(0,V_TEMP);
          MyMessage heat(0,V_STATUS);
          
          void setup()  
          { 
            // Startup up the OneWire library
            sensors.begin();
            // requestTemperatures() will not block current thread
            sensors.setWaitForConversion(false);
          }
          void presentation() {
            // Send the sketch version information to the gateway and Controller
            sendSketchInfo("OneWire Temp+Heating LED", "20180709");
            
            // Fetch the number of attached temperature sensors  
            //numSensors = sensors.getDeviceCount();
          
            // Present all sensors to controller
            for (int i=0; i<ATTACHED_DS18B20; i++) {   
               present(i, S_TEMP);
            }
            for (int i=ATTACHED_DS18B20; i<ATTACHED_DS18B20+5; i++) {   
               present(i, S_HEATER);
            }
          }
          
          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<ATTACHED_DS18B20; i++) {
          
            //Serial.println(sensors.getResolution(D[i]), DEC); 
              // Fetch and round temperature to one decimal
           //   float temperature = static_cast<float>(static_cast<int>((sensors.requestTemperaturesByAddress(D[i])) * 10.)) / 10.;
                float temperature = sensors.getTempC(D[i]);
              // 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;
              }
            }
          
             for (int i=0; i<5;i++){
              int value = analogRead(i);
              /*Serial.print("Pin");
              Serial.print(i);
              Serial.print("=");
              Serial.println(value);
              */
              int j=i+ATTACHED_DS18B20;
              if (value>150) {
                send(heat.setSensor(j).set(1));
              }
              else {
                send(heat.setSensor(j).set(0));
              }
            }
            
            sleep(SLEEP_TIME);
          }
          
          pepsonP 1 Reply Last reply
          0
          • pepsonP Offline
            pepsonP Offline
            pepson
            wrote on last edited by
            #30

            And you dont use library onewire.h ?

            F 1 Reply Last reply
            0
            • pepsonP pepson

              And you dont use library onewire.h ?

              F Offline
              F Offline
              flopp
              wrote on last edited by
              #31

              @pepson said in About DS18B20 onewire.:

              And you dont use library onewire.h ?

              I think it will be included in DallasTemperature.h.

              Doesn’t my sketch work for you?

              pepsonP 2 Replies Last reply
              0
              • F flopp

                @pepson said in About DS18B20 onewire.:

                And you dont use library onewire.h ?

                I think it will be included in DallasTemperature.h.

                Doesn’t my sketch work for you?

                pepsonP Offline
                pepsonP Offline
                pepson
                wrote on last edited by pepson
                #32

                @flopp
                Probably tommorow I test your sketch and send you an info...

                And what you mean in sketch write Heat?

                And is any chance to modify this sketch and add value name "Description" to each sensor Dallas to send info to controller like Home Assistant to user can easily identify sensors in controller? What is what....

                1 Reply Last reply
                0
                • F flopp

                  @pepson said in About DS18B20 onewire.:

                  And you dont use library onewire.h ?

                  I think it will be included in DallasTemperature.h.

                  Doesn’t my sketch work for you?

                  pepsonP Offline
                  pepsonP Offline
                  pepson
                  wrote on last edited by pepson
                  #33

                  @flopp
                  Hi
                  Tell me... is any chance to add in sketch position to write description for sensor and to send this description to Home Assistant....? It is ok write in other sketch for relay and it works perfect:
                  https://github.com/lkankowski/arduino-multi-relay/blob/master/arduino-multi-relay.ino

                  It show in Home Assisnatn this information in description example: Ł2 - kinkiet [C10]
                  0_1555504238931_PART_1555431841808.jpeg

                  mfalkviddM 1 Reply Last reply
                  0
                  • pepsonP pepson

                    @flopp
                    Hi
                    Tell me... is any chance to add in sketch position to write description for sensor and to send this description to Home Assistant....? It is ok write in other sketch for relay and it works perfect:
                    https://github.com/lkankowski/arduino-multi-relay/blob/master/arduino-multi-relay.ino

                    It show in Home Assisnatn this information in description example: Ł2 - kinkiet [C10]
                    0_1555504238931_PART_1555431841808.jpeg

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

                    @pepson yes. Just change the present call, just like in your sketch.

                    Example: change

                    present(i, S_HEATER);
                    

                    to

                    present(i, S_HEATER, "Description goes here");
                    
                    pepsonP 2 Replies Last reply
                    0
                    • mfalkviddM mfalkvidd

                      @pepson yes. Just change the present call, just like in your sketch.

                      Example: change

                      present(i, S_HEATER);
                      

                      to

                      present(i, S_HEATER, "Description goes here");
                      
                      pepsonP Offline
                      pepsonP Offline
                      pepson
                      wrote on last edited by
                      #35

                      @mfalkvidd
                      OK but also must add defined description to all address. But how add also description?

                      rejoe2R 1 Reply Last reply
                      0
                      • pepsonP pepson

                        @mfalkvidd
                        OK but also must add defined description to all address. But how add also description?

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

                        @pepson said in About DS18B20 onewire.:

                        @mfalkvidd
                        OK but also must add defined description to all address. But how add also description?

                        Don't know, if that really works, because I never tested it since my controller sw supports comments: https://github.com/rejoe2/MySensors-Dallas-Address-ChildID-Consistency/blob/master/DallasTemperatureSimple/DallasTemperatureSimple.ino

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

                        pepsonP 1 Reply Last reply
                        0
                        • rejoe2R rejoe2

                          @pepson said in About DS18B20 onewire.:

                          @mfalkvidd
                          OK but also must add defined description to all address. But how add also description?

                          Don't know, if that really works, because I never tested it since my controller sw supports comments: https://github.com/rejoe2/MySensors-Dallas-Address-ChildID-Consistency/blob/master/DallasTemperatureSimple/DallasTemperatureSimple.ino

                          pepsonP Offline
                          pepsonP Offline
                          pepson
                          wrote on last edited by
                          #37

                          @rejoe2
                          But where in sketch you define address and description ?

                          rejoe2R 1 Reply Last reply
                          0
                          • pepsonP pepson

                            @rejoe2
                            But where in sketch you define address and description ?

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

                            @pepson That's not necessary: The sketch reads the bus to get all the necessary info and will just send whatever is found.

                            If you want a "hardcoded version", you'd have to addopt the sketch for something in between these variants: if you use an array for the 1-wire addresses like https://github.com/rejoe2/MySensors-Dallas-Address-ChildID-Consistency/blob/master/Dallas_Addresses_Array_Solution/Dallas_Addresses_Array_Solution.ino does, just built the comment char-array based on that info.

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

                            pepsonP 1 Reply Last reply
                            0
                            • rejoe2R rejoe2

                              @pepson That's not necessary: The sketch reads the bus to get all the necessary info and will just send whatever is found.

                              If you want a "hardcoded version", you'd have to addopt the sketch for something in between these variants: if you use an array for the 1-wire addresses like https://github.com/rejoe2/MySensors-Dallas-Address-ChildID-Consistency/blob/master/Dallas_Addresses_Array_Solution/Dallas_Addresses_Array_Solution.ino does, just built the comment char-array based on that info.

                              pepsonP Offline
                              pepsonP Offline
                              pepson
                              wrote on last edited by
                              #39

                              @rejoe2 said in About DS18B20 onewire.:

                              If you want a "hardcoded version", you'd have to addopt the sketch for something in between these variants: if you use an array for the 1-wire addresses like https://github.com/rejoe2/MySensors-Dallas-Address-ChildID-Consistency/blob/master/Dallas_Addresses_Array_Solution/Dallas_Addresses_Array_Solution.ino does, just built the comment char-array based on that info.

                              Ok i know how add to present description , but still dont know how add description to each sensors.... as in sketch for relay as i show as example.

                              rejoe2R 1 Reply Last reply
                              0
                              • pepsonP pepson

                                @rejoe2 said in About DS18B20 onewire.:

                                If you want a "hardcoded version", you'd have to addopt the sketch for something in between these variants: if you use an array for the 1-wire addresses like https://github.com/rejoe2/MySensors-Dallas-Address-ChildID-Consistency/blob/master/Dallas_Addresses_Array_Solution/Dallas_Addresses_Array_Solution.ino does, just built the comment char-array based on that info.

                                Ok i know how add to present description , but still dont know how add description to each sensors.... as in sketch for relay as i show as example.

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

                                @pepson I'd suggest you make a test with the "simple" variant of the sketches. Then we could lateron discuss how to deal with an array containing the hardcoded addresses.
                                Pls. make also a test with the hardcoded version. Afai remember, it will print the needed array to serial, as long as #define PRINT_ARRAY isn't commented.

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

                                1 Reply Last reply
                                0
                                • mfalkviddM mfalkvidd

                                  @pepson yes. Just change the present call, just like in your sketch.

                                  Example: change

                                  present(i, S_HEATER);
                                  

                                  to

                                  present(i, S_HEATER, "Description goes here");
                                  
                                  pepsonP Offline
                                  pepsonP Offline
                                  pepson
                                  wrote on last edited by
                                  #41

                                  @mfalkvidd Can you help me... or change it ?

                                  1 Reply Last reply
                                  0
                                  • F flopp
                                    /**
                                     * The MySensors Arduino library handles the wireless radio link and protocol
                                     * between your home built sensors/actuators and HA controller of choice.
                                     * The sensors forms a self healing radio network with optional repeaters. Each
                                     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                                     * network topology allowing messages to be routed to nodes.
                                     *
                                     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                                     * Copyright (C) 2013-2015 Sensnology AB
                                     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                                     *
                                     * Documentation: http://www.mysensors.org
                                     * Support Forum: http://forum.mysensors.org
                                     *
                                     * This program is free software; you can redistribute it and/or
                                     * modify it under the terms of the GNU General Public License
                                     * version 2 as published by the Free Software Foundation.
                                     *
                                     *******************************
                                     *
                                     * DESCRIPTION
                                     *
                                     * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
                                     * http://www.mysensors.org/build/temp
                                     */
                                     
                                    // Enable and select radio type attached
                                    #define MY_RADIO_NRF24
                                    
                                    // Enable debug prints to serial monitor
                                    #define MY_DEBUG
                                    
                                    #define MY_NODE_ID 14
                                    
                                    #include <SPI.h>
                                    #include <MySensors.h>
                                    #include <DallasTemperature.h>
                                    
                                    #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No
                                    
                                    #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
                                    #define ATTACHED_DS18B20 40
                                    unsigned long SLEEP_TIME = 60000; // 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. 
                                    
                                    byte D[ATTACHED_DS18B20][8] = {
                                    { 0x10, 0x04, 0xB8, 0x3F, 0x02, 0x08, 0x00, 0xBD }, //KökTbx
                                    { 0x10, 0xF4, 0xD7, 0x3F, 0x02, 0x08, 0x00, 0xB1 }, //UppTbx
                                    { 0x10, 0x92, 0x9F, 0x3E, 0x02, 0x08, 0x00, 0x98 }, //KökUt
                                    { 0x10, 0x4E, 0xE4, 0x3E, 0x02, 0x08, 0x00, 0x3C }, //ToaUt
                                    { 0x10, 0x1E, 0xE8, 0x3E, 0x02, 0x08, 0x00, 0x33 }, //EfterPump
                                    { 0x10, 0x09, 0xA1, 0x3E, 0x02, 0x08, 0x00, 0xF7 }, //HallTbx
                                    { 0x10, 0x59, 0xCB, 0x3F, 0x02, 0x08, 0x00, 0xFA }, //UppUt
                                    { 0x10, 0x07, 0x1B, 0x3F, 0x02, 0x08, 0x00, 0x99 }, //ToaTbx
                                    { 0x28, 0xFF, 0xB1, 0xAA, 0x63, 0x15, 0x03, 0xC8 }, //Kök 
                                    { 0x10, 0x80, 0xB6, 0x3F, 0x02, 0x08, 0x00, 0x29 }, //Panna komp
                                    { 0x10, 0x3C, 0x9C, 0x3E, 0x02, 0x08, 0x00, 0x99 }, //Hall ut
                                    { 0x10, 0x42, 0xE0, 0x3F, 0x02, 0x08, 0x00, 0xD1 }, //Tvätt
                                    { 0x10, 0xCE, 0xE9, 0x3E, 0x02, 0x08, 0x00, 0x3A }, //T12
                                    { 0x10, 0x99, 0xAC, 0x3F, 0x02, 0x08, 0x00, 0x25 }, //V mellan
                                    { 0x10, 0x15, 0xDB, 0x3E, 0x02, 0x08, 0x00, 0x01 }, //Hallen
                                    { 0x10, 0xF3, 0xD7, 0x3F, 0x02, 0x08, 0x00, 0x34 }, //Panna El
                                    { 0x10, 0xFB, 0xCB, 0x3F, 0x02, 0x08, 0x00, 0xC8 }, //Toa Nere
                                    { 0x10, 0x97, 0x23, 0x3F, 0x02, 0x08, 0x00, 0x92 }, //Varmvatten
                                    { 0x10, 0x0F, 0xE6, 0x3E, 0x02, 0x08, 0x00, 0xFD }, //Carport
                                    { 0x10, 0xF3, 0xC6, 0x3F, 0x02, 0x08, 0x00, 0x85 }, //Förrådet
                                    { 0x10, 0x9C, 0x3B, 0x52, 0x02, 0x08, 0x00, 0x25 }, //Mark 60
                                    { 0x10, 0xF2, 0x24, 0x3F, 0x02, 0x08, 0x00, 0xEB }, //Vrum V
                                    { 0x10, 0x6A, 0x5E, 0x52, 0x02, 0x08, 0x00, 0x26 }, //Mark 30
                                    { 0x10, 0x76, 0xCE, 0x3F, 0x02, 0x08, 0x00, 0xBA }, //Plattan
                                    { 0x10, 0x0E, 0x7B, 0x13, 0x02, 0x08, 0x00, 0x7C }, //Utetemp
                                    { 0x10, 0xEE, 0xEB, 0x3E, 0x02, 0x08, 0x00, 0x0F }, //Uterum
                                    { 0x28, 0x8C, 0x2D, 0xB4, 0x04, 0x00, 0x00, 0x9C }, //Kyl uppe
                                    { 0x28, 0xFF, 0xB2, 0x74, 0x63, 0x15, 0x02, 0xCC }, //Kyl mitten
                                    { 0x28, 0xFF, 0x08, 0x07, 0x52, 0x04, 0x00, 0xFF }, //Kyl nere
                                    { 0x28, 0xFF, 0xE6, 0x06, 0x52, 0x04, 0x00, 0x08 }, //Frys uppe
                                    { 0x28, 0xFF, 0xB4, 0x07, 0x55, 0x04, 0x00, 0xEB }, //Kyl bakom
                                    { 0x10, 0x1C, 0xA8, 0x3F, 0x02, 0x08, 0x00, 0x3B }, //Lucas
                                    { 0x10, 0x83, 0x3C, 0x3F, 0x02, 0x08, 0x00, 0x06 }, //Allrum
                                    { 0x10, 0xA3, 0xE8, 0x3E, 0x02, 0x08, 0x00, 0x7E }, //Theo
                                    { 0x10, 0x33, 0x3C, 0x3F, 0x02, 0x08, 0x00, 0x01 }, //Sovrum
                                    { 0x28, 0xFF, 0xFB, 0x3D, 0xC3, 0x16, 0x03, 0x58 }, //Panna luft in(varm)
                                    { 0x28, 0xFF, 0xD4, 0x1C, 0x00, 0x17, 0x03, 0x43 }, //Dränering
                                    { 0x28, 0xFF, 0x97, 0x11, 0x01, 0x15, 0x04, 0xC0 } // Poolvatten
                                    
                                    };
                                    
                                    float lastTemperature[ATTACHED_DS18B20];
                                    // Initialize temperature message
                                    MyMessage msg(0,V_TEMP);
                                    MyMessage heat(0,V_STATUS);
                                    
                                    void setup()  
                                    { 
                                      // Startup up the OneWire library
                                      sensors.begin();
                                      // requestTemperatures() will not block current thread
                                      sensors.setWaitForConversion(false);
                                    }
                                    void presentation() {
                                      // Send the sketch version information to the gateway and Controller
                                      sendSketchInfo("OneWire Temp+Heating LED", "20180709");
                                      
                                      // Fetch the number of attached temperature sensors  
                                      //numSensors = sensors.getDeviceCount();
                                    
                                      // Present all sensors to controller
                                      for (int i=0; i<ATTACHED_DS18B20; i++) {   
                                         present(i, S_TEMP);
                                      }
                                      for (int i=ATTACHED_DS18B20; i<ATTACHED_DS18B20+5; i++) {   
                                         present(i, S_HEATER);
                                      }
                                    }
                                    
                                    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<ATTACHED_DS18B20; i++) {
                                    
                                      //Serial.println(sensors.getResolution(D[i]), DEC); 
                                        // Fetch and round temperature to one decimal
                                     //   float temperature = static_cast<float>(static_cast<int>((sensors.requestTemperaturesByAddress(D[i])) * 10.)) / 10.;
                                          float temperature = sensors.getTempC(D[i]);
                                        // 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;
                                        }
                                      }
                                    
                                       for (int i=0; i<5;i++){
                                        int value = analogRead(i);
                                        /*Serial.print("Pin");
                                        Serial.print(i);
                                        Serial.print("=");
                                        Serial.println(value);
                                        */
                                        int j=i+ATTACHED_DS18B20;
                                        if (value>150) {
                                          send(heat.setSensor(j).set(1));
                                        }
                                        else {
                                          send(heat.setSensor(j).set(0));
                                        }
                                      }
                                      
                                      sleep(SLEEP_TIME);
                                    }
                                    
                                    pepsonP Offline
                                    pepsonP Offline
                                    pepson
                                    wrote on last edited by
                                    #42

                                    @flopp said in About DS18B20 onewire.:

                                    /**
                                     * The MySensors Arduino library handles the wireless radio link and protocol
                                     * between your home built sensors/actuators and HA controller of choice.
                                     * The sensors forms a self healing radio network with optional repeaters. Each
                                     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                                     * network topology allowing messages to be routed to nodes.
                                     *
                                     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                                     * Copyright (C) 2013-2015 Sensnology AB
                                     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                                     *
                                     * Documentation: http://www.mysensors.org
                                     * Support Forum: http://forum.mysensors.org
                                     *
                                     * This program is free software; you can redistribute it and/or
                                     * modify it under the terms of the GNU General Public License
                                     * version 2 as published by the Free Software Foundation.
                                     *
                                     *******************************
                                     *
                                     * DESCRIPTION
                                     *
                                     * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
                                     * http://www.mysensors.org/build/temp
                                     */
                                     
                                    // Enable and select radio type attached
                                    #define MY_RADIO_NRF24
                                    
                                    // Enable debug prints to serial monitor
                                    #define MY_DEBUG
                                    
                                    #define MY_NODE_ID 14
                                    
                                    #include <SPI.h>
                                    #include <MySensors.h>
                                    #include <DallasTemperature.h>
                                    
                                    #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No
                                    
                                    #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
                                    #define ATTACHED_DS18B20 40
                                    unsigned long SLEEP_TIME = 60000; // 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. 
                                    
                                    byte D[ATTACHED_DS18B20][8] = {
                                    { 0x10, 0x04, 0xB8, 0x3F, 0x02, 0x08, 0x00, 0xBD }, //KökTbx
                                    { 0x10, 0xF4, 0xD7, 0x3F, 0x02, 0x08, 0x00, 0xB1 }, //UppTbx
                                    { 0x10, 0x92, 0x9F, 0x3E, 0x02, 0x08, 0x00, 0x98 }, //KökUt
                                    { 0x10, 0x4E, 0xE4, 0x3E, 0x02, 0x08, 0x00, 0x3C }, //ToaUt
                                    { 0x10, 0x1E, 0xE8, 0x3E, 0x02, 0x08, 0x00, 0x33 }, //EfterPump
                                    { 0x10, 0x09, 0xA1, 0x3E, 0x02, 0x08, 0x00, 0xF7 }, //HallTbx
                                    { 0x10, 0x59, 0xCB, 0x3F, 0x02, 0x08, 0x00, 0xFA }, //UppUt
                                    { 0x10, 0x07, 0x1B, 0x3F, 0x02, 0x08, 0x00, 0x99 }, //ToaTbx
                                    { 0x28, 0xFF, 0xB1, 0xAA, 0x63, 0x15, 0x03, 0xC8 }, //Kök 
                                    { 0x10, 0x80, 0xB6, 0x3F, 0x02, 0x08, 0x00, 0x29 }, //Panna komp
                                    { 0x10, 0x3C, 0x9C, 0x3E, 0x02, 0x08, 0x00, 0x99 }, //Hall ut
                                    { 0x10, 0x42, 0xE0, 0x3F, 0x02, 0x08, 0x00, 0xD1 }, //Tvätt
                                    { 0x10, 0xCE, 0xE9, 0x3E, 0x02, 0x08, 0x00, 0x3A }, //T12
                                    { 0x10, 0x99, 0xAC, 0x3F, 0x02, 0x08, 0x00, 0x25 }, //V mellan
                                    { 0x10, 0x15, 0xDB, 0x3E, 0x02, 0x08, 0x00, 0x01 }, //Hallen
                                    { 0x10, 0xF3, 0xD7, 0x3F, 0x02, 0x08, 0x00, 0x34 }, //Panna El
                                    { 0x10, 0xFB, 0xCB, 0x3F, 0x02, 0x08, 0x00, 0xC8 }, //Toa Nere
                                    { 0x10, 0x97, 0x23, 0x3F, 0x02, 0x08, 0x00, 0x92 }, //Varmvatten
                                    { 0x10, 0x0F, 0xE6, 0x3E, 0x02, 0x08, 0x00, 0xFD }, //Carport
                                    { 0x10, 0xF3, 0xC6, 0x3F, 0x02, 0x08, 0x00, 0x85 }, //Förrådet
                                    { 0x10, 0x9C, 0x3B, 0x52, 0x02, 0x08, 0x00, 0x25 }, //Mark 60
                                    { 0x10, 0xF2, 0x24, 0x3F, 0x02, 0x08, 0x00, 0xEB }, //Vrum V
                                    { 0x10, 0x6A, 0x5E, 0x52, 0x02, 0x08, 0x00, 0x26 }, //Mark 30
                                    { 0x10, 0x76, 0xCE, 0x3F, 0x02, 0x08, 0x00, 0xBA }, //Plattan
                                    { 0x10, 0x0E, 0x7B, 0x13, 0x02, 0x08, 0x00, 0x7C }, //Utetemp
                                    { 0x10, 0xEE, 0xEB, 0x3E, 0x02, 0x08, 0x00, 0x0F }, //Uterum
                                    { 0x28, 0x8C, 0x2D, 0xB4, 0x04, 0x00, 0x00, 0x9C }, //Kyl uppe
                                    { 0x28, 0xFF, 0xB2, 0x74, 0x63, 0x15, 0x02, 0xCC }, //Kyl mitten
                                    { 0x28, 0xFF, 0x08, 0x07, 0x52, 0x04, 0x00, 0xFF }, //Kyl nere
                                    { 0x28, 0xFF, 0xE6, 0x06, 0x52, 0x04, 0x00, 0x08 }, //Frys uppe
                                    { 0x28, 0xFF, 0xB4, 0x07, 0x55, 0x04, 0x00, 0xEB }, //Kyl bakom
                                    { 0x10, 0x1C, 0xA8, 0x3F, 0x02, 0x08, 0x00, 0x3B }, //Lucas
                                    { 0x10, 0x83, 0x3C, 0x3F, 0x02, 0x08, 0x00, 0x06 }, //Allrum
                                    { 0x10, 0xA3, 0xE8, 0x3E, 0x02, 0x08, 0x00, 0x7E }, //Theo
                                    { 0x10, 0x33, 0x3C, 0x3F, 0x02, 0x08, 0x00, 0x01 }, //Sovrum
                                    { 0x28, 0xFF, 0xFB, 0x3D, 0xC3, 0x16, 0x03, 0x58 }, //Panna luft in(varm)
                                    { 0x28, 0xFF, 0xD4, 0x1C, 0x00, 0x17, 0x03, 0x43 }, //Dränering
                                    { 0x28, 0xFF, 0x97, 0x11, 0x01, 0x15, 0x04, 0xC0 } // Poolvatten
                                    
                                    };
                                    
                                    float lastTemperature[ATTACHED_DS18B20];
                                    // Initialize temperature message
                                    MyMessage msg(0,V_TEMP);
                                    MyMessage heat(0,V_STATUS);
                                    
                                    void setup()  
                                    { 
                                      // Startup up the OneWire library
                                      sensors.begin();
                                      // requestTemperatures() will not block current thread
                                      sensors.setWaitForConversion(false);
                                    }
                                    void presentation() {
                                      // Send the sketch version information to the gateway and Controller
                                      sendSketchInfo("OneWire Temp+Heating LED", "20180709");
                                      
                                      // Fetch the number of attached temperature sensors  
                                      //numSensors = sensors.getDeviceCount();
                                    
                                      // Present all sensors to controller
                                      for (int i=0; i<ATTACHED_DS18B20; i++) {   
                                         present(i, S_TEMP);
                                      }
                                      for (int i=ATTACHED_DS18B20; i<ATTACHED_DS18B20+5; i++) {   
                                         present(i, S_HEATER);
                                      }
                                    }
                                    
                                    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<ATTACHED_DS18B20; i++) {
                                    
                                      //Serial.println(sensors.getResolution(D[i]), DEC); 
                                        // Fetch and round temperature to one decimal
                                     //   float temperature = static_cast<float>(static_cast<int>((sensors.requestTemperaturesByAddress(D[i])) * 10.)) / 10.;
                                          float temperature = sensors.getTempC(D[i]);
                                        // 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;
                                        }
                                      }
                                    
                                       for (int i=0; i<5;i++){
                                        int value = analogRead(i);
                                        /*Serial.print("Pin");
                                        Serial.print(i);
                                        Serial.print("=");
                                        Serial.println(value);
                                        */
                                        int j=i+ATTACHED_DS18B20;
                                        if (value>150) {
                                          send(heat.setSensor(j).set(1));
                                        }
                                        else {
                                          send(heat.setSensor(j).set(0));
                                        }
                                      }
                                      
                                      sleep(SLEEP_TIME);
                                    }
                                    

                                    When i try compile this sketch it get me error:

                                    C:\Users\Piotrek\Desktop\Temp dallas\Arduino_dallas_18B20_with_desc\Arduino_dallas_18B20_with_desc.ino: In function 'void presentation()':

                                    Arduino_dallas_18B20_with_desc:117:3: error: expected initializer before 'sensors'

                                    sensors.requestTemperatures();

                                    ^

                                    exit status 1
                                    expected initializer before 'sensors'

                                    mfalkviddM 1 Reply Last reply
                                    0
                                    • pepsonP pepson

                                      @flopp said in About DS18B20 onewire.:

                                      /**
                                       * The MySensors Arduino library handles the wireless radio link and protocol
                                       * between your home built sensors/actuators and HA controller of choice.
                                       * The sensors forms a self healing radio network with optional repeaters. Each
                                       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                                       * network topology allowing messages to be routed to nodes.
                                       *
                                       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                                       * Copyright (C) 2013-2015 Sensnology AB
                                       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                                       *
                                       * Documentation: http://www.mysensors.org
                                       * Support Forum: http://forum.mysensors.org
                                       *
                                       * This program is free software; you can redistribute it and/or
                                       * modify it under the terms of the GNU General Public License
                                       * version 2 as published by the Free Software Foundation.
                                       *
                                       *******************************
                                       *
                                       * DESCRIPTION
                                       *
                                       * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
                                       * http://www.mysensors.org/build/temp
                                       */
                                       
                                      // Enable and select radio type attached
                                      #define MY_RADIO_NRF24
                                      
                                      // Enable debug prints to serial monitor
                                      #define MY_DEBUG
                                      
                                      #define MY_NODE_ID 14
                                      
                                      #include <SPI.h>
                                      #include <MySensors.h>
                                      #include <DallasTemperature.h>
                                      
                                      #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No
                                      
                                      #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
                                      #define ATTACHED_DS18B20 40
                                      unsigned long SLEEP_TIME = 60000; // 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. 
                                      
                                      byte D[ATTACHED_DS18B20][8] = {
                                      { 0x10, 0x04, 0xB8, 0x3F, 0x02, 0x08, 0x00, 0xBD }, //KökTbx
                                      { 0x10, 0xF4, 0xD7, 0x3F, 0x02, 0x08, 0x00, 0xB1 }, //UppTbx
                                      { 0x10, 0x92, 0x9F, 0x3E, 0x02, 0x08, 0x00, 0x98 }, //KökUt
                                      { 0x10, 0x4E, 0xE4, 0x3E, 0x02, 0x08, 0x00, 0x3C }, //ToaUt
                                      { 0x10, 0x1E, 0xE8, 0x3E, 0x02, 0x08, 0x00, 0x33 }, //EfterPump
                                      { 0x10, 0x09, 0xA1, 0x3E, 0x02, 0x08, 0x00, 0xF7 }, //HallTbx
                                      { 0x10, 0x59, 0xCB, 0x3F, 0x02, 0x08, 0x00, 0xFA }, //UppUt
                                      { 0x10, 0x07, 0x1B, 0x3F, 0x02, 0x08, 0x00, 0x99 }, //ToaTbx
                                      { 0x28, 0xFF, 0xB1, 0xAA, 0x63, 0x15, 0x03, 0xC8 }, //Kök 
                                      { 0x10, 0x80, 0xB6, 0x3F, 0x02, 0x08, 0x00, 0x29 }, //Panna komp
                                      { 0x10, 0x3C, 0x9C, 0x3E, 0x02, 0x08, 0x00, 0x99 }, //Hall ut
                                      { 0x10, 0x42, 0xE0, 0x3F, 0x02, 0x08, 0x00, 0xD1 }, //Tvätt
                                      { 0x10, 0xCE, 0xE9, 0x3E, 0x02, 0x08, 0x00, 0x3A }, //T12
                                      { 0x10, 0x99, 0xAC, 0x3F, 0x02, 0x08, 0x00, 0x25 }, //V mellan
                                      { 0x10, 0x15, 0xDB, 0x3E, 0x02, 0x08, 0x00, 0x01 }, //Hallen
                                      { 0x10, 0xF3, 0xD7, 0x3F, 0x02, 0x08, 0x00, 0x34 }, //Panna El
                                      { 0x10, 0xFB, 0xCB, 0x3F, 0x02, 0x08, 0x00, 0xC8 }, //Toa Nere
                                      { 0x10, 0x97, 0x23, 0x3F, 0x02, 0x08, 0x00, 0x92 }, //Varmvatten
                                      { 0x10, 0x0F, 0xE6, 0x3E, 0x02, 0x08, 0x00, 0xFD }, //Carport
                                      { 0x10, 0xF3, 0xC6, 0x3F, 0x02, 0x08, 0x00, 0x85 }, //Förrådet
                                      { 0x10, 0x9C, 0x3B, 0x52, 0x02, 0x08, 0x00, 0x25 }, //Mark 60
                                      { 0x10, 0xF2, 0x24, 0x3F, 0x02, 0x08, 0x00, 0xEB }, //Vrum V
                                      { 0x10, 0x6A, 0x5E, 0x52, 0x02, 0x08, 0x00, 0x26 }, //Mark 30
                                      { 0x10, 0x76, 0xCE, 0x3F, 0x02, 0x08, 0x00, 0xBA }, //Plattan
                                      { 0x10, 0x0E, 0x7B, 0x13, 0x02, 0x08, 0x00, 0x7C }, //Utetemp
                                      { 0x10, 0xEE, 0xEB, 0x3E, 0x02, 0x08, 0x00, 0x0F }, //Uterum
                                      { 0x28, 0x8C, 0x2D, 0xB4, 0x04, 0x00, 0x00, 0x9C }, //Kyl uppe
                                      { 0x28, 0xFF, 0xB2, 0x74, 0x63, 0x15, 0x02, 0xCC }, //Kyl mitten
                                      { 0x28, 0xFF, 0x08, 0x07, 0x52, 0x04, 0x00, 0xFF }, //Kyl nere
                                      { 0x28, 0xFF, 0xE6, 0x06, 0x52, 0x04, 0x00, 0x08 }, //Frys uppe
                                      { 0x28, 0xFF, 0xB4, 0x07, 0x55, 0x04, 0x00, 0xEB }, //Kyl bakom
                                      { 0x10, 0x1C, 0xA8, 0x3F, 0x02, 0x08, 0x00, 0x3B }, //Lucas
                                      { 0x10, 0x83, 0x3C, 0x3F, 0x02, 0x08, 0x00, 0x06 }, //Allrum
                                      { 0x10, 0xA3, 0xE8, 0x3E, 0x02, 0x08, 0x00, 0x7E }, //Theo
                                      { 0x10, 0x33, 0x3C, 0x3F, 0x02, 0x08, 0x00, 0x01 }, //Sovrum
                                      { 0x28, 0xFF, 0xFB, 0x3D, 0xC3, 0x16, 0x03, 0x58 }, //Panna luft in(varm)
                                      { 0x28, 0xFF, 0xD4, 0x1C, 0x00, 0x17, 0x03, 0x43 }, //Dränering
                                      { 0x28, 0xFF, 0x97, 0x11, 0x01, 0x15, 0x04, 0xC0 } // Poolvatten
                                      
                                      };
                                      
                                      float lastTemperature[ATTACHED_DS18B20];
                                      // Initialize temperature message
                                      MyMessage msg(0,V_TEMP);
                                      MyMessage heat(0,V_STATUS);
                                      
                                      void setup()  
                                      { 
                                        // Startup up the OneWire library
                                        sensors.begin();
                                        // requestTemperatures() will not block current thread
                                        sensors.setWaitForConversion(false);
                                      }
                                      void presentation() {
                                        // Send the sketch version information to the gateway and Controller
                                        sendSketchInfo("OneWire Temp+Heating LED", "20180709");
                                        
                                        // Fetch the number of attached temperature sensors  
                                        //numSensors = sensors.getDeviceCount();
                                      
                                        // Present all sensors to controller
                                        for (int i=0; i<ATTACHED_DS18B20; i++) {   
                                           present(i, S_TEMP);
                                        }
                                        for (int i=ATTACHED_DS18B20; i<ATTACHED_DS18B20+5; i++) {   
                                           present(i, S_HEATER);
                                        }
                                      }
                                      
                                      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<ATTACHED_DS18B20; i++) {
                                      
                                        //Serial.println(sensors.getResolution(D[i]), DEC); 
                                          // Fetch and round temperature to one decimal
                                       //   float temperature = static_cast<float>(static_cast<int>((sensors.requestTemperaturesByAddress(D[i])) * 10.)) / 10.;
                                            float temperature = sensors.getTempC(D[i]);
                                          // 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;
                                          }
                                        }
                                      
                                         for (int i=0; i<5;i++){
                                          int value = analogRead(i);
                                          /*Serial.print("Pin");
                                          Serial.print(i);
                                          Serial.print("=");
                                          Serial.println(value);
                                          */
                                          int j=i+ATTACHED_DS18B20;
                                          if (value>150) {
                                            send(heat.setSensor(j).set(1));
                                          }
                                          else {
                                            send(heat.setSensor(j).set(0));
                                          }
                                        }
                                        
                                        sleep(SLEEP_TIME);
                                      }
                                      

                                      When i try compile this sketch it get me error:

                                      C:\Users\Piotrek\Desktop\Temp dallas\Arduino_dallas_18B20_with_desc\Arduino_dallas_18B20_with_desc.ino: In function 'void presentation()':

                                      Arduino_dallas_18B20_with_desc:117:3: error: expected initializer before 'sensors'

                                      sensors.requestTemperatures();

                                      ^

                                      exit status 1
                                      expected initializer before 'sensors'

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

                                      @pepson you have a stray } after setWaitForConversion

                                      Tip: use ctrl+t in the editor to easier see this type of mistake

                                      pepsonP 1 Reply Last reply
                                      0
                                      • mfalkviddM mfalkvidd

                                        @pepson you have a stray } after setWaitForConversion

                                        Tip: use ctrl+t in the editor to easier see this type of mistake

                                        pepsonP Offline
                                        pepsonP Offline
                                        pepson
                                        wrote on last edited by
                                        #44

                                        @mfalkvidd
                                        Still is problem after use CTRL+T

                                        /**
                                           The MySensors Arduino library handles the wireless radio link and protocol
                                           between your home built sensors/actuators and HA controller of choice.
                                           The sensors forms a self healing radio network with optional repeaters. Each
                                           repeater and gateway builds a routing tables in EEPROM which keeps track of the
                                           network topology allowing messages to be routed to nodes.
                                        
                                           Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                                           Copyright (C) 2013-2015 Sensnology AB
                                           Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                                        
                                           Documentation: http://www.mysensors.org
                                           Support Forum: http://forum.mysensors.org
                                        
                                           This program is free software; you can redistribute it and/or
                                           modify it under the terms of the GNU General Public License
                                           version 2 as published by the Free Software Foundation.
                                        
                                         *******************************
                                        
                                           DESCRIPTION
                                        
                                           Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
                                           http://www.mysensors.org/build/temp
                                        */
                                        
                                        #define MY_GATEWAY_SERIAL
                                        
                                        // Enable debug prints to serial monitor
                                        #define MY_DEBUG
                                        
                                        #define MY_NODE_ID 14
                                        
                                        #include <SPI.h>
                                        #include <MySensors.h>
                                        #include <DallasTemperature.h>
                                        
                                        #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No
                                        
                                        #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
                                        #define ATTACHED_DS18B20 40
                                        unsigned long SLEEP_TIME = 60000; // 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.
                                        
                                        byte D[ATTACHED_DS18B20][8] = {
                                          { 0x10, 0x04, 0xB8, 0x3F, 0x02, 0x08, 0x00, 0xBD }, //KökTbx
                                          { 0x10, 0xF4, 0xD7, 0x3F, 0x02, 0x08, 0x00, 0xB1 }, //UppTbx
                                          { 0x10, 0x92, 0x9F, 0x3E, 0x02, 0x08, 0x00, 0x98 }, //KökUt
                                          { 0x10, 0x4E, 0xE4, 0x3E, 0x02, 0x08, 0x00, 0x3C }, //ToaUt
                                          { 0x10, 0x1E, 0xE8, 0x3E, 0x02, 0x08, 0x00, 0x33 }, //EfterPump
                                          { 0x10, 0x09, 0xA1, 0x3E, 0x02, 0x08, 0x00, 0xF7 }, //HallTbx
                                          { 0x10, 0x59, 0xCB, 0x3F, 0x02, 0x08, 0x00, 0xFA }, //UppUt
                                          { 0x10, 0x07, 0x1B, 0x3F, 0x02, 0x08, 0x00, 0x99 }, //ToaTbx
                                          { 0x28, 0xFF, 0xB1, 0xAA, 0x63, 0x15, 0x03, 0xC8 }, //Kök
                                          { 0x10, 0x80, 0xB6, 0x3F, 0x02, 0x08, 0x00, 0x29 }, //Panna komp
                                          { 0x10, 0x3C, 0x9C, 0x3E, 0x02, 0x08, 0x00, 0x99 }, //Hall ut
                                          { 0x10, 0x42, 0xE0, 0x3F, 0x02, 0x08, 0x00, 0xD1 }, //Tvätt
                                          { 0x10, 0xCE, 0xE9, 0x3E, 0x02, 0x08, 0x00, 0x3A }, //T12
                                          { 0x10, 0x99, 0xAC, 0x3F, 0x02, 0x08, 0x00, 0x25 }, //V mellan
                                          { 0x10, 0x15, 0xDB, 0x3E, 0x02, 0x08, 0x00, 0x01 }, //Hallen
                                          { 0x10, 0xF3, 0xD7, 0x3F, 0x02, 0x08, 0x00, 0x34 }, //Panna El
                                          { 0x10, 0xFB, 0xCB, 0x3F, 0x02, 0x08, 0x00, 0xC8 }, //Toa Nere
                                          { 0x10, 0x97, 0x23, 0x3F, 0x02, 0x08, 0x00, 0x92 }, //Varmvatten
                                          { 0x10, 0x0F, 0xE6, 0x3E, 0x02, 0x08, 0x00, 0xFD }, //Carport
                                          { 0x10, 0xF3, 0xC6, 0x3F, 0x02, 0x08, 0x00, 0x85 }, //Förrådet
                                          { 0x10, 0x9C, 0x3B, 0x52, 0x02, 0x08, 0x00, 0x25 }, //Mark 60
                                          { 0x10, 0xF2, 0x24, 0x3F, 0x02, 0x08, 0x00, 0xEB }, //Vrum V
                                          { 0x10, 0x6A, 0x5E, 0x52, 0x02, 0x08, 0x00, 0x26 }, //Mark 30
                                          { 0x10, 0x76, 0xCE, 0x3F, 0x02, 0x08, 0x00, 0xBA }, //Plattan
                                          { 0x10, 0x0E, 0x7B, 0x13, 0x02, 0x08, 0x00, 0x7C }, //Utetemp
                                          { 0x10, 0xEE, 0xEB, 0x3E, 0x02, 0x08, 0x00, 0x0F }, //Uterum
                                          { 0x28, 0x8C, 0x2D, 0xB4, 0x04, 0x00, 0x00, 0x9C }, //Kyl uppe
                                          { 0x28, 0xFF, 0xB2, 0x74, 0x63, 0x15, 0x02, 0xCC }, //Kyl mitten
                                          { 0x28, 0xFF, 0x08, 0x07, 0x52, 0x04, 0x00, 0xFF }, //Kyl nere
                                          { 0x28, 0xFF, 0xE6, 0x06, 0x52, 0x04, 0x00, 0x08 }, //Frys uppe
                                          { 0x28, 0xFF, 0xB4, 0x07, 0x55, 0x04, 0x00, 0xEB }, //Kyl bakom
                                          { 0x10, 0x1C, 0xA8, 0x3F, 0x02, 0x08, 0x00, 0x3B }, //Lucas
                                          { 0x10, 0x83, 0x3C, 0x3F, 0x02, 0x08, 0x00, 0x06 }, //Allrum
                                          { 0x10, 0xA3, 0xE8, 0x3E, 0x02, 0x08, 0x00, 0x7E }, //Theo
                                          { 0x10, 0x33, 0x3C, 0x3F, 0x02, 0x08, 0x00, 0x01 }, //Sovrum
                                          { 0x28, 0xFF, 0xFB, 0x3D, 0xC3, 0x16, 0x03, 0x58 }, //Panna luft in(varm)
                                          { 0x28, 0xFF, 0xD4, 0x1C, 0x00, 0x17, 0x03, 0x43 }, //Dränering
                                          { 0x28, 0xFF, 0x97, 0x11, 0x01, 0x15, 0x04, 0xC0 } // Poolvatten
                                        
                                        };
                                        
                                        float lastTemperature[ATTACHED_DS18B20];
                                        // Initialize temperature message
                                        MyMessage msg(0, V_TEMP);
                                        MyMessage heat(0, V_STATUS);
                                        
                                        void setup()
                                        {
                                          // Startup up the OneWire library
                                          sensors.begin();
                                          // requestTemperatures() will not block current thread
                                          sensors.setWaitForConversion(false);
                                        }
                                        void presentation() {
                                          // Send the sketch version information to the gateway and Controller
                                          sendSketchInfo("OneWire Temp+Heating LED", "20180709");
                                        
                                          // Fetch the number of attached temperature sensors
                                          //numSensors = sensors.getDeviceCount();
                                        
                                          // Present all sensors to controller
                                          for (int i = 0; i < ATTACHED_DS18B20; i++) {
                                            present(i, S_TEMP);
                                          }
                                          for (int i = ATTACHED_DS18B20; i < ATTACHED_DS18B20 + 5; i++) {
                                            present(i, S_HEATER);
                                          }
                                        
                                          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 < ATTACHED_DS18B20; i++) {
                                        
                                            //Serial.println(sensors.getResolution(D[i]), DEC);
                                            // Fetch and round temperature to one decimal
                                            //   float temperature = static_cast<float>(static_cast<int>((sensors.requestTemperaturesByAddress(D[i])) * 10.)) / 10.;
                                            float temperature = sensors.getTempC(D[i]);
                                            // 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;
                                            }
                                          }
                                        
                                          for (int i = 0; i < 5; i++) {
                                            int value = analogRead(i);
                                            /*Serial.print("Pin");
                                              Serial.print(i);
                                              Serial.print("=");
                                              Serial.println(value);
                                            */
                                            int j = i + ATTACHED_DS18B20;
                                            if (value > 150) {
                                              send(heat.setSensor(j).set(1));
                                            }
                                            else {
                                              send(heat.setSensor(j).set(0));
                                            }
                                          }
                                        
                                          sleep(SLEEP_TIME);
                                        }
                                        

                                        C:\Users\Piotrek\Desktop\Temp dallas\Arduino_dallas_18B20_with_desc\Arduino_dallas_18B20_with_desc.ino: In function 'void presentation()':

                                        Arduino_dallas_18B20_with_desc:117:3: error: expected initializer before 'sensors'

                                        sensors.requestTemperatures();

                                        ^

                                        exit status 1
                                        expected initializer before 'sensors'

                                        mfalkviddM 1 Reply Last reply
                                        0
                                        • pepsonP pepson

                                          @mfalkvidd
                                          Still is problem after use CTRL+T

                                          /**
                                             The MySensors Arduino library handles the wireless radio link and protocol
                                             between your home built sensors/actuators and HA controller of choice.
                                             The sensors forms a self healing radio network with optional repeaters. Each
                                             repeater and gateway builds a routing tables in EEPROM which keeps track of the
                                             network topology allowing messages to be routed to nodes.
                                          
                                             Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                                             Copyright (C) 2013-2015 Sensnology AB
                                             Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                                          
                                             Documentation: http://www.mysensors.org
                                             Support Forum: http://forum.mysensors.org
                                          
                                             This program is free software; you can redistribute it and/or
                                             modify it under the terms of the GNU General Public License
                                             version 2 as published by the Free Software Foundation.
                                          
                                           *******************************
                                          
                                             DESCRIPTION
                                          
                                             Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
                                             http://www.mysensors.org/build/temp
                                          */
                                          
                                          #define MY_GATEWAY_SERIAL
                                          
                                          // Enable debug prints to serial monitor
                                          #define MY_DEBUG
                                          
                                          #define MY_NODE_ID 14
                                          
                                          #include <SPI.h>
                                          #include <MySensors.h>
                                          #include <DallasTemperature.h>
                                          
                                          #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No
                                          
                                          #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
                                          #define ATTACHED_DS18B20 40
                                          unsigned long SLEEP_TIME = 60000; // 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.
                                          
                                          byte D[ATTACHED_DS18B20][8] = {
                                            { 0x10, 0x04, 0xB8, 0x3F, 0x02, 0x08, 0x00, 0xBD }, //KökTbx
                                            { 0x10, 0xF4, 0xD7, 0x3F, 0x02, 0x08, 0x00, 0xB1 }, //UppTbx
                                            { 0x10, 0x92, 0x9F, 0x3E, 0x02, 0x08, 0x00, 0x98 }, //KökUt
                                            { 0x10, 0x4E, 0xE4, 0x3E, 0x02, 0x08, 0x00, 0x3C }, //ToaUt
                                            { 0x10, 0x1E, 0xE8, 0x3E, 0x02, 0x08, 0x00, 0x33 }, //EfterPump
                                            { 0x10, 0x09, 0xA1, 0x3E, 0x02, 0x08, 0x00, 0xF7 }, //HallTbx
                                            { 0x10, 0x59, 0xCB, 0x3F, 0x02, 0x08, 0x00, 0xFA }, //UppUt
                                            { 0x10, 0x07, 0x1B, 0x3F, 0x02, 0x08, 0x00, 0x99 }, //ToaTbx
                                            { 0x28, 0xFF, 0xB1, 0xAA, 0x63, 0x15, 0x03, 0xC8 }, //Kök
                                            { 0x10, 0x80, 0xB6, 0x3F, 0x02, 0x08, 0x00, 0x29 }, //Panna komp
                                            { 0x10, 0x3C, 0x9C, 0x3E, 0x02, 0x08, 0x00, 0x99 }, //Hall ut
                                            { 0x10, 0x42, 0xE0, 0x3F, 0x02, 0x08, 0x00, 0xD1 }, //Tvätt
                                            { 0x10, 0xCE, 0xE9, 0x3E, 0x02, 0x08, 0x00, 0x3A }, //T12
                                            { 0x10, 0x99, 0xAC, 0x3F, 0x02, 0x08, 0x00, 0x25 }, //V mellan
                                            { 0x10, 0x15, 0xDB, 0x3E, 0x02, 0x08, 0x00, 0x01 }, //Hallen
                                            { 0x10, 0xF3, 0xD7, 0x3F, 0x02, 0x08, 0x00, 0x34 }, //Panna El
                                            { 0x10, 0xFB, 0xCB, 0x3F, 0x02, 0x08, 0x00, 0xC8 }, //Toa Nere
                                            { 0x10, 0x97, 0x23, 0x3F, 0x02, 0x08, 0x00, 0x92 }, //Varmvatten
                                            { 0x10, 0x0F, 0xE6, 0x3E, 0x02, 0x08, 0x00, 0xFD }, //Carport
                                            { 0x10, 0xF3, 0xC6, 0x3F, 0x02, 0x08, 0x00, 0x85 }, //Förrådet
                                            { 0x10, 0x9C, 0x3B, 0x52, 0x02, 0x08, 0x00, 0x25 }, //Mark 60
                                            { 0x10, 0xF2, 0x24, 0x3F, 0x02, 0x08, 0x00, 0xEB }, //Vrum V
                                            { 0x10, 0x6A, 0x5E, 0x52, 0x02, 0x08, 0x00, 0x26 }, //Mark 30
                                            { 0x10, 0x76, 0xCE, 0x3F, 0x02, 0x08, 0x00, 0xBA }, //Plattan
                                            { 0x10, 0x0E, 0x7B, 0x13, 0x02, 0x08, 0x00, 0x7C }, //Utetemp
                                            { 0x10, 0xEE, 0xEB, 0x3E, 0x02, 0x08, 0x00, 0x0F }, //Uterum
                                            { 0x28, 0x8C, 0x2D, 0xB4, 0x04, 0x00, 0x00, 0x9C }, //Kyl uppe
                                            { 0x28, 0xFF, 0xB2, 0x74, 0x63, 0x15, 0x02, 0xCC }, //Kyl mitten
                                            { 0x28, 0xFF, 0x08, 0x07, 0x52, 0x04, 0x00, 0xFF }, //Kyl nere
                                            { 0x28, 0xFF, 0xE6, 0x06, 0x52, 0x04, 0x00, 0x08 }, //Frys uppe
                                            { 0x28, 0xFF, 0xB4, 0x07, 0x55, 0x04, 0x00, 0xEB }, //Kyl bakom
                                            { 0x10, 0x1C, 0xA8, 0x3F, 0x02, 0x08, 0x00, 0x3B }, //Lucas
                                            { 0x10, 0x83, 0x3C, 0x3F, 0x02, 0x08, 0x00, 0x06 }, //Allrum
                                            { 0x10, 0xA3, 0xE8, 0x3E, 0x02, 0x08, 0x00, 0x7E }, //Theo
                                            { 0x10, 0x33, 0x3C, 0x3F, 0x02, 0x08, 0x00, 0x01 }, //Sovrum
                                            { 0x28, 0xFF, 0xFB, 0x3D, 0xC3, 0x16, 0x03, 0x58 }, //Panna luft in(varm)
                                            { 0x28, 0xFF, 0xD4, 0x1C, 0x00, 0x17, 0x03, 0x43 }, //Dränering
                                            { 0x28, 0xFF, 0x97, 0x11, 0x01, 0x15, 0x04, 0xC0 } // Poolvatten
                                          
                                          };
                                          
                                          float lastTemperature[ATTACHED_DS18B20];
                                          // Initialize temperature message
                                          MyMessage msg(0, V_TEMP);
                                          MyMessage heat(0, V_STATUS);
                                          
                                          void setup()
                                          {
                                            // Startup up the OneWire library
                                            sensors.begin();
                                            // requestTemperatures() will not block current thread
                                            sensors.setWaitForConversion(false);
                                          }
                                          void presentation() {
                                            // Send the sketch version information to the gateway and Controller
                                            sendSketchInfo("OneWire Temp+Heating LED", "20180709");
                                          
                                            // Fetch the number of attached temperature sensors
                                            //numSensors = sensors.getDeviceCount();
                                          
                                            // Present all sensors to controller
                                            for (int i = 0; i < ATTACHED_DS18B20; i++) {
                                              present(i, S_TEMP);
                                            }
                                            for (int i = ATTACHED_DS18B20; i < ATTACHED_DS18B20 + 5; i++) {
                                              present(i, S_HEATER);
                                            }
                                          
                                            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 < ATTACHED_DS18B20; i++) {
                                          
                                              //Serial.println(sensors.getResolution(D[i]), DEC);
                                              // Fetch and round temperature to one decimal
                                              //   float temperature = static_cast<float>(static_cast<int>((sensors.requestTemperaturesByAddress(D[i])) * 10.)) / 10.;
                                              float temperature = sensors.getTempC(D[i]);
                                              // 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;
                                              }
                                            }
                                          
                                            for (int i = 0; i < 5; i++) {
                                              int value = analogRead(i);
                                              /*Serial.print("Pin");
                                                Serial.print(i);
                                                Serial.print("=");
                                                Serial.println(value);
                                              */
                                              int j = i + ATTACHED_DS18B20;
                                              if (value > 150) {
                                                send(heat.setSensor(j).set(1));
                                              }
                                              else {
                                                send(heat.setSensor(j).set(0));
                                              }
                                            }
                                          
                                            sleep(SLEEP_TIME);
                                          }
                                          

                                          C:\Users\Piotrek\Desktop\Temp dallas\Arduino_dallas_18B20_with_desc\Arduino_dallas_18B20_with_desc.ino: In function 'void presentation()':

                                          Arduino_dallas_18B20_with_desc:117:3: error: expected initializer before 'sensors'

                                          sensors.requestTemperatures();

                                          ^

                                          exit status 1
                                          expected initializer before 'sensors'

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

                                          @pepson you’re missing a } before start of loop.

                                          pepsonP 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          29

                                          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