Watch: Getting Started with sensors/relays
The video above demonstrates sensors and relay modules in action with Node-RED. Below we cover what each board type does, how to connect things safely, and a first project that ties inputs to outputs.
Prefer the full written guide? The complete text version covers sensor types, wiring paths, flow logic, and beginner mistakes in depth: Getting Started with Sensors and Relays in Node-RED.
Quick answer: Sensors give Node-RED something to react to and relays give it something to control.
Read a DHT22 temperature sensor, run the value through a switch node, and fire a relay module when the room passes your threshold — that loop is the heart of most automations.
What do sensors and relays do in a Node-RED project?
Sensors are inputs: they measure temperature, humidity, motion, light, or moisture and turn that into messages your flow can reason about. Relays are outputs: electrically controlled switches that let a tiny control signal turn larger loads such as fans, pumps, or lamps on and off.
Which sensor should you start with?
The DHT22 remains the classic choice: one inexpensive part reports both temperature and humidity, and Adafruit’s guide documents wiring and reading it with Arduino and Raspberry Pi (learn.adafruit.com/dht). Two useful values from one wire make it ideal for learning threshold logic.
How do relay modules connect to a Raspberry Pi?
A typical relay board has two sides: control pins (VCC, GND, and one signal pin per channel) that connect to your controller, and screw terminals that sit in the switched circuit. Check the module’s trigger-voltage requirements against your controller — the Raspberry Pi’s 40-pin header operates at 3.3 V logic levels, as the interactive reference at pinout.xyz documents, while many relay boards expect 5 V signals.
How should sensor data reach Node-RED?
| Path | Typical hardware | Best for |
|---|---|---|
| Direct GPIO | Wired sensors on the Pi header | Single-board projects |
| MQTT | ESP32 devices or Zigbee bridges publishing to a broker | Multi-device homes |
MQTT’s lightweight publish/subscribe design is why it became the default messaging layer for IoT builds (mqtt.org); inside Node-RED the message-handling model is documented in the nodes user guide.
What safety rules matter with relays?
- Practice with low-voltage loads (USB fans, 12 V LEDs) before touching mains.
- Never work on a powered circuit.
- Add hysteresis in your flow so relays do not chatter on and off around a threshold.
- Label normally-open and normally-closed terminals clearly.
How do our relay and sensor picks compare?
| Board | Type (as listed) | Good first use |
|---|---|---|
| JBtek 4 Channel DC 5V Relay Module | 4-channel relay | Multi-output switching practice |
| Electronics-Salon 4 DPDT Signal Relay Board | DPDT signal relays | Switching two circuits per channel |
| KOOKYE 16-in-1 Smart Home Sensor Kit | Mixed sensor bundle | Trying many input types cheaply |
| SunFounder 5V 8-Channel Relay Shield | 8-channel relay | Larger automation banks |
Top Recommended Products
Here's our complete list of top picks, with detailed justifications:
- JBtek 4 Channel DC 5V Relay Module for Arduino Raspberry Pi: Simple 4-channel relay module perfect for Node-RED beginners to control lights, fans, and other AC devices safely through GPIO.
- Electronics-Salon 4 DPDT Signal Relay Module Board for Arduino Raspberry Pi: DPDT relays provide more switching flexibility for complex Node-RED automations, great for controlling multiple circuits with single modules.
- KOOKYE 16 in 1 Smart Home Sensor Modules Kit for Arduino Raspberry Pi: Comprehensive kit with temperature, humidity, motion, and other sensors, ideal for learning Node-RED sensor integrations.
- SunFounder 5V 8 Channel Relay Shield Module for Arduino Raspberry Pi: 8-channel shield provides extensive relay control for advanced Node-RED home automation projects controlling many devices simultaneously.
As an Amazon Associate I earn from qualifying purchases.
Frequently Asked Questions
Can Node-RED damage my Raspberry Pi?
Software cannot, but miswiring can — always double-check pin assignments against a pinout reference before powering anything.
What is hysteresis?
A buffer band around your threshold: turn the fan on at 28°C but only off at 26°C, so the relay is not toggled constantly near the setpoint.
Do I need a breadboard?
It makes prototyping far easier, but the modules in our picks mostly use jumper wires directly.
Wired or wireless sensors?
Both work. Wired GPIO is simplest for one room; MQTT-connected wireless sensors scale across a house.
Further Reading
Continue with these guides on this site:
- Getting Started with Sensors and Relays in Node-RED — the full written guide this walkthrough accompanies.
- Top 10 Sensors and Relays for Node-RED — hardware picks for the input-and-output side.
Sources
- Raspberry Pi GPIO pinout reference — pin layout and 3.3 V logic levels of the 40-pin header.
- Adafruit DHT sensor guide — wiring and code for DHT22-style sensors.
- MQTT official site — publish/subscribe messaging protocol used by IoT devices.
- Node-RED nodes user guide — how messages move through flows.