PLC Solution Library · Wireless sensor network simulator
Break a wireless sensor network and find the fault
Battery radio nodes read temperature and humidity across a large site. A GateBerry FLEX gateway, built on a Raspberry Pi, receives every reading, checks it and sends it on with MQTT. In this simulator the network runs day and night on four kinds of site.
Then break it: cut the 4G link or the power of the gateway, block a link, drain a battery or warm up one point. You see what the gateway and the server do, and how you tell a node fault from a gateway fault.
Choose your site
Season
Choose a scenario
Event log
Commands
One step is one minute of the site. Each node sends one reading per minute.
Last 24 hours at node 1
Dashed lines: the limits. Dark bands: night. A gap in the line is a time with no reading at the gateway.
Limits
Faults to test
On the selected node:
On the gateway:
Simulation
x1: one minute of the site every 0.2 seconds.
Nodes
| Node | Temp. | RH | Dew point | RSSI | Battery | Counter | Lost | Last packet | State |
|---|
Temperature and humidity are the last values the gateway received. RSSI is the average of the last 10 packets. Lost: readings missing from the gaps in the counter.
Rules on the gateway and the server
| Signal | Condition | Action | Now |
|---|
Example rules and thresholds. You set yours from your product, your radio and the rules that apply to your site.
Alarm list
| Time | Tag | Type | Message | State |
|---|
Active: the condition is still there. Acknowledged: an operator has seen it. An event is a record, not an alarm: for example, a node reset. Lost readings go to the event log.
Node, radio or gateway: how do you tell the faults apart?
Start with one question: do all nodes go quiet at the same time? If yes, look at the gateway, its power or its uplink. If only one node goes quiet, look at that node or its radio path. The gateway measures the signal strength (RSSI) and the time of each packet. Each node sends a packet counter and its battery voltage. These values give each fault its own mark:
- Gateway uplink lost. The server gets no data from the gateway, but the gateway still receives the nodes and keeps the readings. When the link is back, the data arrives with its time stamps.
- Gateway without power. All counters show the same gap when the gateway starts again. The readings sent in that time are lost.
- Weak link. The RSSI of one node goes down and its counter shows gaps.
- Node reset. The counter of one node is back at 1. Once is an event. If it repeats, check the battery or the supply.
- Low battery. The voltage of one node goes down. Near the end, the node resets when it sends, then goes silent.
Run the Gateway power cut scenario and compare it with Battery runs down.
When does the night air reach the dew point?
The dew point is the temperature at which the water in the air condenses. The simulator computes it from the temperature and the relative humidity (RH) with the Magnus formula, and shows it for each node. When the air cools at night, the RH goes up and the gap between the air temperature and the dew point gets small. Any surface colder than the dew point gets wet: walls, roofs, metal and goods.
So a limit on RH alone is not enough. This simulator also warns when the dew point of an air node comes within 2 °C of its temperature for 3 readings. In a real site, compare the dew point with the temperature of the coldest surface, for example a roof or a steel wall.
In a warehouse, part of the night rise also comes from outside air that enters through doors and vents with more water in it. Run A day and a night on the greenhouse and watch the dew point at 03:00.
The architecture in short
Each battery node has a temperature and humidity sensor and a low-power radio. It wakes up, reads the sensor, sends one small packet and sleeps again. A GateBerry FLEX gateway receives the packets. The radio receiver can be a board on one of its four USB ports, as in the warehouse case, or the LoRa expansion board with your own LoRa protocol. For LoRaWAN sensors, use a LoRaWAN gateway and read its MQTT feed.
On the gateway, a program in Node-RED or Python checks each packet: counter, RSSI, battery and limits. It writes the data to local storage and sends it with MQTT to a broker, over Ethernet or the 4G expansion board. A database stores the data and a dashboard shows it. The GateBerry FLEX takes one expansion board: if you use it for LoRa, send the data over Ethernet or a USB modem; if you use it for 4G, put the radio receiver on USB.
The gateway has a real-time clock with a battery, so each reading keeps a correct time stamp. Its UPS with supercapacitors shuts Linux down safely when the power fails.
One pattern, four sites
The nodes, the gateway and the rules stay the same. What changes is the radio path, the place of each point and the limits.
- Warehouse. A large floor with racks and dock doors. Metal racks and goods change the radio path when the stock moves. The points near the doors change first.
- Greenhouse. High humidity at night and condensation on the crop and the roof. Put the sensors at crop height, in a shield against direct sun.
- Grain store or silo. Temperature cables hang in the grain and find a point that warms up while the others stay steady. The radio node sits at the top of the silo and reads them: grain and steel walls weaken radio signals a lot.
- Field storage pile. Probes go into the pile on a cable. The radio node stays on the surface or on a stake. The inside of the pile changes slowly, the surface follows the night air and the frost. The gateway stands at the edge, with 4G for the data.
Case study
Real project
- Warehouse temperature and humidity: 11 battery radio nodes read temperature and humidity every minute on a floor of 450 x 250 m. A Raspberry Pi gateway sends the data with MQTT over LTE to a cloud server. The case explains the radio frames, the map of the floor and the link checks. This simulator adds the gateway faults (4G link and power), the alarm rules with delay and hysteresis, the dew point and three more sites. Read the case study
Design choices you make
1. How often each node reports
Each reading costs energy. In the warehouse case each node wakes every 60 s, and two AA cells are expected to last more than a year. A longer interval gives a longer battery life, but the gateway needs more time to find a silent node.
2. A counter in every packet
A counter that only goes up costs a few bytes and tells you three things. A gap means lost packets, the same number means a duplicate, and a counter back at 1 means a reset. Without it, you only see that a value is old.
3. When is a node silent?
This simulator raises the alarm after 3 minutes without a packet, that is 3 missed readings. Do not alarm on one missed reading: a lost packet now and then is normal on radio.
4. A delay and a hysteresis on each limit
The alarm comes when a value stays outside the limit for 3 readings in a row. It clears only when the value is 0.5 °C or 2 % RH back inside the limit. So a value that moves around a limit does not raise and clear the alarm every minute.
5. Compare each point with the others
A limit catches a floor that is too warm. A hot spot in grain, or a heater near one point, shows earlier as a difference from the other points. Here the rule is: more than 3 °C away from the median of the points of the same group for 10 minutes. When a point is already close to its limit, the limit can come first. The comparison is what finds a hot spot that stays inside the limits.
6. Keep the data when the uplink fails
The gateway writes each reading to its storage first and sends it with MQTT after. When the 4G link comes back, it sends the buffer with the original time stamps. On the server, one alarm says that the gateway is offline, instead of one alarm for each node.
7. Tell a gateway fault from a node fault
When all nodes stop at the same time and their counters show the same gap, the cause is the gateway or its power, not the nodes. The rules hold the node alarms while the gateway is offline.
8. Warn early on the battery
With lithium AA cells the voltage stays almost flat and falls fast at the end. Alkaline cells fall slowly over their whole life. In both cases the voltage drops during each radio transmission, so a node near the end can reset when it sends. In cold sites, use lithium cells. This simulator warns at 2.4 V for two AA cells, an example value. Check the minimum supply voltage of your radio and your sensor in their datasheets.
GateBerry FLEX: the specs that matter here
| Computer | Raspberry Pi 4, quad core 64-bit, 1.8 GHz. Raspberry Pi 5 as an option |
|---|---|
| RAM | 2 to 16 GB |
| Software | Debian 64-bit, preinstalled. Build the logic with Node-RED, MQTT, Python or Docker |
| Ports | 1 x Gigabit Ethernet, 2 x USB 2.0, 2 x USB 3.0, RS-485, I2C, Wi-Fi, Bluetooth LE |
| Expansion | One board: LoRa (EU, US or Asia band), 4G (LTE-M/NB-IoT or LTE Cat 4), CAN, M-Bus or RS-232 |
| Reliability | UPS with supercapacitors for a safe shutdown, real-time clock with battery |
| Power supply | 12 to 24 Vdc with polarity and overvoltage protection |
| Environment | 0 to 55 °C, 10 to 95 % humidity without condensation |
| Mounting | DIN rail TS35, IP20, inside a cabinet |
To switch fans, heaters or vents from the same values, add a PLC next to the equipment: the GateBerry FLEX is the gateway, the PLC drives the outputs. See the greenhouse climate simulator.
Full specs: GateBerry FLEX · GateBerry datasheet.
Learn the building blocks
These examples cover parts of this pattern. Some use an ESP32 PLC or a Raspberry PLC: the logic is the same.
- Central Mosquitto MQTT broker for a device fleet
- Node-RED MQTT concentrator
- Offline-first MQTT data logging with an SD card
- MQTT to SQL Server bridge in Python
- Payload bit packing for small radio packets
- FreeRTOS tasks with a LoRaWAN watchdog
- Hardware watchdog for unattended devices
- Remote site telemetry simulator: alarms from remote sites in a water network
More examples: PLC Solution Library · all simulators.
FAQ
What does a gap in the packet counter of a sensor node mean?
The node adds 1 to its counter for each reading it sends. If the gateway receives 41 and then 44, readings 42 and 43 were lost on the way. If it receives a number lower than the last one, usually 1, the node has restarted. The same number twice is a duplicate: keep one copy. If your counter has 16 bits, a jump from 65535 to 0 is a rollover, not a reset. Count the gaps per node: a few lost readings per day are normal on radio, a growing number points to a weak link.
How long should the gateway wait before it marks a node as silent?
Wait for more than one missed reading, because one lost packet is normal on radio. With one reading per minute, 3 minutes without a packet is a common choice and the one in this simulator. With a longer interval, the wait grows with it. If all nodes go silent at the same time, check the gateway first.
What RSSI is too weak for a sensor node?
A link is weak when its RSSI comes close to the sensitivity of the receiver. In this simulator the warning is at -90 dBm, an example value. Read the sensitivity of your radio in its datasheet, for your data rate, and keep a margin for people, goods and doors that move. Watch the average of several packets, not one value.
How do I set an alarm limit so it does not flicker?
Add a delay and a hysteresis. In this simulator the alarm comes when a value stays outside the limit for 3 readings in a row, and it clears only when the value is 0.5 °C or 2 % RH back inside. A value that moves around the limit then gives one alarm, not one every minute. Set the delay from your reading interval and how fast your product reacts.
What happens to the data if the 4G link of the gateway fails?
If the gateway stores each reading before it sends it, nothing is lost. It keeps receiving the nodes, saves the readings with their time stamps and sends them when the link comes back. The server raises one alarm for the gateway, not one alarm per node. If the gateway itself has no power, the readings sent in that time are lost, and all counters show the same gap.
Can the same network monitor a greenhouse, a grain store or a field pile?
Yes. The pattern is the same: battery nodes, one gateway, MQTT and a set of rules. What changes is the radio path, the place of the points and the limits. Grain, wet goods and steel walls weaken radio signals, so test the links at the real positions before you fix the nodes.
Do I need to write code to build this?
The nodes run the firmware of their supplier or yours. The gateway rules are a short list: limits, delays, counter checks and a timer for silent nodes. On the GateBerry FLEX you can write them in Node-RED with flow blocks, or in Python. If you prefer, an integrator can set them up from your list of points and limits.
Plan the network for your site
Tell us about your site: its size, the variables and their limits, how many points you want and where the data must go. Our team replies with a proposed node layout, radio and gateway for your case. Your simulator settings go with the request.