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. NOT WORKING: DHT and RELAYS on Ethernet GW

NOT WORKING: DHT and RELAYS on Ethernet GW

Scheduled Pinned Locked Moved Development
20 Posts 3 Posters 2.4k Views 3 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.
  • gohanG gohan

    @zachflem I'd put a

    wait(300000)

    at the end of loop so the sensor only sends data every 5 minutes while the rest of the GW functions keep working

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

    @gohan The reason behind proposing to use a non-blocking loop() was as follows: The former gw.process()-function has been pushed in the background so it is no longer visible directly in the sketches. But nevertheless I thought, for GW's and repeaters it still is highly recommended to go through the loop() as often as possible to avoid any delays in the processing of ingoing messages.
    The proposal to just use wait() is not really compatible with this understanding of the internal machanics of MySensors. Did I get something wrong?

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

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

      "Wait" will keep the rest of the GW functions running, it is not like "delay" that blocks the code execution

      rejoe2R 1 Reply Last reply
      2
      • gohanG gohan

        @zachflem I'd put a

        wait(300000)

        at the end of loop so the sensor only sends data every 5 minutes while the rest of the GW functions keep working

        Z Offline
        Z Offline
        ZachFlem
        wrote on last edited by
        #6

        @gohan would the 5 minute wait() affect the rest of the loop? as in, if I add the wait, will it delay the activation of relays etc

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

          It does affect the loop of course, but since you are only running the DHT code it shouldn't be an issue. Give it a try, it is not a complicated change :)

          1 Reply Last reply
          0
          • gohanG gohan

            "Wait" will keep the rest of the GW functions running, it is not like "delay" that blocks the code execution

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

            @gohan said in NOT WORKING: DHT and RELAYS on Ethernet GW:

            "Wait" will keep the rest of the GW functions running, it is not like "delay" that blocks the code execution

            Thx for clarification :+1:

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

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              ZachFlem
              wrote on last edited by
              #9

              OK folks, so I've got it going to some extent.

              Added the wait(), and that seems to have calmed things down a bit, but I also added an external 5v power supply to the sensor and relay board

              The relays are working, and the temp and humidity are being reported on the serial monitor, but there is no value coming back to MyController from the DHT22.

              Sketch @ https://pastebin.com/mMxh65xp

              As always, your help is appreciated.

              Cheers

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

                Is the gateway actually sending the temperature? Do you see it in the logs?

                Z 1 Reply Last reply
                0
                • gohanG gohan

                  Is the gateway actually sending the temperature? Do you see it in the logs?

                  Z Offline
                  Z Offline
                  ZachFlem
                  wrote on last edited by
                  #11

                  @gohan nope, just checked, and I can see the presentation, and my manual trigger of the relays, but no data back from the sensor.

                  I'm also only getting the humidity presented to MyController

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

                    DHT sensors are quite lazy so they need their time, try adding a wait(1000) before the

                    float temperature = dht.getTemperature();

                    Z 1 Reply Last reply
                    0
                    • rejoe2R Offline
                      rejoe2R Offline
                      rejoe2
                      wrote on last edited by
                      #13

                      @zachflem said in NOT WORKING: DHT and RELAYS on Ethernet GW:

                      I'm also only getting the humidity presented to MyController

                      This also indicates some trouble in the communication between GW and Controller. For debugging, you may also add some wait()-time in between the presentation of the individual child-ID's.

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

                      1 Reply Last reply
                      0
                      • Z Offline
                        Z Offline
                        ZachFlem
                        wrote on last edited by
                        #14

                        So I've moved inside (it was bloody hot in the shed) and I'm working on my development board (it's a mirror of the setup in the shed, minus the external power supply for the sensors)

                        But with the shed sketch loaded into this MEGA, I'm getting the DHT values in the Serial Monitor, I'll hook it up proper to the network and see how we go.

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

                          As a personal suggestion, I'd start looking at better sensors like the I2C ones (SHT31, SHT21, Si7021, BME280, etc)

                          1 Reply Last reply
                          0
                          • gohanG gohan

                            DHT sensors are quite lazy so they need their time, try adding a wait(1000) before the

                            float temperature = dht.getTemperature();

                            Z Offline
                            Z Offline
                            ZachFlem
                            wrote on last edited by
                            #16

                            @gohan said in NOT WORKING: DHT and RELAYS on Ethernet GW:

                            DHT sensors are quite lazy so they need their time, try adding a wait(1000) before the

                            float temperature = dht.getTemperature();

                            So far I've done this, and I have a value coming from the GW for humidity, and I'm seeing a presentation for the temp sensor in the logs, but nothing comes up when I discover the GW...

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

                              What kind of gateway are you running?

                              Z 1 Reply Last reply
                              0
                              • gohanG gohan

                                What kind of gateway are you running?

                                Z Offline
                                Z Offline
                                ZachFlem
                                wrote on last edited by
                                #18

                                @gohan said in NOT WORKING: DHT and RELAYS on Ethernet GW:

                                What kind of gateway are you running?

                                An arduino mega clone with a w5100 based ethernet shield.

                                I think I might have found the problem, the humidity sensor reports as ID 0, the 2 relays as 1 and 2, and the temp sensor is showing up as 1, but before the relay.

                                So I think i need to add something to the sketch so that each type of sensor has a different prefix.

                                i.e. relays are 1XX, temp are 2XX etc

                                any thoughts?

                                rejoe2R 1 Reply Last reply
                                0
                                • Z ZachFlem

                                  @gohan said in NOT WORKING: DHT and RELAYS on Ethernet GW:

                                  What kind of gateway are you running?

                                  An arduino mega clone with a w5100 based ethernet shield.

                                  I think I might have found the problem, the humidity sensor reports as ID 0, the 2 relays as 1 and 2, and the temp sensor is showing up as 1, but before the relay.

                                  So I think i need to add something to the sketch so that each type of sensor has a different prefix.

                                  i.e. relays are 1XX, temp are 2XX etc

                                  any thoughts?

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

                                  @zachflem said in NOT WORKING: DHT and RELAYS on Ethernet GW:

                                  any thoughts?

                                  Not sure about if that's still valid, but there had been the recommendation to use ChildID 1 for the first relay. So you may use 3+4 for temp/hum or start with 10, 20 (or whatever you like) as proposed to have room for further relays or other type of switches.

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

                                  Z 1 Reply Last reply
                                  0
                                  • rejoe2R rejoe2

                                    @zachflem said in NOT WORKING: DHT and RELAYS on Ethernet GW:

                                    any thoughts?

                                    Not sure about if that's still valid, but there had been the recommendation to use ChildID 1 for the first relay. So you may use 3+4 for temp/hum or start with 10, 20 (or whatever you like) as proposed to have room for further relays or other type of switches.

                                    Z Offline
                                    Z Offline
                                    ZachFlem
                                    wrote on last edited by
                                    #20

                                    @rejoe2 said in NOT WORKING: DHT and RELAYS on Ethernet GW:

                                    @zachflem said in NOT WORKING: DHT and RELAYS on Ethernet GW:

                                    any thoughts?

                                    Not sure about if that's still valid, but there had been the recommendation to use ChildID 1 for the first relay. So you may use 3+4 for temp/hum or start with 10, 20 (or whatever you like) as proposed to have room for further relays or other type of switches.

                                    Yeah, just re-read it and found the hard define for the IDs of those, and set them to 100 and 101.

                                    Now I have the 2 relays defined as 1 & 2 and the Humidity as 100 and Temp as 101.

                                    Can see all 4 sensors but only getting a value from the temp sensor.

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


                                    16

                                    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