# Design and Implementation of a Mixed IoT LPWAN Network Architecture
## 4 Electronic Design
### Meter Data Acquisition and IoT Connectivity
The device showed in Figure 10 has been developed, and includes an electronics circuit board where are embedded the microcontroller and communications module, discrete electronic components to acquire the impulse signal generated by the water-meter and the voltage level of battery, jointly with a bi-stable relay to control external loads. The assembly is available in a plastic housing of ABS material with IP54 protection and threaded industrial connectors for the meter and the solenoid valve. No external antenna or charging port are necessary. Figure 10: Data acquisition device with IoT connectivity: (**a**) External view; (**b**) Internal view. Figure 9: Downlink frame and fields description. Electronic design is based on the Pycom LoPi4 [35] module for IoT solutions. The Pycom [36] module includes the Espressif ESP32 chipset as main processor running a MicroPython [37] interpreter. This offers a combination of power, friendliness and flexibility. It also includes multiple ways of connectivity: WiFi, Bluetooth LE, Sigfox, LoRa/LoRaWAN and FSK. WiFi and Bluetooth 2.4 GHz antenna is integrated in the module but it requires an additional one for the 868 MHz band in order to use Sigfox/LoRa capabilities. Due to this, it has been glued inside the box an 868 MHz flexible antenna with small dimensions and UFL connector suitable for the LoPi4 module. High frequency noise filtering is applied to the signal coming from the water-meter. An I/O port of the microcontroller is used to acquire it, which has been configured as digital input and has been activated the capability of generate an interruption to wake up the processor from the low power consumption mode. In this prototype, power is supplied by an included rechargeable Ion-Lithium battery, but due to the low consumption characteristics of the circuit, it is not needed to recharge it in several years, so it could be used a primary non-rechargeable Lithium Thionyl Chloride battery as an improvement making the cost of the product even cheaper. Battery voltage range (3.4-4.2 V) is directly compatible with the input power range in the Pycom LoPy4 (3.4-5.5 V), avoiding the need for additional components. To increase load control flexibility, a potential free output has been used, operated by a relay able to manage 220 VAC loads. To accomplish the large autonomy requirement desirable in any IoT device operated on battery, a dual coil bi-stable relay has been adopted. This relay is energized during 30 ms to open or close contacts and is able to remains in the last condition without continuous energy consumption. As relay coils require higher current to the one supplied by the microcontroller, outputs current drivers have been added. Although the chosen relay is a 3-way type, in this application relay contacts are used as a simple switch to open or close an external electrical circuit connected to the solenoid valve. In Figure 11 is showed a block diagram with all the elements of the design described here. Device operation, as shown in the flowchart in Figure 12, starts in a low power state until meter activity is detected. Then water consumption value stored in non-volatile memory is updated and low power mode is set again. If user defined data delivery interval is reached, the frame with the information to be sent is generated, radio hardware is initialized and it proceeds to the transmission. In the Sigfox network case, the maximum allowed uplink and downlink messages per day are taken into account, so a downlink to receive new device configuration is only requested once a day. If output status change or other configuration data are received, they are executed and power mode is set again. Figure 11: Block diagram of the data acquisition device. Both the way of operation and the selection of hardware components allow an energy autonomy of 2 years minimum with the internal battery. Autonomy variation will depend fundamentally on the configured delivery interval, since it is the transmission process the one that consumes most of the energy.