We've gotten our hands on an IoT Relay II from Digital Loggers for testing. This device can be controlled by either a digital signal from a microcontroller or by an AC input voltage, providing flexibility and ease of use for a variety of applications. It accepts a control voltage range of 3-48VDC or 12-120VAC. This means you can use either a DC voltage between 3V and 48V, or an AC voltage between 12V and 120V to control the relay. We will be using the CM4-Pro to control power to the CM4-Nano which is plugged into the Digital Logger power switch.
The Digital Logger device has Normal ON, always ON, and normally OFF. The CM4-Nano power supply is plugged into the Normally ON port, we will triggr it to turn off from the controller using the following wiring:
Now that the devices are wired up, plug in the CM4-Nano and head over to the CM4-Pro's control page:
From here we can control the relay for testing, the device connected to the Digital Logger power switch should power on and off on each click of the Relay Open/Close button.
First, a few setup steps to get started:
Start Unity, create new project, import Parallax Plugin.
Next open the UI Setup Wizard to configure the page.
Window > Parallax Control System > UI Setup Wizard
Name the page, add an icon and add the page elements.
To customize the text and to set the join id, go to
Window > Parallax Control System > UI Elements Panel. Or you can directly find the buttons in the Hierarchy on the left.
Setup the connection settings, so the user interface knows where to find the CM4-Pro processor.
Window > Parallax Control System >Settings
Go to File > Build Settings, press Add Open Scenes. We are going to build for Mac, press Build and Run.
Now the UI project is complete, next wire up the back-end logic in Node-Red.
Log into the processors IP, and access the Node-Red Dashboard:
Install the Parallax Control NPM package for Node-Red:
Next, drop in the MQTT nodes:
Aedes MQTT broker
Mqtt in
Add the Switch node:
From the Parallax package, add the "input-select" node, set the top node to 1 and the bottom to 2. This simulates selecting the first and second input of the "cm4-pro-relay" node. Add the "cm4-pro-relay" node.
Now when pressing On or Off, it will trigger the logic in Node-Red and the relay will trigger the Digital Logger power switch.
Next, build your project and run the application on your desktop or mobile device. Ensure the network permits connectivity between the user interface and processor.