ARISTOTLE UNIVERSITY OF THESSALONÍKI COMPUTER SCIENCE DEPARTMENT

IoT Configuration for Industrial and Domestic Water Saving Monitoring

Iraklis Moutidis

Advisor: Ioannis Stamelos

1 Abstract The main objective of the thesis is to implement a water flow monitoring system, using a water flow sensor, the prototyping board and the board. The system should be efficient regarding the electricity consumption and flexible regarding the water installation it will be placed. The information obtained from the sensor(s) is uploaded to a cloud platform (Thingspeak.com) and also locally stored on the Raspberry Pi, which is used as a server for any boards like the Arduino that control a sensor. The data can be further processed to obtain more information about the water consumption of the installation.

2 Contents

1. Introduction………………………..………………………………………..………..……6 1.1 Research Background……………………………………………………………….6 1.2 Problem Statement…………………………………………………………………..7 1.3 Objective of the Study……………………………………………………………….8 1.4 Scope of the Study…………………………………………………………………..8

2. Wireless Sensor Networks………….………………………..……………………….9 2.1 Introduction…….…...………………………………………………………………...9 2.2 Types of Wireless Sensor Networks……………………………………………...10 2.3 Applications………………………………………………………………………….12 2.3.1 Military Applications…….…………………………………………………13 2.3.2 Environmental Monitoring………………………………………………..13 2.3.3 Inventory Monitoring……………………………………………………...15 2.3.4 Health Applications………………………………………………………..16 2.4 Internal Sensor System……………..……………………………………………..16 2.4.1 Operating Systems………………………………………………………..16 2.4.2 Standards…………………………………………………………………..17 2.4.3 Storage……………………………………………………………………..17 2.4.4 Testbeds……………………………………………………………………17 2.4.5 Diagnostics and Debugging Supported…………………………………18

3. Open Source Hardware………………………………………………………………..19 3.1 Introduction……………………………………………………………………………19 3.2 History……………………………...………………………………………………….19 3.3 Open Source Hardware and Business Models……………………………………20 3.4 Licenses……………………………………………………………………………….22 3.5 Open Source Hardware projects…………………………………………………...28 3.5.1 RepRap – The Replication Rapid Prototyper…………….……………...28 3.5.2 TABBY EVO: Modular open source electric car platform…….………...30 3.5.3 FarmBot Open Hardware CNC farming machine………………….……31 3.5.4 Arducopter Open Source Hardware Drone……………………………...32 3.5.5 Open Hand Project: robotic prosthetic hands…………………………...34

4. The Arduino Board………………………………………………………………………36 4.1 What is the Arduino Board?…………………………………………………………36 4.2 Arduino Variations and Replicas……………………………………………………38 4.3 Software Development………………………………………………………………40 4.4 The Arduino Board in Education……………………………………………………41 4.5 Prototyping with Arduino…………………………………………………………….43

3 5. The Raspberry Pi Board……………………………………………………………...45 5.1 About Raspberry Pi………………………………………………………………….45 5.2 Raspberry Pi and the Internet of Things………………………………………….46 5.3 Raspberry Pi Operating Systems………………………………………………….47 5.3.1 Raspbian…………………….….…………………………………………...47 5.3.2 Mate……………….….…………………………………………….48 5.3.3 Snappy Ubuntu……………….…………………………………………….48 5.3.4 Pidora………………………….…………………………………………….49 5.3.5 Linutop……….……………………………………………………………...50 5.3.6 SARPi………………………….………….……...………………………….50 5.3.7 Arch ARM………………………….…………………………………50 5.3.8 Gentoo Linux……………………………………………………………….50 5.3.9 FreeBSD………………………………...………………………………….51 5.3.10 ……………………………...…………………………………..51 5.4 Raspberry Pi Alternatives……………………………………………………………52 5.4.1 Odroid XU4………………………………………………………………….52 5.4.2 BeagleBoard………………………………………………………………..52 5.4.3 Galileo Gen: 2………………………………………………………...53 5.4.4 Udoo Dual Basic…………………………………………………………...54 5.4.5 4……………………………………………………………….54

6. Water Flow Sensors…………………………………………………………………….56 6.1 Turbine Sensors……………………………………………………………………...56 6.2 Magnetic Sensors…………………………………………………………………….57 6.3 Ultrasonic Sensors…………………………………………………………………...58 6.4 Vortex Shedding……………………………………………………………………...59 6.5 Variable Area Flow meters…………………………………………………………..60 6.6 Positive displacement floe meters………………………………………………….61 6.7 Thermal Sensors……………………………………………………………………..62 6.8 Paddle Wheel Sensors………………………………………………………………63 6.9 Differential Pressure…………………………………………………………………64 6.10 Vane/Piston………………………………………………………………………….65

7. Implemented System………………………………………………………………….66 7.1 System Components……………………………………………………………….66 7.1.1 Water Flow Sensor……………………………………………………….66 7.1.2 Arduino Bluetooth module……………………………………………….66 7.1.3 Arduino and Raspberry Pi boards………………………………………67 7.1.4 System Casing……………………………………………………………67 7.1.5 Power Supply……………………………………………………………..69 7.1.6 Android Mobile Phone/Tablet……………………………………………69 7.2 System Software……………………………………………………………………70 7.2.1 Arduino IDE………………………………………………………………..70 7.2.2 Raspbian OS………………………………………………………………70 7.2.3 VNC Viewer………………………………………………………………..70 7.3 System Configuration……………………………………………………………….71 7.4 Energy Consumption of the System………………………………………………72 7.5 System Code………………………………………………………………………...73

4 8. Conclusion…………………………………………………………………………...76

References…………………………………………………………………….………....77

Appendix A: Installation Manual……………………………………………..…..81 A.1 Equipment and Software………………………………………………………81 A.2 Hardware Configuration………………………………………………………..82 A.3 Software Configuration………………………………………………………...83 A.3.1 Uploading the code to Arduino……………………………………...83 A.3.2 Installing the Raspbian OS to the Raspberry Pi…………………..84

5 1.Introduction

1.1 Research Background

During the last years, technologies and applications such as, smart grids, smart homes, smart water networks, intelligent transportation are infrastructure systems that have spread more than any optimistic prediction about this technology could tell. The concept that includes all of these technologies is the Internet of Things (IoT), where through the use of sensors and control devices, the infrastructure components of an installation are enhanced with information and communication technologies. Interconnected embedded devices can manage and monitor any given infrastructure in an intelligent manner, utilizing transmissions of measurement information and control commands via distributed sensor networks. A wireless sensor network (WSN) is a network formed by a large number of sensor nodes where each node is equipped with a sensor to detect physical phenomena such as water flow, light, heat, pressure etc. Wireless sensor networks are regarded as a revolutionary information gathering method to build the information and communication system which will greatly improve the reliability and efficiency of infrastructure systems. Compared with a wired solution, WSNs feature easier deployment and better flexibility of devices. With the rapid technological development of sensors, wireless sensor networks will become the key technology for IoT applications. On the other hand there are some challenges that WSNs must surpass such as energy consumption and network range. Methodologies for more optimized data and command transmissions has been tested during the implementation of our approach in order the deployed sensors will consume the minimum energy possible. Taking advantage of open source hardware technologies can help us implement our sensor network efficiently and with low cost. "Open source hardware," refers to the design specifications of a physical object which are licensed in such a way that said object can be studied, modified, created, and distributed by anyone. Like open source software, open source hardware uses intellectual property laws creatively to make hardware designs publicly accessible. Many projects use existing free and open source software licenses when licensing their works (GPL, FreeBSD, MIT). Others use the Creative Commons By Attribution licenses, which are more focused on the features of works of art, as opposed to software. Very useful open hardware devices for sensor networks can be the Arduino microcontroller board and the Raspberry Pi board. IoT installations can provide a big amount of information regarding the usage of it, the consumption of different resources and the “habits” of the users. Analyzing this information we can obtain valuable indications about how we can save our resources, detect malfunctions of the facility or even give the appropriate commands in order to use a given facility more efficiently. On this thesis we discuss the use of wireless sensor networks in the wider context of IoT for monitoring and controlling the water flow of a domestic or an industrial infrastructure.

6 1.2 Problem Statement

Managing our resources is a big task that takes a lot of effort and time. There are approaches both in industry and in households that try to save resources such as electricity, water and fuel. New devices, strategies and methods have been tested in order to use our resources more efficiently. In all cases we need a method to measure how much we consume using a given approach, in order to evaluate how much of that resource we save. Monitoring the resource consumption, can also help us to decide which approaches are more suitable for our infrastructure, reveal problems on our facilities (leaks, malfunctions) and guide us to new strategies about the usage of our resources. Resource monitoring can be a very challenging task, depending the environment, the location, duration of the measurement and what kind of resource we need to measure. The measuring configuration should be easy to install and use by the user or to be configured once from an expert and then used. It must also consume a small amount of energy, in order to be able to measure the wanted resource for a lot of time before its energy supply will need to be replaced. Keeping the energy consumption of the sensor device can save us a lot of time maintaining it and effort/money because the expert will handle the device much less times. The cost of the installed device must also be in a reasonable scale. It is possible that a large number of sensors must be applied for the desired measurement, so the cost of the configuration we will choose to apply must be kept as low as possible. Open hardware solutions (microcontrollers, single board computers) are the ideal choice for this kind of applications, because they are flexible, consume low energy, they are very reasonable priced and they have big communities that can provide a lot of support. The configuration that is going to be installed must be flexible and “hidden” from the common eye. For that reason a wireless sensor network (WSN) is preferred as it can be more easy to install, it is more flexible and it can be “hidden” a lot easier than any wired solution. Lastly the measuring system must upload the obtained data to the Internet (cloud) so that all actors of the system can access easily this information without having to go on the site to do so.

Picture 1: A Wireless Sensor Network

7 1.3 Objective of the study

The main goal of this study is to create a combination of sensors, microcontrollers, and single board computers, in order to monitor the amount of water (and other materials) that we can save, using some water saving devices and strategies / methodologies. This system will be applied on different social services buildings (Town halls, schools, municipality buildings) so it must be hidden from the public eye to prevent vandalism and interference with the measurements. As mentioned on the problem statement our configuration must be energy efficient in order to be able to take measurements for a big time period without the need for a battery replacement. An approach for this problem has been suggested in [1] where a paddle wheel sensor is connected on an Arduino microcontroller which have an on-board WiFi module that transits to the cloud platform (ThingSpeak) every one second the amount of water that passed through the sensor. This configuration can stay operational for about 3 hours with energy supplied from a power bank of 5000 mAh. The autonomy of that device is inefficient for the target application and for that reason in this thesis we suggest a new configuration using a wireless sensor network which will be more energy efficient. On our approach we will use a paddle wheel sensor, an Arduino microcontroller with a bluetooth board and a Raspberry pi for collecting the data and transmitting them to the cloud platform (ThingSpeak).

1.4 Scope of the Study

In order to fulfill the stated objectives several steps must be taken. These steps involve both software programming, hardware implementation and analysis of the obtained information.

These steps are as follows: • Install a water flow sensor on the water network of the building. • Connect the water sensor to the Arduino microcontroller. • Install the microcontroller on a safe spot. • Establish a wireless connection (bluetooth) between the Arduino microcontroller and the Raspberry Pi (server) • Install the Raspberry by on a location inside the range of the microcontrollers (20- 25m). • Establish a wired connection (via USB) between the Raspberry Pi and an Android device (smart phone, tablet) using the VNC server software. • Program the Arduino device to properly measure the water flow and transit the data to the Raspberry Pi. • Install the appropriate software (, Server Clients) to the Raspberry Pi. • Program the Raspberry Pi to receive the transmitted data from the Arduino convert them to litters and save the water consumption information locally and to the cloud platform. • Analise the obtained information from the water sensors.

8 2. Wireless Sensor Networks

2.1 Introduction

Wireless sensor networks (WSNs) have gained worldwide attention in recent years, particularly with the proliferation in Micro-Electro-Mechanical Systems (MEMS) technology which has facilitated the development of smart sensors. These sensors are small, with limited processing and computing resources, and they are inexpensive compared to traditional sensors. These sensor nodes can sense, measure, and gather information from the environment and, based on some local decision process, they can transmit the sensed data to the user. Smart sensor nodes are low power devices equipped with one or more sensors, a processor, memory, a power supply, a radio, and an actuator. An actuator is an electro-mechanical device that can be used to control different components in a system. In a sensor node, actuators can actuate different sensing devices, adjust sensor parameters, move the sensor, or monitor power in the sensor node. A variety of mechanical, thermal, biological, chemical, optical, and magnetic sensors may be attached to the sensor node to measure properties of the environment. Since the sensor nodes have limited memory and are typically deployed in difficult-to-access locations, a radio is implemented for wireless communication to transfer the data to a base station (e.g., a laptop, a personal hand-held device, or an access point to a fixed infrastructure). Battery is the main power source in a sensor node. Secondary power supply that harvests power from the environment such as solar panels may be added to the node depending on the appropriateness of the environment where the sensor will be deployed. Depending on the application and the type of sensors used, actuators may be incorporated in the sensors. A WSN typically has little or no infrastructure. It consists of a number of sensor nodes (few tens to thousands)working together to monitor a region to obtain data about the environment. There are two types of WSNs: structured and unstructured. An unstructured WSN is one that contains a dense collection of sensor nodes. Sensor nodes may be deployed in an ad hoc manner into the field (randomly placed). Once deployed, the network is left unattended to perform monitoring and reporting functions. In an unstructured WSN, network maintenance such as managing connectivity and detecting failures is difficult since there are so many nodes. In a structured WSN, all or some of the sensor nodes are deployed in a preplanned manner. The advantage of a structured network is that fewer nodes can be deployed with lower network maintenance and management cost. Fewer nodes can be deployed now since nodes are placed at specific locations to provide coverage while ad hoc deployment can have uncovered regions. Unlike traditional networks, a WSN has its own design and resource constraints. Resource constraints include a limited amount of energy, short communication range, low bandwidth, and limited processing and storage in each node. Design constraints are application dependent and are based on the monitored environment. The environment plays a key role in determining the size of the network, the deployment scheme, and the network topology. The size of the network varies with the monitored environment. For indoor environments, fewer nodes are required to form a network in a limited space whereas outdoor environments may require more nodes to cover a larger area. An ad hoc

9 deployment is preferred over preplanned deployment when the environment is inaccessible by humans or when the network is composed of hundreds to thousands of nodes. Restraints in the environment can also limit communication between nodes, which in turn affects the network connectivity (or topology). Research in WSNs aims to meet the above constraints by introducing new design concepts, creating or improving existing protocols, building new applications, and developing new algorithms. The building blocks of a WSN are modules that can sense, communicate, process and actuate. Devices of this kind, which are created either as prototypes or as commercial products, are generally referred to as “motes”. A mote is an autonomous, compact device, a sensor unit that also has the capability of processing and communicating wirelessly. Despite the autonomy they present, the big strength of motes is that they can form networks and co-operate according to various models and architectures.

2.2 Types of Wireless Sensor Networks

Current wireless sensor networks are deployed on land, underground, and underwater. Depending on the environment, a sensor network faces different challenges and constraints. There are five types of WSNs: terrestrial WSN, underground WSN, underwater WSN, multi-media WSN, and mobile WSN. Terrestrial WSNs [2] typically consist of hundreds to thousands of inexpensive wireless sensor nodes deployed in a given area, either in an ad hoc or in a preplanned manner. In ad hoc deployment, sensor nodes can be dropped from a plane and randomly placed into the target area. In preplanned deployment, there is grid placement, optimal placement , 2-d and 3-d placement models.

In a terrestrial WSN, reliable communication in a dense environment is very important. Terrestrial sensor nodes must be able to effectively communicate data back to the base station. While battery power is limited and may not be rechargeable, terrestrial sensor nodes however can be equipped with a secondary power source such as solar cells. In any case, it is important for sensor nodes to conserve energy. For a terrestrial WSN, energy can be conserved with multi-hop optimal routing, short transmission range, in- network data aggregation, eliminating data redundancy, minimizing delays, and using low duty-cycle operations.

Underground WSNs [3,4] consist of a number of sensor nodes buried underground or in a cave or mine used to monitor underground conditions. Additional sink nodes are located above ground to relay information from the sensor nodes to the base station. An underground WSN is more expensive than a terrestrial WSN in terms of equipment, deployment, and maintenance. Underground sensor nodes are expensive because appropriate equipment parts must be selected to ensure reliable communication through soil, rocks, water, and other mineral contents. The underground environment makes wireless communication a challenge due to signal losses and high levels of attenuation. Unlike terrestrial WSNs, the deployment of an underground WSN requires careful planning and energy and cost considerations. Energy is an important concern in underground WSNs. Like terrestrial WSN, underground sensor nodes are equipped with a limited battery power and once deployed into the ground, it is difficult to recharge or replace a sensor node’s battery. As before, a key objective is to conserve energy in order to increase the lifetime of network which can be achieved by implementing efficient communication protocol.

10 Underwater WSNs [5,6] consist of a number of sensor nodes and vehicles deployed underwater. As opposite to terrestrial WSNs, underwater sensor nodes are more expensive and fewer sensor nodes are deployed. Autonomous underwater vehicles are used for exploration or gathering data from sensor nodes. Compared to a dense deployment of sensor nodes in a terrestrial WSN, a sparse deployment of sensor nodes is placed underwater. Typical underwater wireless communications are established through transmission of acoustic waves. A challenge in underwater acoustic communication is the limited bandwidth, long propagation delay, and signal fading issue. Another challenge is sensor node failure due to environmental conditions. Underwater sensor nodes must be able to self-configure and adapt to harsh ocean environment. Underwater sensor nodes are equipped with a limited battery which cannot be replaced or recharged. The issue of energy conservation for underwater WSNs involves developing efficient underwater communication and net- working techniques.

Multimedia WSNs [7] have been proposed to enable monitoring and tracking of events in the form of multimedia such as video, audio, and imaging. Multimedia WSNs consist of a number of low cost sensor nodes equipped with cameras and microphones. These sensor nodes interconnect with each other over a wireless connection for data retrieval, process, correlation, and compression. Multi-media sensor nodes are deployed in a preplanned manner into the environment to guarantee coverage. Challenges in multi-media WSN include high bandwidth demand, high energy consumption, quality of service (QoS) provisioning, data processing and compressing techniques, and cross-layer design. Multi- media content such as a video stream requires high bandwidth in order for the content to be delivered. As a result, high data rate leads to high energy consumption. Transmission techniques that support high bandwidth and low energy consumption have to be developed. QoS provisioning is a challenging task in a multi-media WSN due to the variable delay and variable channel capacity. It is important that a certain level of QoS must be achieved for reliable content delivery. In-network processing, filtering, and compression can significantly improve network performance in terms of filtering and extracting redundant information and merging contents. Similarly, cross-layer interaction among the layers can improve the processing and the delivery process.

Mobile WSNs consist of a collection of sensor nodes that can move on their own and interact with the physical environment. Mobile nodes have the ability sense, compute, and communicate like static nodes. A key difference is mobile nodes have the ability to reposition and organize itself in the network. A mobile WSN can start off with some ini- tial deployment and nodes can then spread out to gather information. Information gathered by a mobile node can be communicated to another mobile node when they are within range of each other. Another key difference is data distribution. In a static WSN, data can be distributed using fixed routing or flooding while dynamic routing is used in a mobile WSN. Challenges in mobile WSN include deployment, localization, self- organization, navigation and control, coverage, energy, maintenance, and data process. Mobile WSN applications include but are not limited to environment monitoring, target tracking, search and rescue, and real-time monitoring of hazardous material. For environmental monitoring in disaster areas, manual deployment might not be possible. With mobile sensor nodes, they can move to areas of events after deployment to provide the required coverage. In military surveillance and tracking, mobile sensor nodes can collaborate and make decisions based on the target. Mobile sensor nodes

11 can achieve a higher degree of coverage and connectivity compared to static sensor nodes. In the presence of obstacles in the field, mobile sensor nodes can plan ahead and move appropriately to obstructed regions to increase target exposure.

2.3 Applications

Wireless Sensor Network applications can be classified into two categories: monitoring and tracking. Monitoring applications include indoor/outdoor environmental monitoring, health and wellness monitoring, power monitoring, inventory location monitoring, factory and process automation, and seismic and structural monitoring. Tracking applications include tracking objects, animals, humans, and vehicles. While there are many different applications, below we describe a few example applications that have been deployed and tested in the real environment.

Picture 2: Sensor Applications Categories

12 2.3.1 Military applications

Military applications are very closely related to the concept of wireless sensor networks. In fact, it is very difficult to say for sure whether motes were developed because of military and air defense needs or whether they were invented independently and were subsequently applied to army services. Regarding military applications, the area of interest extents from information collection, generally, to enemy tracking, battlefield surveillance or target classification. Classification algorithms use, for instance, input data that come from seismic and acoustic signal sensing. For example, mines may be regarded as dangerous and obsolete in the future and may be replaced by thousands of dispersed motes that will detect an intrusion of hostile units. Then, the prevention of intrusion will be the response of the defense system. Another demonstration, described in [8] deals with multi–vehicle tracking in the framework of a pursuit-evasion game. There are two competitive teams: the pursuers and the evaders. A third part is a sensor network which is used to help pursuers locate their opponents. The sensor network informs the pursuers about the relative positions and movements of the enemy units. So, the sensors network augments the “vision” of the pursuer team and reveals their rivals. In spite of the fact that the above research refers to wartime scenarios, its results can also be used during pace time. Peacetime applications such as homeland security, property protection and surveillance, border patrol, etc. are activities that perhaps in future sensors networks will undertake.

2.3.2 Environmental monitoring

Researchers and graduate students at CITRIS installed fifty matchbox-size "Smartdust Motes" throughout Cory Hall, which houses the Department of Electrical Engineering and Computer Sciences of U.C. Berkeley [9] to monitor light and temperature. The capability of sensing temperature, light, status of frames (windows, doors), air streams and indoor air pollution can be utilized for optimal control of the indoor environment. Moreover, a major waste of energy occurs through unnecessary heating or cooling of buildings. Motes can help in using heaters, fans and other relevant equipment at a reasonable and economic way, leading to a healthier environment and greater level of comfort for residents. The use of motes to improve the environmental conditions inside buildings has also preoccupied the American Society of Heating, Refrigerating and Air-Conditioning Engineers (ASHRAE). A wireless network was deployed in an office building at Pacific Northwest National Laboratory, Richland, Washington, to survey the advantages and drawbacks of wireless technology in operation of heating, ventilation and air condition (HVAC) systems [10], [11]. Other indoor applications can be mitigation of fire and earthquake damages. Fire and smoke detection is something common, nowadays, in buildings and in most countries it is imposed by relevant laws. The existence, also, of light- signals indicating exits is, usually, obligatory in big buildings. However, these two systems do not cooperate in case of a fire. The installation of sensor networks in buildings can lead to the integration of these two systems. So, the role of a sensor network is to guide the trapped residents through the safest route and save their lives. Sensor networks may also be useful after an earthquake. In addition to systems like the ones described above for fires, civil engineering research has shown that the inspection of structures based on vibrations is possible [12]. Based on this observation, the incorporation of wireless sensors inside cement blocks during construction, or their

13 attachment to structural units makes sense. The recording of vibrations during the life of a building can function as the identity of the building. The inspection of a building after an earthquake, by the use of this system, will not be restricted to evaluation of cracks and damages, but will be accompanied by real data. Computation of average and maximum values of vibrations maybe done by each mote, so the inspection can be done faster and the determination for any repairs can be more precise. Outdoor monitoring is another vast area for applications of sensors networks. One of the most representative examples is the deployment of a sensor network consisting of 32 nodes on Great Duck Island (GDI), [13]. This network was used for habitat monitoring. The sensors that 720 were used were able to sense temperature, barometric pressure, and humidity. In addition, passive infrared sensors and photo-resistors were used. The aim was to monitor the natural environment of a bird (storm petrel) and its behavior according to climatic changes. For that reason, some motes were installed inside birds’ burrows, to detect the bird’s presence, while the rest were deployed in the surrounding area. Data are aggregated via sensor nodes and are passed through to a gateway. The role of the gateway is to transmit data using a higher-level network to a local base station (database). The database is accessible through the internet and is replicated to another remote location for safety. This application provides an example for monitoring using a heterogeneous, multi-level network. The University of Hawaii has also been occupied with the study of the environment [14]. They have focused theresearch in Volcano National Park, trying to discover why some species can only live in a specific region. The outcome of this study would be very useful when trying to prevent endangered species from extinction. Each unit (called POD) is equipped with environmental sensors and, in some cases, with a high-resolution digital camera. These platforms were based on “Tephranet” developed by MIT’s Media Lab research team. Each sensor unit collects it own data and also forwards data coming from other units toward an Internet node. A characteristic of the topology of this deployment is that motes are separated into two sub-networks, one dense, to monitor the selected territory, and another sparse, to serve primarily as a link between the first group and an Internet gateway (but also collect data in the vicinity of its nodes). In related work, North Carolina State University is conducting a study of the red wolf, another endangered species [15]. The plan is to attach a node to each animal, in order to record information about its condition and behavior. The inability of motes to transmit over large distances and their energy constraints implies that it is unfeasible to keep all the motes on-line at all times. To overcome this problem, the network contains two types of nodes: mobile and static. The concept is that a moving mote collects and stores information until the animal runs across a static mote. The static mote triggers the communication capabilities of the moving mote and the latter establishes a connection and uploads the stored data. Other applications pertaining to outdoor monitoring that have been implemented concern environmental observations and forecasting weather phenomena. Following their successful implementation on GDI, Mainwaring et al. have deployed another sensor network at the James San Jacinto Mountains Reserve in Idyllwild, California. The aim is environmental observations. In contrast to the GDI network, in this application the time scales are much slower (climatic changes are expected to be sluggish) and the area covered is vast (29 acres). To sum up, wireless sensor networks are ideal for remote monitoring and event detection in geographically large regions or inhospitable areas. Proposals have also been developed to deploy motes to agriculture, to enhance the efficiency and growth of cultivations. Intel Corporation in cooperation with Intel Research

14 Berkeley Labs have studied the case of deploying a sensor network in a vineyard [16], [17]. The original idea was that a survey of microclimates would improve productivity and would be useful for farmers. Consequently, the prototype platforms were equipped initially with temperature sensors. However, interviews with farmers led to the conclusion that another source of raw data was practically useless for them. The perspective changed as a result. The sensor network turned out to be a component of a system that could be useful for every participant in the wine making process, from the time of growing the grapes to wine production and marketing. Many activities like filling out of timesheets, automatic calculation of salaries overtimes and billing, time-programming and monitoring of tasks such as pruning (by attaching sensors to tools such as pruning shears), targeting of chemicals and pesticides to selected points (by forecasting diseases through monitoring of temperature and humidity) and harvest timing (observing the ripeness of grapes). Generally, crop management, lowering costs and increasing quality is in the scope of applying sensors network technology to agriculture.

2.3.3 Inventory Monitoring

Inventory control is a major problem for big companies. Management of assets (pieces of equipment, machinery, different types of stock or products) can be a predicament. The problem is highly distributed, as these companies expand all over the world. A promising way to achieve asset tracking and cope with this problem is believed to be the use of RF ID tags and wireless sensor networks. British Petroleum (BP), participating in CoBIs program and Accenture Technology Labs have invested in research in this area. BP in [18] describes smart surrogates. The application refers to warehouses and storage management of barrels. The concept is that motes attached to barrels will be capable of locating nearby objects (other barrels), detecting their content and alerting in case of incompatibility with their own (danger of a chemical reaction), aging effects of the enclosure etc. This will enhance safety and guarantee product quality. British supermarket Tesco PLC has, also, applied first generation systems of this kind for inventory control. BP and Accenture Technology Labs have also used wireless sensor networks for fleet management. Tracing of lorries and rail cars and tracking of parameters regarding carried goods is possible through motes and the GPS system. So, telemetry and wireless sensing can be combined to build smart objects and vehicles. Other examples in industry are Shell Oil Co, which monitors the condition of pumps at gas stations, York International Corp., which installs ventilation systems and Tyco Thermal Controls LLC. York Int. tries to program maintenance of installed systems depending on customer needs, while Tyco aims to reduce the installation costs of laying wires by replacing them with motes in pipe-heating systems. BP, in addition, uses RF ID tags for the inspection of equipment at a refinery in Toledo, Ohio. In that case, the tags do not form a wireless network, but report to hand-held equipment as inspection personnel pass in the vicinity [18]. The same company plans to use this technology for tracking “lone” personnel in hazardous regions in their facilities at Hull (UK). Researchers at UC Berkeley have also proposed a similar application based on “wearable motes”. The integration of a mote to a part of the equipment that firemen wear, not only makes the coordination of fire- extinguishing easier and more effective, but can also act as a supplementary safety measure by revealing the exact location of each fireman. In case of an accident, rescue crews can act more effectively. Delivery and distribution systems are another area of applications for wireless sensors. Again BP, in [18], describes the advantages of using this technology for managing the delivery of liquefied petroleum gas (LPG) to its clients. The

15 content of each customer’s tank is monitored so that the supply department of the company knows the remaining quantity. That is useful in programming the trips of supply tank-trucks and consequently increases the efficiency of the delivery system. BP in cooperation with Andronics, has deployed this system in the north of England and already equipped around 2000 tanks.

2.3.4 Health Applications

Health science and the health care system can also benefit from the use of wireless sensors. Intel’s research concerns senior citizens and their problems. Cognitive disorders, which perhaps lead to Alzheimer’s, can be monitored and controlled at their early stages, using wireless sensors. Intel in Portland and in Las Vegas is carrying out such an experiment (Proactive Health Research). The nodes can be used to record recent actions (taking medication, last visitor, etc.) and remind senior citizens, indicate the person’s real behavior, or detect an emerging problem. Related research, conducted by Intel and the University of Washington, uses RF ID tags to examine patient behavior and customs by recording the frequency with which they touch certain objects. The application includes a display, which will help the “caregiver” extract information about the indisposed person discreetly and without hurting their feelings. Finally, motes can also be used in order to study the behavior of young children. For example, the aim of the study reported in [19] was to analyze children behavior, by monitoring sensors enclosed inside toys. Another medical application refers to human vision restoration [20] by retina prosthesis. Sensors are implanted to human organs to support a function and they require the capability to communicate wirelessly with an external computer system, which carries out the advanced processing. Energy limitations do not allow this computing to be carried out on-board the sensors. Other applications of wireless sensors to health care that have been proposed include tracking and monitoring doctors and patients, or tracking drug usage inside hospitals [21].

2.4 Internal Sensor System

For a sensor to operate in a wireless sensor network, there are several internal system issues that need to be addressed through the system platform and operating system (OS) support. In addition, supporting standards, storage, and physical testbeds are reviewed in the following subsections.

2.4.1 Operating Systems

Current WSN platforms are built to support a wide range of sensors. Products that offer sensors and sensor nodes have different radio components, processors, and storage. It is a challenge to integrate multiple sensors on a WSN platform since sensor hardware is different and processing raw data can be a problem with limited resources in the sensor node. System software such as the OS must be designed to support these sensor platforms. Research in this area involves designing platforms that support automatic management, optimizing network durability, and distributed programming.

16 2.4.2 Standards

Wireless sensor standards have been developed with the key design requirement for low power consumption. The standard defines the functions and protocols necessary for sensor nodes to interface with a variety of networks. Some of these standards include IEEE 802.15.4 [22], ZigBee [23], WirelessHART [24], ISA100.11 , IETF 6LoW- PAN [25], IEEE 802.15.3 [26], Wibree. The following paragraphs describes these standards in more detail. IEEE 802.15.4: IEEE 802.15.4 [22] is the proposed stan- dard for low rate wireless personal area networks (LR-WPAN’s). IEEE 802.15.4 focuses on low cost of deployment, low complexity, and low power consumption. IEEE 802.15.4 is designed for wireless sensor applications that require short range communication to maximize battery life. The standard allows the formation of the star and peer-to-peer topology for communication between network devices. Devices in the star topology communicate with a central controller while in the peer-to-peer topology ad hoc and self- configuring networks can be formed. IEEE 802.15.4 devices are designed to support the physical and data-link layer protocols. The physical layer supports 868/915 MHz low bands and 2.4 GHz high bands. The MAC layer controls access to the radio channel using the CSMA-CA mechanism. The MAC layer is also responsible for validating frames, frame delivery, network interface, network synchronization, device association, and secure services. Wireless sensor applications using IEEE 802.15.4 include residential, industrial, and environment monitoring, control and automation.

2.4.3 Storage

Conventional approaches in WSNs require that data be transferred from sensor nodes to a centralized base station because storage is limited in sensor nodes. Techniques such as aggregation and compression reduce the amount of data transferred, thereby reducing communication and energy costs. These techniques are important for real-time or event-based applications, but they may not suffice. Applications that operate on a query-and-collect approach will selectively decide which data are important to collect. Optimizing sensor storage becomes important in this case when massive data is stored over time. Given that storage space is limited and communication is expensive, a storage model is necessary to satisfy storage constraints and query requirements. In this subsection, we evaluate several storage methods in terms of design goals, assumptions, operation models, and performance.

2.4.4 Testbeds

A WSN testbed is consists of sensor nodes deployed in a controlled environment. It is designed to support experimental research in a real-world setting. It provides researchers a way to test their protocols, algorithms, network issues and applications. Experiments can easily be configured, run, and monitored remotely. Experiments can also be repeated to produce the same results for analysis.

Some popular WSN testbeds are: • ORBIT: Open access research testbed for next-generation wireless networks (ORBIT) [27] consists of 64 remotely accessible sensor nodes placed indoor with #1 m spacing apart. Each ORBIT radio node consists of a 1-GHz VIA C3 processor, two wireless PCI 802.11a/b/g interface, two ports, and an integrated chassis manager.

17 • MoteLab: MoteLab [28] is a web-based WSN testbed consisting of a set of MicaZ motes connected to a central server. The central server handles scheduling, reprogramming and data logging of the motes. A user can log onto a web interface to create and schedule experiments. The goal of MoteLab is to allow users to evaluate WSN applications without manually re-programming and redeploying the nodes into the physical environment. • Emulab: Emulab [29] is a remotely accessible mobile and wireless sensor testbed. The testbed consists of Acroname robots carrying an XScale based Startgate small computer and 900 Hz Mica2 mote. The robots operate on battery power which last up to 3 hours and uses 802.11b for communication. The radios are set to 900 MHz. The robot’s motion and steering comes from two drive wheels that operate at a maximum rate of 2 m/s. There are six infrared proximity sensors on all sides of the robot to detect obstructions.

2.4.5 Diagnostics and debugging support

In order to guarantee the success of the sensor network in the real environment, it is important to have a diagnostic and debugging system that can measure and monitor the sensor node performance of the overall network. Studies that deal with handling various types of hardware and software failures help extend the life of each sensor which in turn help increase the sensor network lifetime. In addition to failures, addressing methods to enhance communication performance can make the system more efficient. A diagnostic and debugging tool is Sympathy [30], it is specifically designed for data- collection applications where nodes periodically send data back to a centralized base station or sink. Sympathy detects failures in a system by selecting metrics such as connectivity, data flow, node’s neighbor and next hops. Connectivity metrics provide connectivity information from every node in the network. Sympathy collects every node’s current routing table with information for next hop and path quality. Flow metrics provide the network’s traffic load as well as its connectivity. Sympathy collects packet level information transmitted and received from each node. In addition, Sympathy also maintains information for packets transmitted from the sink to the nodes. Based on these metrics, Sympathy detects when nodes are not delivering sufficient data to the sink and locates the cause of the failure.

18 3. Open Source Hardware

3.1 Introduction

Open Source Software (OSS) has fundamentally shaped the software industry. A radical notion where software is distributed with its source code, freely allowing anyone to modify and redistribute it for any purpose. This may sound like a completely unrealistic utopia but nothing could be farther from the truth. Open Source Hardware (OSHW) is an attempt to bring the same freedom and power to physical devices, but is as of yet still a newborn compared to OSS. The future success of OSHW largely depends on its adoption among developers and users; individuals, organizations, companies, and governments. The Open Source Hardware concept has largely been born from the same philosophical concept that Open Source Software was constructed from, the freedom of redistribution of verbatim copies, access to source files, and the right for others to freely distribute derivative versions of the device. OSHW differs from OSS in that it focuses on hardware “physical artifacts” rather than immaterial source code. One description of OSHW is, as per the Open Source Hardware Statement of Principles and Definition v1.0 [31]: “Open source hardware is hardware whose design is made publicly available so that anyone can study, modify, distribute, make, and sell the design or hardware based on that design. The hardware’s source, the design from which it is made, is available in the preferred format for making modifications to it. Ideally, open source hardware uses readily- available components and materials, standard processes, open infrastructure, unrestricted content, and open-source design tools to maximize the ability of individuals to make and use hardware. Open source hardware gives people the freedom to control their technology while sharing knowledge and encouraging commerce through the open exchange of designs.”

3.2 History

Open source hardware has a long history and has gone through several cycles of growth. It can be argued that the first notion of open source hardware was in the early 1970's with groups such as the Homebrew Computing Club. In these early days of computer engineering a small group of engineers collaborated and openly shared designs of what would become one of the first personal computers. According to Apple co-founder Stephen Wozniak, "a lot of tech-type people would gather and trade integrated circuits back and forth" [32]. There was no official or formal organization and the main role of the club was to trade circuit designs amongst members. The theme of the club was "Give help to others" and membership to the group was mostly as a hobby. Wozniak states that schematics and designs for Apple I products were "passed around freely" and help was provided in order to help other members build their own systems. Free revealing in this manner, provided the designers of the Apple computer with early feedback on their initial prototype by other lead users and at least part of the motivation for free revealing was the increased reputation gained amongst peers. Open source hardware designs in this case relied on the ability of users to tie different components together. The use of breadboards made it such that users did not need manufacturers in the process of developing products.

19 Information was transferred from Innovating lead users to all users in the community through newsletters and informal gatherings. From the early days of open source hardware at the "product" level, soon lead developers turned their attention into how to create the basic building blocks of the products. While the initial wave of Open Source Hardware was related to how to put the basic building blocks together the late 1970's to mid 1980's saw large development at the function level of the value chain. In the 1970's Carve Meade and Lynn Conway developed a method by which users could begin to design large-scale integrated circuits. Several designs were grouped into a single production run in order to reduce development costs. Designs were transmitted using the Arpanet to manufacturing sites in order to be built. This process allowed universities access to low cost production of highly complex integrated circuits but users outside of this system could not easily develop or replicate the same products [33]. Although there were several free development tools, the computing power needed to produce large designs was extremely expensive. In this phase of open source hardware users began requiring the services of manufacturers in order to develop their products. The 1990's saw increased development of proprietary design tools and this increased the knowledge needed to design o a particular platform making it difficult to switch and share designs at the user level. Although the design tools allowed for easy transfer of design output to manufacturers the increased segmentation in the tool market made it difficult to share designs between different users. Board design tools did not easily translate from one CAD manufacturer to another, for example design rules and databases for a board being designed with a tool such as "Mentor Graphics" were not easily translated to that begin designed under the "Cadence" environment. On the IC design side design input was begin driven by the IC manufacturers making it difficult to translate designs from one type of IC to other types of IC. This made it such that one ended up designing for a particular "targeted device" on a particular "tool flow", making it difficult to reuse the design or share it with others that were not operating on the same platform. This approach led to the creation of whole groups of digital designers segmented by manufacturer and/or design tool. Today changes in tool design methodology and standardization of interfaces have made it easier for open source to thrive and for user innovation communities to develop. Open Source hardware is thriving in cases in which users require manufacturers and cases in which users require little to no manufacturing involvement. As will be shown later most of the growth appears to be in innovation communities in which manufacturer involvement is little and where users can easily share, modify and upgrade the hardware with low cost approaches.

3.3 Open Source Hardware & Business Models

Henry Chesbrough explained some of the dynamics that business were facing when investing in innovation. First useful knowledge and technology are becoming increasingly widespread and distributed across companies of different sizes and many parts of the world. Second there are two distinct market dynamics that are contributing to the rising cost of innovation [34] . The first dynamic is that of an increasing cost of investment in order to develop new and advanced technology. Chesbrough showed that the cost of a new semiconductor fabrication plant had seen a 100% increase in of the cost building the plant over 20 years to reach a total figure of $3 billion [34]. A second market dynamic was that of shorter product life cycles. An example cited was that of the expected model of hard-drive retaining its leadership position in the market having shifted from two-three

20 years down to six to nine months before newer and better solutions appeared. Chesbrough demonstrated that the combination of these two forces reduced a company's ability to earn a satisfactory return on its investment in innovation. If a company decided to open its business model it could attack the cost side problem by leveraging external R&D resources to save time and money in the innovation process. A company that engages in Open Source Hardware development can leverage innovative solutions from outside the company in most cases for relatively little cost. A key idea from Open Innovation as stated by Chesbrough was the fact that "not all of the smart people work for you". A company that invests in open source hardware can have access to innovation communities developing novel and advanced products as well as access to lead users who are developing commercially attractive products. Links to these communities allow businesses to better serve some of their customers by gaining insight into their current needs and applications. Businesses can position themselves in a manner such that they can profit from open source hardware.

The following approaches described by Chesbrough for open source software companies have equivalent open source hardware approaches: • Selling support, service or customization of hardware. A company that invests and participates in developing open source hardware can benefit from users seeking support or customization of open source hardware designs that they are utilizing. An example of this is the Arduino hardware whose founders along with making a small profit by the sale of their open source circuit. Gain most of their revenue from client who wants to build devices based on their board and who hire the founders of the company as consultants. [35] • Versioning of Hardware, lower level IP blocks used as entry offerings with higher performance cores or value added offerings. Some core developers have favored this approach by providing certain lower level cores for free as a trial basis for user to test and then charge a premium higher performance closed designs or added features such as higher performance or lower power consumption. • Integrate the Open Source hardware to build higher value products that a customer may not want to manufacture. Companies such as VIA have released a full set of schematics and CAD diagrams in order to build an open source notebook. With this information anybody can build a notebook through a low cost manufacturer. The advantage for the company is that the design is based on their microprocessor and associated IC's. By releasing the design for the full product design, the company will gain market share if consumers decide to build based on its desing and integrated circuits. • Provide complements to the open source hardware by building proprietary modules or tools that work with existing open source hardware modules. Companies such as Bluespec have released open source designs to OpenCores. Developers who utilize this cores will see the benefit of designing with Bluespec modeling and design solutions and will see the value of investing in one of several tools provided by the company.

Businesses also have strong reasons participating in open source hardware through the release of some of their designs. First old or unused designs may find new niches or applications by members of the open source hardware community. A company that maintains manufacturing capacity for certain parts of the design or certain portions of a design can see an increase in sales of an old design if an open source community finds

21 new and novel approaches utilizing the components or technology that were not originally though of by the company. A company can also obtain revenue from support services for a design.

3.4 Licenses

Open source hardware," refers to the design specifications of a physical object which are licensed in such a way that said object can be studied, modified, created, and distributed by anyone. Licensing the open source hardware is a way to give people rights that they wouldn’t otherwise have to use intellectual property (IP) and, in return, to place restrictions on how they exercise those rights. Licensing is often used for copyrighted information, which includes the source-code to computer programs, the text of books, photographs, recordings of music, etc. By placing an open-source license on a copyrighted work, you give people permission to make copies of it — a right they wouldn’t otherwise have. In return, you can require them to, for example, license derivatives of your work under the same license (a condition known as “copyleft”). This works well for source code, documentation, and other works for which copyright applies.Things are more complicated when it comes to hardware. Mostly, that is because copyright does not apply to hardware in the way that it does to software. In the United States (as well as many other nations), useful or functional objects are excluded from the scope of copyright protection. (The expression of the objects in a design file, however, may be covered by copyright. More on that below.) Functional objects can be protected by patents but applying for a patent is an expensive and time-consuming process — in contrast to copyright, which applies automatically. As a result, many potentially patentable items will not actually get patented. Like open source software, open source hardware uses intellectual property laws creatively to make hardware designs publicly accessible. Many projects use existing free and open source software licenses when licensing their works (GPL, FreeBSD, MIT). Others use the Creative Commons By Attribution licenses, which are more focused on the features of works of art, as opposed to software.

Some of the most important licenses are listed below:

MIT License Applications:Hardware, Documents & Files, Software Benefits: Open license. Provides basic liability protections. Requires that the associated copyright notice is included in derived works. Roughly equivalent to the the Simplified BSD License. Similar to the Modified BSD License, except does not prohibit the use of the name of the copyright holder in promotion. License: Copyright (c) Permission is hereby granted, free of charge, to any person obtaining a copy of this hardware, software, and associated documentation files (the "Product"), to deal in the Product without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Product, and to permit persons to whom the Product is furnished to do so, subject to the following conditions:

22 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Product. THE PRODUCT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE PRODUCT OR THE USE OR OTHER DEALINGS IN THE PRODUCT.

Simplified BSD License Applications: Hardware, Documents & Files, Software Benefits: Open license. Provides basic liability protections. Requires that the associated copyright notice is included in derived works. Approved as an Open Source License by the Open Source Initiative (OSI). Roughly equivalent to the the MIT License. Similar to the Modified BSD License, except does not prohibit the use of the name of the copyright holder in promotion. License: Copyright . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.Redistributions of product specifications, source code, and documentation must retain the above copyright notice, this list of conditions and the following disclaimer. 2.Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS PRODUCT IS PROVIDED BY "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS PRODUCT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

23 The views and conclusions contained in the hardware, software, and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of .

Modified BSD License Applications: Hardware, Documents & Files, Software Benefits: Open license. Provides basic liability protections. Unlike the MIT License and the Modified BSD License it does prohibit the use of the name of the copyright holder in promotion. Also requires that the associated copyright notice is included in derived works. License: Copyright (c) . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

•Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

•Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

•Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this product without specific prior written permission. THIS PRODUCT IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS PRODUCT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

24 Creative Commons - Attribution 3.0 Applications: Hardware, Documents & Files, Software Benefits: Open license. Provides basic liability protections. Requires that the attribution is given on derived works. License: This is a human-readable summary of the full license below. You are free:

•to Share—to copy, distribute and transmit the work, and

•to Remix—to adapt the work Under the following conditions:

•Attribution—You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work.) With the understanding that:

•Waiver—Any of the above conditions can be waived if you get permission from the copyright holder.

•Other Rights—In no way are any of the following rights affected by the license:

•your fair dealing or fair use rights;

•the author's moral rights; and

•rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights. •Notice—For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do that is with a link to: http://creativecommons.org/licenses/by/3.0/

25 Creative Commons - Attribution - ShareAlike 3.0 Applications: Hardware, Documents & Files, Software Benefits: Open license. Provides basic liability protections. Requires that the attribution is given on derived works and that derived works remain open source. License: This is a human-readable summary of the full license below. You are free:

•to Share—to copy, distribute and transmit the work, and

•to Remix—to adapt the work Under the following conditions:

•Attribution—You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work.)

•Share Alike—If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license. With the understanding that:

•Waiver—Any of the above conditions can be waived if you get permission from the copyright holder.

•Other Rights—In no way are any of the following rights affected by the license:

•your fair dealing or fair use rights;

•the author's moral rights; and

•rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights. •Notice—For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do that is with a link to : http://creativecommons.org/licenses/by-sa/3.0/

26 TAPR Open Hardware License (OHL) Applications: Hardware, Documents & Files Benefits: Specifically designed for open hardware, and avoids the issues other licenses have with focusing on copyright protecting documentation instead of the right to make, distribute, or use a product based on that documentation. Requires that all derived works use the same license and include before and after documentation if any changes were made. License: Visit the TAPR website for the full text of the TAPR Open Hardware License (OHL). The numbered sections of the agreement take precedence over this preamble.

•You may modify the documentation and make products based upon it.

•You may use products for any legal purpose without limitation.

•You may distribute unmodified documentation, but you must include the complete package as you received it.

•You may distribute products you make to third parties, if you either include the documentation on which the product is based, or make it available without charge for at least three years to anyone who requests it.

•You may distribute modified documentation or products based on it, if you:

•License your modifications under the OHL.

•Include those modifications, following the requirements stated below.

•Attempt to send the modified documentation by email to any of the developers who have provided their email address. This is a good faith obligation -- if the email fails, you need do nothing more and may go on with your distribution.

•If you create a design that you want to license under the OHL, you should:

•Include the OHL document in a file named LICENSE.TXT (or LICENSE.PDF) that is included in the documentation package.

•If the file format allows, include a notice like "Licensed under the TAPR Open Hardware License (www.tapr.org/OHL)" in each documentation file. While not required, you should also include this notice on printed circuit board artwork and the product itself; if space is limited the notice can be shortened or abbreviated.

•Include a copyright notice in each file and on printed circuit board artwork.

•If you wish to be notified of modifications that others may make, include your email address in a file named "CONTRIB.TXT" or something similar.

27 •Any time the OHL requires you to make documentation available to others, you must include all the materials you received from the upstream licensors. In addition, if you have modified the documentation:

•You must identify the modifications in a text file (preferably named "CHANGES.TXT") that you include with the documentation. That file must also include a statement like "These modifications are licensed under the TAPR Open Hardware License."

•You must include any new files you created, including any manufacturing files (such as Gerber files) you create in the course of making products.

•You must include both "before" and "after" versions of all files you modified.

•You may include files in proprietary formats, but you must also include open format versions (such as Gerber, ASCII, Postscript, or PDF) if your tools can create them.

3.5 Open Source Hardware projects

3.5.1 RepRap - The Replicating Rapid Prototyper

RepRap was started by Adrian Bowyer at the University of Bath and his team has since designed and built two printers, one being the first generation called Darwin and a second generation called Mendel. All of the Mendel machine's plastic parts were printed on the Darwin prototyper while attempting to fix Darwin's problems [36]. These improvements included making the printing area bigger, improved z-axis constraints, better axis efficiency, simpler assembly, the ability to allow extruder head change, and lighter weight. The most important goal to this community is self replication of the machine and currently Mendel can print 6.83% of its parts by number (counting each bolt, washer, and nut as separate piece), but 48% excluding nuts, bolts, and washers [36]. The remainder of the machine can be built using locally sourced materials and electronic equipment that can be bought or put together. The RepRap can currently print with ABS, polycaprolactone, polyactic acid, and HDPE, which all cost between $7-14/lb. The extruder intakes a filament of the working material, heats it, and extrudes it through a nozzle [36]. The printer uses a three coordinate system, where each axis involves a stepper motor that makes the axis move and a limit switch, which prevents further movement along the axis. The printing process is a sequential layer deposition where the extruder nozzle deposits a 2-D layer of the working material, then the Z (vertical) axis will lower, and the extruder will deposit another layer on top of the first. In this way it can build three dimensional models from a series of two dimensional layers. The printer can handle up to 45 o overhang, but new methods are being developed to allow full overhangs including printable supports. The maximum size of a printed object is 1,110 cm. Currently, Mendel can only print with plastics, so work is being done to create new extruder heads that can print other materials. Developers are currently working on a paste extruder as it can be used many materials, a spoolhead extruder to print metal wire onto plastic which in future can be used to print circuit boards, and a granule extruder including a method to create the granules [37]. A granular extruder is particularly relevant to OSAT related printing involving the use of locally sourced materials. A new extruder mount has been developed to pick up and place plastic components together and an inkjet printer for

28 the RepRap has been made. Work is in progress to use a RepRap with a laser cutter head, scribing tool head, a photopolymerization head and a selective laser sintering extruder head. All these different extruder heads will help RepRap gain full replication and greater OSAT component potential. There are several current limitations with the RepRap, the largest being its printing time. Currently, the deposition occurs at around 15 cm 3 /hr which would make the production of large parts prohibitively slow, though a slightly modified RapMan machine has printed up to 5 times faster. In addition, the durability of the machine has yet to be proven in long-term real-world testing, however it is hopeful that a large portion of the machine can be printed, and therefore replaced when parts wear out. The machine has a 0.5mm diameter nozzle and has 0.1mm positioning accuracy and 0.3 layer thickness. The tolerances for the machine are acceptable for many consumer grade products and OSAT related components.

Picture 3: The Mendel generation RepRap 3D printer.

29 3.5.2 TABBY EVO: modular open source electric car platform.

TABBY EVO [38] is an open source hardware platform for electric vehicles. Completely modular, ready to use, open source and available to everyone. It’s the 2nd version of the platform: now it’s harder, better, faster and stronger. It is an open source framework for the creation of complete electric vehicles: it can be used to bootstrap businesses (EV startups), to create your own vehicle, for education purposes, and much more.

By using TABBY EVO you save millions of dollars and years of R&D. All the plans and blueprints can be downloaded in the website’s download section. Any one can modify the blueprints and create his own version of the car. The community can make upgrades, changes and fix any issues of the car and contribute them back to the project through the OSV forum.

It can be used for building anything from city cars, autonomous vehicles, agricultural vehicles, military vehicles, multi-utility vehicles, logistics vehicles, and much more. The platform includes all the mechanical and electrical components that make the vehicle move, including chassis, steering and suspension system and complete powertrain. Packaging: TABBY EVO is shipped in components so to optimize logistics dimensions and import taxes. Thanks to its modularity, assembling TABBY EVO is really simple, it will take you less than one hour! The platform components and structural design are compliant to road legal certification in the EU, US, and ASIA.

The final road legal approval has to be given to the complete vehicle since it’s related deeply to parts in the bodywork and interiors whose configuration influences the design considerably (e.g. the lights, safety belts, airbags, etc.). The OSVehicle project is currently developing two different open source models. The Tabby features a small two or four person chassis that, according to the company, only needs an hour to be assembled. The Tabby can be fitted with a traditional combustion engine, an electric motor or a hybrid sports electric engine (IHE). The IHE is a unique hybrid engine currently being developed by OSVehicle and consists of two electric motors combined with an internal combustion engine. According to OSVehicle, the IHE will come with a "very competitive price tag." The Urban Tabby on the other hand features a structure that you can mount on top of the Tabby chassis, providing users with a road-ready and certified car which will be legally recognized in Europe, Asia and the United States. The Urban Tabby has been designed for several international markets and all the detailed specs of the final build of the Urban Tabby will be soon available on the company's website. Currently, the models have a top speed of approximately 70 to 90 km/h (43 to 56 mph).

30 Picture 4: The Tabby EVO project and four cars that were created based on it.

3.5.3 FarmBot Open Hardware CNC farming machine.

Most agricultural food production in the modern day is performed in large scale, monocrop farms on huge plots of land. While it has been streamlined to produce huge amounts of food at a relatively cheap price, monocrop farming puts a significant strain on the soil and the surrounding environment by using up specific nutrients for different crops, as well as using tremendous amounts of water [39]. The idea with Farmbot is to shift dependence on large scale agriculture by giving people the ability to cultivate their own plants with little to no actual physical labor on their part. Farmbot would be able to remember the location of each plant, and provide specialized care to feed nutrients and water to each plant as needed based on an online database. This means that, with Farmbot, a person with little to no actual gardening experience could have the home-garden of their dreams with no more effort than a few taps on the screen of a . Farmbot is a functioning robot with the ability to move, use multiple tools, plant seeds, and feed plants necessary nutrients to thrive. The Farmbot project also provides a template for future users to continue and develop new tools, which may include weed removal, plowing, or assorted types of data collection.

31 Picture 5: The FarmBot device.

3.5.4 Arducopter – Open Source Hardware Drone The DIY drones ArduCopter is an easy to set up and easy to fly platform for multirotors (quadcopter) and helicopters that goes way beyond most RC quadcopters on the market in the UK and Europe [40]. Arducopter is an open source project started at DIY drones. Arducopter is able to be a complete UAV solution capable of both remote control and fully autonomous waypoint based flight. Upgrades can enable wireless telemetry, and video streams from your diy drones quadcopter back to a powerful ground control station (also open source by the diy drones community) that will run on your laptop.

32 Arducopter Features Include: -Flight Controller board be used to fly tricopters, quadcopter, hexacompter, octacopter and traditional helicopters.

-High quality auto level and auto altitude control – fly level and straight. Or fly the awesome "simple flight" mode, which makes ArduCopter one of the easiest quadcopter to fly. Don't worry about keeping an eye on your quadcopter orientation--let the computer figure it out! You just push the stick the way you want to go, and the autopilot figures out what that means for whatever orientation the copter is in, using its onboard magnetometer. -Unlimited GPS way-points. Just point and click waypoints in the Mission Planner, and ArduCopter will fly itself to them. No distance limits! You can script entire missions, including camera control

-Flight modes include, stabilise, loiter, position hold, autonomous mission mode including automatic takeoff and landing

-More features constantly being added by the DIY drones community.

Picture 6: A quadcopter implemented using the Arducopter platform.

33 3.5.5 Open Hand Project: robotic prosthetic hands The Open Hand Project aims to make advanced prosthetic hands more accessible to amputees. The Dextrus hand is the realization of this goal, it's a low-cost robotic hand that offers much of the functionality of a human hand. Ultimately, these hands will be sold for under $1000 (£630).

The Open Hand Project is open-source, which means all of the plans to make a robotic hand will be published online with no patents, anyone has the right to make their own and even sell it themselves.

The Dextrus hand is for anyone who wants an advanced robotic hand. This could be an amputee who wants a little more than a metal hook, a researcher who's looking into control systems for telepresence robots or perhaps a hobbyist who is making a humanoid robot. The Dextrus hand works much like a human hand. It uses electric motors instead of muscles and steel cables instead of tendons. 3D printed plastic parts work like bones and a rubber coating acts as the skin. All of these parts are controlled by electronics to give it a natural movement that can handle all sorts of different objects.

The hand can be connected to an existing prosthesis using a standard connector to give an amputee another option. It uses stick-on electrodes to read signals from their remaining muscles, which can control the hand, telling it to open or close.

The fingers are individually powered and each one can sense when an object is impeding its movement. This gives it the ability to grasp objects gently and means the fingers can really wrap around unusual shapes to grip them firmly. Currently there are three types of the Open Hand Project: • Dextrus: A standard version of the Dextrus hand. It's aimed at hobbyists and people who want to attach it to things and then control it from a computer or from some custom electronics. • Dextrus EMG: A prosthetic version of the Dextrus hand. It's aimed at amputees that want another attachment for their existing prosthesis. • Dextrus Research: A research version of the Dextrus hand. It's aimed at Universities and Research Institutions. It has all of the same features of the standard Dextrus hand but with a number of enhancements such as power supply, denser plastics, upgraded servo motor and ball bearings in the joints.

34 Picture 7: The wrist of the Dextrus Open Hand Project

Picture 8: A person using the Dextrus EMG prosthetic

35 4. The Arduino Board

4.1 What is The Arduino Board?

Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. To do so you use the Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on Processing. Over the years Arduino has been the brain of thousands of projects, from everyday objects to complex scientific instruments. A worldwide community of makers - students, hobbyists, artists, programmers, and professionals - has gathered around this open-source platform, their contributions have added up to an incredible amount of accessible knowledge that can be of great help to novices and experts alike. Arduino was born at the Ivrea Interaction Design Institute as an easy tool for fast prototyping, aimed at students without a background in electronics and programming. As soon as it reached a wider community, the Arduino board started changing to adapt to new needs and challenges, differentiating its offer from simple 8-bit boards to products for IoT applications, wearable, 3D printing, and embedded environments. All Arduino boards are completely open-source, empowering users to build them independently and eventually adapt them to their particular needs. The software, too, is open-source, and it is growing through the contributions of users worldwide.

Thanks to its simple and accessible user experience, Arduino has been used in thousands of different projects and applications. The Arduino software is easy-to-use for beginners, yet flexible enough for advanced users. It runs on Mac, Windows, and Linux. Teachers and students use it to build low cost scientific instruments, to prove chemistry and physics principles, or to get started with programming and robotics. Designers and architects build interactive prototypes, musicians and artists use it for installations and to experiment with new musical instruments. Makers, of course, use it to build many of the projects exhibited at the Maker Faire, for example. Arduino is a key tool to learn new things. Anyone - children, hobbyists, artists, programmers - can start tinkering just following the step by step instructions of a kit, or sharing ideas online with other members of the Arduino community. There are many other microcontrollers and microcontroller platforms available for physical computing. Parallax Basic Stamp, Netmedia's BX-24, Phidgets, MIT's Handyboard, and many others offer similar functionality. All of these tools take the messy details of microcontroller programming and wrap it up in an easy-to-use package. Arduino also simplifies the process of working with microcontrollers.

It offers some advantage for teachers, students, and interested amateurs over other systems:

Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller platforms. The least expensive version of the Arduino module can be assembled by hand, and even the pre-assembled Arduino modules cost less than $50 Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX, and Linux operating systems. Most microcontroller systems are limited to Windows.

36 Simple, clear programming environment - The Arduino Software (IDE) is easy-to-use for beginners, yet flexible enough for advanced users to take advantage of as well. For teachers, it's conveniently based on the Processing programming environment, so students learning to program in that environment will be familiar with how the Arduino IDE works.

Open source and extensible software - The Arduino software is published as open source tools, available for extension by experienced programmers. The language can be expanded through C++ libraries, and people wanting to understand the technical details can make the leap from Arduino to the AVR C programming language on which it's based. Similarly, you can add AVR-C code directly into your Arduino programs if you want to.

Open source and extensible hardware - The plans of the Arduino boards are published under a Creative Commons license, so experienced circuit designers can make their own version of the module, extending it and improving it. Even relatively inexperienced users can build the breadboard version of the module in order to understand how it works and save money.

The Arduino licence allows anyone to improve, build or expand Arduino (licensed under a Creative Commons Attribution Share-Alike 2.5). This licence led to a very popular platform and its extension. The original Arduino and its development environment was founded in 2005 in Italy in the SmartProjects company. A year later this project won an award at the Prix Ars Electronica 2006. In addition to this project several clones were made. These clones usually contain some improvements and are compatible with the Arduino and its development environment. These clones are not allowed to bear the name Arduino, but for example FreeDuino (primarily, a name that anyone can use), Boarduino, Seeduino, Roboduino (intended for design of robots) and others are allowed. The microcontroller belongs to an Atmega family manufactured by a Norway's company Atmel [41]. Arduino microcontrollers are pre-programmed with a boot loader that simplifies uploading of programs to the on- . The default bootloader of the Aduino UNO is the optiboot bootloader [42]. Boards are loaded with program code via a serial connection to another computer. Some serial Arduino boards contain a level shifter circuit to convert between RS-232 logic levels and transistor–transistor logic (TTL) level signals. Current Arduino boards are programmed via Universal Serial Bus (USB), implemented using USB-to-serial adapter chips such as the FTDI FT232. Some boards, such as later-model Uno boards, substitute the FTDI chip with a separate AVR chip containing USB-to-serial firmware, which is reprogrammable via its own ICSP header. Other variants, such as the Arduino Mini and the unofficial Boarduino, use a detachable USB-to-serial adapter board or cable, Bluetooth or other methods, when used with traditional microcontroller tools instead of the Arduino IDE, standard AVR in-system programming (ISP) programming is used.

37 Picture 9: The Arduino Uno Board

4.2 Arduino Variations and Replicas

The Arduino project has a big number of different official boards, depending on the expected use. Some boards have more features and modules, such as wifi, bluetooth or RF modules, or they may have a larger number of available pins than other ones and so on. There are also Shields for the arduino boards which are printed circuit expansion boards and can be pluged into the normally supplied Arduino pin headers. They can enhance the usage of the board by extending its functionality. For example there is a shield that can make the arduino board able to read a GSM mobile phone card and perform actions such as phone messaging and phone calls. Other examples are motor controls for 3D printing and other applications, Global Positioning System shields (GPS), Ethernet shields, liquid crystal display shields (LCD), or breadboarding shields (prototyping). As Arduino is an open source platform anyone can make Arduino compatible boards. Many such boards are available in the market like the FreeDuino and NetDuino. One way to differentiate between original boards and the compatible models is to look for the trade name on the board. The name Arduino is trademarked and reserved for boards made from the original patent company in Italy. All compatible Arduino boards use a different but look alike trade name like Freeduino, Netduino, etc. If you want a cheaper alternative of the arduino, you can always buy the clone boards.

38 Picture 10: Official Arduino Boards, Shields and Modules

Picture 11: Arduino Boards

39 4.3 Software Development

Arduino programs may be written in any programming language with a compiler that produces binary machine code. Atmel provides a development environment for their microcontrollers, AVR Studio and the newer Atmel Studio, which can be used for programming Arduino.[43][44] The Arduino project provides the Arduino integrated development environment (IDE), which is a cross-platform application written in the programming language Java. It originated from the IDE for the languages Processing and Wiring. It was created for people with no profound knowledge of electronics. It includes a code editor with features such as syntax highlighting, brace matching, cutting-pasting and searching-replacing text, and automatic indenting, and provides simple one-click mechanism to compile and upload programs to an Arduino board. It also contains a message area, a text console, a toolbar with buttons for common functions and a series of menus. A program written with the IDE for Arduino is called a "sketch".[40] Sketches are saved on the development computer as files with the file extension .ino. Arduino Software (IDE) pre- 1.0 saved sketches with the extension .pde. The Arduino IDE supports the languages C and C++ using special rules to organize code. The Arduino IDE supplies a software library from the Wiring project, which provides many common input and output procedures. User-written code only requires two functions, for starting the sketch and the main programs loop, that are compiled and linked with a program stub main() into an executable cyclic executive program with the GNU toolchain, also included with the IDE distribution. The Arduino IDE employs the program avrdude to convert the executable code into a text file in hexadecimal coding that is loaded into the Arduino board by a loader program in the board's firmware.

A basic Arduino C/C++ sketch, as seen by the Arduino IDE programmer, consist of only two functions: setup() - This function is called once when a sketch starts after power-up or reset. It is used to initialize variables, input and output pin modes, and other libraries needed in the sketch. loop() - After setup() is called, this function is called repeatedly by a program loop in the main program. It controls the board until it is powered off or is reset.

Most Arduino boards contain a light-emitting diode (LED) and a load resistor connected between pin 13 and ground, which is a convenient feature for many tests and program functions. A typical program for a beginning Arduino programmer blinks an LED repeatedly which is the equivalent of the “Hallo World” program on other programming languages. This program is usually loaded in the Arduino by the manufacturer. This program uses the functions pinMode(), digitalWrite(), and delay(), which are provided by the internal libraries included in the IDE environment.

40 Picture 12: The Blink code on the Arduino IDE

4.4 The Arduino Board in education

The Arduino board is ideal for use in educational projects. A huge number of applications exist utilizing the Arduino for teaching individuals programming and electronics. In recent years, computer programming course have spread to Science, Technology, Engineering and Mathematics (STEM) degrees. The reason is simple: as computers have become a fundamental tool scientists and engineers often need to write or understand computer programs. Lecturers in charge of these subjects face a complex challenge. STEM students usually struggle to learn the main programming concepts. They often consider the subject to be unrelated to their core interests and feel uncomfortable when learning to program for the first time. New teaching methodologies might help the student to overcome their initial difficulties [45],[46]. Several studies have proposed the use of the physical computing paradigm. This paradigm takes the computational concepts “out of the screen” and into the real world so that the student can interact with them [47].

41 The major benefits for using Arduino in an educational setting are [48]: • Ease of setup - plug and play • Many examples for controlling peripherals - preloaded in the IDE • Many open source projects to look at • Works on Windows, Linux, and Mac • Low cost hardware - build or purchase prebuilt • Low cost software - free • Low maintenance cost - Destroyed microprocessors can be replaced for approximately 4 USD • Students can prototype quickly • Can be programmed in an a number of languages including C

Picture 13: Benefits of using Arduino for educational reasons

Picture 14: Mbot: Arduino based Educational Robot for Kids

42 4.5 Prototyping with Arduino

In electrical and computer engineering (among other majors) the prototyping board is a prefabricated board that includes a microchip or set of chips that allows various types of systems to be experimented with, designed, and tested without having to build the PCB (Printed circuit board) and test that part of the system. The word prototyping implies that the system, once, completed, could be designed more efficiently, but during prototyping most of the systems features can be used on these boards. These boards are used both in industry and education. The most popular and affordable microprocessor prototyping boards are the Arduino, the Raspberry Pi and the BeagleBoard. Raspberry Pi is a full microcomputer and runs a version of Linux. Because it’s a full computing environment, it can run any desktop software, but it lacks some flexibility that IoT developers may need. For instance, the Raspberry Pi needs extra hardware to read analog sensors. And because it’s a full computer, programs created on a Raspberry Pi don’t directly translate to the production version of an IoT device that will have limited battery and computational power. Arduino provides a programmable microprocessor and tools for programming it, including an integrated development environment and function library. Programming is in C++, not a special-purpose language, so software developers don’t need special training to get started. Because the Arduino is simply a board, developing for it requires managing the memory, power, and computing limitations the final IoT product will have to handle. There are also add-ons to Arduino called “shields” that extend basic functionality with features like Ethernet and Wi-Fi. The inherent limitations plus the extension products mean that prototyping with Arduino can get started quickly but also address many real-world concerns. Once we’ve got a working prototype, we can transition to a production design. In some cases we can use the Arduino board in production, but more often you’ll want to design a custom PCB that includes only the circuitry needed for your application. It’s also necessary to make sure a production version handles issues we may not have considered in a proof- of-concept prototype, such as battery or communication failures. Think about how troubleshooting and upgrading will work when the product is deployed in the field; we may want to build in the ability to replace an individual component or output debugging information. For very low volume production, perhaps 100 units a year or fewer, it may make sense to use commercially available Arduino Uno ($25) or Mini ($10) boards with a custom- designed PCB either as a shield (if using the Uno) or for containing your circuit in addition to mounting the Mini. In applications where you may be using another shield, such as a motor controller, need the barrel jack for power input, or may need the USB for troubleshooting, using a Mini instead of an Uno might not be worth it. The additional design and assembly effort required (including additional headers and soldering) make the Mini slightly more difficult to use for extremely low volumes. However if you're concerned with size and power requirements the Mini may be the way to go. For higher volume production, perhaps 1000 units a year or more, you might save enough by integrating the features of the Arduino, any controllers you plan to use (the schematics for most boards are readily available), and your own custom circuit that it makes sense to invest the extra effort into designing a custom board with everything integrated. Another important thing to take into account is the complexity of assembly and the connectors that you're going to need. If you're designing something that's going to be

43 assembled by hand, minimizing the amount of soldering, wire cutting, and assembly of complicated connections will be very important. Troubleshooting and upgrading your products in the field is another area to consider when producing things based on the Arduino. In short - for very low volumes it makes more sense to use commercially-produced boards and shields because the savings from integrating everything into one board doesn't begin to outweigh the additional design costs until you reach higher volumes.

Picture 15: Arduino prototyping cycle

44 5. The Raspberry Pi Board 5.1 About Raspberry Pi

Raspberry Pi is a small, powerful, cheap, hackable and education-oriented computer board introduced in 2012. It operates in the same way as a standard PC, requiring a keyboard for command entry, a display unit and a power supply. This credit card-sized computer with many performances and affordable for 25-35$ is perfect platform for interfacing with many devices. The vast majority of the system’s components – its central and graphics processing units, audio and communications hardware along with 1024 MB memory chip, are built onto single component. The Raspberry Pi board shown in contains essential (processor, graphics chip, program memory - RAM) and other optional devices (various interfaces and connectors for peripherals). The processor of Raspberry Pi (model 3) is a 64 bit, 1200 MHz , which is built on the ARM11 architecture and can be overclocked for more power. SD Flash memory serves as a hard drive to Raspberry Pi’s processor. The unit is powered via the micro USB connector while internet connectivity may be via an Ethernet/LAN cable or via an USB dongle (WiFi connectivity). The Raspberry Pi, like any other computer, uses an operating system. The Linux option called Raspbian is a great match for Raspberry Pi because it’s free and open source, keeping the price of the platform low, and making it more hackable. There are also a few non-Linux OS options available.

Picture 16: The Raspberry Pi 3 and its components

45 5.2 Raspberry Pi and the Internet of Things The Internet of Things (IoT) is a novel paradigm that is rapidly gaining ground in the scenario of modern wireless telecommunications. The basic idea of this concept is the pervasive presence around us of a variety of things or objects– such as Radio-Frequency IDentification (RFID) tags, sensors, actuators, mobile phones, etc. – which, through unique addressing schemes, are able to interact with each other and cooperate with their neighbors to reach common goals [49]. Unquestionably, the main strength of the IoT idea is the high impact it will have on several aspects of everyday-life and behavior of potential users. From the point of view of a private user, the most obvious effects of the IoT introduction will be visible in both working and domestic fields. In this context, domotics, assisted living, e-health, enhanced learning are only a few examples of possible appli- cation scenarios in which the new paradigm will play a leading role in the near future. Similarly, from the perspective of business users, the most apparent consequences will be equally visible in fields such as, automation and industrial manufacturing, logistics, business/process management, intelligent transportation of people and goods. By starting from the considerations above, it should not be surprising that IoT is included by the US National Intelligence Council in the list of six ‘‘Disruptive Civil Technologies” with potential impacts on US national power [50].

NIC foresees that ‘‘by 2025 Internet nodes may reside in everyday things – food packages, furniture, paper documents, and more”. It highlights future opportunities that will arise, starting from the idea that ‘‘popular demand combined with technology advances could drive widespread diffusion of an Internet of Things (IoT) that could, like the present Internet, contribute invaluably to economic development”. The possible threats deriving from a widespread adoption of such a technology are also stressed. Indeed, it is emphasized that ‘‘to the extent that everyday objects become information security risks, the IoT could distribute those risks far more widely than the Internet has to date”. Central issues are making a full interoperability of interconnected devices possible, providing them with an always higher degree of smartness by enabling their adaptation and autonomous behavior, while guaranteeing trust, privacy, and security. Also, the IoT idea poses several new problems concerning the networking aspects. In fact, the things composing the IoT will be characterized by low resources in terms of both computation and energy capacity. Accordingly, the proposed solutions need to pay special attention to resource efficiency besides the obvious scalability problems. Several industrial, standardization and research bodies are currently involved in the activity of development of solutions to fulfill the highlighted technological requirements. One of the key platforms for IoT (both for learning and production) is the Raspberry Pi. The RasPi is a popular platform because it offers a complete Linux server in a tiny platform for a very low cost. One can find thousands based on the RasPi. Also the community behind this platform is huge and everyone can get support for his project.

46 5.3 Raspberry Pi Operating Systems As we already know the raspberry pi board is a credit card sized personal computer. Thus there is a big number of operating systems that we can load of them. Although practically we can load any OS that can work with the ARM architecture of the board (even Windows 10) there are specific distributions of operating system make especially for the Raspberry Pi. We will see some of the best and most popular open source distributions for the platform.

5.3.1 Raspbian A free -based OS optimized for Raspberry Pi’s hardware, Raspbian comes with all the basic programs and utilities you expect from a general-purpose operating system. Supported officially by the Raspberry foundation, this OS is popular for its fast performance and its more than 35,000 packages.

The easiest way to install Raspbian on your Pi is by deploying its image file onto an SD card. It uses the lightweight LXDE desktop for its user-friendly graphical session. Its helpful community [51] supports and develops for Raspbian, and you’ll need a 8 GB SD card to load its latest version, Jessie.

Picture 17: The Raspbian Operating System

47 5.3.2 Ubuntu Mate Ubuntu MATE [52] is a stable and simple OS, which brings a configurable yet still light-on- resources MATE desktop for its users. It is especially good for devices short on hardware specs, making it perfect for Raspberry Pi devices that can’t run a composite desktop. MATE desktop comes with essential apps like a file manager, text editor, image viewer, system monitor, document viewer and terminal.

Unlike Snappy Ubuntu, Ubuntu MATE is original Ubuntu with an APT package manager and Ubuntu’s Software Center. It also works with remote workstation solutions like LTSP and X2Go, and comes with themes and artworks similar to Ubuntu. For loading its latest version, Ubuntu MATE 15.10 (Wily Werewolf) on Raspberry Pi, developers recommend 4GB or more high-speed SD card.

Picture 18: The Ubuntu Mate Operating System

5.3.3 Snappy Ubuntu A lightweight edition of the popular Ubuntu OS aimed for clouds and devices, Snappy [53] Ubuntu Core uses a minimal server image with the same system libraries. Applications run noticeably faster and are more reliable and secure because of the transactional systems management (like Docker); hence the term “Snappy”.

Unlike Ubuntu MATE, Snappy Ubuntu is altered Ubuntu with a difference in apps and updates installation and uninstallation – it provides a simpler approach with rollback facility. Available for Raspberry Pi 2, Snappy Ubuntu Core is one of the recommended OSs to run on the chip. The latest images for Ubuntu Snappy Core 15.04 are available to download and can be loaded on a 4 GB SD card.

48 Picture 19: The Snappy Ubuntu Operating System

5.3.4 Pidora Pidora [54] is a remix of the well-known Fedora operating system for Raspberry Pi. Designed from the latest build of Fedora for the ARMv6 architecture, Pidora allows greater speed, and carries applications and components from the Fedora 20 package set. This also comes with other software besides including the essentials provided by Raspberry Pi Foundation for device access. The main attraction in its feature set is the “Headless mode”, which lets you set up the OS on Pi devices lacking a monitor or display.

Picture 20: The Snappy Ubuntu Operating System

49 5.3.5 Linutop An OS that can be quickly set up on a Raspberry Pi, Linutop [55] uses a Raspbian-base with classic and lightweight XFCE graphical environment. It’s also handy for secure professional uses, such as in Kiosks casting public access or in embedded systems like electronic devices.

Linutop can be configured quickly for every purpose and boots in under 30 seconds. Its security features include a “read-only mode” where alterations aren’t saved unless you input the password, rendering viruses and hack attempts fruitless. It runs well on modest specs of 800 MHz and 512MB RAM.

5.3.6 SARPi Short for “Slackware ARM on a Raspberry Pi”, SARPi [56] is a community product of Slackware Linux enthusiasts. Considered widely as one of the best OS choice for Raspberry Pi, this can be installed on an 8 GB SD card. Although the ARM version doesn’t support all the apps, but most applications (including essential ones) have been ported for the ARM architecture.

Slackware is easy to use even if you’re unfamiliar with how Linux works, which is why SARPi is a good choice for Raspberry Pi novices. The website offers a step-by-step rundown of the setup process if this is your first time setting SARPi up on a mini-computer.

5.3.7 ARM A version of Arch Linux ported for ARM computers, Arch Linux ARM [57] offers versions 6 and 7 for Raspberry Pi and Raspberry Pi 2 respectively. Its design philosophy promotes simplicity and user-centrism, ensuring that Linux users are in full control of the system. Its packages are signed by the build system, and it can be updated through daily small packages, as opposed to huge updates found in other OSs. Most of these packages are improved for the best performance even on low specs. A minimum of 2 GB SD card suffices for loading its latest version.

5.3.8 Gentoo Linux An open source Linux-based computer OS, Gentoo Linux [58] compiles source code locally according to the user’s preferences to uphold performance. For this reason, Gentoo Linux’s builds are often optimized for a specific type of computer, such as Raspberry Pi. Other than the near limitless adaptability, this Linux distro uses Portage software management that increases security and streamlines performance. It’s also easy to install

50 and update software, and even build custom packages from existing ones. Its website recommend installing it on a 4 GB SD card. 5.3.9 FreeBSD A computer OS used to power servers, embedded systems as well as computers, FreeBSD [59] offers advanced networking, security and storage features. Its powerful networking services make it the platform of choice when setting up an Internet or Intranet server, thus ensuring fast response times and robust memory management. The ARM versions of FreeBSD supports Raspberry Pi and Raspberry Pi 2, and the images of its latest version (10.2) can be written on to 512 MB SD card. Its small size requirement and fast performance makes it a suitable choice to install on a Pi chip.

5.3.10 Kali Linux Kali Linux [60] is an advanced penetration platform with versions designed to support Raspberry Pi. A Debian-based Linux distribution, this OS has several tools for information security operations such as penetration testing, forensics, and reverse engineering. It’s not limited to those operations as it is suitable for a general-purpose OS too. A rebuild of the famous BackTrack Linux, it is a free platform under continuous development and comes with comprehensive support for devices and networks. It offers customizability that extends down to the Kernel level, and its installation is recommended on a 8 GB SD card.

Picture 21: The Kali Linux Operating System 51 5.4 Raspberry Pi Alternatives 5.4.1 Odroid XU4 The Odroid XU4 has a more powerful form factor and a smaller size compared to its predecessor, the Odroid XU3. The unit is capable of running the latest Ubuntu, or Android kit kat / Lollipop depending on the users choice. The Odroid XU4 offers faster data transfer and networking speeds, resulting in an overall speed up in the device’s performance. The company also decided to go 1 step further, by making it compatible with its predecessor, so that you can use both the units in cohesion with each other.

Picture 22: The Odroid XU4 Board

5.4.2 BeagleBoard BeagleBoard is produced by Texas Instruments as a single board computer system. It is low power compared to its competitors, but does the job really well. It is based on open source hardware and Software and is available to the public for various purposes. It was designed by a small group of engineers, with the development and promotion of open source software in mind. It is designed as teaching aid for teachers to introduce students and other people to the world of Open Source Software development just like the Raspberry Pi. The BeagleBoard measures 75mm x 75mm making it a highly compact and portable Unit. It comes with ARM CORTEX A8 CPU, which is capable of supporting Sybian, Risc Os, Linux Minix, FREE BSD and OPEN BSD.

52 Picture 23: Texas Instruments BeagleBoard 5.4.3 Gen: 2 Intel had decided to step into the market of single board computers with its previously introduced Intel Galileo single board unit. With fairly good specifications, the unit could only do so much in a market dominated by upcoming brands offering attractive prices and higher specifications . Intel needed to answer back, and Intel Galileo Gen 2 was a result of this brain storming at Intel. The new Galileo gen 2 is powered by Intel’s Quark Application processor with a 32 bit intel system on it.

The unit also features out of the box compatibility with the Arduino tools that are available out there, so that you can get to developing you ideas as soon as possible. Apart from Arduino all round compatibility, the unit features some unique onboard input and output slots and expansion ports that can enhance the experience to the next level. Some of the noteworthy features are listed below, these features are mandatory in every variant of the Intel Galileo Gen 2.

Picture 24: The Intel Galileo Board 53 5.4.4 Udoo Dual Basic This is another alternative to the raspberry Pi, with some advantages over its competitors where as some disadvantages as well. It is another single board computer powered by an onboard chip CPU with an integrated Arduino 2 micro controller in it. This unit was originally marketed on Kickstarter which quickly helped the company to develop. It has a smaller size and runs from a single power supply unlike some other single board computers out there. It is available with both the quad core and the dual core processor variant, making it more versatile and diverse.

Picture 25: The Udoo Dual Basic Board

5.4.5 CubieBoard 4 CubieTech, the company behind CubieBoard is another manufacturer that makes single board computers, with high performance specifications at attractive price points. The company’s latest installment in its long running line of is the new CubieBoard 4. It is a high end Processing unit with very high specifications to perform high end and time sensitive tasks with ease. The unit is compatible with both Linux and Android and offers the following images for download for open source use with your CubieBoard 4.

The machine is manufactured with the following specifications: 1- A80 octa-core processors for lightning-fast computing speed. 2- Power VR 64 core GPU , for all your intensive graphics need. 3- 2GB 64 bit RAM for smooth functioning of the unit. 4- Onboard default EMMC storage is 8GB and expandable up to 64GB 5- two HDMI ports and one VGA port with support for 1080p output.

54 6- Four USB 2.0 ports and one USB 3.0 port, for all your connectivity needs 7- Wifi Compatibility with support for rechargeable batteries as well.

Picture 26: The CubieBoard 4

55 6. Water Flow Sensors The implemented system will measure only the flow of clean water. For that reason the appropriate sensors were chosen. For clean water measurements ten different kind of sensors are proposed from the industry. Each solution has its advantages and disadvantages and depending the application each one is more suited than the other:

1. Turbine sensors 2. Magnetic sensors 3. Ultrasonic sensors 4. Vortex Shedding 5. Variable Area flow meters 6. Positive displacement flow meters 7. Thermal sensors 8. Paddle wheel sensors 9. Differential pressure 10. Vane/Piston

6.1 Turbine Sensors Turbine flow sensors use the mechanical energy of the water to rotate a “pinwheel” (rotor) in the flow stream. Blades on the rotor are angled to transform energy from the flow stream into rotational energy. The rotor shaft spins on bearings. When the fluid moves faster, the rotor spins proportionally faster. Shaft rotation can be sensed mechanically or by detecting the movement of the blades. Blade movement is often detected magnetically (Hall effect [61]), with each blade or embedded piece of metal generating a pulse. When the water moves faster, more pulses are generated. The transmitter processes the pulse signal to determine the flow of the fluid. Transmitters and sensing systems are available to sense flow in both the forward and reverse flow directions. We used a 1/2" water flow sensor switch which can measure 1-30 liters per minute.

Pluses and Minuses Turbine sensors are very good at clean, low viscosity fluids of moderate velocity and a steady rate. Also they are reliable if put in a clean fluid especially if it has some lubricity. On the other hand they can cause some pressure drop where that may be a factor such as gravity flows. Lastly they are not reliable for steam and their bearings wear out over time.

56 Picture 27: Turbine Sensor

6.2 Magnetic Sensors The principle of operation for the magnetic flow meter sensors is based on the Faraday’s Law of Electromagnetic Induction [62]. An electrical current (I) is applied to a coil package inside the flow meter. As a result, a magnetic field (B) is created across the metering pipe. When a conductive liquid flows through the magnetic field, a small voltage (u) is induced. This voltage is proportional to the velocity of the flow and is accurately measured by two stainless steel electrodes mounted opposite each other inside the metering pipe. The two electrodes are connected to an advanced electronic input circuitry which processes the signal and in turn feeds it to a microprocessor inside the electronics module. The microprocessor then calculates the volumetric flow and controls the various outputs on the terminal board. Pluses and Minuses

The accuracy of the sensors is intermediate therefore this kind of sensors are only used in configurations with inexpensive liquids (water, wastes, sanitary uses). The magnetic sensors are very reliable and large line sizes are available in the industry. Lastly magnetic sensors work only with conductive fluids(oils and gas can not be measured with this method).

57 Picture 28: Magnetic Sensor

6.3 Ultrasonic Sensors Ultrasonic flow meters use sound waves to determine the velocity of a fluid flowing in a pipe. There are two types of ultrasonic sensors:

• Doppler effect sensors: At no flow conditions, the frequencies of an ultrasonic wave transmitted into a pipe and its reflections from the fluid are the same. Under flowing conditions, the frequency of the reflected wave is different due to the Doppler effect [63]. When the fluid moves faster, the frequency shift increases linearly. The transmitter processes signals from the transmitted wave and its reflections to determine the flow rate.

• Transit time ultrasonic flow meters: This kind of sensors send and receive ultrasonic waves between transducers in both the upstream and downstream directions in the pipe. At no flow conditions, it takes the same time to travel upstream and downstream between the transducers. Under flowing conditions, the upstream wave will travel slower and take more time than the (faster) downstream wave. When the fluid moves faster, the difference between the upstream and downstream times increases. The transmitter processes upstream and downstream times to determine the flow rate.

58 Pluses and Minuses

Ultrasonic flow sensors are very accurate, reliable and can be used for measuring the flow of expensive fluids (petroleum, gasoline), they can handle high pressures and temperatures. It can be applied to the pipe without penetrating it (non invasive), although that can decrease the accuracy of the sensor. The maintenance of the sensors is very low as they don’t have any mechanical parts. A disadvantage of these sensors is that they are very expensive and they don’t perform well when the liquid is mixed with gases (air bubbles).

Picture 29: Doppler effect and transit time ultrasonic sensors

6.4 Vortex Shedding Fluidic flow meters are flow meters that generate oscillations as a result of flow. Vortex shedding flow meters use a bluff body obstruction, whereas other fluidic flow meters include designs based upon the Coanda effect [64] and vortex precession. Increasing flow increases the frequency of oscillation. A sensor detects the oscillations and a transmitter generates a flow measurement signal. Vortex shedding flow meters use a bluff body (shedder) located to symmetrically traverse the flowing stream to create vortices downstream of the shedder. The frequency is directly proportional to the flow rate of the fluid.

59 Coanda effect flow meters contain two feedback passages that alternately bring fluid back to the flow meter inlet so as to alternately direct the flow to attach itself to one of the two internal “walls” of the flow meter. The frequency that the flow alternates between the feedback passages is directly proportional to the flow rate of the fluid. Pluses and Minuses

Vortex flow meters are suitable to measure liquids, steam and gas, and for that reason they can be applied in a large number of different configurations. The vortex sensors do not have any moving / mechanical parts, making them more maintainable and robust. The accuracy of these sensors is relatively high. One disadvantage is that high pressure drop is possible at high end of the scale although negligible at midscale.

Picture 30: How a Vortex Shedding sensor works

60 6.5 Variable Area flow meters Variable area flow meters (Float Style) measure flow by allowing the flow stream to change the opening within the flow meter by moving an internal part. When the flow increases, the fluid generates more force and moves the internal part farther. A variable area flow meter measures flow in a vertical metering tube by balancing the downward weight of a float with the upward force of the flowing fluid. Spring-opposed float designs allow this type of flow meter to be installed in horizontal pipes, because the functioning of the float is not dependent upon gravity. These flow meters can be read locally because their glass or plastic metering tubes have markings that relate the height of the float (that can be seen) with the flow rate of the fluid. Flow meters with remote signals are typically constructed with metal tubes, and include a transmitter that senses the height of the float to determine fluid flow.

Pluses and Minuses

Variable area sensors have relatively low cost and they are easy to install. They are easily maintainable, robust and they don’t need a power supply to operate. They can be applied to liquid and gas installations. On the other hand this flow meters are sensitive to changes in temperature, viscosity and pressure.

Picture 31: Variable Area flow meter

61 6.6 Positive displacement flow meters Positive displacement flow meter technology is the only flow measurement technology that directly measures the volume of the fluid passing through the flow meter. Positive displacement flow meters achieve this by repeatedly entrapping fluid in order to measure its flow. This process can be thought of as repeatedly filling a bucket with fluid before dumping the contents downstream. The number of times that the bucket is filled and emptied is indicative of the flow through the flow meter. Many positive displacement flow meter geometries are available. Some positive displacement flow meters have mechanical registers that show the total flow on a local display. Other positive displacement flow meters output pulses that can be used by a secondary electronic device to determine the flow rate. Positive displacement flow meters can be applied to clean, sanitary, and corrosive liquids, such as water and foods, and some gases. Pluses and Minuses

Positive displacement flow meters are capable for small line sizes, low flow rates with high viscosity. Some disadvantages are that they have moving parts, they need maintenance and impure liquids can cause malfunctions to the meter.

Picture 32: Positive displacement flow meter

62 6.7 Thermal Sensors Thermal sensors use the thermal properties of the fluid to measure the flow of a fluid flowing in a pipe or duct. In a typical thermal flow sensor, a measured amount of heat is applied to the heater of the sensor. Some of this heat is lost to the flowing fluid. As flow increases, more heat is lost. The amount of heat lost is sensed using temperature measurement(s) in the sensor. The transmitter uses the heat input and temperature measurements to determine fluid flow. Most thermal sensors are used to measure gas flows. In applications where the thermal properties of the fluid are known and relatively constant during actual operation, thermal sensors can be used to measure the mass flow of the fluid because the thermal flow measurement is not dependent upon the pressure or temperature of the fluid.

Pluses and Minuses

Thermal sensors are commonly used to measure the mass flow of clean gases, (air, nitrogen, helium…). This kind of sensors are independent of the density of the gas although we need to know the properties of each gas that we are going to measure. Thermal sensors can also be used to measure corrosive gases such as hydrogen chloride and hydrogen sulfide.

Picture 33: Thermal Mass sensor

63 6.8 Paddle Wheel Sensors Paddle wheel flow meters use the mechanical energy of the fluid to rotate a paddle wheel (just like a riverboat) in the flow stream. Paddles on the rotor are inserted into the flow to transform energy from the flow stream into rotational energy. The rotor shaft spins on bearings. When the fluid moves faster, the paddle wheel spins proportionally faster. Shaft rotation can be sensed mechanically or by detecting the movement of the paddles. Paddle movement is often detected magnetically, with each paddle or embedded piece of metal generating a pulse. When the fluid moves faster, more pulses are generated. The transmitter processes the pulse signal to determine the flow of the fluid. Pluses and Minuses

Like the turbine sensors the accuracy of the sensors is intermediate therefore this kind of sensors are only used in configurations with inexpensive liquids (water, wastes, sanitary uses). The magnetic sensors are very reliable and large line sizes are available in the industry. Lastly magnetic sensors work only with conductive fluids(oils and gas can not be measured with this method).

Picture 34: Paddle Wheel Sensor

6.9 Differential Pressure Differential pressure sensors use Bernoulli’s equation [65] to measure the flow of fluid in a pipe. Differential pressure sensors introduce a constriction in the pipe that creates a pressure drop across the sensor. When the flow increases, more pressure drop is created. Impulse piping routes the upstream and downstream pressures of the flow meter to the transmitter that measures the differential pressure to determine the fluid flow. Bernoulli’s equation states that the pressure drop across the constriction is proportional to the square

64 of the flow rate. Using this relationship, 10 percent of full scale flow produces only 1 percent of the full scale differential pressure. At 10 percent of full scale flow, the differential pressure flow meter accuracy is dependent upon the transmitter being accurate over a 100:1 range of differential pressure. Pluses and Minuses

Differential Pressure sensors have low cost and can be used on a large number of applications and materials (fluids, gases). Some disadvantages are that this method does not provide the best accuracy and it can deteriorate with wear and clogging.

Picture 35: Differential Pressure Sensor

65 6.10 Vane/Piston Vane/Piston sensors measurement is based on a vane wheel rotating at a speed proportional to the flow velocity of the fluid which surrounds it. The rotational speed is virtually independent of density, pressure and temperature of the medium. Vane wheel anemometers can be used in gases and liquids. Sensing the vane wheel rotation is by a proximity switch which has no braking effect on the vane wheel flow meter. A further proximity switch allows sensing of rotational direction and with it recognition of the +/- direction of flow. Contamination does not influence pulse recognition. Pluses and Minuses

Thanks to the lightness of the vane wheel, the rotation speed adjusts to velocity increases in milliseconds in gases and liquids, thus ensuring precise measuring of the flow velocity. Vane wheel flow meters can be adjusted and calibrated at the same frequency, so that flow sensors of the same type are interchangeable without restriction.

Picture 36: Vane/Piston sensor

66 7. Implemented System 7.1 System Components 7.1.1 Water Flow Sensor On our implementation we used the water flow sensor that was described on paragraph 6.8. The paddle wheel flow meter uses the mechanical energy of the fluid to rotate a paddle wheel (just like a riverboat) in the flow stream. This category of flow meter doesn’t provide the most accurate measurements, but they are really easy to use, they can be installed very easily and they are low cost. The paddle flow meter is connected to the arduino board and it is sending pulses to the board depending the amount of water it passes throw it. After some experimentation we calibrated the amount of pulses the flow meter transmit to the number of litters (400 pulses = 1 litter of water). We have to mention here that this calibration may vary in different situations, like the kind of liquid we measure and the pressure of the fluid. 7.1.2 Arduino Bluetooth module For transmitting data from the Arduino to the Raspberry Pi board we used the HC-05- Bluetooth to Serial Port Module. Using a bluetooth transmitter has the advantage of saving a large amount of energy (more than 10 times from wifi transmission). Using this module we managed to keep the Arduino board powered for about 45 hours using a powerbank device with capacity of 5000 mAh.

HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup. Serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR (Enhanced Data Rate) 3Mbps Modulation with complete 2.4GHz radio transceiver and baseband. It uses CSR Bluecore 04-External single chip Bluetooth system with CMOS technology and with AFH(Adaptive Frequency Hopping Feature). It has the footprint as small as 12.7mmx27mm and its range is between 15 meters (with obstacles) to 25 meters (without obstacles).

Picture 37: The HC-05 module

67 7.1.3 Arduino and Raspberry Pi Boards On paragraphs 5 and 6 we talk about these two boards. We chose these boards because they were low cost, they are open source, there is a big community behind both of them and they are friendly to unexperienced users that need to create a prototypes for their projects. The Arduino model that we use is the Arduino UNO. Arduino/Genuino Uno is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.

The Raspberry Pi board is the version 2 Model B which is the second generation of Raspberry Pis. It replaced the original Raspberry Pi 1 Model B+ in February 2015. It has a 900MHz quad-core ARM Cortex-A7 CPU 1GB RAM, 4 USB ports, 40 GPIO pins, Full HDMI port, Ethernet port, Combined 3.5mm audio jack and composite video, Camera interface (CSI), Display interface (DSI), Micro SD card slot and a VideoCore IV 3D graphics core. Because it has an ARMv7 processor, it can run the full range of ARM GNU/Linux distributions, including Snappy Ubuntu Core, as well as Windows 10. Additionally we installed a WiFi and a bluetooth dongle for internet access and connection with the Arduino. 7.1.4 System Casing The park of our configuration that will be connected to the water supply network is the Arduino with the attached water flow sensor. The environment that our device will operate is near the water source and for that reason we have to protect it from water contact. We chose an IP 65 casing for this task.

IP ratings, or ingress protection, were developed by the IEC (International Electrotechnical Commission) and are most heavily used in Europe and Asia, with some adherents in North America as well. Since these are international standards, the testing is often certified by the TUV instead of UL, although both provide stringent testing.

The IP Code, International Protection Marking, IEC standard 60529, sometimes interpreted as Ingress Protection Marking, classifies and rates the degree of protection provided against intrusion (body parts such as hands and fingers), dust, accidental contact, and water by mechanical casings and electrical enclosures. It is published by the International Electrotechnical Commission (IEC). The equivalent European standard is EN 60529.

68 The standard aims to provide users more detailed information than vague marketing terms such as waterproof. The digits (characteristic numerals) indicate conformity with the conditions summarized in the tables below. Where there is no data available to specify a protection rating with regard to one of the criteria, the digit is replaced with the letter X. The digit 0 is used where no protection is provided. A rating of X for one or more of the protection criteria can be erroneously misinterpreted as "no protection". To illustrate, a piece of electronic equipment rated IPX7 will almost certainly demonstrate a robust resistance to the ingress of particles, even though a rating for ingress of solids hasn't been formally assigned. Hence, an X designation shouldn't be automatically misconstrued as a lack of protection.

Picture 38: IP Ratings Chart

69 7.1.5 Power Supply We provide power to our devices by a power bank in the case of the Arduino/Water flow sensor and with a micro USB charger in the case of the Raspberry Pi (server). The specifications of the power bank are: Capacity: 20000 mAh Charging time: up to 12 h Input voltage: 5V DC 2,1 A (micro USB) Output voltage 1: 5 V DC 1 A (USB) Output voltage 2: 5 V DC 2,1 A (USB) Input port: micro USB Output port: 2x USB For the power consumption tests we also used a power bank with lower capacity (5000 mAh).The power supply for the Raspberry Pi is a micro USB charger with output voltage of 5.0V DC and 2.1 A. 7.1.6 Android Mobile Phone/Tablet The Arduino and the Raspberry Pi will be install in remote areas where the available space might be very limited. In order to be able to control our configuration without having to install many devices to it (mouse, keyboard, screen monitor), we configured our system to be able to connect with and Android device via the USB port. The user has full control of the Raspberry Pi by only using his mobile phone or table and installing one application to establish the connection (VNC server).

Picture 39: The Components of the implemented System

70 7.2 System Software 7.2.1 Arduino IDE To code that runs on the Arduino device was created using the Arduino IDE. The Arduino Integrated Development Environment - or Arduino Software (IDE) - contains a text editor for writing code, a message area, a text console, a toolbar with buttons for common functions and a series of menus. It connects to the Arduino and Genuino hardware to upload programs and communicate with them.

Programs written using Arduino Software (IDE) are called sketches. These sketches are written in the text editor and are saved with the file extension .ino. The editor has features for cutting/pasting and for searching/replacing text. The message area gives feedback while saving and exporting and also displays errors. The console displays text output by the Arduino Software (IDE), including complete error messages and other information. The bottom righthand corner of the window displays the configured board and serial port. The toolbar buttons allow you to verify and upload programs, create, open, and save sketches, and open the serial monitor.

The Arduino Software (IDE) uses the concept of a sketchbook: a standard place to store your programs (or sketches). The sketches in your sketchbook can be opened from the File > Sketchbook menu or from the Open button on the toolbar. The first time you run the Arduino software, it will automatically create a directory for your sketchbook. You can view or change the location of the sketchbook location from with the Preferences dialog. 7.2.2 Raspbian OS The operating system that we chose to install to the Raspberry Pi was the Raspbian. Raspbian is a Debian-based computer operating system for Raspberry Pi. It is now officially provided by the Raspberry Pi Foundation, as the primary operating system for the family of Raspberry Pi single-board computers. Raspbian was created by Mike Thompson and Peter Green as an independent project. The initial build was completed in June 2012. The operating system is still under active development. Raspbian is highly optimized for the Raspberry Pi line's low-performance ARM CPUs.

Raspbian uses PIXEL, Pi Improved Xwindows Environment, Lightweight as its main desktop environment as of the latest update. It is composed of a modified LXDE desktop environment and the Openbox stacking window manager with a new theme and few other changes.

71 7.2.3 VNC Viewer VNC Viewer for Android is the original Open Source (GPL) remote desktop program for Android devices. Connects to most VNC servers: incl TightVNC, RealVNC on Win and Linux, x11vnc, and Apple Remote Desktop on OS/X. Lots of customizable features let you adapt the way your device controls map to the controls of your desktop.

0.5.0 -- Will preserve sent text from session to session. Import/Export settings to a file on SD card (Can import from URL, useful when deploying to many devices with same configuration) add button in zoom control to bring up keyboard. 7.3 System Configuration The purpose of our system is to efficiently measure the water consumption of a household, an industrial building or a public building consuming the minimum possible energy. Our system consist two main parts. The first one is the Arduino with the water flow sensor and the bluetooth transmitter and the second one is the Raspberry Pi that receives the transmitted data store them locally and uploading them to the cloud to the ThingSpeak platform. ThingSpeak is an open source Internet of Things (IoT) application and API to store and retrieve data from things using the HTTP protocol over the Internet or via a Local Area Network. ThingSpeak enables the creation of sensor logging applications, location tracking applications, and a social network of things with status updates.ThingSpeak was originally launched by ioBridge in 2010 as a service in support of IoT applications. ThingSpeak has integrated support from the numerical computing software MATLAB from MathWorks.[4] Allowing ThingSpeak users to analyze and visualize uploaded data using Matlab without requiring the purchase of a Matlab license from Mathworks.

72 Picture 40: System Configuration. The Arduino board transits the flow data to the Raspberry Pi, which then uploads them to the cloud platform (ThingSpeak)

7.4 Energy Consumption of the System One of the main goals of the implemented system is to be operational without a battery recharge / replacement for as long as possible. For that reason we chose to transit the data from the Arduino using the bluetooth module instead of a WiFi one. The bluetooth is more energy efficient and can cover a recent area (25 meters without obstacles and 15 meters with obstacles). Additionaly we tried to save more energy by powering down the Arduino when the sensor was not working. The minimum amount of time that the Arduino can operate with a power bank with capacity of 5000 mAh is 37 hours and the maximum (transmitting data every six hours) is 48 hours. The 5000 mAh power bank was used for testing and the final product will use a 20000 mAh power bank, so the operation time of the sensor will be four times longer.

73 Below is a diagram with the operation time depending on the transmission intervals of our implementation:

Picture 41: Operational time using a 5000 mAh power bank

7.5 System Code There were two main parts of code. The first one was the code needed for the Arduino which was written in C. The second part was for the Raspberry Pi which was written in Python. In the C code we use the SoftwareSerial library to establish communication with the Raspberry Pi. The Arduino hardware has built-in support for serial communication on pins 0 and 1 (which also goes to the computer via the USB connection). The native serial support happens via a piece of hardware (built into the chip) called a UART. This hardware allows the Atmega chip to receive serial communication even while working on other tasks, as long as there room in the 64 byte serial buffer. The SoftwareSerial library has been developed to allow serial communication on other digital pins of the Arduino, using

74 software to replicate the functionality (hence the name "SoftwareSerial"). It is possible to have multiple software serial ports with speeds up to 115200 bps. A parameter enables inverted signaling for devices which require that protocol. We also use the LowPower library in order to save energy by powering of the Arduino. LowPower is a simple and easy to use library that has the following features: -Supports all sleeping mode of ATmega328P: -Idle. -ADC reduction mode. -Power save. -Power down. -Standby. -Extended standby. -Selectable sleep duration: 15 ms, 30 ms, 60 ms, 120 ms, 250 ms, 500 ms, 1 s, 2 s, 4 s, 8 s, and forever (wake up using other resources) through on chip 125 kHz Watchdog timer. Using sleeping forever duration, the Watchdog timer module is not in use and will further reduce the current consumption by approximately 4 µA. -Option to shutdown Analog to Digital Converter (ADC) module to further reduce current consumption. -Option to disable Brownout Detector (BOD) module to further reduce current consumption by approximately 17 µA. BOD module cannot be disabled through software in idle and ADC noise reduction mode. It can only be disabled through fuse setting in these 2 modes. -Option to shutdown Timer 2 module in idle, ADC noise reduction, power save, and extended standby mode. Timer 2 is used by the core of Arduino for PWM operation. -Option to shutdown Timer 0, Timer 1, USART0, TWI, and SPI module in idle mode. On the Python code we used the serial library to receive the information from the Arduino, the urllib and the httplib for uploading the data to the ThingSpeak platform.

75 The C code running on Arduino: //In this sketch we read the pulses from the flow meter //and transmit them to the serial port //We make the transmision when the flowmeter stops to detect pulses //and if the pulses exeed a given threshold

//The software serial library helps to transmit data with the bluetooth device // using the serial port #include //The LowPower library is used in order to power down the arduino and save power #include "LowPower.h"

// Declaring variables SoftwareSerial blueSerial(10,11); //10 reading pin RX, 11 transmit pin TX, for the bluetooth device int flowPin = 2; // Arduino flowmeter pin number int pulsesThreshold = 400; // Threshold of pulses in case of a leak float pulsesCounter; // Main pulses counter float pulsesAux; // Auxiliary counter float pulsesPrev; // Auxiliary counter to track pulses activity between loops int loopsNumber = 0;

/** * Interrupt Service Routine for interrupt 0 (ISR0) * ISR0 services an interrupt condition on Pin 2 - whenever voltage on that pin rises. */ void rpm () { loopsNumber = 0; pulsesCounter++; // Every RISING pulse causes pulsesCounter to increase by one. }

void setup() { pinMode(flowPin, INPUT); // Initialize the digital pin as an input //Serial.begin(9600); // Starting serial port (USB) blueSerial.begin(9600); // Starting serial port (Bluetooth) attachInterrupt(0, rpm, RISING); // Interrupt is attached to rpm function sei(); // Enable interrupt 0 on Pin 2 for a RISING signal. }

void loop () { cli(); // Disable interrupts to check the counter pulsesAux = pulsesCounter; // Copy the ISR variable (main counter). Don't corrupt the counting process sei(); // Enable interrupts

// If pulses are non-zero and doesn't change during a loop (delay time: ~1sec), // send the data to the Serial port if ( ((pulsesAux != 0) && (pulsesPrev == pulsesAux)) || ((pulsesAux != 0) && (pulsesAux > pulsesThreshold))) { // pulsesPrev == pulsesAux means that the flow has stoped

blueSerial.print("pulses:"); // Sending the string via blutooth blueSerial.println(pulsesAux, DEC); // Sending the pulses counter via bluetooth cli(); // Disable interrupts pulsesCounter = 0; // Reset main counter sei(); // Enable interrupts pulsesPrev = 0; // Reset previous counter pulsesAux = 0; // Reset auxiliary counter } //if the flow stops for a number of loops we power down the arduino if (pulsesPrev == pulsesAux){ loopsNumber++; } if (loopsNumber > 8){ LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); }

cli(); // Disable interrupts to copy the pulses count pulsesPrev = pulsesAux; sei(); // Enable interrupts delay(1000); // Delay time between loops 1sec }

76 The Python Code running on Raspberry Pi:

#!/usr/bin/python

#Reading the information of the arduino device from the serial port and #uploading it to the thingspeak cloud platform import httplib import serial import urllib import json import time

# Serial port connection USB #try: # ser = serial.Serial("/dev/ttyACM0", 9600, timeout=1) #except: # ser = serial.Serial("/dev/ttyACM1", 9600, timeout=1)

#Serial port connection Bluetooth ser = serial.Serial("/dev/rfcomm0", baudrate=9600, timeout=1) pulses = 0; liters = 0; numberOfMeasures = 0; key = "EE9FJQGXOHZXF2K2" pulsesPerLiter = 400; while True: # Read line received try: line = ser.readline().strip() except: print "Serial port error"

if line: print line # Remove possible garbage lines if line.startswith("pulses"): piece = line.split(":") if 2==len(piece): pulses = float(piece[1].strip()) print pulses liters = float(pulses)/pulsesPerLiter print liters

#Preparing to send the information to the cloud params=urllib.urlencode({'field1':liters,'key':key}) headers={"Content-typZZe": "application/x-www-form- urlencoded","Accept":"text/plain"} conn=httplib.HTTPConnection("api.thingspeak.com:80")

#Sending the data to the thingspeak platform try: conn.request("POST", "/update", params, headers) response=conn.getresponse() print response.status, response.reason data=response.read() conn.close() except: print "connection failed"

#Writing the data to a file for backup file = open("littersSaved.csv","a") numberOfMeasures +=1 cTime = time.strftime("%H:%M:%S") cDate = time.strftime("%Y-%m-%d") record = cDate + " " + cTime + " " + "+0300," + str(numberOfMeasures) + "," + str(liters) + "\n" file.write(record) file.close()

77 8. Conclusion

During this thesis we learned how we can utilize open source hardware and software technologies in order to create systems, configurations and prototypes that can solve every day and industrial problems. Monitoring the water consumption of an installation can give us multiple benefits. Such benefits can be the evaluation of water saving techniques so we can be able to make the right decisions about which strategies and devices we can use to save the maximum amount of water. Also by monitoring the water flow we can detect leaks to our water supply network and we can fix them saving in many cases a large amount of water (and money of course). Finally we can even detect wasteful behaviors into our facilities and take the appropriate measures to avoid them. In addition we experimented into how we can install and configure such a system in order to be a much as possible energy autonomous and efficient while keeping its cost into reasonable levels. Selecting open hardware devices (Arduino , Raspberry Pi) proved that such goals can be achieved. Also we concluded that using more efficient methods for transmitting our data between our devices can save us a lot of energy (HC-05 bluetooth module). Finally uploading all the information a cloud platform has many advantages. All the users of the system can monitor it remotely wherever they are. Also we don’t need any experts to extract this information from the system (the user only needs to know how to handle a web browser). Lastly we have a constantly updated backup of the retrieved information in the cloud, so in case the hardware is damages we don’t lose any of it.

78 REFERENCES [1] Σύστημα Βασισμένο σε Arduino για την παρατήρηση ροής υγρού. Βλαγοΐδης Νικόλαος Σταμέλος Ιωάννης 2016 [2] I.F. Akyildiz, W. Su, Y. Sankarasubramaniam, E. Cayirci, A survey on sensor networks, IEEE Communications Magazine 40 (8) (2002) 104–112. [3] I.F. Akyildiz, E.P. Stuntebeck, Wireless underground sensor networks: research challenges, Ad-Hoc Networks 4 (2006) 669–686. [4] M. Li, Y. Liu, Underground structure monitoring with wireless sensor networks, in: Proceedings of the IPSN, Cambridge, MA, 2007. [5] I.F. Akyildiz, D. Pompili, T. Melodia, Challenges for efficient communication in underwater acoustic sensor networks, ACM Sigbed Review 1 (2) (2004) 3–8. [6] J. Heidemann, Y. Li, A. Syed, J. Wills, W. Ye, Underwater sensor networking: research challenges and potential applications, in: Proceedings of the Technical Report ISI-TR- 2005-603, USC/Information Sciences Institute, 2005. [7] I.F. Akyildiz, T. Melodia, K.R. Chowdhury, A survey on wireless multimedia sensor networks, Computer Networks Elsevier 51 (2007) 921–960. [8] B. Sinopoli, C. Sharp, L. Schenato, S. Shaffert, Sh. S. Sastry, “Distributed control applications within sensor networks”, Proc. Of the IEEE, August 2003. [9] http://www.coe.berkeley.edu/labnotes/0701brainybuildings.html [10] M. Kintner-Meyer, M. R. Brambley, “Pros & Cons of Wireless”, ASHRAE Journal, pp. 54-59, Nov 2002. [11] M. Kintner-Meyer, M.R. Brambley, “Wireless Sensors: How Cost-Effective Are They in Commercial Buildings?” PNNL-SA-36839. [12] A. Rytter. “Vibration based inspection of civil engineering structures”, PhD dissertation, Dept. of Building Technology and Structural Eng., Aalborg University, Denmark, 1993. [13] A. Mainwaring, J. Polastre, R. Szewczyk, D. Culler, and J. Anderson, “Wireless sensor networks for habitat monitoring”, In ACM Inter. Workshop on Wireless Sensor Networks and Applications (WSNA'02), Atlanta, GA, 2002. [14] E. Biagioni, K. Bridges, “The application of remote sensor technology to assist the recovery of rare and endangered species”, In Sp. iss. on Distributed Sensor Networks for the Int. Journ. of High Performance Computing Applications, Vol. 16, N. 3, 2002. [15] Red Wolf Recovery Program 1 st Quarter Report October - December 2010 Coordinator: David R. Rabon Jr., PhD Wildlife Biologists: Art Beyer, Chris Lucash, Ford Mauney, Michael L. Morse Biological Technician: Ryan Nordsven Outreach Coordinator: Vacant Administrative Assistant: Vacant Intern (Caretaker): Janet Hohn www.fws.gov/redwolf

79 [16] J. Burrell, T. Brooke, R. Beckwith, “Vineyard computing: sensor networks in agricultural production” Pervasive Computing, IEEE, Volume: 3, Issue: 1, pp. 38-45, Jan.- Mar 2004. [17] T. Brooke, J. Burrell, “From Ethnography to Design in a Vineyard”, ACM 2003. [18] T. Knot, “BP Frontiers Magazine”, Issue 9, pp. 6-10, April 2004. [19] M. B. Srivastava, R. R. Muntz, and M. Potkonjak, “Smartkindergarten: sensorbased wireless networks for smart developmental problem-solving environments”. In Mobile Computing and Networking, pp. 132-138, 2001. [20] L. Schwiebert, S. K. S. Gupta, and J. Weinmann, “Research challenges in wireless networks of biomedical sensors”. In Mobile Computing and Networking, pp. 151-165, 2001. [21] I. F. Akyildiz, W. Su, Y. Sankarasubramaniam, and E. Cayirci,“Wireless sensor networks: a survey”, Computer Networks 38, Elsevier, pp. 393–422, 2012. [22] I. Howitt, J.A. Gutierrez, IEEE802.15.4 low rate-wireless personal area network coexistence issues, Wireless Communications and Networking 3 (2003) 1481–1486. [23] ZigBee Standards Overview, [24] HART–The Logical Wireless Solution, [25] G. Montenegro, N. Kushalnagar, J. Hui, D. Culler, Transmission of IPv6 packets over IEEE 802.15.4 networks, RFC 4944 (2007). [26] IEEE Standard 802.15.3, Wireless medium access control (MAC) and physical layer (PHY) specifications for high rate wireless person area networks (WPANs), September 2003. [27] D. Raychaudhuri, I. Seskar, M. Ott, S. Ganu, K. Ramachandran, H. Kremo, R. Siracusa, H. Liu, M. Singh, Overview of the ORBIT radio grid testbed for evaluation of next-generation wireless network protocols, in: Proceedings of the IEEE Wireless Communications and Networking Conference, 2005. [28] G. Werner-Allen, P. Swieskowski, M. Welsh, MoteLab: a wireless sensor network testbed, in: ISPN, 2010 [29] D. Johnson, T. Stack, R. Fish, D.M. Flickinger, L. Stoller, R. Ricci, J. Lepreau, Mobile Emulab: a robotic wireless and sensor network testbed, in: IEEE INFOCOM, 2006. [30] J.H. Huang, S. Amjad, S. Mishra, CenWits: A sensor-based loosely coupled search and rescue system using witnesses, in: Proceedings of the Third International Conference on Embedded Networked Sensor Systems (Sensys), San Diego, CA, 2005.

80 [31] Open Source Hardware Statement of Principles and Definition V1.0. http://freedomdefined.org/Definition. (Cited on pages 4 and 13.) [32] Wozniak, Stephen "Homebrew and How the Apple Came to Be" in Steve Ditlea, ed., Digital Deli, 1984 [33] Smith, Gina "Unsung Innovators: Lynn Conway and Carver Mead" Computerworld 2007 [34] Chesbrough, Henry Open Business Models. Boston, MA Harvard Business Press (2006) [35] Thompson, Clive "Build It. Share It. Profit. Can Open Source Hardware Work?" Wired Oct. 2008 [36] Jones, R., Haufe, P., Sells, E., Iravani, P., Olliver, V., Palmer, C., and Bowyer, A.,: RepRap - The Replicating Rapid Prototyper, Robotica (2011) volume 29, pp. 177–191. Cambridge University Press. [37] Bayless, J., Chen, M., & Dai, B. (2010). Wire embedding 3D printer, University of British Columbia, Vancouver, BC. [Online] Available: http://reprap.org/mediawiki/images/2/25/SpoolHead_FinalReport.pdf (July 23, 2010). [38] https://www.osvehicle.com/ [39] FarmBot Final Design Report December 5, 2014. Rory Aronson Mechanical Engineering Department California Polytechnic State University San Luis Obispo [40] http://www.arducopter.co.uk/ [41] MALÝ, M.,. Arduino: vývojový kit pro hrátky s hardware. Root. [Online] Internet Info, s.r.o, 30. 9 2009. [Citated: 2012. 1 24.] http://www.root.cz/clanky/arduino-vyvojovy-kitpro- hratky-s-hardware/. [42] "Optiboot Bootloader for Arduino and Atmel AVR". Retrieved 2015-10-01. [43] "Using Atmel Studio for Arduino development". Megunolink.com. Retrieved 2013-01-18. [44] "Using AVR Studio for Arduino development". Engblaze.com. Retrieved 2013-01-18. [45] J. Wells, R. M. Barry, and A. Spence, “Using Video Tutorials as a Carrot-and-Stick Approach to Learning,” IEEE Transactions on Education, vol. 55, pp. 453–458, 2012. [46] K. E. Merrick, “An Empirical Evaluation of Puzzle-Based Learning as an Interest Approach for Teaching Introductory Computer Science,” IEEE Transactions on Education, vol. 53, pp. 677–680, 2010. [47] G. T. Richard, “Employing Physical Computing in Education: How Teachers and Students Utilized Physical Computing to Develop Embodied and Tangible Learning Objects,” The International Journal of Technology, Knowledge and Society, 2010.

81 [48] P. Jaimeson, "Arduino for Teaching Embedded Systems. Are Computer Scientists and Engineering Educators Missing the Boat?," in International Conference on Frontiers in Education: Computer Science and Computer Engineering, Las Vegas, NV, 2011. [49] D. Giusto, A. Iera, G. Morabito, L. Atzori (Eds.), The Internet of Things, Springer, 2010. ISBN: 978-1-4419-1673-0 [50] National Intelligence Council, Disruptive Civil Technologies – Six Technologies with Potential Impacts on US Interests Out to 2025 – Conference Report CR 2008-07, April 2008, [51] https://www.raspberrypi.org/forums/viewforum.php?f=66 [52] https://ubuntu-mate.org/about/ [53] https://developer.ubuntu.com/core [54] http://pidora.ca/ [55] http://www.linutop.com/software.en.html [56] http://rpi.fatdog.eu/ [57] https://archlinuxarm.org/ [58] https://www.gentoo.org/ [59] https://www.freebsd.org/ [60] https://www.kali.org/ [61] The discovery of Hall effect G S Leadstone Physics Department, Atlantic College South Wales. [62] Sadiku, M. N. O. (2007). Elements of Electromagnetics (fourth ed.). New York (USA)/Oxford (UK): Oxford University Press. p. 386. [63] Florian Ion, Petrescu. A New Doppler Effect. Books on Demand. p. 81. [64] Tritton, D.J., Physical Fluid Dynamics, Van Nostrand Reinhold 1977, Section 22.7, The Coandă Effect. [65] Clancy, L.J., Aerodynamics, Chapter 3.

82 APPENDIX A: Installation Manual A.1 Equipment and Software The equipment of this system is described in the paragraph 7 of the thesis. What we need is:

• An Arduino Board (with a USB cable for powering it up)

• A Raspberry Pi board (with a USB cable for powering it up)

• A WiFi and a Bluetooth USB dongle (in case we got a Raspberry Pi 3 these are not needed)

• An HC – 05 Bluetooth modele for the Arduino

• A 1/2" Hall Effect Flowmeter Control Water Flow Sensor for Arduino

• A USB power bank (with large capacity)

• A breadboard

• An IP 65 or higher case

• An Arduino starter kit with cables, transistors, LEDs

• An android mobile phone or tablet

• A Raspberry Pi starter kit (case, hit sinks, power supply, an so on)

• A micro SD card for the Raspberry Pi (at least 8 GB)

The software we will need is: • The Arduino IDE Arduino IDE Link

• The Raspbian Operating System Raspbian OS

• The VNC Viewer Android application VNC Viewr Link

• The Source code of the project Git Repository

83 A.2 Hardware Configuration We have to connect the water flow sensor and the bluetooth module to the Arduino. In the following diagrams (pictures 42, 43) we describe how to connect them.

Picture 42: Connecting the water flow sensor to the Arduino

Picture 43: Connecting the HC-05 module to the Arduino

84 A.3 Software Configuration A.3.1 Uploading the code to Arduino After downloading the project code from GitHub we have to upload the corresponding code to the Arduino board. 1. First we have to open the Arduino IDE 2. We need to setup the environment to Tools menu and select Board. Then select the type of Arduino you want to program, in our case it’s the Arduino Uno.

Picture 44: Setting Up Arduino IDE

3. Enter the code to the IDE 4. Plug your Arduino UNO board in to the USB cable and into your computer. Now go back to the Tools > Serial Port menu and select the port where the Arduino is connected. If you are not sure about which one it is, disconnect the board check the menu and the one that is missing is the port we are looking for.

85 Picture 45: Selecting the appropriate port

5. Once you have selected your serial or COM port you can then press the button with the arrow pointing to the right, to upload your code to the board.

Picture 46: Upload button

A.3.2 Installing the Raspbian OS to the Raspberry Pi For Windows users: 1. Insert the SD card into your SD card reader and check which drive letter was assigned. You can easily see the drive letter, such as G:, by looking in the left column of Windows Explorer. You can use the SD card slot if you have one, or a cheap SD adapter in a USB port. 2. Download the Win32DiskImager utility from the Sourceforge Project page as a zip file; you can run this from a USB drive. 3. Extract the executable from the zip file and run the Win32DiskImager utility; you may need to run this as administrator. Right-click on the file, and select Run as administrator. 4. Select the image file you extracted earlier.

86 5. Select the drive letter of the SD card in the device box. Be careful to select the correct drive; if you get the wrong one you can destroy the data on your computer's hard disk! If you are using an SD card slot in your computer and can't see the drive in the Win32DiskImager window, try using an external SD adapter. 6. Click Write and wait for the write to complete. 7. Exit the imager and eject the SD card.

Picture 47: Win32 Disk Imager

For Linux Users: 1. Run df -h to see what devices are currently mounted. 2. If your computer has a slot for SD cards, insert the card. If not, insert the card into an SD card reader, then connect the reader to your computer. 3. Run df -h again. The new device that has appeared is your SD card. The left column gives the device name of your SD card; it will be listed as something like /dev/mmcblk0p1 or /dev/sdd1. The last part (p1 or 1 respectively) is the partition number but you want to write to the whole SD card, not just one partition. You therefore need to remove that part from the name, getting, for example, /dev/mmcblk0 or /dev/sdd as the device name for the whole SD card. Note that the SD card can show up more than once in the output of df; it will do this if you have previously written a Raspberry Pi image to this SD card, because the Raspberry Pi SD images have more than one partition.

87 Picture 48: Currently mounded devices

4. Now that you've noted what the device name is, you need to unmount it so that files can't be read or written to the SD card while you are copying over the SD image. 5. Run umount /dev/sdd1, replacing sdd1 with whatever your SD card's device name is (including the partition number). 6. If your SD card shows up more than once in the output of df due to having multiple partitions on the SD card, you should unmount all of these partitions. 7. In the terminal, write the image to the card with the command below, making sure you replace the input file if= argument with the path to your .img file, and the /dev/sdd in the output file of= argument with the right device name. This is very important, as you will lose all data on the hard drive if you provide the wrong device name. Make sure the device name is the name of the whole SD card as described above, not just a partition of it; for example, sdd, not sdds1 or sddp1, and mmcblk0, not mmcblk0p1. 8. dd bs=4M if=2017-01-11-raspbian-jessie.img of=/dev/sdd

88 Picture 49: Writing the image to the card

9. Please note that block size set to 4M will work most of the time; if not, please try 1M, although this will take considerably longer. 10.Also note that if you are not logged in as root you will need to prefix this with sudo. 11.The dd command does not give any information of its progress and so may appear to have frozen; it could take more than five minutes to finish writing to the card. If your card reader has an LED it may blink during the write process. To see the progress of the copy operation you can run pkill -USR1 -n -x dd in another terminal, prefixed with sudo if you are not logged in as root. The progress will be displayed in the original window and not the window with the pkill command; it may not display immediately, due to buffering. 12.Instead of dd you can use dcfldd; it will give a progress report about how much has been written.

89 13.You can check what's written to the SD card by dd-ing from the card back to another image on your hard disk, truncating the new image to the same size as the original, and then running diff (or md5sum) on those two images. 14.The SD card might be bigger than the original image, and dd will make a copy of the whole card. We must therefore truncate the new image to the size of the original image. Make sure you replace the input file if= argument with the right device name. diff should report that the files are identical. 15.dd bs=4M if=/dev/sdd of=from-sd-card.img truncate --reference 2017-01-11-raspbian-jessie.img from-sd-card.img diff -s from-sd-card.img 2017-01-11-raspbian-jessie.img 16.Run sync; this will ensure the write cache is flushed and that it is safe to unmount your SD card. 17.Remove the SD card from the card reader.

90