MonSet-Dev
MonSet is an industrial-grade IoT monitoring device built around the STM32F407VET6 microcontroller. It reads sensor data over Modbus RTU (RS-485)
MonSet — Industrial IoT Monitoring Device with W5500 Ethernet, NB-IoT, and Multi-Channel Failover on STM32F407
Tags: W5500 · STM32 · Modbus RTU · MQTT · ThingsBoard · Industrial IoT · NB-IoT · TLS
Overview
MonSet is an industrial-grade IoT monitoring device built around the STM32F407VET6 microcontroller. It reads sensor data over Modbus RTU (RS-485), logs it to a MicroSD card, and transmits telemetry to a ThingsBoard cloud platform via WIZnet W5500 Ethernet or SIM7020C NB-IoT — with automatic failover across multiple communication channels.
The project targets remote industrial sites such as water level monitoring stations, pumping facilities, and environmental measurement points where reliable, multi-channel connectivity and offline-safe data buffering are critical requirements.
Hardware Platform
| Component | Description |
|---|---|
| MCU | STM32F407VET6 — 168 MHz, 512 KB Flash, 192 KB RAM |
| Ethernet | WIZnet W5500 via SPI1 |
| NB-IoT / GSM | SIM7020C → SIM7020E (NB-IoT Cat NB1) |
| WiFi | ESP8266 (USART6) |
| Satellite | Iridium SBD NR9602G (UART5) |
| RTC | DS3231 (I2C1) |
| Sensors | Modbus RTU via USART3 + UART4 (RS-485), configurable per-port |
| Storage | MicroSD — FAT32 via SDIO 1-bit |
How WIZnet W5500 is Used
The W5500 is the primary and highest-priority communication channel in MonSet. It is connected over SPI1 (PA5/PA6/PA7) with a dedicated chip select on PA8, reset on PC3, and an interrupt line on PC4. The firmware uses WIZnet's ioLibrary (hardware TCP/IP offload stack) together with mbedTLS 1.2 to open both MQTT over TCP and HTTPS sessions — protocol selection is runtime-configurable via config.json on the SD card.
W5500 Socket Functions in MonSet
1. MQTT Telemetry (TCP) The device publishes sensor readings to ThingsBoard MQTT broker at configurable intervals. The W5500 handles the TCP connection so the STM32 is free of software TCP/IP stack overhead.
2. HTTPS Telemetry (TLS over TCP) For environments that require encrypted transport, MonSet uses mbedTLS on top of the W5500 TCP socket. The STM32's hardware RNG provides entropy for TLS handshakes.
3. Modbus TCP Master The W5500 also opens TCP client sockets to poll Modbus TCP slave devices on the local LAN — without any change to firmware (register map is configured in JSON on SD).
4. Modbus TCP Slave MonSet can itself act as a Modbus TCP server, exposing its sensor readings to SCADA systems (GE iFIX, WinCC, InTouch) on the local network.
5. Web Interface A built-in HTTP server accessible through the W5500's static IP serves a full runtime web UI for configuration, live sensor values, and log download — no cloud dependency required.
6. NTP Time Sync The device synchronizes its clock via NTP over the W5500 on startup and can fall back to the DS3231 hardware RTC.
Multi-Channel Failover Architecture
One of MonSet's key design strengths is its priority-based channel switching:
Ethernet W5500 → GSM NB-IoT → WiFi ESP8266 → Iridium SBD
(1st) (2nd) (3rd) (4th)Each channel has its own WatchDog timer. When the active channel fails, the device automatically switches to the next available one and returns to the higher-priority channel once it recovers. During any outage, undelivered readings are saved to Backup.json on the SD card as JSONL and re-transmitted after the connection is restored — ensuring zero data loss.
Sensor Data Collection
Sensors are read over two independent RS-485 Modbus RTU ports (USART3 and UART4). The register map — including device address, Modbus function code, data type (int16 / uint32 / float), scaling factor, and engineering unit — is defined in a JSON file on the SD card. New sensors can be added without reflashing firmware.
Supported measurement pipeline:
- Read raw Modbus registers
- Apply zero-offset and scale coefficients
- Average over N samples
- Log to date-rotated
.txtfiles on SD - Transmit to ThingsBoard / Home Assistant (Mosquitto) / Node-RED / Yandex IoT Core / HTTP Webhook
Web Interface Features
The built-in web server (accessible via W5500, ESP8266, or GSM static IP) provides:
- Live sensor readings — no ThingsBoard needed
- Full configuration editor — APN, MQTT broker, polling intervals, channel priorities, Modbus register map
- Runtime log viewer — separate tab for log streaming
- Log download —
.txtlog files direct to browser - CSV export —
Backup.json→ CSV for Excel / Google Sheets - Battery level indicator — read via STM32 ADC, shown in UI and sent to server
- Setup wizard (Captive Portal via ESP8266) — simple and advanced modes for first-time configuration
Application Fields
MonSet is designed for and directly applicable to:
- Water infrastructure — river/reservoir level monitoring, pumping station telemetry
- Environmental monitoring — remote outdoor sensor stations
- Industrial automation — Modbus RTU → cloud gateway for legacy PLCs and field instruments
- Smart building & facility management — energy, temperature, humidity logging with SCADA integration
- Oil & gas / utilities — remote RTU replacement with multi-channel backup connectivity
Why W5500 for Industrial IoT?
In industrial environments, wired Ethernet is the most reliable communication medium. The W5500's hardwired TCP/IP offload engine means the STM32 does not need to run a software network stack, freeing MCU cycles for Modbus polling, SD logging, and TLS processing simultaneously. The W5500 also enables MonSet to operate as both a cloud-connected MQTT client and a local Modbus TCP server on the same hardware — a dual-role that would be difficult to achieve with a software TCP/IP stack on a resource-constrained MCU.
