# A Low Power IoT Sensor Node Architecture for Waste Management Within Smart Cities Context
## 4 Node Architecture
### ATmega328 Microcontroller  
The ultrasound distance sensor, as well as the LoRa module, requires the presence of a microcontroller unit to operate: this component too has to be chosen on the base of the best compromise between cost, power consumption and efficiency. Since most part of low power microcontrollers have current absorption around few mA, the impact of this component on the overall power consumption of the node can be considered negligible, allowing a greater degree of freedom in the choice.  
As a consequence, the first prototype of the node was set up by using an Arduino UNO development board. This platform allowed a plug-and-play solution for the integration of the LoRa transmission module: indeed, through an Arduino Multiprotocol Radio Shield it is possible to integrate the LoRa module directly on board, possibly combining it with other wireless communication modules like ZigBee or Bluetooth. The Arduino UNO board was also chosen for the presence of 6 analog and 13 digital pins, allowing the direct connection of a wide range of sensors, and of a 3.3 V pin, a 5 V pin and 3 Ground pins. All these ports enable the direct connection of the HC-SR04 sensor since, as described in Section 4.2, it requires 5 V and Ground for powering and two digital pins for the signal.  
The first prototype (Figure 3) was then realized by simply integrating the components listed before: it allowed to test the operation of the whole node. Following these first tests, the operation of the HC-SR04 sensor as well as its effectiveness in measuring the filling level of the trash bin, and of the LoRa transmission module, was proved. Additional details on the test phase will be presented in Section 6.  
Since the proposed sensor node has only to read an analog value from a sensor, calculate the filling level and transmit it through a radio module, the use of a general purpose single-board microcontroller (like the Arduino UNO) can be considered redundant. Indeed, this kind of board is provided with a wide range of analog and digital inputs as well as LEDs and other components that are useless for the proposed scenario. Moreover, single-board microcontrollers have higher current absorptions if compared with the corresponding microchip microcontroller. For example, while current absorption of the Arduino UNO board is around 40 mA, the absorption of the ATmega328 microchip (the microcontroller on board of the Arduino) is only 10 mA. Since the average current absorption of low power microcontrollers when active is generally low, in the order of few mA, the choice of the microcontroller to be employed was based more on its technical features and ease of use rather than on its actual power consumption. For this reason the choice fell on the ATmega328/P microcontroller,  
Figure 3: First prototype of the node.  
whose datasheet is reported in [69], since it is the one on which the Arduino UNO board is designed and did not require any additional programming and hardware compared to the prototype made with Arduino. This single-chip microcontroller requires a few additional circuitry to run, like resistors and capacitors, and a quartz crystal so as to set its clock frequency. Moreover, this microcontroller can be purchased with the Arduino bootloader already set on it, making it easily programmable with the same firmware developed for the Arduino board. As it will be described within Section 5.1, the microcontroller firmware plays a fundamental role in implementing the energy-saving policy: it is in charge of switching on the level sensor as well as the LoRa module only for the required time respectively for the measure and the transmission, involving a reduction of power absorption. Finally, by means of a firmware instruction, the microcontroller shuts down the whole Block B of Figure 1.