Read Arduino Uno or Nano Sensors over Serial in Node-RED
An Arduino Uno or classic Nano can collect sensor readings locally and send them to a computer over USB serial. Node-RED can read each line, parse it and route data to a dashboard, file or another service. This is useful when the board has no network connection or you want a direct USB link.
The key design choice is to separate machine-readable data from human-friendly debugging text. A serial stream containing arbitrary messages, partial records and sensor values is difficult to parse reliably. Here, the Arduino emits one newline-terminated JSON object per sample, and Node-RED treats each line as a record.
1. Define a serial message format
For a simple data logger, a record might look like this JSON object:
Send a newline after each complete record, for example with Serial.println(). JSON is useful when each record has several named fields. For a very small constrained record, documented comma-separated values can also work. Do not mix startup banners or debug prose into the same stream if Node-RED expects every line to be JSON.
Make the baud rate explicit and use the same value at both ends. Keep the sample rate sensible: serial has finite throughput, and a high-frequency stream can overwhelm downstream dashboard or storage nodes.
2. Upload a transport test to Arduino
This sketch verifies that Arduino-to-Node-RED transport works before adding a real sensor. It reports the raw ADC reading from A0 and a sample counter. The ADC number is not a calibrated voltage or temperature. Replace the test fields with measurements only after you implement the appropriate sensor conversion.
Keep memory use modest on Uno/Nano and avoid building large dynamic strings for long-running streams. Close Arduino IDE's Serial Monitor before Node-RED opens the same serial port because many operating systems allow only one application to own it at a time.
3. Configure the Node-RED serial input
Install a maintained serial node package appropriate for your Node-RED installation if a serial node is not present. Add a serial input node, select the operating system's port for the Arduino, set 115200 baud to match the sketch, and configure the node to emit a complete line when it receives a newline delimiter.
The port name differs by operating system and device. Windows commonly displays a COM port; Linux commonly exposes a tty device; macOS uses a device path. Do not guess based on an old screenshot. Recheck it when reconnecting the board or changing USB adapters.
Connect Serial In to Debug first. Confirm each output contains exactly one line and lines do not arrive as fragments or combined records.
4. Parse and validate each line
Connect serial input to a JSON node, then to Debug. Inspect the type emitted by your serial node: it may provide a string or buffer depending on configuration. Configure the parser for the actual incoming type rather than assuming it.
Before driving a gauge or writing to a database, check that required values exist and are finite numbers. If a line is malformed, route it to an error branch or count it for diagnostics; do not automatically turn it into zero. For long-running logs, record a receive timestamp and decide what to do if the Arduino stops sending.
5. Send values to a dashboard or logger
Once parsing works, route validated fields to FlowFuse Dashboard widgets or a storage node. If your JSON object contains raw ADC counts, label the field as counts. Do not label it volts unless converted with the correct board reference voltage and ADC resolution. Do not label it temperature until an appropriate sensor and conversion are in place.
For a chart, include time or use the timestamp behavior documented by the chosen node. Keep sampling cadence and retention deliberate; a direct serial stream can create a large number of points in a long session.
Troubleshooting
No data: check power, the selected port and baud-rate agreement; close Serial Monitor.
Garbled output: check baud rate, line endings and cable/USB connection.
JSON parse error: verify every emitted line is valid JSON and no diagnostic message is mixed into the stream.
Port busy: close other applications using the serial port, then reconnect the device or restart the relevant serial node.
Dashboard freezes: measure arrival rate, verify serial input still continues and inspect downstream node errors.
Next steps
- Your First Node-RED Flow: Inject, Function and Debug
- Node-RED Dashboard 2.0: Install Buttons, Switches and Gauges
- Live DHT11 and BMP280 Dashboard with ESP32 and MQTT
Official reference: Node-RED messages and documentation for the specific serial node package. Record your operating system, board variant, node package version and baud rate when reproducing serial issues.