Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. Could use a bid help to get started

Could use a bid help to get started

Scheduled Pinned Locked Moved Troubleshooting
24 Posts 3 Posters 5.8k Views 2 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.
  • R Offline
    R Offline
    Rene046
    wrote on last edited by
    #4

    this is the sketch :
    /**

    • 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.

    • REVISION HISTORY
    • Version 1.0: Henrik EKblad
    • Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz)
    • DESCRIPTION
    • This sketch provides an example of how to implement a humidity/temperature
    • sensor using a DHT11/DHT-22.
    • For more information, please visit:
    • http://www.mysensors.org/build/humidity

    */

    // Enable debug prints
    #define MY_DEBUG

    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    //#define MY_RS485

    #include <SPI.h>
    #include <MySensors.h>
    #include <DHT.h>

    // Set this to the pin you connected the DHT's data pin to
    #define DHT_DATA_PIN 2

    // Set this offset if the sensor has a permanent small offset to the real temperatures
    #define SENSOR_TEMP_OFFSET 0

    // Sleep time between sensor updates (in milliseconds)
    // Must be >1000ms for DHT22 and >2000ms for DHT11
    static const uint64_t UPDATE_INTERVAL = 60000;

    // Force sending an update of the temperature after n sensor reads, so a controller showing the
    // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
    // the value didn't change since;
    // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
    static const uint8_t FORCE_UPDATE_N_READS = 10;

    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1

    float lastTemp;
    float lastHum;
    uint8_t nNoUpdatesTemp;
    uint8_t nNoUpdatesHum;
    bool metric = true;

    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    DHT dht;

    void presentation()
    {
    // Send the sketch version information to the gateway
    sendSketchInfo("TemperatureAndHumidity", "1.1");

    // Register all sensors to gw (they will be created as child devices)
    present(CHILD_ID_HUM, S_HUM);
    present(CHILD_ID_TEMP, S_TEMP);

    metric = getConfig().isMetric;
    }

    void setup()
    {
    dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
    if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
    Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
    }
    // Sleep for the time of the minimum sampling period to give the sensor time to power up
    // (otherwise, timeout errors might occure for the first reading)
    sleep(dht.getMinimumSamplingPeriod());
    }

    void loop()
    {
    // Force reading sensor, so it works also after sleep()
    dht.readSensor(true);

    // Get temperature from DHT library
    float temperature = dht.getTemperature();
    if (isnan(temperature)) {
    Serial.println("Failed reading temperature from DHT!");
    } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
    // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
    lastTemp = temperature;
    if (!metric) {
    temperature = dht.toFahrenheit(temperature);
    }
    // Reset no updates counter
    nNoUpdatesTemp = 0;
    temperature += SENSOR_TEMP_OFFSET;
    send(msgTemp.set(temperature, 1));

    #ifdef MY_DEBUG
    Serial.print("T: ");
    Serial.println(temperature);
    #endif
    

    } else {
    // Increase no update counter if the temperature stayed the same
    nNoUpdatesTemp++;
    }

    // Get humidity from DHT library
    float humidity = dht.getHumidity();
    if (isnan(humidity)) {
    Serial.println("Failed reading humidity from DHT");
    } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
    // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
    lastHum = humidity;
    // Reset no updates counter
    nNoUpdatesHum = 0;
    send(msgHum.set(humidity, 1));

    #ifdef MY_DEBUG
    Serial.print("H: ");
    Serial.println(humidity);
    #endif
    

    } else {
    // Increase no update counter if the humidity stayed the same
    nNoUpdatesHum++;
    }

    // Sleep for a while to save energy
    sleep(UPDATE_INTERVAL);
    }

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rene046
      wrote on last edited by
      #5

      Hi,

      What i see also often is that Mysensor.h is used in a lot of sketches
      and cant be found by Arduino's ide.

      WARNING: Spurious .mystools folder in 'MySensors' library
      H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\DHT22-1\DHT22-1.ino:2:22: fatal error: MySensor.h: No such file or directory

      i am afraid i have done something verry wrong that nothing seems to be working here.

      Installed arduino ide many times removed library's many time's but still no sketch with Mysensor works here.

      Please please help

      mfalkviddM 1 Reply Last reply
      0
      • R Rene046

        Hi,

        What i see also often is that Mysensor.h is used in a lot of sketches
        and cant be found by Arduino's ide.

        WARNING: Spurious .mystools folder in 'MySensors' library
        H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\DHT22-1\DHT22-1.ino:2:22: fatal error: MySensor.h: No such file or directory

        i am afraid i have done something verry wrong that nothing seems to be working here.

        Installed arduino ide many times removed library's many time's but still no sketch with Mysensor works here.

        Please please help

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

        @Rene046 how did you install the MySensors library? Did you use the instructions at https://www.mysensors.org/about/arduino#installing-the-sensor-libraries ?

        Where did you find the dht11 sketch? MySensor.h (without s before the dot) is from MySensors 1.x so it seems there is a mixup between different versions.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Rene046
          wrote on last edited by
          #7

          jes i installed it like in your link.

          Seems my sketch is then from an older version. because it uses Mysensor.h
          I also tried changing it to mysensors.h but then allot of things go wrong while compiling

          Maybe you could point me to a DHT sketch thats up-to-date ? for mysensor version 2.1.1
          i installed.

          Im totally new with mysensor, and now you told me i understand that lots of sketches on internet are old and dont work anymore.
          Where can i find info about changes ?

          i now am trying the sketch of this person
          https://forum.mysensors.org/topic/3774/multiple-dht22-in-one-sensor-for-greenhouse-newbee-question/5

          but he also seems to use old version, i see again mysensor.h instead of mysensors.h

          hope for an answer....

          mfalkviddM 1 Reply Last reply
          0
          • R Rene046

            jes i installed it like in your link.

            Seems my sketch is then from an older version. because it uses Mysensor.h
            I also tried changing it to mysensors.h but then allot of things go wrong while compiling

            Maybe you could point me to a DHT sketch thats up-to-date ? for mysensor version 2.1.1
            i installed.

            Im totally new with mysensor, and now you told me i understand that lots of sketches on internet are old and dont work anymore.
            Where can i find info about changes ?

            i now am trying the sketch of this person
            https://forum.mysensors.org/topic/3774/multiple-dht22-in-one-sensor-for-greenhouse-newbee-question/5

            but he also seems to use old version, i see again mysensor.h instead of mysensors.h

            hope for an answer....

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

            @Rene046 many MySensors sketches are included with the MySensors library. You can find them in File->Examples-MySensors in the Arduino IDE

            However, sketches that require external libraries (such as the temperature example which requires a MySensors fork of the DHT library) can not be included within the library. Therefore, they are available at https://github.com/mysensors/MySensorsArduinoExamples/archive/master.zip

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Rene046
              wrote on last edited by
              #9

              All those samples seems to work and compile perfect,

              But there is no sample with an DHT sensor temp. and hum included. or do i overlook ?

              mfalkviddM 1 Reply Last reply
              0
              • R Rene046

                All those samples seems to work and compile perfect,

                But there is no sample with an DHT sensor temp. and hum included. or do i overlook ?

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

                @Rene046 in the MySensorsArduinoExamples zip file is examples/DhtTemperatureAndHumiditySensor and libraries/DHT

                You'll need both those folders.

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Rene046
                  wrote on last edited by
                  #11

                  should i unzip those inside the mysensor map or arduino ?

                  mfalkviddM 1 Reply Last reply
                  0
                  • R Rene046

                    should i unzip those inside the mysensor map or arduino ?

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

                    @Rene046 I am not sure, but try putting DhtTemperatureAndHumiditySensor in the Arduino sketch folder (My Documents\Arduino on my computer) and DHT in the libraries folder (My Documents\Arduino\libraries on my computer)

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Rene046
                      wrote on last edited by
                      #13

                      ok done that, opened the sketch sample for dht.
                      compile and i get :

                      H:\WINDOW~1\Temp\arduino_modified_sketch_660970\DhtTemperatureAndHumiditySensor.ino: In function 'void presentation()':
                      
                      DhtTemperatureAndHumiditySensor:85: error: 'getConfig' was not declared in this scope
                      
                         metric = getConfig().isMetric;
                      
                                            ^
                      
                      Multiple libraries were found for "DHT.h"
                       Used: H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT
                       Not used: H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT-sensor-library-master
                      exit status 1
                      'getConfig' was not declared in this scope
                      
                      
                      mfalkviddM 1 Reply Last reply
                      0
                      • R Rene046

                        ok done that, opened the sketch sample for dht.
                        compile and i get :

                        H:\WINDOW~1\Temp\arduino_modified_sketch_660970\DhtTemperatureAndHumiditySensor.ino: In function 'void presentation()':
                        
                        DhtTemperatureAndHumiditySensor:85: error: 'getConfig' was not declared in this scope
                        
                           metric = getConfig().isMetric;
                        
                                              ^
                        
                        Multiple libraries were found for "DHT.h"
                         Used: H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT
                         Not used: H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT-sensor-library-master
                        exit status 1
                        'getConfig' was not declared in this scope
                        
                        
                        mfalkviddM Offline
                        mfalkviddM Offline
                        mfalkvidd
                        Mod
                        wrote on last edited by mfalkvidd
                        #14

                        @Rene046 There are two DHT folders. Delete the DHT folder that didn't come from the MySensorsArduinoExamples zip file.

                        1 Reply Last reply
                        0
                        • R Offline
                          R Offline
                          Rene046
                          wrote on last edited by
                          #15

                          ok now im left with this

                          H:\WINDOW~1\Temp\arduino_modified_sketch_225110\DhtTemperatureAndHumiditySensor.ino: In function 'void presentation()':
                          
                          DhtTemperatureAndHumiditySensor:85: error: 'getConfig' was not declared in this scope
                          
                             metric = getConfig().isMetric;
                          
                                                ^
                          
                          exit status 1
                          'getConfig' was not declared in this scope
                          
                          
                          mfalkviddM 1 Reply Last reply
                          0
                          • R Rene046

                            ok now im left with this

                            H:\WINDOW~1\Temp\arduino_modified_sketch_225110\DhtTemperatureAndHumiditySensor.ino: In function 'void presentation()':
                            
                            DhtTemperatureAndHumiditySensor:85: error: 'getConfig' was not declared in this scope
                            
                               metric = getConfig().isMetric;
                            
                                                  ^
                            
                            exit status 1
                            'getConfig' was not declared in this scope
                            
                            
                            mfalkviddM Offline
                            mfalkviddM Offline
                            mfalkvidd
                            Mod
                            wrote on last edited by
                            #16

                            @Rene046 see https://forum.mysensors.org/topic/5841/getconfig-was-not-declared-in-this-scope-v2-1-1-fixed/2
                            (change getConfig to getControllerConfig)

                            1 Reply Last reply
                            1
                            • R Offline
                              R Offline
                              Rene046
                              wrote on last edited by
                              #17

                              thanks it works... i love you ..lol

                              why do they change basic commands.... this make it hard to use.......

                              Like this command and why make from mysensor.h mysensors.h.

                              i also looked inside domoticz and i got data

                              thank you very very much

                              mfalkviddM 1 Reply Last reply
                              0
                              • R Rene046

                                thanks it works... i love you ..lol

                                why do they change basic commands.... this make it hard to use.......

                                Like this command and why make from mysensor.h mysensors.h.

                                i also looked inside domoticz and i got data

                                thank you very very much

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

                                @Rene046 the change from MySensor to MySensors is because the Arduino IDE requires the .h file to have exactly the same name as the library. That was not the case when MySensors was created, but happened some time in 2015 I think. So to comply with Arduino IDE rules, it had to be changed.

                                The reason for changing getConfig is logged at https://github.com/mysensors/MySensors/issues/736 but I am not sure why and the fix (https://github.com/mysensors/MySensors/pull/737 ) does not explain why either, but seems to be due to a mistake in https://github.com/mysensors/MySensors/commit/92cbd2ac8f49fe2f8cb25726e08aac9ecd597b84

                                1 Reply Last reply
                                0
                                • R Offline
                                  R Offline
                                  Rene046
                                  wrote on last edited by
                                  #19

                                  ok,

                                  At least i can now experiment with other sensors for my weather station project.
                                  i now all electronics are working, i saved this sketch and commented those changes.
                                  Again thank you for getting me started.

                                  mfalkviddM 1 Reply Last reply
                                  1
                                  • R Rene046

                                    ok,

                                    At least i can now experiment with other sensors for my weather station project.
                                    i now all electronics are working, i saved this sketch and commented those changes.
                                    Again thank you for getting me started.

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

                                    @Rene046 you're welcome. Great that you got it working.

                                    1 Reply Last reply
                                    0
                                    • R Offline
                                      R Offline
                                      Rene046
                                      wrote on last edited by
                                      #21

                                      can i ask another question....

                                      Im trying to add a battery sense pin to the sketch. they use gw. commands, are those also changed in the new version ?they are not recognized....

                                      They serail monitor shows me the voltage but how do i send it as and child to domoticz.

                                      mfalkviddM 1 Reply Last reply
                                      0
                                      • R Rene046

                                        can i ask another question....

                                        Im trying to add a battery sense pin to the sketch. they use gw. commands, are those also changed in the new version ?they are not recognized....

                                        They serail monitor shows me the voltage but how do i send it as and child to domoticz.

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

                                        @Rene046 most commands were simplified in MySensors 2.0. If the example you found uses gw.send(), remove gw. and just use send().

                                        1 Reply Last reply
                                        0
                                        • R Offline
                                          R Offline
                                          Rene046
                                          wrote on last edited by
                                          #23

                                          Thanks Mikael,

                                          could i find those new commands somewhere

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


                                          14

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular