Installation & migration guide

RS-485 home sensors

Radon sensors, power meters and temperature/humidity sensors on RS-485/Modbus, bridged to MQTT by Wemos D1 Mini boards and shown in Homey. This page covers wiring, flashing and setup for every part, and how to move it all to a new server or Homey.

Bus RS-485 · Modbus RTU · 9600 / 4800 baud Broker Mosquitto 2.0 Homey Pro, app com.radonsensor.mqtt
System overview: two RS-485 buses, two Wemos bridges, one MQTT broker, one Homey Radon sensor ×1–7 Uno + RD200M + LCD RS-485 · 9600 8N1 Wemos bridge BRIDGE_ID "radon" Meters + climate DTSU666 · SDM120 · Renke RS-485 · 4800 8N1 Wemos bridge BRIDGE_ID "power" Mosquitto broker Ubuntu server :1883 WiFi · MQTT WiFi · MQTT LAN · MQTT Homey Pro RS-485 Bridge (MQTT)
Radon sensors sit on a bus of their own: the Uno firmware only speaks 9600 8N1 and reacts to stray bytes in other devices' traffic. The meters and climate sensors share the power bus at 4800 8N1.

At runtime the server only runs the MQTT broker. The radon sensors work on their own (the LCD shows ID, status and radon level) with no network at all. Build tools are only needed to flash firmware or install the Homey app.

Folder in ~/arduino/arduino/Contents
RadonSensorArduino_v2/Uno firmware, setup guide, meter manuals
WemosD1MiniRS485ModbusMqtt/Bridge firmware, one codebase for every bridge (git)
com.radonsensor.mqtt/Homey app (git)
Ubuntu server

MQTT server

Mosquitto receives everything the bridges publish and passes it to Homey. It needs a fixed address and a login for every client.

  1. Give the server a fixed IP.

    The bridges and the Homey app store the broker address, so it must never change: use a DHCP reservation in the router, or a static IP. This guide writes it as <broker-ip>. Avoid addresses ending in .0 or .255: on a typical /24 network those are not usable host addresses.

  2. Install Mosquitto.
    sudo apt update
    sudo apt install mosquitto mosquitto-clients
    sudo systemctl enable --now mosquitto
  3. Listen on the LAN and require a login.

    Create /etc/mosquitto/conf.d/local.conf:

    listener 1883
    allow_anonymous false
    password_file /etc/mosquitto/passwd

    Leave the package's mosquitto.conf as is: it already enables persistence, so retained messages (link state, backlight, WiFi signal) survive a broker restart.

  4. Create one user per client.

    One for the bridges, one for Homey, so either can be revoked on its own.

    # -c only for the first user: it creates the file
    sudo mosquitto_passwd -c /etc/mosquitto/passwd wemos
    sudo mosquitto_passwd /etc/mosquitto/passwd homey
    sudo chown mosquitto:mosquitto /etc/mosquitto/passwd
    sudo chmod 640 /etc/mosquitto/passwd
    sudo systemctl restart mosquitto
  5. Allow MQTT from the LAN only.

    If ufw is active, with your LAN subnet in place of <lan-subnet>. Never expose port 1883 to the internet: it is unencrypted.

    sudo ufw allow from <lan-subnet> to any port 1883 proto tcp   # e.g. 192.168.1.0/24
  6. Install the build tools (only on the machine you flash from).
    sudo usermod -aG dialout $USER   # serial ports; log in again
    curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
    arduino-cli config init
    arduino-cli config set directories.user ~/arduino/arduino
    arduino-cli config add board_manager.additional_urls \
      https://arduino.esp8266.com/stable/package_esp8266com_index.json
    arduino-cli core update-index
    arduino-cli core install arduino:avr@1.8.8 esp8266:esp8266@3.1.2
    arduino-cli lib install "ModbusMaster@2.0.1" "PubSubClient@2.8"
    # Homey CLI via Node.js 24
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
    nvm install 24 && npm install -g homey

    The Uno needs the fmalpartida "New LiquidCrystal" library, which is not in the Library Manager: copy ~/arduino/arduino/libraries/LCD from the old machine.

Check

Anonymous access must be refused (not authorised). With a login, every bridge's messages appear within a minute:

mosquitto_sub -h <broker-ip> -u homey -P '<password>' -t 'rs485/#' -v

Topics

Everything is under rs485/<bridge>/. A device state always carries link (1/0); other fields appear only when read successfully in that poll, otherwise error says what failed.

TopicPayloadRetained
statusonline / offline (last will)yes
namethe bridge's BRIDGE_NAME, e.g. Power bridge (Homey's pairing name)yes
wifi/rssisignal in dBm, e.g. -57yes
button/<1-3>pressedno
inventoryboot scan result, e.g. {"radon":[7],"unknown":[12]}yes
radon/<id>/state{"link":1,"radon":85.9,"backlight":"on"}yes
dtsu666/<id>/statepower, energy_import/export, voltage_l1–l3, current_l1–l3yes
sdm120/<id>/statepower, energy_import/export, voltage, currentyes
renke_th/<id>/state{"link":1,"temperature":21.5,"humidity":68.3}yes
radon/<id>/backlight/seton / off (command to the bridge)no
Arduino Uno · RD200M · 16×2 LCD

Radon sensor

A standalone sensor that shows its ID, status and radon level on the LCD, and answers as a Modbus slave on the radon bus.

Radon sensor wiring: RD200M to Uno D2/D3, LCD on I2C A4/A5, MAX485 on D7/D8/D9, ID straps D10–D12 to D13 RD200M radon module TX RX Supply per RD200M datasheet (not recorded in this project) Arduino Uno D2 (RX) D3 (TX) A4 SDA A5 SCL D7 D8 D9 D10 D11 D12 D13 TX → D2 RX ← D3 · 19200 LCD 16×2 I2C 0x27 SDA SCL MAX485 DE+RE RO DI A B A B to bus ID straps: each jumper to D13 sets a bit. D10 = 1, D11 = 2, D12 = 4. All three = ID 7. 5V / GND LCD and MAX485 VCC/GND from the Uno
Pins as built. The RS-485 A and B lines run to every node on the radon bus and to the radon bridge.
SignalUno pinNotes
RD200M TX → UnoD2SoftwareSerial RX, 19200 baud
Uno → RD200M RXD3SoftwareSerial TX
LCD SDA / SCLA4 / A5I2C address 0x27
MAX485 DE + RE (tied)D7HIGH = transmit
MAX485 RO → UnoD8SoftwareSerial RX, 9600 8N1
Uno → MAX485 DID9SoftwareSerial TX
ID strapsD10–D12 ↔ D13read once at boot
  1. Set the bus ID with the straps.

    Use IDs 1–7, unique on the bus. Never use ID 0: it is the Modbus broadcast address and can never answer.

  2. Flash the firmware.
    arduino-cli board list   # find the port, e.g. /dev/ttyACM0
    cd ~/arduino/arduino/RadonSensorArduino_v2
    arduino-cli compile --fqbn arduino:avr:uno .
    arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:avr:uno .

    The firmware needs no configuration.

  3. Wire it onto the radon bus.

    A to A, B to B, with a common ground between all nodes. Terminate the two physical ends of the bus with 120 Ω.

  4. Restart the radon bridge. Its boot scan finds the new ID by itself (see Wemos bridge). Radon sensors must use an ID from 1 to 7.

Check

After boot, line 1 shows the status and the ID as its last character, and line 2 shows the radon level in Bq/m³. The RD200M only updates every 10 minutes, so the value changes slowly.

Wemos D1 Mini Pro · ESP8266 · MAX485

Wemos bridge

The Modbus master for exactly one bus. At boot it finds the devices on that bus, then polls them, publishes their state to MQTT, and has three pushbuttons for Homey flows. Every bridge runs the same firmware; one small committed file per bridge makes each one different.

Wemos bridge wiring: MAX485 on D0/D1/D2, optional OLED on D3/D4, status LED on D8 to GND, buttons on D5/D6/D7 with pull-ups Wemos D1 Mini Pro D0 D1 D2 3V3 D8 D3 D4 D5 D6 D7 GND MAX485 DE+RE RO DI A B A B GND common with MAX485 3V3 LED: D8 → 220–1000 Ω → LED → GND active high: D8 HIGH = on. Never to 3V3: D8 must be LOW at boot SSD1306 OLED SDA SCL/SCK 128×64 or ×32 optional · 3.3 V module only BTN1 BTN2 BTN3 10 kΩ pull-ups buttons switch to GND
The firmware also enables the ESP8266's internal pull-ups on D5–D7 as a backup, but fit the external 10 kΩ resistors.
Wire the LED to GND, never to 3V3. D8 (GPIO15) must be LOW when the board starts. An LED from 3V3 to D8 pulls it up, and the board then hangs at boot ("boot mode (7,7) waiting for host") and can't even be flashed. D3 and D4 must be HIGH at boot, which an OLED's I2C pull-ups guarantee; a 5 V display backpack would put 5 V on the pins.
Check the MAX485 output level. ESP8266 pins do not tolerate 5 V. If the MAX485 module runs on 5 V and drives RO at 5 V, use a 3.3 V-compatible module or a level shifter on RO.
SignalWemos pinNotes
MAX485 DE + RE (tied)D0HIGH = transmit
MAX485 RO → WemosD1SoftwareSerial RX, must be 3.3 V
Wemos → MAX485 DID2SoftwareSerial TX
Optional OLED SDA / SCL (SCK)D3 / D4SSD1306, 0.96" 128×64 or 0.91" 128×32 (set DISPLAY_HEIGHT), I2C 0x3C or 0x3D. VCC to 3V3, GND to GND; 3.3 V module only. Some modules label SCL as SCK. Detected at boot; without one the bridge runs as normal
Status LEDD8active high: D8 → 220–1000 Ω → LED → GND. Blinks on polls, errors and presses
Buttons 1 / 2 / 3D5 / D6 / D7to GND, 10 kΩ pull-up to 3V3
USB serialRX / TXkept free for the debug log, 115200 baud

Plan the buses and bridges

Planning the Modbus side is up to you. The bridge configures nothing on the devices: it only finds devices that are already set up and wired. Before a bridge can find a device, give it a Modbus ID that is unique on its bus (straps on a radon Uno, menu or setup registers on a meter), set its serial format to match the rest of its bus, and wire it on (A to A, B to B, common ground, 120 Ω at both ends).

One bus, one serial format. A bridge talks to its whole bus with one baud rate, parity and stop-bit setting, so every device on the bus must use the same. When devices can't agree, they go on separate buses, and each bus gets its own bridge.

You need another bridge whenExample
Devices can't share a serial formatRadon Unos only speak 9600 8N1; the meters and climate sensors here run 4800 8N1. Two buses, two bridges.
A device must be alone on its busRadon Unos react to stray bytes in other devices' traffic, so they never share a bus with meters. The build refuses a config that mixes them.
There is no cable route between devicesA meter in a detached garage and one in the house: give each building its own short bus and bridge instead of running cable between them. WiFi carries the rest.
IDs run out or clashA radon Uno can only use IDs 1–7, so an 8th radon sensor needs a second radon bus. Two devices with the same fixed ID also need separate buses.

Extra bridges cost nothing in Homey: each has its own BRIDGE_ID, and devices are keyed by bridge + type + ID, so the same ID can exist on two buses. At the extreme you could give every device its own bridge. That works, but a single bus carries many devices, so one bridge per bus is the normal setup; add bridges where formats, building layout or ID ranges call for it.

Examples

SetupBridgesBridge file (src/bridges/)BRIDGE_ID
Radon sensors only1radon.h: 9600 8N1, types 1"radon"
Radon sensors plus meters and climate sensors (this house today)2radon.h: 9600 8N1, types 1
power.h: 4800 8N1, types 2, 3, 4
"radon"
"power"
DTSU666 in the house, SDM120 in a detached garage, no cable between2two files with the same bus settings, types 2, 3"power"
"garage"
One bridge per device1 eache.g. types 3, scan range narrowed to the meter's own IDone per bridge

Every bridge also needs its own MQTT_CLIENT_ID. With the scan range narrowed to a single ID, the boot scan takes well under a second.

The config files

FilePer bridge?What it holds
src/bridges/<name>.hyes, one file eachThe bridge's ID (BRIDGE_ID) and Homey name (BRIDGE_NAME), its MQTT_CLIENT_ID, the OLED size (DISPLAY_HEIGHT), and its bus: serial format, boot scan settings, and which device types to look for. Committed.
secrets.hno, sharedWiFi and MQTT login. Gitignored.
bus_config.hnoPicks the bridge file from the name given to build.sh.
device_catalog.hnoEvery device type the firmware knows, by number. Changes only when support for a new type is added.

The catalogue is the dictionary that turns a short number in a bridge file into a device type. Numbers are never reused or changed.

NumberTypeIDsPolled every
1Radon sensor (Arduino Uno + RD200M)1–760 s
2Chint DTSU666 3-phase meter1–24710 s
3Eastron SDM120-M 1-phase meter1–24710 s
4Renke RS-WS-N01-2 temperature/humidity transmitter1–24730 s

How the boot scan works. Each catalogue entry holds two requests: a presence request sent to every ID the type allows (any reply, even a Modbus error reply, means "something answers here"), and an identify request that only that type answers correctly: a DTSU666 reports its own ID in register 0x002E, an SDM120 a mains voltage, and the Renke, which answers every unknown register with 0, is checked last by its humidity. The bridge sends the presence request to each ID in the scan range, retries silent IDs in later passes, identifies every ID that answered, logs the result and publishes it as its inventory. The scan takes roughly silent IDs × timeout × passes: a few seconds for the radon bus, about 105 s for the full 1–247 scan of the power bus, so narrow the range to the IDs you use. A bridge holds up to 32 devices.

Adding a new device type is a firmware change, not just a config edit: it needs a catalogue entry, code that reads and publishes the device's values (meters.cpp and pollDevice() in the .ino), and a matching driver in the Homey app.

  1. Create the shared secrets.h (once, for all bridges).
    cd ~/arduino/arduino/WemosD1MiniRS485ModbusMqtt
    cp secrets.example.h secrets.h   # gitignored, never commit it
    SettingSet to
    WIFI_SSID, WIFI_PASSWORDyour WiFi network
    MQTT_HOST<broker-ip>, the broker's fixed IP
    MQTT_USERNAME, MQTT_PASSWORDthe wemos user
  2. Set up the bridge's file in src/bridges/. radon.h and power.h exist; for a new bridge, copy one.
    Settingradon.hpower.h
    BRIDGE_NAME"Radon bridge""Power bridge"
    BRIDGE_ID"radon""power"
    MQTT_CLIENT_IDhome-esp8266-rs485-01home-esp8266-rs485-02
    BUS_BAUD96004800
    BUS_DATA_BITS, BUS_PARITY, BUS_STOP_BITS8, 'N', 1
    BUS_SCAN_FIRST_ID, BUS_SCAN_LAST_ID1, 247 (narrow it to shorten the scan)
    BUS_SCAN_TIMEOUT_MS, BUS_SCAN_PASSES300, 3200, 2
    BUS_DEVICE_TYPES12, 3, 4
    DISPLAY_HEIGHTnot set (64)32 (0.91" OLED fitted)

    BRIDGE_NAME (1–32 characters) is the name Homey gives the bridge when it is paired; renaming later is done in Homey. DISPLAY_HEIGHT is the OLED's pixel height, 32 or 64 (the default); on a 128×32 display the bridge shows only its ID, the MQTT state and three device lines. BRIDGE_ID becomes the topic prefix rs485/<BRIDGE_ID>/; don't change it after pairing in Homey. Every bridge needs its own MQTT_CLIENT_ID, or the broker keeps disconnecting one of them. No slave IDs are listed anywhere: at every boot the bridge scans the bus, identifies each device that answers, and polls only those. Radon sensors only answer on IDs 1–7 and must be alone on their 8N1 bus; the build fails if a bridge file breaks that rule. A device added later is found at the next bridge restart.

    For a new bridge, also add a BRIDGE_<NAME> line to bus_config.h and the board's USB serial number (from ls -l /dev/serial/by-id/) to build.sh.

  3. Build and flash it. build.sh picks the bridge file and flashes only that bridge's own board, found by its USB serial number, so firmware can't land on the wrong bridge even with both plugged in. It refuses to upload while a serial monitor holds the port: an upload that competes for the port can report success while the board keeps the old firmware.
    ./build.sh radon           # compile only
    ./build.sh radon upload    # compile and flash the radon bridge
    ./build.sh power upload    # compile and flash the power bridge

    A plain arduino-cli compile stops with "No bridge selected" instead of guessing.

Check

The serial log (115200 baud) shows the bridge ID and bus format, then the boot scan:

[Scan] Looking for types: 1=radon
[Scan] Probing IDs 1-7, 3 pass(es), timeout 300 ms
[Scan] ID 7 answers
[Scan] 1 device found in 6.9 s
[Scan]   ID 7: radon
[Scan] Done: 1 matched, 0 unknown

then WiFi with signal strength and the MQTT connection. The LED blinks once when WiFi connects and three times when MQTT does. Opening the serial port restarts the board, and with it the boot scan. On the broker you should see rs485/<bridge>/status online, the inventory, wifi/rssi every minute, a state per device, and button/<n> pressed for each press. For button trouble, set kButtonPinDiagnostics = true in the .ino to log raw pin levels.

Chint DTSU666 · Eastron SDM120-M · Renke RS-WS-N01-2

Power meters and climate sensors

Three-phase and single-phase DIN-rail meters, read every 10 seconds, and wall-mounted temperature/humidity transmitters, read every 30 seconds, share one bus at 4800 8N1 behind the power bridge.

Power bus: power bridge MAX485 daisy-chained to DTSU666 terminals 15/16, SDM120 terminals 10/9/8 and the Renke's yellow/blue wires, 120 ohm at both ends Wemos bridge "power" + MAX485 A B signal ground / common reference 120 Ω 120 Ω DTSU666 3-phase · set to 4800 n.1 15 = A 16 = B SDM120-M 1-phase · set to 4800 8N1 10 = A 9 = B 8 = GND Renke RS-WS-N01-2 temp/humidity · 4800 8N1 yellow = A · blue = B 10–30 V DC: brown +, black −
Daisy-chain the devices with twisted pair: A to A, B to B, terminated with 120 Ω at the two physical ends. Terminal numbers and wire colours are from the manufacturers' manuals. The Renke needs its own 10–30 V DC supply.
Mains voltage. The meters' measuring side is connected to 230/400 V. The DTSU666 manual requires installation by qualified professionals with the inputs and supply disconnected; treat the SDM120 the same way.

One-time device setup

Every device on the power bus must run 4800 baud, 8 data bits, no parity, 1 stop bit, with a unique ID (1–247). Change IDs with only that one device connected: every device ships with ID 1.

  1. DTSU666: switch it to Modbus.

    It ships in DL/T 645 mode, not Modbus. In the meter's menu (password 701, then Conn) set Addr to its ID and bAud to 4800. The protocol register 0x002C selects Modbus and the framing: 3 = n.1 (no parity, 1 stop bit), which the power bus uses.

  2. SDM120: set baud, framing and ID.

    It ships at 2400 baud, ID 1. Hold its button for 3 s until the display shows -SET-, then write the holding registers over Modbus at its current 2400 baud, for example from the server with a USB-RS485 adapter and mbpoll:

    RegisterValueMeaning
    4002914800 baud
    400190no parity, 1 stop bit
    40021new ID1–247

    Values are 32-bit floats, written with function 0x10. Power-cycle the meter afterwards. UNKNOWN The manual gives both "none" and "even" as the default parity; check the display.

  3. Renke: set the ID.

    It ships at 4800 8N1, ID 1, which already matches the bus. Change the ID with Renke's "485 parameter configuration software" from the manufacturer's data package, with only that one transmitter connected. It only supports function 0x03: register 0x0000 is humidity ×10 (%RH), 0x0001 temperature ×10 (°C, negative below zero).

  4. Flash the power bridge (./build.sh power upload). Its boot scan finds every device at the ID you set and names its type in the serial log; tested with 5 DTSU666, 6 SDM120 and 6 Renke transmitters on one bus.
  5. Compare the first readings with each meter's own display.

    Verified on real meters: the DTSU666 answers function 0x03, sends floats high word first, and its voltage, current and power scaling is right. One detail is still open, a one-line switch at the top of meters.cpp:

    • UNKNOWN Energy scaling: 1.0 assumed (kDtsuEnergyScale). Correct it if the kWh reading differs from the display.

What each device reports

ValueDTSU666 (3-phase)SDM120 (1-phase)Renke
Power nowtotal W, negative when exportingW–
Energy imported / exportedkWh / kWhkWh / kWh–
VoltageL1, L2, L3 (V)V–
CurrentL1, L2, L3 (A)A–
Temperature / humidity––°C / %RH
Registers read0x2006–0x2013, 0x401E–0x40290x0000–0x000D, 0x0048–0x004B (FC 04)0x0000–0x0001
Raw scalingV ×0.1, A ×0.001, W ×0.1 (direct connection, no CT)none, already in units×0.1, temperature signed

With external current transformers on the DTSU666, current and power must also be multiplied by the CT ratio.

Homey Pro · app com.radonsensor.mqtt

Homey

The "RS-485 Bridge (MQTT)" app turns every bridge and device into a Homey device. It needs a Homey Pro on the same LAN as the broker; Homey Cloud cannot run it.

  1. Point the app at the broker.

    Set MQTT_HOST in config.js to <broker-ip>, and create the gitignored env.json with the homey user. Keep it out of anything you share.

    {
      "MQTT_USERNAME": "homey",
      "MQTT_PASSWORD": "<password>"
    }
  2. Install it on a Homey. To move to another Homey, run the same commands with that Homey selected. Devices, flows and Insights history do not move with the app.
    cd ~/arduino/arduino/com.radonsensor.mqtt
    npm install
    homey login
    homey select
    homey app validate --level debug
    homey app install
  3. Pair the devices (Add device → RS-485 Bridge (MQTT)). The bridges must already be running: pairing lists the devices in each bridge's boot scan inventory, so allow a minute. A paired device that a later scan no longer finds shows as unavailable ("Not found on the bus at the bridge's last boot").
    DriverPairs asShows
    Radon sensorRadon sensor 7 (radon)radon Bq/m³, LCD backlight on/off
    3-phase power meterPower meter 3 (power)power, energy in/out, V and A per phase
    1-phase power meterPower meter 60 (power)power, energy in/out, V, A
    Temperature/humidity sensor (Renke)Climate sensor 10 (power)temperature, humidity
    RS-485 bridgeRadon bridge (its BRIDGE_NAME)buttons 1–3, WiFi signal, online state

Check

Each device becomes available once its first state arrives, and shows "Link lost" when its bus stops answering, or "Not found on the bus at the bridge's last boot" when the bridge's scan no longer finds it. The bridge device's flow card Button [1/2/3] was pressed fires on a physical press and on a tap on the tile.