## 7 Migrating Existing OSH Designs to SensoTube Architecture
### Towards Energy Optimized MCU-Based Functional Expansion Shields  
As to the question if any one of the existing OSEP main-boards could be used as a MCU-based functional layer shield, or else, if a WSAN system was exclusively based on an existing OSEP main-board, the answer is yes, but the system would suffer from the constraints identified in Section 2 above, and the most important, the system would have very poor energy efficiency. To prove this statement, we chose three of the most popular OSH platforms today, namely the Arduino Uno Rev. 3, the Nucleo STM32L152, and the FRDM-KL25Z. The first one is an 8-bit MCU platform whereas the last two are 32-bit ARM-based MCU platforms (see Figure 30). Our aim was to demonstrate their energy efficiency for a battery-operated WSAN system deployed in the agricultural field.  
The methodology of the test was to measure the current drawn by each one of the aforementioned platforms having their MCUs in full active and in deep sleep operation modes. The difference between these two current consumptions is equal to the current required for a functional shield which is using just the MCU circuits and not any kind of auxiliary circuits. The current consumption in MCU deep sleep mode indicates the current consumption of the auxiliary circuits.  
Figure 30: Three of the most popular open-source hardware platforms. Arduino Uno Rev. 3 from Arduino; Nucleo STM32L152 from ST Microelectronics, and FRDM-KL25Z from Freescale/NXP.  
The power supply was decided to be +5 Vdc provided through the USB ports of the three individual platforms. The alternative of providing external voltages greater than +5 Vdc through the external voltage inputs of the boards was rejected because the voltage regulation circuitry of each board is differently implemented and it has different energy efficiency. Therefore, the power supply through the USB ports ensures an equal treatment of the three boards.  
The full active state of the MCUs was realized by putting them in an endless loop using a _while_ loop programming structure. For the deep sleep mode of MCU state, we used the minimum possible programming functions for each one of the MCUs. The firmware development was easily implemented using the C programming language through two popular integrated development environments (IDEs), namely the Arduino IDE for the Arduino, and the Mbed for the Nucleo and the FRDM respectively. Figures 31 and 32 present the particular codes for the active and deep sleep modes of the MCUs for both IDEs.  
The results of the current measurements are presented in Table 4. \(I_{\mu}\) stands for full the active current, \(I_{ds}\) stands for the current in deep sleep mode, while \(I_{mcu}\) stands for the maximum current consumption of the MCU circuitry. As revealed, the current consumption due to the operation of various auxiliary circuitry on the boards (e.g., programming circuitry, sensors, LED indicators, etc.) is orders of magnitude greater than that actually required for operating the MCU circuitry. Hence, the use of the existing open-source hardware mainboards is not suitable for battery-operated WSAN systems. On the other hand, following the abstraction concept of SensoTube architecture, more energy efficient WSAN systems can be built. Figure 33 indicates how much energy would be reserved if a MCU-based expansion shield facilitated just the MCU circuitry.  
Figure 31: **(a)** Implementation of the full active mode; and, **(b)** implementation of the deep sleep mode. Both implementations have been implemented using the Arduino IDE.  
Figure 32: **(a)** Implementation of the full active mode; and, **(b)** implementation of the deep sleep mode. Both implementations have been mae using the Mbed IDE.