Case StudiesArrow - Elements Webflow Library - BRIX Templates
Controlling a Digital Logger power switch

Controlling a Digital Logger power switch

May 9, 2024

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.

High level overview

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:

Wiring Diagram

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.

Powered On
Powered Off

Part II: Create a desktop application to control the relay.

First, a few setup steps to get started:

Start Unity, create new project, import Parallax Plugin.

New Project

Create project
Import Parallax Control Plugin

Dont have the plugin? Get a free trial on the website to follow along: https://www.parallaxcontrol.com/trial
The empty canvas

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.

UI Setup Wizard

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.

UI Elements Panel
The UI is complete, next setup the connection settings

Setup the connection settings, so the user interface knows where to find the CM4-Pro processor.

Window > Parallax Control System >Settings

Settings Panel

Go to File > Build Settings, press Add Open Scenes. We are going to build for Mac, press Build and Run.

Configure Build Settings

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:

Log into Node-Red

Install the Parallax Control NPM package for Node-Red:

Hamburger Menu > Manage Pallet

Next, drop in the MQTT nodes:

Aedes MQTT broker

Mqtt in

Configure the MQTT node

Add username and password for security

Set your server to local host 127.0.0.1 which refers the processors IP. Set your Topic to match what you are publishing from Unity.

Add the Switch node:

Mqtt input node with Topic "digital_input" passing messages to the switch node for processing.

Switch on the msg.payload.JoinID, using 10 for ON and 11 for OFF as set in Unity.

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.

The completed flow.

Now when pressing On or Off, it will trigger the logic in Node-Red and the relay will trigger the Digital Logger power switch.

Programmer View (left is Node-Red, right is Unity)

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.