Decaf Sensor / Control WiFi Network Nodes

Last Update: May 24, 2023 @ 15:15 Preliminary information, subject to change.

Application Note

Placing arrays of sensors on to network nodes is feasible and affordable using a RaspberryPi (“RPi3” or “RPi 4”) with WiFi host. The RPi3 or Rpi4 are ideal, but may have more capability than needed, or the physical space or power consumption may be issues. The RaspberryPi Zero-2W (“Zero”) with a USB2 hat is a viable option, and is physically smaller than the RPi3.

The Zero-2W replaces the original 1GHz single-core Pi Zero with the 1GHz quad-core cpu from the RPi3B, but still with 512KB of ram. The new cpu provides a substantial increase in performance. The 512KB ram is still a limiting factor esspecially for any browser or graphics applications. If just sensor I/O data transfer is required (e.g. using MQTT protocols) the Zero is an ideal device.

The image above shows the Zero plus the USB expansion board with four USB2 type A ports implemented as a USB hub. The two boards are connected with a jumper circuit board from the USB-OTG connector on the Zero.

One port (left side) is at present reserved for a wireless Mouse/Keyboard dongle for development work and potentially node management.

The three remaining ports could used for Decaf IOC-M-2 modules, giving the node a maximum of 24 digital inputs, 24 digital outputs, and 6 analog inputs.

Alternatively, if more analog support is needed, one to three Decaf IOC-2xe boards could be used. This would give a maximum of 48 digital inputs, 48 digital outputs, and 24 analog inputs.

Note that there are power limitations to the power that each USB port can consume. IOC-M and IOC-2xe boards consume very little, while Decaf boards with a LCD will usually require a powered hub or external power supply. Tests show the Zero will boot with an IOC-235 connected, however the in-rush current on plugging it into a running system overloads the Zero USB power circuit and crashes Raspbian.

Enabling the WiFi on the RaspberryPi Zero-2W

This takes less than a minute, via a console window, and is configured as an IPv4 node. This means that the Zero is expected to be part of a LAN with an IPv6 gateway to the Internet. The WiFi IP address can be configured via DHCP (the default mode) or with some fiddling with your router, as a static IP address. The node does not have to have access to the Internet unless this a requirement for your project. See the notes below on using MQTT.

Display Screen Options

The Zero can boot up to a desktop in around 53 seconds, or a console boot is about 24 seconds.  An app does not have to use the Zero HDMI to have a display. Any of the Decaf boards with LCDs can be used, and a minimal User Interface displayed on it. For example, a geothermal pump system RPi3 node could transmit operating data to the Zero node, which would remotely display operating parameters. It should be noted that the RPi3 node could also send data to be presented on a Zero node HDMI display using a browser.

App Development

While this can be done on the Zero, it is probably better to use a faster RPi3 with the necessary developer libraries and tools. Once development is done, the app and end-user libraries only are deployed to the Zero.

If the app requires a user interface, the GTK framework is a suitable option. The app makes use of the Decaf SDK to access all the connected devices.

What does the App have to do?

An app running on the Zero has to act as

  1. a data concentrator that acquires the input sensor data into packets, encrypted if desired, and transmitted to another master node on the network.
  2. a command processor that handles instructions for the digital outputs, and read commands for digital inputs. If an LCD is present, process LCD graphics commands, and potentially LCD touch commands.
  3. a controller to acquire data from, and send commands to, the connected Decaf board(s).

These requirements can easily be handled using the MQTT libraries that can be easily installed on the Zero. Requirement #1 above becomes a MQTT publisher, and #2 becomes a subscriber.

Network Security Issues

Encryption and other security packages are available for Raspbian. MQTT (a.k.a. ‘mosquitto’) packets can be configured to be transmitted encrypted.

You can create MQTT apps on Windows using a new extension command library built into PiXCL 20 ISC. A RaspberryPi or other linux node can easily work with the PiXCL app.

A PiXCL 22 app running as a ‘mosquitto’ publisher and subscriber, with LAN nodes on Windows 10, a Broker on Intel ubuntu 18.04 and publishers on Raspbian, with additional EyeFi current sensor nodes. Accessible nodes are marked with the green tick icon.

< More to come, check back again soon. >

Copyright © 2024 PiXCL Automation Tech Notes, Canada. All Rights Reserved.