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. Development
  3. Generic Temperature/repeater node

Generic Temperature/repeater node

Scheduled Pinned Locked Moved Development
9 Posts 3 Posters 5.3k Views 1 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.
  • B Offline
    B Offline
    blackdog65
    wrote on last edited by
    #1

    Hi Guys,

    I have several nodes up and running which I feed into Domoticz.

    I'm currently trying to turn the DallasTemperatureSensor script into a repeater node. I have built some plug-in temp sensors but I have range issues due to living in a "Faraday Mansion". Some of my internal walls are 700mm+ in thickness! My current "get around" is to have a Raspberry Pi + Arduino gateway connected to each wifi point (yeah wifi is a huge issue too!)

    So far I have
    gw.begin(NULL, AUTO, true);
    in the
    void setup()

    and I'm calling process() in my loop()

    But I don't know where to go with regard to sleep/wait etc.
    I'd like to take a temp reading every 10 - 15 mins but I'm stuck

    Any pointers? :D

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AWI
      Hero Member
      wrote on last edited by
      #2

      Hi and welcome. You can try a non-blocking code loop like:

      if (millis() > lastUpdate + loopDelay){
          < whatever you want to do> ;
         lastUpdate = millis();
      }
      

      make sure you have the lastUpdate (and loopDelay) as unisigned long

      • or -

      use gw.wait() ;

      1 Reply Last reply
      0
      • B Offline
        B Offline
        blackdog65
        wrote on last edited by
        #3

        Thanks for the reply!

        I got my "Arduino for Dummies" book from Amazon today... sooo let's give it a go :)

        1 Reply Last reply
        0
        • B Offline
          B Offline
          blackdog65
          wrote on last edited by
          #4

          Ok... I tried this based on the standard dallas DS18B20 sketch and I think it's working.

          It shows up in MSController as both a TEMP sensor and an ARDUINO_RELAY

          Tomorrow I'll try it with Domoticz

          Many thanks for the advice ;)

          #include <MySensor.h>  
          #include <SPI.h>
          #include <DallasTemperature.h>
          #include <OneWire.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 MAX_ATTACHED_DS18B20 16
          unsigned long WAIT_TIME = 300000; // Wait 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. 
          MySensor gw;
          float lastTemperature[MAX_ATTACHED_DS18B20];
          int numSensors=0;
          boolean receivedConfig = false;
          boolean metric = true; 
          // Initialize temperature message
          MyMessage msg(0,V_TEMP);
          
          void setup()  
          { 
            // Startup up the OneWire library
            sensors.begin();
            // requestTemperatures() will not block current thread
            sensors.setWaitForConversion(false);
          
            // Startup and initialize MySensors library. Set callback for incoming messages. 
            gw.begin(NULL, AUTO, true);
          
            // Send the sketch version information to the gateway and Controller
            gw.sendSketchInfo("Temperature Sensor", "1.1");
          
            // Fetch the number of attached temperature sensors  
            numSensors = sensors.getDeviceCount();
          
            // Present all sensors to controller
            for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {   
               gw.present(i, S_TEMP);
            }
          }
          
          
          void loop()     
          {     
            // Process incoming messages (like config from server)
            gw.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)
            gw.wait(conversionTime);
          
            // Read temperatures and send them to controller 
            for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
           
              // Fetch and round temperature to one decimal
              float temperature = static_cast<float>(static_cast<int>((gw.getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
           
              // Only send data if temperature has changed and no error
              #if COMPARE_TEMP == 1
              if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
              #else
              if (temperature != -127.00 && temperature != 85.00) {
              #endif
           
                // Send in the new temperature
                gw.send(msg.setSensor(i).set(temperature,1));
                // Save new temperatures for next compare
                lastTemperature[i]=temperature;
              }
            }
            gw.wait(WAIT_TIME);
          }
          1 Reply Last reply
          0
          • B Offline
            B Offline
            blackdog65
            wrote on last edited by
            #5

            Ah... actually it doesn't work :(
            It takes one temp reading and then sits there with a led flashing... damn!

            Anyone see the problem?

            A 1 Reply Last reply
            0
            • B blackdog65

              Ah... actually it doesn't work :(
              It takes one temp reading and then sits there with a led flashing... damn!

              Anyone see the problem?

              A Offline
              A Offline
              AWI
              Hero Member
              wrote on last edited by
              #6

              @blackdog65 You can include a few Serial.print's. It could block for while if "conversionTime" is long..

              1 Reply Last reply
              0
              • B Offline
                B Offline
                blackdog65
                wrote on last edited by
                #7

                How odd? Turned off and on... (which I'd tried obviously) and has worked perfectly since
                go figure

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  NotYetRated
                  wrote on last edited by
                  #8

                  700mm walls? Do you live in a blast shelter?! haha that has got to be infuriating. Although, the sound dampening from room to room between those walls has got to be nice!

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    blackdog65
                    wrote on last edited by
                    #9

                    It drives me crazy! The oldest part of the house pre-dates 1650 and was built to last. I have 4 wifi points hard-wired in as wifi will only reach the next room.

                    On the plus side, it's cool in summer and warm in winter ;)

                    1 Reply Last reply
                    1

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    48

                    Online

                    12.0k

                    Users

                    11.2k

                    Topics

                    113.4k

                    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