15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 115007-3 Conrad Adventskalender Internet of Things 2017_en.indd 113.08.2017 17:02:5213.08.2017 17:02:52
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 215007-3 Conrad Adventskalender Internet of Things 2017_en.indd 213.08.2017 17:02:5613.08.2017 17:02:56
Internet of Things Advent Calendar 201
7
-
n
the code
5007-3
oad there
f
the archive.
d
s
.
-
-
d
.
x
If Cisco has its way, more than 50 billion linked devices will be used by 2020; even more optimistically,
Intel expects 200 billion devices1. Each of these devices – or “things” – has a unique address and communicates with the outside world through the internet or through some other interfaces, such as Blue
tooth: From the coffee machine to the fridge, from the car to the train, from the production machine to
the bracelet: everything can be programmed and can communicate with other things. This topic is more
than just a hype. It is becoming the state of the art, and we should all be dealing with it. Use the Advent
season and get into the Internet of Things (IoT). 24 experiments will introduce you to the subject and let
you program your own thing. Have fun!
Source codes and additional informatio
In the next 24 days, you will learn many new things about the subject of IoT (Internet of Things) and
implement exciting projects. So that you won’t have to type down the programs, some of which can
be rather large, we procured the entire source codes and any additional information for download. Go
ttp://www.buch.cd and enter
archive contains a separate directory for every day. For detailed information, read the fi le Liesmich.pd
in
Some of the programs from day 8 onwards are very large and not printed in full here. Only those parts of
the project that you must have to understand and implement it are described in the handbook. Projects
that are controlled with the dedicated Smartphone app are available for download in full. If you want to
make any changes to the program, always have a look at the fi nished program fi rst; then make a copy of
it and modify the copy. If anything goes wrong, you can get the initial fi les from
1
You will fi nd an archive for downl
ttp://www.buch.c
. The
Updates in the download area
The advent calendar was created long before Advent and is based on program versions from that
time. If any greater changes occur before Advent, you can fi nd an update of the affected projects in the
ownload area.
Background knowledge on the component
Every compartment contains one component. Here, we will provide the most important information on
the components
LEDs (light-emitting diodes) are lit when power runs through them in the fl ow direction. LEDs are illus
trated in circuits with an arrow-shaped triangle that indicates the current direction from the plus to the
minus pole or to the ground line. An LED lets through nearly any amount of power in the fl ow direction,
and has only a very small resistance. I order to limit the fl ow current and to prevent the LED from burn
ing through, one usually must install a 220Ohm dropping resistor between the connection pin used an
the anode of the LED or between the cathode and the ground pin. This dropping resistor also protects
the output of the included IoT-board from too-high currents. The LEDs in the Advent calendar have the
dropping resistor already installed, and therefore can be connected directly to the pins of the IoT board
Circuit diagram of an LED with a dropping resistor
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 315007-3 Conrad Adventskalender Internet of Things 2017_en.indd 313.08.2017 17:02:5713.08.2017 17:02:57
n which direction is the LED connected?
-
s
-
.
.
,
t.
r
g
)
)
g
er10
0%
1
%
1
0
%
00
%
0llow
0
000
n
000
%
000.000
%
t
000.000
e10
000.000.000
The two connection wires of an LED are differently long. The longer one is the plus pole, the anode, the
horter one the cathode. It‘s easy to remember: The plus has one dash more than the minus and there
fore also makes the wire a bit longer. Most LEDs are also fl attened on the minus side, like a minus
ign. It‘s easy to remember: Cathode = short = edge.
Resistors and their colour code
Colou
ilv
Gold10
Black
Brown
Red2
Orange3310
ree
Blue
iole
Grey
Whit
Resistance in Ohm
. Rin
(tens
. Ring
ones)
. Ring
multiplier
= 0,01±1
= 0,
10 =
10 = 1
10 = 1
= 1.00
4
1
= 10.
10 = 100.
10 = 1.
10
= 10.000.000±0,1%
10 = 100.
= 1.
reading direction clear. The tolerance value is hardly relevant in digital electronics. The table shows the
meaning of the coloured rings on resistors.
. Rin
tolerance)
±5
±1
±2
±0,5
±0,25
±0,05%
esistors are used to limit current at sensitive elec
ronic components and as dropping resistors for
EDs. The unit of measurement for resistors is Ohm.
,000Ohm make one Kiloohm, in short: kOhm.
,000kOhm make one Megaohm, in short: MOhm.
he unit Ohm is often represented by the Omega
aracter Ω
e coloured rings on the resistors indicate the
esistance. They are much easier to recognise than
iny fi gures that can still be found only on very old
esistors. With a little practice, you can “translate”
he values from the colour codes quite quickly
ost resistors have four such colour rings. The fi rst
wo colour rings represent the digits, the third one is
a multiplier and the fourth the tolerance. This tolerance ring is usually golden or silver – colours that
o not appear in the fi rst two rings. This makes the
It doesn’t matter in which direction the resistor is installed. The installation direction of LEDs, in contrast
is relevan
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 415007-3 Conrad Adventskalender Internet of Things 2017_en.indd 413.08.2017 17:02:5713.08.2017 17:02:57
1st Da
y
y
2
.
-
.
d
E
d
:
h.
.
E
.
E
.
.
r
In the Advent calendar toda
1x IoT Bluething board
Today, you will get to know the board with which you will implement the projects of the next 24 days. To
prepare for the next days, you will install the driver for the USB connection, install the
rduino IDE and fi nally create your fi rst program for the board
Chipset on the IoT-board
The IoT-board comes with two chipsets. For program execution, the board has an ATmega328P. This
micro controller communicates with an HC-05 via a serial interface. The HC-05 is responsible for the
wireless connection (Bluetooth). The module supports Bluetooth V2.0+EDR. You will need a Smart
hone with Android for App communication.
Confi guring the IoT-board
In order to take the IoT-board into operation, you need a computer with Linux, MacOSX or Windows
nd a Micro-USB-cable. This connection cable serves power supply and connection of the IoT-board to
the PC in order to program it. You do not need to buy such a cable. You probably have one already –
lmost all modern Smartphones use this plug type
Select the proper USB-port at the PC
Connect the cable to a USB 2.0 connection of your PC if you can. USB-3.0 connections may have connection problems. You can often recognise a USB-3.0-connection by the blue socket.
1. Day
Before connecting the board to a PC, complete the following steps:
Step 1: Installation of the driver for the IoT-boar
Step 2: Installation of the Arduino ID
Step 1: Installation of the driver for the IoT-boar
The USB port on the IoT-board is connected to a CH340G-chipset. In order to use
this chipset for a USB connection, you need to install the matching driver for your
perating system. Perform the following four steps for this
1 Download the example programs and the drive drivers from
cd. Enter the code
5007-3 there and follow the instructions on the screen.
ttp://www.buc
Installation of the device drive
2 Unpack the ZIP archive into any folder under your user folder
Connect the IoT-board via the USB-cable and start the driver installation with the fi le
H341SER.EX
.
You may need to confi rm a query from the Windows user account control for installation
In the installation dialogue, clickInstall and wait until driver installation is confi rmed.
Step 2: Installation of the Arduino ID
The IoT-board is compatible with the Arduino Nano and can be programmed with the Arduino IDE3. In
the Arduino IDE, you can write the programs in the programming language C and transfer them directly
to the IoT-board. After transfer, the program will run without any connection to the PC, which means that
you may disconnect the board.
Switching off the IoT-board
The IoT-board has no off-switch. You just need to disconnect the USB-cable from the computer PC or
the mains unit, and the IoT-board will switch off. The last saved program will start automatically when
the board is switched on again. The same happens if you push the reset button
2Called the IoT-board below.
3 The Arduino IDE in version 1.8.2 has been used for the projects. If a newer version is available by the time the Advent calendar is
sold, you can use it instead. If there are any distinctive changes, you will fi nd a corresponding note in the download area
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 515007-3 Conrad Adventskalender Internet of Things 2017_en.indd 513.08.2017 17:02:5713.08.2017 17:02:57
Download the Windows Installer for the current version of the Arduino IDE from
e
.
-
d
choose
ools
t
in the Arduino IDE menu. Only a single serial port is usually displayed here.
use the menu ite
ect the
-
ust be chosen as CPU
n
e
oad the
board
use the icons
stead: Use the arrow to
.
the IoT-
d.
.
stallation of the
E
d
www.arduino.cc/en/Main/Softwareor use the fi le
rduino-windows.ex
from the
downloads for the Advent calendar. Under Windows10, you can also download
the Arduino IDE from the Windows Store and install it from there
Make sure that all boxes are checked in the dialogue fi eld Installation Options
Depending on the Windows confi guration, the user account control must be con
rmed.
Update of the fi rmware on the IoT-boar
To enable you to reproduce all experiments with your IoT-board, fi rst update the
fi rmware on your board. For this, fi rst open the previously installed Arduino IDE
nd
In
Arduino ID
r
heck this.
T
/
Then
cally.
mega328 m
m
ls/Board to sel
.
Arduino Nano if it has not been recognised automati
Choose the right board in the Arduino IDE
After starting the Arduino IDE and selecting the board, open the fi rmware Firmware_V1.2b.ino now via
he menu item File/Open... It can be found in the download archive, directory Firmware_V1.2b Befor
ou install the fi rmware, ensure that the jumper on the IoT board is set to AT L
Quick start of the fi rmware
ownload onto the boar
he
the right to load the fi rmware4 onto the board
After a short time, the status line of the editor should show the messageUpload complete Now
viaSketch/Upload. You can also
oard has been update
4 The fi rmware is a regular Arduino-program. Such an Arduino-program is called a Sketch
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 615007-3 Conrad Adventskalender Internet of Things 2017_en.indd 613.08.2017 17:02:5713.08.2017 17:02:57
fi rmware onto
in the editor for this in
Testing the IoT-board
y-
.
-
.
d.
d.
h
.
g.
.
.
d.
ection can be established
out a ne
fter updating the fi rmware, you can now test the board. For this, open the serial monitor of the Arduino
IDE via Tools/Serial Monitor. Set the data transmission to 57600 Baud. Now you should see legible text
in the output window. Finally, there will be an output sa
ing Confi guration successful!, followed by information on
the wireless network
Now you can use your Android Smartphone to test whether
you can see the wireless network. For this, switch on Blue
tooth on your Smartphone; the wireless network should
appear after a short time. Now select the wireless network
(in the following screen shot: Bluething103) and confi rm
your selection with
K.
The name of the network in this example is Bluething103 and the password is 1234
On your system, the name of the IoT-board will also
tart with Bluething, but may end on a different
umber. The number is generated individually
ased on the MAC address of your board
ou must enter a password for establishing the connection; in this case, it is
fter entering the proper password, the network will appear in
NNECTED DEVICES.
234
Now your Smartphone can communicate with your IoT-boar
On your system, the name of the IoT-board will also start with Bluething, but may end on a
different number. The number is generated individually based on the MAC address of your
oar
Making the on-board-LED fl as
Now we want to test programming of the IoT-board. We use the fl ash Sketch integrated into the
rduino IDE as an example. For this, choose Datei/Beispiele/01.Basics/Blink in the menu
Now click the round icon with the arrow at the upper left, in order to upload the program to the
connected IoT-board, which is also called fl ashin
Use the check mark to compile the data;
the arrow to the right uploads the program to the IoT-board
fter the upload is complete, the LED D2 (next to connection D13) on the IoT-board will fl ash.
Now the board is ready for the next days
ou must enter a password to connect to the IoT-
r
Once a device has been connected to a Smartphone,
he conn
n.
with
w
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 715007-3 Conrad Adventskalender Internet of Things 2017_en.indd 713.08.2017 17:02:5813.08.2017 17:02:58
Below the source code window, you can see the outputs of the Arduino IDE when compiling and uploading
.
t
.
If the LED does not fl ash, look at the error messages in the Arduino IDE.
he connection to the IoT-board has failed here. In this case, you have chosen the wrong port; this can be fi xed quickly in the menu itemTools/Por
Always use the IoT-board in AT mode
The IoT-board has a Jumper. This jumper must be set to
for all projects in this calendar
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 815007-3 Conrad Adventskalender Internet of Things 2017_en.indd 813.08.2017 17:03:0013.08.2017 17:03:00
2nd Da
y
)
s
)
m
d l
h
.
.
;
;
{
;
{
;
(
);
ks
;
in
d
p
{
;
);
p
)
p()
p
.
p()
;
d
e
p
al.
)
000
seconds.
aud
y
In the Advent calendar today
•1x board (SYB 46
•1x jumper cable
Measuring analogue value
Today, you will program a Sketch in the Arduino IDE to read
out the values of an analogue input. The values will be graphically displayed by text output.
omponents: 1x board, 1xjumper cable (male – male
The progra
The program for this day is called
irectory
int analogValue = 0
int analogPin = A0
oid setup()
pinMode(analogPin, INPUT)
Serial.begin(9600);
ag02 wit
in the download archive
ag02.ino an
ocated in
oid loop()
analogValue = analogRead(analogPin)
Serial.println(analogValue);
delay
2. Da
The jumper cable serves as an antenna. Try measurements without its cable as well, to see if
the cable makes a difference to your measuring environment
1000
How the program wor
int analogPin = A0
First, the pin number used is specifi ed in the variable
made up at least of the two functions
oid setup()
pinMode(analogPin, INPUT)
Serial.begin(9600
The function
as the input.
etu
runs once initially and is usually used for confi guration. The analogue pin is specifi ed
erial.begin(9600
etup
n
starts serial communication in order to display values on the serial
monitor and the serial plotter. The parameter in this function is the Baud rate.
oid loo
The function
{
oo
is repeated until the power supply
is disconnected or the reset button pushed
oid loo
analogValue = analogRead(analogPin);
Serial.println(analogValue)
delay(1000);
{
loo
nalogP
All programs in the Arduino IDE are
analogRea
he variabl
rintlndelay(1000
1
saves the value of the analogue input in
nalogValue and out
uts it via
makes the program wait for
milli
ri
The data rate must be set correctly in the dropdown in the lower right corner of the window, in this case
B
Now, open the serial monitor via Tools/Serial Moni-
. You can see the measured value there. You can also have the values displayed graphically. For this,
connect the previously opened serial monitor and open the serial plotter via Tools/Serial plotter.
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 915007-3 Conrad Adventskalender Internet of Things 2017_en.indd 913.08.2017 17:03:0113.08.2017 17:03:01
1
0
y
r
e
r
m
ino
;
;
{
);
{
;
;
);
;
;
able
lly
O
(
)
.
y
3rd Day
3. Da
In the Advent calendar toda
•1x LED red with dropping resisto
•1x switching wir
You do not need any separate resistor, since the LED already has an integrated one
lashing light
Today, you will make an LED fl ash at a frequency of 2Hz.
omponents: 1x board, 1xLED red with dropping resisto
e progra
The program for this day is called Tag03.
irectory
const int ledPin = 2
nt ledState = LOW
void setup()
pinMode(ledPin, OUTPUT
void loop()
if (ledState == LOW) ledState = HIGH
else ledState = LOW
digitalWrite(ledPin, ledState
delay(500)
ag03
and located in
How the program works
if (ledState == LOW) ledState = HIGH
else ledState = LOW;
The vari
value is switched every 500ms via delay
records whether the LED is lit or not. Initia
500
. This makes the LED fl ash.
, the variable has the value L
W
This
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 1015007-3 Conrad Adventskalender Internet of Things 2017_en.indd 1013.08.2017 17:03:0113.08.2017 17:03:01
4th Da
y
r
y.
-
r
m
d l
4
;
;
{
;
);
);
;
;
;
{
;
);
}
;
ks
;
;
;
;
}
i
hich
in1
.
.
In the Advent calendar today
•1x LED yellow with dropping resisto
Alternating fl ash
Two LEDs fl ash alternatingl
omponents: 1x board, 1xLED yellow with dropping resi
stor, 1xLED red with dropping resisto
The progra
The program for this day is called
irectory
const int ledPin1 = 10;
const int ledPin2 = 12;
nt ledState = LOW
nt pin = ledPin1
oid setup()
pinMode(ledPin1, OUTPUT)
pinMode(ledPin2, OUTPUT
digitalWrite(ledPin1, LOW
digitalWrite(ledPin2, LOW)
ag0
ag04.ino an
ocated in
4. Day
Both cathodes (short legs of the LED) must be connected to GND. The left one is the yellow LED,
The temporary variable p
switches the variable to the other pin, and the currently lit LED is switched off. Switching takes place
every 500ms
n saves w
LED is currently lit. Initially this value is ledP
. An if-query
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 1115007-3 Conrad Adventskalender Internet of Things 2017_en.indd 1113.08.2017 17:03:0213.08.2017 17:03:02
5th Day
y
r
.
-
d
-
-
.
.
!
-
l
the element
ect to
.
-
oad the latest versio
.
.
y
5. Da
In the Advent calendar toda
•1x LED green with dropping resisto
Starting at three LEDs, things get a little crowded, so that GND is separately connected to the
upper strip. LEDs from the left to the right: green, yellow and red.
need to install a special Sketch on your board: Firmata. For this, connect the IoT-board to your PC
nd open the Arduino IDE. Select File/Examples/Firmata/Standard Firmata and download the
Sketch to the board by clicking the arrow to the right. Now you can program the board with Snap4Arduino
raffi c light
oday’s project is a traffi c light that is created with the graphi-
cal development interface Snap!
omponents: 1x board, 1xLED green with dropping resistor,
xLED yellow with dropping resistor, 1xLED red with drop
ng resistor, 1xjumper
nstalling Snap! and preparing the IoT-boar
Snap! is a graphical development interface that exists specifi
cally for Arduino as well in the form of Snap4Arduino. Down-
oad the software version used for this calendar from
www.buch.cd5. After installation, switch the interface lan
guage to German. For this, click the settings icon (cogwheel) in
Snap4Arduino and choose the language
erman in the menu
anguage
n order to be able to use Snap4Arduino on your board, you
ttp://
e category Arduino contains the elements for
controlling the IoT-board.
o not use Arduino IDE and Snap! at the same time
he Arduino IDE and Snap! cannot be used at the same time. Therefore, close the respective other
rogram before you work in the desired environment
mplementing a program in Snap
A program is assembled in Snap! with graphical elements that are divided into
categories. The category menu can be found in the upper left.
ow pull the element with the green colour into the middle working area from
ontrol. Use the element Set digital pin in order to switch the LEDs on and off. Set
he values via the switchable element
gram from ending, you need the loop element from Control. To keep the LEDs from
witching again at once, include a break of one second using wait from Contro
efore starting the program, you need to connect the IoT-board to Snap!. For this,
ick
nn
Arduino in the categoryArduino. When clicking the
mbol, you will see the available connections. Select the fi rst connection. Now
click the green arrow (upper right), and the traffi c light will start
pening an external project in Snap!
he program for today is located in folder
enu bar and select
mport... Navigate to the folder
nap.xml The project is now open and you can use it.
rue from
ag05
perators To prevent the pro
Go to the fi rst symbol in the
ag05 and select tag05
he program created in Snap!
You can also downl
screen shots, but the programs should work the same
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 1215007-3 Conrad Adventskalender Internet of Things 2017_en.indd 1213.08.2017 17:03:0213.08.2017 17:03:02
n from http://snap4arduino.org/ The interface may deviate slightly from the
3
6th Da
y
r
.
r
.
m
o
e
.
y
and rename the
g
also
g
o
g
the
edPinBlue
:
3
2
tup
:
p()
...
);
g
:
)){
);
;
}
)){
;
;
}
board receives
ed o
O
d
-
switch the
.
.
y
y
1
In the Advent calendar today
•1x LED blue with dropping resisto
Connection to the IoT-board
To day, you will connect your Smartphone to the IoT-board and
switch the blue LED on and off again with your Smartphone
omponents: 1x board, 1xLED blue with dropping resisto
Installing the App for control
Today, you will not use a dedicated App yet, but control the
board via the free App
erial Bluetooth Terminal from the
pp-Store Google Play
he circuit is similar to the circuit from day 3
The progra
The program for this day is based on the fi rmware for the IoT-board. The program parts needed from the
fi rmware are enclosed in the fi le
Radio connection ready
The fi rmware (and thus also the template) is programmed in such a way that the orange LED
at pin 13 remains lit when the wireless connection is ready. Therefore, wait until this LED lights
up before you connect to the IoT-board
orlage.in
in directory
emplat
6. Da
Copy the fi le Vorlage.ino into a new director
the fi nished fi le Ta
06.in
from the directory
ag06
ag06 ri
ht away. Now open the fi le
fi le Ta
06.ino
You can
ith
rduino IDE. The template contains some functions already. The constant for the internal LED is
present already. The constant L
for the additional LED can be defi ned right below the
internal LED
#defi ne LedPin 1
#defi ne LedPinBlue
the end of the method se
oid setu
digitalWrite(LedPinBlue, HIGH
{
, the LED is switched on
The code for switching the integrated LED at pin 13 on and off is already there. Add the followin
to it
if (Text.startsWith(“Led on”) || Text.startsWith(“LED on”) || Text.startsWith(“LED
ON”
digitalWrite(LedPin, HIGH
digitalWrite(LedPinBlue, HIGH)
if (Text.startsWith(“Led off”) || Text.startsWith(“LED off”) || Text.startsWith(“LED
After the fi rst start, you will see an empty black
window
When the
rite(LedPinBlue, HIGH) will
15007-3 Conrad Adventskalender Internet of Things 2017_en.indd 1315007-3 Conrad Adventskalender Internet of Things 2017_en.indd 1313.08.2017 17:03:0313.08.2017 17:03:03
LED on or L
n
r LED
N
digitalWrite(LedPin, HIGH) an
digital
internal LED and the blue LED on.
Loading...
+ 30 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.