IoT GET-U-GOING Maartje Jansee
In 35 fun projects, this book will show you how to build your own Internet of Things system. We’ll cover the hardware (primarily the Raspberry Pi and Arduino) and the software that makes control via Internet possible. We employ Wi-Fi and radio links so no requirement any longer to install cabling crisscross through your home.
IN 35 PROJECTS WITH THE RASPBERRY PI AND ARDUINO
IoT GET-U-GOING
● MAARTJE JANSEE
The Internet of Things (IoT) is a trend with a strong technological impulse. At home, we want to do everything on our tablets, from browsing Facebook to watching TV, from operating lights to keeping an eye on the temperature.
IoT GET-U-GOING
IN 35 PROJECTS WITH THE RASPBERRY PI AND ARDUINO
Assuming the projects in the book are finished, you have a complete Internet of Things system that allows you to control and view of everything in your home. For example, if there’s something in the mail box is or the car is securely in the garage. Also, you can switch on the lights and the alarm from your couch. The crisp explanations allow the projects to be customized with ease, for example, to turn on your coffee machine or TV remotely. The index gives easy access to creative projects that can serve as an example, enabling you to do all the connecting to the IoT independently. All project software can be downloaded free of charge from the Elektor website. In this unique book, Raspberry Pi, Arduino and HTML webpages with stylesheets and JavaScript come together in clearly-described, easy-to-build projects. This special book is an essential part of your collection!
LEARN DESIGN
www.elektor.com
Maartje Jansee LEARN
DESIGN
SHARE
SHARE
LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SH ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● GN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SH ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ●
Contents Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1 What You’ll Need . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.1 Raspberry Pi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.2 SD Card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.3 RasWIK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.4 Interfacing Screw Shield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.5 Free Software Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.6 Network Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 1.7 Piccolino (Optional) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2 Installing the Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.1 Raspberry Pi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1.1 Keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1.2 Arduino IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.1.3 IP Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2 Windows PC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.2.1 Win32 Disk Imager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.2.2 PuTTY (SSH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2.3 Xming (X Window) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.2.4 WinSCP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.2.5 GIMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.2.6 Arduino IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3 A Brief Introduction to… . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 3.1 Programming the Arduino in C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 3.2 Radio Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 3.3 Web Design Using Cascading Style Sheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
15.116-IoT-UK-04.indd 5
09-10-15 10:41
3.4 A Raspberry Pi Webserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
3.4.1 Static Pages (HTML and CSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
3.4.2 CGI Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.4.3 Internet Versus Intranet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
4. Radio Communication via Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 4.1 LED On / Off . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 4.2 Magnetic Reed Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 4.3 Voltmeter 100 4.4 Relative Humidity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 4.5 A 10 V, 200 mA Lamp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 4.6 Current Sensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 4.7 Adjustable-Speed Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
5 Everything on the Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 5.1 You’ve Got Mail! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 5.2 Give the Plants a Voice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 5.3 Time for Fertilizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 5.4 Controlling a 240 V Lamp Using a Relay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 5.5 Monitoring an Outdoor Lamp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 5.6 Smoke Alarm Detector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 5.7 Door or Window Left Open? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 5.8 Taking the Temperature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 5.9 Is the Light on in the Kids’ Room? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 5.10 Is the Car in the Garage? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 5.11 Intruder Alert! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 5.12 Is the Radio Link Working? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 5.13 Your Own Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
5.13.1 Names and pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
5.13.2 Using try ... except during testing . . . . . . . . . . . . . . . . . . . . . . . . . . 273
5.13.3 Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
5.13.4 An example: Has someone been in the fridge? . . . . . . . . . . . . . . . . . 274
15.116-IoT-UK-04.indd 6
09-10-15 10:41
6 Miscellaneous Internet Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 6.1 Internet-Controlled Doorbell with Music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 6.2 Programming the Arduino Wirelessly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
6.2.1 From the SRFStick . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
6.2.2 From the Raspberry Pi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
6.3 Radio Range Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 6.4 Wireless Code Lock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 6.5 Radio LCD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 6.6 Internet LCD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 6.7 Internet Light Chaser or Christmas Light (15 to 135 LEDs) . . . . . . . . . . . . . . . . 310 6.8 Monitoring a Terrarium via Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 6.9 Send Email from the Raspberry Pi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
6.9.1 Email from the command line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
6.9.2 Email from Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
6.10 Sounding an Alarm from the Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 6.11 Displaying Bargraphed Results Using HTML and CSS . . . . . . . . . . . . . . . . . . . . 335 6.12 Build a Radio Shield for the Piccolino using a Slice of Pi . . . . . . . . . . . . . . . . . . 339 6.13 Person Detector with Internet Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 6.14 Intruder Deterrent – Time Switch with Light Meter . . . . . . . . . . . . . . . . . . . . . 353 6.15 A 240 V Relay on the Raspberry Pi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
6.15.1 AC relays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
6.15.2 Bistable relays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 A.1 Regulated Power Supply (1.2 V to 13 V) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 A.2 Raspberry Pi Pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 A.3 “No Such File or Directory” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 A.4 WinOscillo (Free Windows Oscilloscope) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376 A.5 Python and pySerial on a PC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
15.116-IoT-UK-04.indd 7
09-10-15 10:41
IoT GET-U-GOING ● In 35 Projects with the Raspberry Pi and Arduino
3 A Brief Introduction to … In this book, we make use of the Raspberry Pi, with its Linux operating system, and program it in Python. We assume that you know how the Raspberry Pi works, how to get around in Linux, and how to read and modify Python programs. We make this assumption not because everyone has such knowledge, but because it was covered in the popular book, Raspberry Pi - Explore the RPI in 45 Electronic Projects, and that’s a book we expect many readers of the book you’re holding will already have purchased. To repeat everything in there would be redundant, and it would take up 40 pages and make this book more costly. 3.1 Programming the Arduino in C++
The Arduino’s standard programming language is based on C++, which in turn is based on C. In this book, we’ll speak only of the parts of C / C++ that have been implemented on the Arduino. The purpose of this chapter is not to teach C or C++, but to ensure that you can read, understand and adapt the projects in this book for your own requirements. The programs in this chapter are not in the downloadable companion file, because it is intended that you type in the code in and try it out, and, in so doing, learn a bit of the language. For this, your setup needs to be similar to that illustrated in Fig. 3-1. You may make use of a separate, large breadboard, the small breadboard from the RasWIK, or a development shield such as is shown in the image. You may use the XinoRF as an Arduino, or use a regular Arduino with an SRF shield—this won’t make any functional difference. Pictured in Fig. 3-1 is an Arduino Uno with a development shield attached. Remove power from the circuit (disconnect the USB cable) before you build it, to avoid accidental short circuits.
10k LIN S
470 10k LED Pin 2
GND
Pin 3
+5V
Pin A1
XinoRF
Figure 3-1: Example setup on Arduino Uno with breadboarded development shield.
● 34
15.116-IoT-UK-04.indd 34
09-10-15 10:42
3 ● A Brief Introduction to …
All Arduino sketches have a fixed basic structure consisting of two required functions. The setup() function is the first, and it contains all of the instructions that the sketch needs to carry out just once, at startup. The second required function is loop(). Everything within this function will keep running until the Arduino is turned off, or is otherwise interrupted, e.g. when another sketch is uploaded to it. There is a third, optional section, which comes right at the beginning. This is the definitions secion, and it main purpose is to define constants that the sketch will use later.
// definitions here void setup() { } void loop() { }
Listing 3-1: Bare minimum.
You can see that the two functions have the same structure. They are declared beginning with the word void. This keyword indicates that these functions return no values. You can define functions that return values, but we’ll address those later. After the function name, there are two parentheses – (). These exist for functions that can accept values that are sent to them. We’ll also encounter these later. Values that are passed to functions are placed between parentheses, but, since these two functions don’t accept values, there is nothing between their parentheses. After the parentheses is a pair of braces – {}. All of the instructions belonging to the function are placed therein. It’s normal to indent the instructions so that it can be seen what code belongs to which function. In this case, there is nothing between the braces, so this sketch does… well, nothing. Despite this sketch doing nothing, it does it well. It has no errors in it at all. Type the sketch into the Arduino IDE. It’s very important that you save your sketch before continuing. The IDE does not automatically save your sketch, so, if something goes wrong and the IDE crashes, your work is lost. Choose a filename such as listing301 and save it somewhere. It’s best to create a separate folder for your projects. The Arduino IDE automatically creates a subfolder for each sketch that you save, so you can save all data related to the sketch in the same place (for example, photographs and diagrams). In this way, you have everything together.
● 35
15.116-IoT-UK-04.indd 35
09-10-15 10:42
IoT GET-U-GOING ● In 35 Projects with the Raspberry Pi and Arduino
Figure 3-2: Basic structure of an Arduino sketch.
Now select Sketch -> Verify/Compile (or press Ctrl-R). The sketch will be checked for errors and then compiled. This means that the sketch will be converted from the humanreadable C-like program to machine code that the Arduino can understand. In the black pane of the IDE, below the text “Done compiling”, you will see the result of the compilation. In our case, there are no errors or warnings. This pane also shows you how large the sketch is (466 bytes) and how much memory is available, in total, on the Arduino (32,256 bytes). The former may vary depending on which version of the IDE is used to compile your sketch, while the latter depends on which physical Arduino variant you’re using. Assuming that there are no errors in the sketch, we may now upload it to the Arduino. Click on the circled arrow on the top-left, or press Ctrl-U. The sketch is re-checked for errors and compiled again, then finally uploaded to the Arduino. Should the IDE not be able to find the Arduino, you’ll be asked to connect one or select the relevant COM port. 3.1.1 Pins – Digital
There are four pin headers on the Arduino. These are tied to the inputs and outputs of the microcontroller on board. In order to use these pins, we’ll first set whether the pins are to be used as outputs or as inputs. Setting a pin as an OUTPUT means that, while a sketch is running, the Arduino can control whether the pin puts out 5 V or 0 V (HIGH or LOW / ‘1’ OR ‘0’). Conversely, setting a pin as an INPUT means that the user can apply a ‘1’ or a ‘0’ to
● 36
15.116-IoT-UK-04.indd 36
09-10-15 10:42
3 ● A Brief Introduction to …
the pin externally, and the Arduino will be able to read this state. We’ve chosen to connect an LED to Pin 2, so we’ll need to set pin 2 as an output. The function to achieve this is: pinMode(number, INPUT / OUTPUT)
In the sketch, we’ll do this, then turn the LED on (on is HIGH, off is LOW). The function call for this is: digitalWrite(number, HIGH / LOW)
Here’s the complete sketch:
// definitions void setup() { pinMode(2, OUTPUT); digitalWrite(2, HIGH); } void loop() { }
Listing 3-2: Turning the LED on.
As you see, OUTPUT and HIGH must be in capital letters. When you run this sketch, the LED turns on and stays on. Try it out – you’ll learn from typing it in and running it for yourself. You may have noticed that the statements are followed by a semicolon. For the C++ compiler, this has a similar meaning to what a full stop means to us: the end of a line, or, in the case of the compiler, the end of a statement. No semicolon is required after a closing brace (}), as the closing brace is always the end of the block of instructions. Nonetheless, if you had one there, you wouldn’t get an error message about it. Let’s make the LED blink. This means we have to turn the LED on, wait a bit, and then turn it off, wait a bit, and repeat the process. Since we want to repeat this process indefinitely, the instructions must be placed within the loop() function:
● 37
15.116-IoT-UK-04.indd 37
09-10-15 10:42
IoT GET-U-GOING ● In 35 Projects with the Raspberry Pi and Arduino
4. Radio Communication via Internet In this chapter, we’ll create a series of projects that can be controlled from a web page, which may, in turn, be accessed using a PC, tablet, or smartphone. We’ll start with a simple project to turn an LED on and off. If you wish to put together any of the other projects in this chapter, it’s still important that you’ve carefully read through this first project. Everything is laid out in detail here. In later projects, we’ll build upon this knowledge, and everything will be less painstakingly described. The structure of the projects in this chapter is as follows: 1. The user visits a webpage from a tablet. This webpage is running on the Raspberry Pi. On the page, there exists a variety of buttons that can be tapped on. 2. As soon as a button is tapped on, the webpage starts a program running on the Raspberry Pi. The program seeks a radio connection with an Arduino, and issues a command to it. The program then waits for a response. 3. On the Arduino, a program is running continuously that listens for commands from the Raspberry Pi. As soon as an instruction comes in, it is carried out. A confirmation is then sent back to the Raspberry Pi via the radio link. This confirmation may take the form of “I have carried out the instruction”, but may also be the result of a measurement. 4. On the Raspberry Pi, the program awaits the confirmation. As soon as this comes in, it is sent to the web page that the user is viewing. 5. The user sees the response on the web page.
Figure 4-1: Operating the system using a tablet.
● 108
15.116-IoT-UK-04.indd 108
09-10-15 10:42
4 ● Radio Communication via Internet
Note: As mentioned in the last chapter, when you’ve created or modified a program and saved it as a file using your PC (e.g. hello.py), then transferred it to the Raspberry Pi using WinSCP, you may get an error message on the Raspberry Pi, rather than a web page served to your PC or other device. 192.168.178.10 - - [15/Apr/2015 09:04:27] “GET /cgi-bin/hello.py HTTP/1.1” 200 : No such file or directory
It seems that this error is about the hello.py file not existing, but, since you’ve confirmed that you’ve created this file and placed it in the correct place, the error must have some other cause. The first line in that Python file is important: #!/usr/bin/env python
This tells the CGI handler where to find Python. The problem is that Windows applications and Linux applications deal with text files differently. When you type a line of text in a Windows editor and then hit the Enter key, Windows adds a couple of (invisible) characters to the end of the line: Line Feed (LF, or “\n”) and Carriage Return (CR, or “r”). The first is the character that prescribes moving to a new line, while the second prescribes moving the cursor back to the beginning of the line. This is a convention as old as DOS, and Windows adheres to this convention. Linux, on the other hand, will just place a single invisible character at the end of a line of text: the Line Feed (LF, “\n”). This is a Unix convention, and Linux is based on Unix. The carriage return that Windows adds is usually ignored by Linux, but not when it comes to filenames. When you create a file, such as a Python script, in Windows and then transfer it to the Linux machine (using, say, WinSCP or FTP) to use it there, Linux won’t see this as the first line’s content: #!/usr/bin/env python
Rather, it will see this: #!/usr/bin/env python\r
The file python\r does not exist. The solution is to edit the program file once it has been transferred to the Raspberry Pi. Open it with WinSCP, hit the spacebar and then delete that extra space, then close the file again, saving it when prompted to do so. WinSCP saves the program with the line endings conforming to the Unix standard. While you’re at it, you can also use WinSCP to ensure that your program files have the correct permissions assigned. Right-click on the file (while it’s on the Raspberry Pi), and select ‘Properties’, and ensure that the checkbox for the ‘X’ next to ‘Owner’ is checked.
● 109
15.116-IoT-UK-04.indd 109
09-10-15 10:42
IoT GET-U-GOING ● In 35 Projects with the Raspberry Pi and Arduino
4.1 LED On / Off
In this project, we’ll control an ordinary LED connected to the Arduino via a web page. By clicking (or tapping) on buttons on the web page, the LED can be turned on and off. The artwork
In the download archive, you’ll find a template image (iss_base.png) of an Interfacing Screw Shield (ISS) with a few buttons next to it. Depending on the project, we’ll use a version of the image specific to that project. This means having the appropriate buttons in the correct places (and deleting the rest), and making each button a hotspot. If you don’t feel like putting these together yourself, you will, of course, find all the necessary images and pages in the download.
Figure 4-2: The image (issbase.png) in GIMP, buttons visible on the upper-left.
First, we’ll load this file into GIMP.53 In this project, we want to turn the Arduino’s LED on and off. The on-board LED is connected to pin 13. You can tell by the color of the pin in the image that this pin has a special function. We want to be able to turn the LED on and off, so we’ll need the ‘on’ and ‘off’ buttons. We copy and paste these buttons to the appropriate place, and erase the buttons that we don’t need. Save the image as issprj01.png, but don’t close GIMP just yet.
If you don’t have GIMP installed, consult section 2.2.5. You might also make use of another graphics package with the same functionality.
53
● 110
15.116-IoT-UK-04.indd 110
09-10-15 10:42
4 ● Radio Communication via Internet
Figure 4-3: The selected button is placed close to pin 13.
The following step is to determine these so-called hotspots. These are areas of an image that may be used as links. When set up in your web page, you can click on that area and link it to an action, causing something to happen. The hotspots in an image are defined as a map, using the map element: <map name=”issprjmap”> <area shape=”rect” coords=”551,200,610,219” href=”13on.py” target=”myframe”> <area shape=”rect” coords=”615,199,671,223” href=”13off.py” target=”myframe”> </map>
The attributes of the map and area tags have the following meanings: Tag
Attribute
Description
map
name
Map name. You can choose this yourself.
area
shape
Shape of the hotspot. rect stands for rectangle.
area
coords
The hotspot’s coordinates.
area
href
The link with which the hotspot is associated.
area
target
The window in which the link must be opened. Table 4-1: Attributes of the map and area tags.
● 111
15.116-IoT-UK-04.indd 111
09-10-15 10:42
5 ● Everything on the Internet
5 Everything on the Internet In this chapter, we’ll describe a modular system that will enable you to monitor and control all sorts of things in your house via a tablet. You can choose for yourself which modules you’d like to create, and whether you’d like more than one of certain modules. You may also want to protect some rooms against intruders. You can adapt the system to your needs completely, and create far more than the 12 projects in this chapter. Or fewer. The projects in this chapter are more complicated than those in Chapter 4. In any event, it’s important for you to read through the first project in the chapter thoroughly, understand how the system works, and how modules may be added to the system (or removed). The download for each section contains all of the modules that have been created prior to that point. If you have more than one wireless Arduino, Project 5.7 may be of interest to you, as we make use of two Arduinos there.
Figure 5-1: Everything on the internet, on a tablet.
● 167
15.116-IoT-UK-04.indd 167
09-10-15 10:43
IoT GET-U-GOING ● In 35 Projects with the Raspberry Pi and Arduino
The operation flow of the projects in this chapter is as follows: 1. The user uses a tablet web browser to call up a program on the Raspberry Pi. The program creates a webpage on the fly, or dynamically, and displays it to the user. On the webpage, the users sees a diverse range of modules that display information over anything from plant status to open rooms. This information comes from files on the Raspberry Pi. Whenever the user visits the page (or refreshes it), the files are read anew and the information on the page is updated. 2. On the Raspberry Pi, a program runs continuously in the background, seeking contact with the Arduino, and checking the status of the various modules.71 The status might be, for example, which rooms are open, or the result of a current measurement. 3. On the Arduino, a sketch runs continuously, listening for radio commands from the Raspberry Pi. The sketch carries out with the requested measurements and operations, and responds with the result. 4. The program on the Raspberry Pi saves the received information to files accessible by the Raspberry Pi’s webserver. At this point, we’re back at Step 1, where the contents of these files are displayed. 5. Sometimes, the user may tap on a module on the webpage to view the contents of a file, usually to acknowledge that he has seen what the module has reported. You can see that the workflow is quite different to that in Chapter 4. This is because the modules in Chapter 5 have to remain running at all times, even when no one is viewing the webpage. The reason for this is that the Raspberry Pi is running a program that continuously seeks out an Arduino, as well as ensures that all of the associated files on the Pi are current.
5.1 You’ve Got Mail!
In this project, you can check continuously whether you’ve received any post (or at least, if the postbox has been opened). We mount a micro switch in the post box, assign the Arduino to monitor it, and use the Raspberry Pi as a central internet server. The postman opens the postbox briefly, and as soon as that happens, the notification is updated to a file, which is presented as an attractive webpage using the internet. Moreover, the user may erase the content of the file, acknowledging that the notification has been seen. It is strongly advised that you go through this project thoroughly, even if you’re not planning to put it together, because all of the steps in the project are carefully laid out. In later projects, it is assumed that you’ve read this, and the descriptions will be more concise.
If you have more than one Arduino in use, they will both be interrogated by the program.
71
● 168
15.116-IoT-UK-04.indd 168
09-10-15 10:43
5 ● Everything on the Internet Postbox
Tablet
10 k
pin 9 GND
ISS shield
Arduino
WiFi link
+5 volt
RS232 link
radio link
SRF radio shield
SRF "slice of pi"
RS232 link
Raspberry Pi
Figure 5-2: Schematic overview. The Wi-Fi link is via a router.
The setup may look complicated, but it’s not really. A switch in the postbox is connected to an Arduino via a special ISS (Interfacing Screw Shield). The Arduino also has an SRF radio shield (you may have a XinoRF, which has the radio module onboard). Via a radio link, the Arduino is in contact with the Raspberry Pi, which is acting as a server. From the PC or tablet, the user can call the webpage from the Raspberry Pi. The structure of this project is as follows: 1. The Arduino is connected to the switch in the mailbox. 2. A sketch on the Arduino polls the radio module for any commands from the Raspberry Pi. 3. A script on the Raspberry Pi queries the state of the switch, every half-second, and saves the result in a file. 4. When you make contact with the Pi using your web browser, the Pi will report this state, on a user-friendly webpage. Steps 1 to 3 run continuously, and automatically. Step 4 occurs only when the user visits the webpage, or refreshes it. The system is put together modularly. You can monitor and control many more things than a postbox via the internet. The projects to follow will show us how. The artwork
You can find many suitable icons on the internet, but it’s always nicer to use your own. As an example, we’ll make our own icon for the postbox module. You’ll need the free GIMP graphics package for this. The installation thereof is covered in Section 2.2.5. You may also use another graphics package, assuming it has the same functionality. We begin with a photograph of a pile of letters on the ground in the entrance hall. We could always use this photograph as-is, but it’s neater if we have a transparent background for it, so that only the letters themselves are visible. Let’s create a transparent background for our image.
● 169
15.116-IoT-UK-04.indd 169
09-10-15 10:43
IoT GET-U-GOING ● In 35 Projects with the Raspberry Pi and Arduino
1. Start GIMP and load up the photograph. You may have one of your own mail, but, if not, feel free to use the one in the download. Select Layer -> Transparency -> Add Alpha Channel. The image now has a second layer underneath the photo of the mail.
Figure 5-3: Adding an alpha channel to create a transparent layer.
2. When we cut a snippet out of our original image, the second layer becomes visible. Actually, an alpha channel is transparent, so, effectively, we’re looking right through the image background. Enlarge the image (arrow numbered ‘1’ in Fig. 5-4) to, say, 100%, and select the lasso tool (arrow 2).
Figure 5-4: Adjust the magnification to work more comfortably.
● 170
15.116-IoT-UK-04.indd 170
09-10-15 10:43
IoT GET-U-GOING ● In 35 Projects with the Raspberry Pi and Arduino
6 Miscellaneous Internet Projects In this chapter, we’ll have a look at a variety of smaller projects. These are freestanding projects that you can use as part of your own applications. Many of the projects are more complex than those in chapters 4 and 5. The structure varies between projects, so read the usage instructions below each project carefully.
6.1 Internet-Controlled Doorbell with Music
We’ll make a doorbell play a tune, and control it from a tablet. Note: for this project, you’ll need the SD card from the Raspberry Pi book, as described in Section 1.2. A handy place to keep your Raspberry Pi is next to the router. This is often placed in a cupboard, where you may also be fortunate enough to have a wire running to the doorbell. We’ll put this project together on the Raspberry Pi alone, not the Arduino. We’ll use the techniques from the Raspberry Pi book to control the Raspberry Pi GPIO pins. Since the Slice of Radio module has no pins on its top side, nothing can be placed on top of it, unless you solder wires directly to the radio module. We’ll create a less permanent solution, using a circuit board that’s connected to the Raspberry Pi using a short, flat, ribbon cable. On the board, we’ll add an extra pin header where the Slice of Radio can still be plugged in.
Figure 6-1: The prototyping printed circuit board.96
It looks as if the connectors could be closer, but the Slice of Radio needs to fit in there. Check that carefully when you want to make other setups. In Figure 6-4, you’ll see the schematic.
96
● 276
15.116-IoT-UK-04.indd 276
09-10-15 10:43
6 ● Miscellaneous Internet Projects
The radio is not used in this project, but space is made for it so that you can combine this with other projects in the book. If you don’t want to use the radio module at all, you don’t need to make the board at all, and can simply mount the electronics directly on the Raspberry Pi. A few of the pins on the Raspberry Pi board are used for the Slice of Radio module, as outlined in Table 6-1. These connections must thus be passed through from the one connector (on the Raspberry Pi side) to the other (where the radio module is). For the doorbell, we’ll use a single free pin, in this case, pin 16 (GPIO 23). Raspberry Pi pin
Notes
01 (3.3 V)
19 – 33 mA
06 (GND)
ground
08 (GPIO 14)
serial communication
10 (GPIO 15)
serial communication
15 (GPIO 22)
DTR Table 6-1: Connections for the Slice of Radio.
We shouldn’t allow our input pins to ‘float’. That is, it should always be connected to something—either a signal source or ground. Just as with the Arduino, we should connect the doorbell switch S as indicated in the following image, as that’s how we’ve done it in this book all along.
+3.3V
S
10k
RPI pin
GND
GND
Figure 6-2: Our usual method of wiring up a switch so that it doesn’t ‘float’.
When the switch is open, the Raspberry Pi is connected via the 10 kΩ resistor to ground, and the pin will read as LOW. When the switch is closed, the pin is connected to the +3.3 V supply, and will read HIGH. Obviously, current will flow through the 10 kΩ resistor, but it is negligibly small: I = V/R = 3.3 / 10,000 = 0.33 mA
● 277
15.116-IoT-UK-04.indd 277
09-10-15 10:43
IoT GET-U-GOING ● In 35 Projects with the Raspberry Pi and Arduino
But what happens if the pin is defined as an output instead of an input, and is LOW? On an Arduino or Piccolino, that won’t happen so easily, as, whenever a sketch starts up, the pins are all set as inputs bu default, until otherwise set by the programmer. However, on a Raspberry Pi, this is quite possible, as it’s a multitasking system, and, with several programs running simultaneously, any of them may do something to the pin. Your program might set the pin as an input, and then along comes another program that makes it an output and sets it LOW. A small oversight, but with serious consequences. As long as the switch is open, we’re fine, as the pin in question is tied to ground via the resistor. However, as soon as the switch is depressed, the 3.3 V power is connected to ground, causing a short circuit. This will probably bring a quick end to the Raspberry Pi. To avoid this, we place an extra 1 kΩ resistor in circuit as follows:
1k
+3.3V
S
10k
RPI pin
GND
GND
Figure 6-3: Safety resistor for the switch.
Under normal use, this resistor will have little influence. When the switch is open, it’s not in circuit at all, and when the switch is closed, a voltage divider is created that outputs 3.0 V: VRPI pin = 10 kΩ / (1 kΩ + 10 kΩ) × 3.3 V = 3.0 V That’s high enough for the Raspberry Pi to still see a ‘1’ on the input, so the resistor doesn’t affect the closed-switch reading, either—the switch continues to work as intended. The advantage is clear to see when the pin is accidentally defined as an output. If the pin is set HIGH, the resistance to ground is 10 kΩ. If the pin is pulled LOW by the program, there is no longer a short circuit, but a path to 3.3 V via the 1 kΩ resistor. The 1 kΩ resistor prevents damage to the circuit by limiting the current to 3.3 mA: Iclosed circuit = V / R = 3.3 V / 1,000 Ω = 0.0033 A = 3.3 mA.
● 278
15.116-IoT-UK-04.indd 278
09-10-15 10:43
6 ● Miscellaneous Internet Projects
That’s low enough that it won’t damage the Raspberry Pi. Your program won’t work (as the pin is defined as an output), but the Raspberry Pi hardware will be safe. When we combine this with the signals that have to be passed through for the Slice of Radio module, we end up with the complete schematic in Fig. 6-4.
GND
10k
RPi 2 +3.3V 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
S 1k
radio 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Figure 6-4: The complete schematic. ‘S’ is the doorbell switch.97
The left pin header connector is connected to the Raspberry Pi using the ribbon cable, while the right connector is for the radio module. The soldered version should look similar to the setup in Fig. 6-1.
97
Resistor color codes: 1 kΩ = brown-black-red, 10 kΩ = brown-black-orange.
● 279
15.116-IoT-UK-04.indd 279
09-10-15 10:43
IoT GET-U-GOING ● In 35 Projects with the Raspberry Pi and Arduino
Index ^ .................................................... 46 - ..................................................... 42 -- .................................................... 53 -= ................................................... 53 ! ..................................................... 46 != ............................................ 42, 270 * ..................................................... 42 *= ................................................... 53 / ..................................................... 42 // .................................................. 162 /= ................................................... 53 & ..................................................... 46 && ................................................... 46 % .................................................... 42 + .................................................... 42 ++ .................................................. 53 += .................................................. 53 < .................................................... 42 = .................................................... 42 == .................................................. 42 > .................................................... 42 >= .................................................. 42 | ..................................................... 46 || .................................................... 46 ~ .................................................... 46 16f887_bert_piccolino.jal .................. 343 39MF22 .......................................... 360 240 volts ........................................ 364 404 ............................................... 101 71427 ............................................ 157 (char) .............................................. 62 /dev/ttyAMA0 ..................................... 70 /etc/network/interfaces ...................... 20 %s .................................................. 185 /usr/bin/env ..................... 106, 119, 375 a ..................................................... 90 aLink ............................................... 78 aluminium foil ................................. 349 analogRead() .................................... 44 analogWrite() .................................. 163 AND ................................................ 46 Arduino IDE ................................. 15, 32 ASCII ............................................... 51
ATmega328P ..................................... 44 A window manager... ......................... 26 background ...................................... 78 background color ............................... 79 background-color .............................. 94 backup ............................................. 22 bargraph ........................................ 336 BC547C .......................................... 364 bgcolor ....................................... 77, 78 body ............................................ 77, 95 border ............................................. 94 border-radius .................................... 94 button .............................................. 96 byte ................................................ 39 C++ ................................................ 34 cascading style sheet ......................... 78 CGI ............................................... 103 cgi-bin .................................... 103, 116 cgi-bin path .................................... 205 CGIHTTPServer ........................ 100, 123 charAt() ........................................... 60 checkbox ........................................... 98 chmod ......... 105, 122, 130, 135, 142, 153 class ................................................ 87 color ................................................ 94 coords ........................................... 111 CS22, CS21, CS20 ........................... 161 CSS .......................................... 76, 184 cursor line ...................................... 378 Darlington ...................................... 144 date .............................................. 202 datetime ........................................ 203 delay() ............................................ 38 Deplace .......................................... 378 DHCP ............................................... 21 digitalRead() ..................................... 41 digitalWrite() .................................. 37 display ............................................ 84 display: inline ................................... 94 duty cycle 156 Echelle ........................................... 378 Edimax ............................................ 13 else ................................................. 41 equals() ........................................... 60 execute ........................ permissions 105 favicon ........................................... 102
● 380
15.116-IoT-UK-04.indd 380
09-10-15 10:44
● Index
float ................................................ 94 font-family ....................................... 94 font-size ........................................... 94 for loop ........................................... 52 form name ....................................... 98 function ........................................... 96 functions .......................................... 56 GIMP ................................. 31, 110, 169 HCH 1000 ....................................... 139 head ............................................ 77, 95 header, 26-pin ................................ 276 HIGH ................................................. 37 hotspot .......................................... 112 href .......................................... 79, 111 HTML .......................................... 76, 95 humidity ........................................ 136 if .................................................... 41 iframe ............................................ 117 images ............................................. 86 img .................................................. 86 import ............................................. 49 index.html ...................................... 100 indexOf() .................................... 60, 63 inline .............................................. 84 INPUT ............................................... 37 input, inverting ............................... 222 input, non-inverting ......................... 222 int ................................................... 39 Interfacing Screw Shield (ISS) ..... 10, 128 IP Address ........................................ 16 isocalendar ..................................... 203 JavaScript ........................................ 95 keyboard .......................................... 14 LDR ............................................... 246 length() ........................................... 60 link ............................................. 78, 79 links ................................................ 90 LM317 ........................................... 372 loop() .............................................. 35 LOW .................................................. 37 lux ................................................ 246 LXDE ............................................... 26 magnetic reed switch ....................... 127 map ................................................ 111 margin ........................................ 88, 94 math ............................................. 242
max-width ................................... 88, 94 MCP1702/3302 ............................... 341 MCP6232 ........................................ 221 memory, EEPROM .............................. 45 memory, flash ................................... 45 memory, RAM ................................... 45 meta ................................................. 92 minicom ........................................... 67 moisture sensor .............................. 194 name ............................................. 111 No such file... .......................... 106, 375 NOT ................................................. 46 now.day ......................................... 358 NTC ............................................... 238 objects ............................................. 60 Ohm’s law ........................................ 40 Only one lxsession... .......................... 29 op amp ................................... 221, 222 OR .................................................. 46 oscilloscope, software ...................... 376 OUTPUT .............................................. 37 password .......................................... 23 person detector ............................... 346 Piccolino .................................... 13, 339 piezo ............................................. 221 pinMode() ......................................... 37 pins, analog ...................................... 43 pins, digital ....................................... 36 port 8080 ....................................... 101 port forwarding ............................... 107 power supply, regulated ................... 372 prescaler ........................................ 160 pulse ............................................. 156 pulseIn() ....................................... 257 pulse width ..................................... 163 PuTTY .............................................. 23 PuTTY X11 proxy... ............................ 28 PWM .............................................. 156 pySerial ........................................... 70 radio ................................................ 61 RAL 5W-K ....................................... 367 Raspi-config ............................... 14, 202 RasWIK ........................................ 9, 67 readline() ....................................... 205 reboot ......................................... 21, 22 refresh ............................................. 92
● 381
15.116-IoT-UK-04.indd 381
09-10-15 10:44
IoT GET-U-GOING ● In 35 Projects with the Raspberry Pi and Arduino
relay .............................................. 360 relay shield ..................................... 208 script ............................................... 95 SD card ............................................. 9 SEN0018 ........................................ 261 serial .......................................... 47, 49 Serial.available() ............................... 47 Serial.begin() .................................... 47 Serial Monitor ................................... 48 Serial.print() ..................................... 47 Serial.println() .................................. 47 Serial.read() ................................ 47, 62 serial, reset ...................................... 70 serial, reset delay .............................. 49 Serial_SW_invert ............................. 343 server, cgi ...................................... 103 server, CGI ..................................... 116 server, HTML ................................... 100 setCharAt() ...................................... 60 setup() ............................................ 35 shape ............................................ 111 shunt ............................................. 151 sleep() ............................................. 49 Slice of Radio .................................... 10 snubber ......................................... 366 solid state ...................................... 360 speed of sound ................................ 255 src .................................................. 86 SRF05 ............................................ 253 SRF shield ........................................ 10 SRF-Stick .................................... 10, 68 SSH ................................................. 23 static IP ........................................... 19 static lease ....................................... 18 strings ............................................. 59 style sheet ......................... 76, 184, 188 submit ............................................. 96 substring() ....................................... 60 sudo apt-get update .......................... 15 sudoset.sh ........................................ 28 suppressor diode ...................... 145, 158 table ........................................... 80, 81 tag .................................................. 96 target ............................................ 111 TC4427A ........................................ 368 TCCR2B .......................................... 161
td .................................................... 81 text ................................................. 78 text-align ......................................... 94 timeout ............................................ 73 timer ............................................. 255 timer1, 2, 3 .................................... 160 tr .................................................... 81 transistor ....................................... 363 trim() .............................................. 60 try … except ............................ 135, 273 ULN2003 ........................................ 144 ultrasonic ....................................... 253 Unable to access... ............................ 28 unsigned int ...................................... 39 usemap .......................................... 112 viewport .................................... 94, 117 V = I × R ......................................... 40 vlink ................................................ 78 void ................................................. 35 voltage divider ......................... 133, 340 voltmeter ....................................... 131 wall wart ........................................ 215 while ............................................... 54 while loop ........................................ 52 Wi-Fi ............................................... 13 Win32 Disk Imager ............................ 22 WinOscillo ...................................... 376 WinSCP ............................................ 29 Xinerama ......................................... 26 XinoRF ............................................. 10 Xming .............................................. 24 XOR ................................................. 46 X Window System .............................. 24 Zener diode .................................... 216
● 382
15.116-IoT-UK-04.indd 382
09-10-15 10:44
IoT GET-U-GOING Maartje Jansee
In 35 fun projects, this book will show you how to build your own Internet of Things system. We’ll cover the hardware (primarily the Raspberry Pi and Arduino) and the software that makes control via Internet possible. We employ Wi-Fi and radio links so no requirement any longer to install cabling crisscross through your home.
IN 35 PROJECTS WITH THE RASPBERRY PI AND ARDUINO
IoT GET-U-GOING
● MAARTJE JANSEE
The Internet of Things (IoT) is a trend with a strong technological impulse. At home, we want to do everything on our tablets, from browsing Facebook to watching TV, from operating lights to keeping an eye on the temperature.
IoT GET-U-GOING
IN 35 PROJECTS WITH THE RASPBERRY PI AND ARDUINO
Assuming the projects in the book are finished, you have a complete Internet of Things system that allows you to control and view of everything in your home. For example, if there’s something in the mail box is or the car is securely in the garage. Also, you can switch on the lights and the alarm from your couch. The crisp explanations allow the projects to be customized with ease, for example, to turn on your coffee machine or TV remotely. The index gives easy access to creative projects that can serve as an example, enabling you to do all the connecting to the IoT independently. All project software can be downloaded free of charge from the Elektor website. In this unique book, Raspberry Pi, Arduino and HTML webpages with stylesheets and JavaScript come together in clearly-described, easy-to-build projects. This special book is an essential part of your collection!
LEARN DESIGN
www.elektor.com
Maartje Jansee LEARN
DESIGN
SHARE
SHARE
LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SH ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● GN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SH ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ● LEARN ● DESIGN ● SHARE ●