## 4 Methods
### Experimental Scenarios
On the software side, as Figure 6 shows, Node-RED flow represents an HTTP endpoint capable of handling incoming POST requests. Once data have been received, a switch node is used to differentiate between the two sensor types, so their data can be decoded, cleaned, and directed to InfluxDB and MongoDB. This scenario addresses environmental control in agricultural buildings, such as greenhouses or storage areas, where monitoring temperature, humidity, and sound levels is key to maintaining crops, livestock health, and infrastructure conditions. The fifth experimental scenario investigates the use of UDP for IoT communication over WiFi networks. This setup targets applications requiring fast, low-latency communication, such as vibration monitoring in silos or livestock scales, as well as detecting rainfall or water levels in tanks for irrigation or water resource management. An ESP32 microcontroller is used in conjunction with two sensors: a KY-002 vibration sensor, which detects physical motion, and a water level sensor, which can monitor the presence or height of liquid. The ESP32 is programmed to send sensor readings via UDP in real time, using JSON-formatted payloads. For every UDP packet received, Node-RED parses the incoming data through a dedicated UDP-IN node, which feeds the messages into a processing flow (Figure 7), where they are categorized based on sensor type. The decoded sensor data are then stored in our two databases, InfluxDB and MongoDB. Figure 5: Scenario 3-Wifi-MQTT Node-RED Flow. Figure 6: Scenario 4-Wifi-HTTP Node-RED Flow. The sixth and final experimental scenario explores the use of CoAP over WiFi networks. CoAP is a lightweight protocol designed specifically for resource-limited systems and follows a request-response model similar to HTTP but optimized to run over UDP, significantly reducing overhead and energy consumption. This configuration reflects lightweight, power-efficient sensing for measurement tasks in rural facilities, such as detecting the presence or movement in milking stations or measuring distance to verify occupancy or equipment positioning. In this deployment, the ESP32 microcontroller is connected to an HC-SR04 ultrasonic sensor, which measures distance by emitting sound waves and detecting their reflection. The ESP32 device is configured to perform regular measurements and sends the sensor readings to a CoAP server hosted on the dockerized Node-RED instance. Figure 8 shows Node-RED flow equipped with a CoAP-IN node configured to listen for PUT requests on a specified endpoint. Once a message has been received, its payload is parsed using a JSON conversion node and then forwarded for further processing, to be finally stored in InfluxDB and MongoDB. Grafana dashboards were configured for each scenario to support data analysis. Each dashboard is customized to display the data collected in each scenario: monitoring temperature, sound levels, analyzing door status logs, or water level variations. This visualization layer facilitates anomaly detection, pattern recognition, and manual data inspection. Together, these interfaces help contextualize the sensor behavior and validate system performance across scenarios. Most tests were performed in a controlled indoor environment, including sensor activation, communication tests, and data capture validation. The GPS-based scenario was verified outdoors to confirm signal acquisition and location accuracy. Future iterations will consider more extensive outdoor field testing. Each scenario can be executed independently, with a focus on verifying functionality and the persistence of sensor data. For each test, the same sequence of steps was followed, using a repeatable procedure:  
1. Sensor Setup: The corresponding end device was programmed and configured with specific parameters. 2. Network Configuration: Network setup was different depending on the type of connectivity. LoRaWAN scenarios used gateways linked to The Things Network or operating in stand-alone mode. WiFi scenarios used a local access point provided by a Dragino LPS8 router. 3.