As an IoT team, we love pushing boundaries. What happens when you take Node-RED—already known for its efficiency—and run it on truly limited hardware? From Raspberry Pi 4s managing greenhouse sensors to Android phones running full IoT flows via Termux emulation, we've discovered that powerful automation doesn't always need powerful hardware.
Here's what we've learned from our experiments, complete with the code snippets and configuration tricks that made it all work.
Setting Up Node-RED on Raspberry Pi 4/CM4: A Solid Foundation for IoT Experiments
The Raspberry Pi is our go-to for stationary IoT projects, and Node-RED installs like a charm using NVM (Node Version Manager) for easy Node.js management and PM2 for process reliability. This setup ensures your flows run smoothly 24/7, even after reboots. We've used it to build everything from greenhouse monitors to custom USB controllers.
Step 1: Install NVM and Node.js
Start by grabbing NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Then load it (or restart your terminal):
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
Install Node 20 and set it as default, plus global packages:
nvm install 20
nvm alias default 20
npm i -g pm2 node-red gtop
Step 2: Initialize Node-RED and Set Up PM2
Fire up Node-RED once to create its config folder (stop with Ctrl-C):
node-red
Make it autostart with PM2:
pm2 startup
# Follow the prompted command, e.g., sudo env PATH=$PATH:/home/...
pm2 start node-red
pm2 save
Step 3: Add Fun Packages and Permissions
We've enhanced our Pi setups with Dashboard 2.0 for interactive UIs, an MQTT broker, GPIO nodes for hardware tinkering, and USB HID for connecting devices like keyboards or custom controllers:
cd ~/.node-red
npm i @flowfuse/node-red-dashboard node-red-contrib-aedes node-red-node-pi-gpio @gdziuba/node-red-usbhid
For USB HID on Debian/Pi, install dependencies and set permissions:
sudo apt install libusb-1.0-0 libusb-1.0-0-dev libudev-dev -y
sudo mkdir -p /etc/udev/rules.d
sudo nano /etc/udev/rules.d/85-pure-data.rules
Paste this into the file:
SUBSYSTEM=="input", GROUP="input", MODE="0777"
SUBSYSTEM=="usb", MODE:="777", GROUP="input"
KERNEL=="hidraw0", MODE="0777", GROUP="input"
KERNEL=="hidraw1", MODE="0777", GROUP="input"
KERNEL=="hidraw2", MODE="0777", GROUP="input"
Then apply:
sudo groupadd -f input
sudo gpasswd -a $USER input
sudo udevadm control --reload-rules
Bonus: Setting Up an MQTT Server in Node-RED
For IoT magic, add node-red-contrib-aedes
as a built-in broker. Test connections externally:
sudo apt-get install mosquitto-clients
mosquitto_sub -h 192.168.0.X -p 1883 -u username -P password -t '#' -v --quiet -W 5
We've used this to connect sensors across devices – super fun for real-time data flows!
Running Node-RED on Android via Termux: Portable IoT on the Go
Now for the wild part: emulating a full Linux environment on Android with Termux to run Node-RED. This turns your phone into a mobile IoT controller, perfect for fieldwork or quick prototypes. We've tested it on budget phones, and it handles flows surprisingly well, even with emulated hardware limits.
Just install Termux, Termux:API, and Termux:Tasker from F-Droid (avoid Play Store versions for compatibility).
Step 1: Disable Phantom Process Killer
Android loves killing background apps, so we disable this via ADB (enable USB/Wireless Debugging first):
adb pair IP:PORT # e.g., adb pair 192.168.50.174:39663
# Enter pairing code
adb connect IP:DIFFERENT_PORT # e.g., adb connect 192.168.50.174:37593
adb shell "/system/bin/device_config set_sync_disabled_for_tests persistent"
adb shell "/system/bin/device_config put activity_manager max_phantom_processes 2147483647"
adb shell settings put global settings_enable_monitor_phantom_procs false
Step 2: Install Packages in Termux
Update and grab essentials:
pkg upgrade
pkg install root-repo x11-repo coreutils nano net-tools wireless-tools tigervnc which termux-api openssh nodejs-lts git
Step 3: Set Up Remote SSH Access
For easy remote management:
mkdir ~/.ssh
nano authorized_keys # Paste your public key
Connect via: ssh u0_a13@IP -p 8022
Step 4: Install Node-RED and Extras
pkg install nodejs
npm i -g --unsafe-perm node-red pm2 gtop
npm i -g --unsafe-perm @flowfuse/node-red-dashboard node-red-contrib-aedes image-tools node-red-contrib-termux-api
Step 5: Configure VNC for a Desktop View
Install XFCE4:
pkg i xfce4
vncserver -geometry 1920x1080 -xstartup startxfce4
Autostart services in .bash_profile
:
sshd
pm2 start node-red
pm2 save
vncserver -geometry 1920x1080 -xstartup startxfce4
Step 6: Auto-Start on Boot
Use split-screen with ZeroTier, lock apps, and tweak battery settings. For benchmarks, we've run glmark2
to test the emulated desktop performance.
Our Team's Experimental Tidbits: Proving It Works on Limited Hardware
We've pushed these setups hard to show Node-RED's robustness. Here are some code snippets from our experiments:
1. Increasing Swap Space
On low-RAM devices like older Pis or Android emulators, we boost swap to prevent crashes during heavy flows (e.g., image processing):
sudo fallocate -l 2G /swapfile # Create 2GB swap file
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab # Make persistent
2. Friendly Networking Names
To make devices easier to find on the network, we set hostnames:
sudo hostnamectl set-hostname my-iot-hub # On systemd systems like Pi
echo "my-iot-hub" > /etc/hostname # Fallback
sudo systemctl restart systemd-hostnamed
3. Adding ZeroTier for Fixed IPs on Android
ZeroTier gives virtual networks and static IPs, ideal for mobile setups. Install the app, join a network (e.g., x1234yz
), and authorize. In Termux, we've scripted checks:
zerotier-cli join NETWORK_ID # If CLI available
zerotier-cli listnetworks # Verify connection
Real-World Applications We've Built
Greenhouse Monitoring System
Using a Pi 4 with Node-RED, we built a complete greenhouse automation system:
- Temperature/humidity sensors via GPIO
- Camera module for plant monitoring
- MQTT integration for remote alerts
- Dashboard 2.0 for real-time visualization
- Automated watering based on soil moisture
Mobile Field Data Collection
With Node-RED on Android via Termux:
- GPS tracking for agricultural surveys
- Photo capture with metadata tagging
- Offline data storage with sync when connected
- ZeroTier networking for secure data transmission
Custom USB Controller Interface
Connecting specialized hardware:
- USB HID integration for custom input devices
- Real-time data processing from sensors
- Web-based control panels accessible from any device
- MQTT bridging to cloud services
Performance Insights: What We Learned
Memory Management
- Raspberry Pi 4 (4GB): Handles 50+ complex flows simultaneously
- Android (6GB RAM): Runs Node-RED + VNC + multiple apps without issues
- Swap optimization: Critical for image processing and large data flows
Network Performance
- ZeroTier overhead: ~5-10ms latency increase, negligible for IoT
- MQTT throughput: 1000+ messages/second on Pi 4
- Dashboard responsiveness: Sub-100ms updates on local network
Power Consumption
- Pi 4 with Node-RED: ~3-5W average (perfect for solar setups)
- Android with Termux: Battery drain comparable to video streaming
- Optimization tip: Use PM2's cluster mode for CPU-intensive flows
Why This Matters for IoT Development
Our experiments prove that sophisticated IoT automation doesn't require expensive hardware. With Node-RED's visual programming and these optimization techniques, you can:
- Prototype rapidly on any available hardware
- Deploy cost-effectively in resource-constrained environments
- Scale incrementally from proof-of-concept to production
- Maintain flexibility with portable, emulated environments
Ready to Build Your Own IoT Lab?
These Node-RED experiments are just the beginning of what's possible with creative hardware utilization. Whether you're monitoring crops, automating your home, or building industrial sensors, the principles we've shared here will help you maximize your hardware investment.
Want to dive deeper into DIY IoT infrastructure?
🔧 Explore our complete HomeLab DIY series where we cover everything from hardware selection to advanced networking setups. Our Tech Hotpot blog features detailed guides on:
- Hardware Selection: Choosing the right devices for your IoT projects
- Network Architecture: Building robust, scalable IoT networks
- Data Management: Handling sensor data at scale
- Security Best Practices: Protecting your IoT infrastructure
- Advanced Automation: Complex flows and integrations
From Raspberry Pi clusters to edge computing setups, our HomeLab series shows you how to build professional-grade IoT infrastructure on a budget.