Announcement

Collapse
No announcement yet.

Project weekend: Using MQTT with HS3

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #46
    Is it possible with one HS3 device to get the status of and control an ESP8266 relay?

    I have an ESP8266 relay talking to my in-home MQTT broker, and that communicates to HS3 via the MQTT plug-in so my HS3 device follows the on/off state follows the state of the relay. But I haven't been able to create controls on that HS3 device to actually control that same relay.

    Thank you!


    ~Bill

    Comment


      #47
      Originally posted by Bill Brower View Post
      Is it possible with one HS3 device to get the status of and control an ESP8266 relay?

      I have an ESP8266 relay talking to my in-home MQTT broker, and that communicates to HS3 via the MQTT plug-in so my HS3 device follows the on/off state follows the state of the relay. But I haven't been able to create controls on that HS3 device to actually control that same relay.

      Thank you!
      I just created a garage door controller, so can monitor the input for the door status, and can trigger a relay to turn on momentarily that's connected to the garage door. I used a Wemos with the Wemos Relay shield.

      EDIT: Link https://www.wemos.cc/product/relay-shield.html

      EDIT2: For clarity, I created a virtual device for the relay, then have an event trigger to send the MQTT string to that device. "Publish custom topic: /raw/garage01/doorrelay 1"

      Comment


        #48
        Originally posted by mloebl View Post
        I just created a garage door controller, so can monitor the input for the door status, and can trigger a relay to turn on momentarily that's connected to the garage door. I used a Wemos with the Wemos Relay shield.

        EDIT: Link https://www.wemos.cc/product/relay-shield.html

        EDIT2: For clarity, I created a virtual device for the relay, then have an event trigger to send the MQTT string to that device. "Publish custom topic: /raw/garage01/doorrelay 1"
        Nice - Wemos are awesome little devices. I just do not know if I can publish and subscribe using one HS3 device. The ESP has a local switch that toggles the relay. So ideally this would act like a ZWave switch where locally it can be controlled and it sends the new status to HS3, or remotely I can toggle the relay from HS3.


        ~Bill

        Comment


          #49
          Originally posted by Bill Brower View Post
          Nice - Wemos are awesome little devices. I just do not know if I can publish and subscribe using one HS3 device. The ESP has a local switch that toggles the relay. So ideally this would act like a ZWave switch where locally it can be controlled and it sends the new status to HS3, or remotely I can toggle the relay from HS3.
          I do the event off the virtual device status change. If I click on/off, it sends a on (the 1) then off (0) 1.5seconds later.

          Comment


            #50
            Originally posted by mloebl View Post
            I do the event off the virtual device status change. If I click on/off, it sends a on (the 1) then off (0) 1.5seconds later.
            If you are using ESP Easy firmware I would actually instead of sending an ON then and then an OFF I would convert it to a rule that is run on the ESP that once it sees the relay toggle to ON, 1.5 seconds later let the ESP take care of the OFF. If the ESP gets an ON command and latches the relay and does not get an OFF for any number of reasons there is less of a chance of the still closed relay burning up a door opener controller.

            These ESPs are great for distributed controls. I could have have a bunch of money on running wires.


            ~Bill

            Comment


              #51
              So for some reason I've been really fascinated by LoRaWAN (I don't know why), but reasonably affordable 915mhz multichannel versions haven't been very attainable. I finally pulled the plug and I picked up a risingHF LoRa gateway from Seeedstudio ( https://www.seeedstudio.com/LoRa%2FL...-3-p-2821.html )

              I followed this setup using resin.io and a Raspberry Pi 3, https://github.com/jpmeijers/ttn-resin-gateway-rpi and was up and running connected to The Things Network in a few minutes.

              Code:
              18.06.17 21:12:53 (-0400) ##### 2017-06-19 01:12:53 GMT #####
              18.06.17 21:12:53 (-0400) ### [UPSTREAM] ###
              18.06.17 21:12:53 (-0400) # RF packets received by concentrator: 1
              18.06.17 21:12:53 (-0400) # CRC_OK: 100.00%, CRC_FAIL: 0.00%, NO_CRC: 0.00%
              18.06.17 21:12:53 (-0400) # RF packets forwarded: 1 (15 bytes)
              18.06.17 21:12:53 (-0400) # PUSH_DATA datagrams sent: 2 (416 bytes)
              18.06.17 21:12:53 (-0400) # PUSH_DATA acknowledged: 0.00%
              18.06.17 21:12:53 (-0400) ### [DOWNSTREAM] ###
              18.06.17 21:12:53 (-0400) # PULL_DATA sent: 3 (100.00% acknowledged)
              18.06.17 21:12:53 (-0400) # PULL_RESP(onse) datagrams received: 0 (0 bytes)
              18.06.17 21:12:53 (-0400) # RF packets sent to concentrator: 0 (0 bytes)
              18.06.17 21:12:53 (-0400) # TX errors: 0
              18.06.17 21:12:53 (-0400) ### [GPS] ###
              18.06.17 21:12:53 (-0400) # GPS sync is disabled
              18.06.17 21:12:53 (-0400) ##### END #####
              18.06.17 21:12:59 (-0400) INFO: [down] for server router.us.thethings.network PULL_ACK received in 78 ms
              18.06.17 21:13:09 (-0400) INFO: [down] for server router.us.thethings.network PULL_ACK received in 79 ms
              18.06.17 21:13:19 (-0400) INFO: [down] for server router.us.thethings.network PULL_ACK received in 76 ms

              Real challenge was getting an Adafruit Feather with LoRa and TTN's stack working, but finally got it connected going thru a ton of examples. The interesting thing about LoRa and using The Things Network, is that if you have remote devices, you don't have to go thru your gw but just need to hit one via 915mhz. There's not a lot yet here in the US, but in Europe it's quite a bit more popular on 868mhz (and I think 433mhz.) https://www.thethingsnetwork.org/map Also the 915mhz (and lower) frequencies tend to have much better range than wifi (could be miles if LoS with an omni antenna.)

              Server output is pretty interesting with plenty of connection details:
              Code:
              {
                "time": "2017-06-19T01:14:53.64245484Z",
                "frequency": 904.3,
                "modulation": "LORA",
                "data_rate": "SF10BW125",
                "coding_rate": "4/5",
                "gateways": [
                  {
                    "gtw_id": "xxxxxxxxxxxxxxxxxx",
                    "timestamp": 2358452148,
                    "time": "2017-06-19T01:14:53.72879Z",
                    "channel": 2,
                    "rssi": -54,
                    "snr": 9,
                    "latitude": XXXXXX,
                    "longitude": -XXXXXX,
                    "altitude": 100
                  }
                ]
              }
              Why is this relevant here? Well The Things Network has a MQTT bridge, so after doing some playing this weekend, was finally able to get my Feather sending some test value:

              Code:
              test_nodes/devices/adafruit_feather_01/up/testval1 8
              test_nodes/devices/adafruit_feather_01/up/testval2 7
              Uses encryption and custom apps you create (can have several), each with their own credentials. Can also pull out the connection details thru MQTT as well so can know the frequency, signal strength, gateway it used, etc. Pretty interesting. If I get a bit more traction on this, and this interest, I may write this up as a dedicated post. I searched the HS forum, and seen some LoRa, but nothing using The Things Network yet.

              Comment

              Working...
              X