Announcement

Collapse
No announcement yet.

Use HS4 Virtual Devices to Monitor/Control Raspberry Pi GPIO Pins

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

    Use HS4 Virtual Devices to Monitor/Control Raspberry Pi GPIO Pins

    I started working on this a few days ago for my son, who wants to use a Raspberry Pi (or 2) to monitor and control a model railroad layout. This is a write up to get him started. In this demo environment, I have HS4-Pi running on a Pi-400 and Node-RED running on a 3B. The GPIO connections are on the 3B. There's a jumper wire between GPIO20 (Out) and GPIO21 (In). I will use an HS Device with two features for this demo.

    Create a new HS device which will result in a Root Device and a Feature Device. The feature will have controls we will use to control the GPIO20 output. Set the Status/Graphics tab for the feature as follows:

    Click image for larger version

Name:	Screen Shot 2022-04-20 at 12.37.19 PM.png
Views:	285
Size:	83.9 KB
ID:	1538267


    Next, use Bulk Edit to make a copy of the feature and set its Status/Graphics tab as follows:

    Click image for larger version

Name:	Screen Shot 2022-04-20 at 12.41.57 PM.png
Views:	196
Size:	64.7 KB
ID:	1538268
    Basically, just delete the controls for the monitoring device. That's it for the HS Device setup.

    Now onto Node-RED. Again, Node-RED is running on a 3B and HS4-Pi on a Pi-400 but it could be on the same Pi. The key is that this flow needs to be running on the Pi you want to monitor and control. Here's the complete flow:

    Click image for larger version

Name:	Screen Shot 2022-04-20 at 12.52.37 PM.png
Views:	195
Size:	38.6 KB
ID:	1538269

    Here's the output control nodes:

    Click image for larger version

Name:	Screen Shot 2022-04-20 at 12.54.21 PM.png
Views:	195
Size:	22.0 KB
ID:	1538270

    Click image for larger version

Name:	Screen Shot 2022-04-20 at 12.54.55 PM.png
Views:	203
Size:	18.1 KB
ID:	1538271

    Click image for larger version

Name:	Screen Shot 2022-04-20 at 12.59.55 PM.png
Views:	201
Size:	91.1 KB
ID:	1538272

    And the monitoring input nodes:

    Click image for larger version

Name:	Screen Shot 2022-04-20 at 1.09.16 PM.png
Views:	192
Size:	91.3 KB
ID:	1538273

    Click image for larger version

Name:	Screen Shot 2022-04-20 at 1.09.50 PM.png
Views:	195
Size:	18.1 KB
ID:	1538274

    Click image for larger version

Name:	Screen Shot 2022-04-20 at 1.10.07 PM.png
Views:	199
Size:	21.1 KB
ID:	1538275

    Now, when you click on the Low/High buttons on the control device, the GPIO output will be set Low or High. Since it's jumped to the GPIO Input, you'll see the monitoring device change as well.

    Click image for larger version

Name:	Screen Shot 2022-04-20 at 1.29.32 PM.png
Views:	190
Size:	26.0 KB
ID:	1538276

    Use Bulk Edit to make copies of the input/output features and duplicate/edit the input/output nodes for additional GPIOs.

    Feel free to ask questions.
    Ken
    "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

    #2
    Are you controlling the trains or lights and other scenery on buildings, streets, etc, or both? Have you heard of JMRI? It can likely do a lot of this for you. It also has MQTT capabilities.

    Karl S
    HS4Pro on Windows 10
    1070 Devices
    56 Z-Wave Nodes
    104 Events
    HSTouch Clients: 3 Android, 1 iOS
    Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

    Comment


      #3
      Sorry, also meant to ask if you are using DCC for the trains themselves.
      Karl S
      HS4Pro on Windows 10
      1070 Devices
      56 Z-Wave Nodes
      104 Events
      HSTouch Clients: 3 Android, 1 iOS
      Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

      Comment


        #4
        TBH, he's just in the planning (thinking) stage. He is most interested in a switching yard and using GPIOs to manage switches (i.e. keep opposing things from happening). Yes, scene lighting, buildings, street lighting, etc. will be included. JMRI is a little more than what he wants. He was looking at using Node-RED only, but since he knew I've been using HomeSeer for 20+ years, he asked about what kind of Raspberry Pi support it had.

        Yes, he has 4x DCC locos and 2x that aren't. This is N scale in case that matters.
        "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

        Comment


          #5
          Out of curiosity, what, other than utilizing your comfort level with it, is homeseer actually providing in this setup?

          Comment


            #6
            TBH, not much. There's a lot of ways to do this without HomeSeer, I just wanted to figure out how to control and monitor GPIO pins from HS devices and also gauge my son's interest in learning HomeSeer. In the end he's likely going to use Java. (JMRI).
            "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

            Comment

            Working...
            X