This document describes the design of a smart home system using Internet of Things devices. The system will use a Particle Photon microcontroller to connect various sensors in the home, like temperature sensors and light sensors, to a cloud server. The server will then interface with a mobile app to allow remote monitoring and control of devices in the home. Sensors will be installed in both the home and an attached greenhouse to monitor and control temperature, humidity, lighting, and other functions through the mobile app over the internet.
2. BOARD OF DIRECTORS
/2
“Live as if you were to die
tomorrow. Learn as if you were to
live forever.”
Mahatma Gandhi
* Special thank you note to professor Yuri Panarin and professor Leslie
Shoemaker for excellence in guidance and mentoring.
3. Table of contents
Table of contents 3
Table of figures 4
I. Abstract 5
II. Introduction 6
III. Background/ Research 7
3.1. The Particle Photon Development Platform 7
3.2. The Blynk Mobile Application Development Platform (Android & iOS) 9
3.3. Smart Home Device Components 12
IV. The Proposed Solution 17
4.1. Requirements of the Smart Home System 17
4.2. How the circuitry and components will be used in the Smart Home 18
V. The “Implementation” 21
5.1. Project Concept 21
5.2. Hardware selection 23
5.3. Smart home - Design concept 26
5.4. Logical diagram 27
5.5. Server side development 28
5.5.1. Blink Server - A Non-blocking I/O (Java) solution 28
5.5.2. Running Blink Server on a Raspberry PI 29
5.5.3. Blynk mobile App 31
5.6. Client side development 32
5.6.1. Greenhouse board - Code analysis 32
VI. Results and Evaluation 35
6.1. Electronics 35
6.2. Network Connection 37
VII. Summary 38
VIII. References 39
IX. Appendices 40
9.1. Particle photon code - Upstairs Board 40
9.2. LM35 Datasheet 41
9.3. Micro servo Datasheet 42
9.4. DHT11 Datasheet 43
9.5. Twitter Bot code 44
/3
4. Table of figures
Figure 1: The Particle Photon Board [Particle Photon, n.d.] 7
Figure 2: Particle Photon Pinout Map 8
Figure 3: Particle Photon Functions and Features 8
Figure 4: The 4 Channel Relay Module 12
Figure 5: 4 Channel Relay Module Schematic 13
Figure 6: LM35 layout 14
Figure 7: LM35 Schematic 14
Figure 8: DHT11/22 Pinout and operating specifications 14
Figure 9: LDR Pinout and operating specifications 15
Figure 10: Servo Pinout and operating specifications 15
Figure 11: LED Pinout and operating specifications 16
Figure 12: AC Mains power device control diagram [Kevin Majewski, Fritzing Software, n.d.] 18
Figure 13: Single colour and RGB LED diagram [Kevin Majewski, Fritzing Software, n.d.] 19
Figure 14: Micro servo diagram [Kevin Majewski, Fritzing Software, n.d.] 19
Figure 15: Temperature and Humidity sensor diagram [Ricardo Pereira, Fritzing Software, n.d.] 20
Figure 16: LM35 Thermistor diagram [Kevin Majewski, Fritzing Software, n.d.] 20
Figure 17: LDR diagram [Ricardo Pereira, Fritzing Software, n.d.] 20
Figure 18: Prototype/ Working model image [Group, n.d.] 22
Figure 18: Arduino Yún internal bridge diagram [Arduino Yún , n.d.] 24
Figure 19: 3D layout smart home [Ricardo Pereira, Sketchup, n.d.] 26
Figure 20: Logical network diagram [Ricardo Pereira, MS Visio, n.d.] 27
Figure 21: NIO Architecture diagram [Netty project, n.d.] 28
Figure 22: Electronics test phase [Group, n.d.] 35
Figure 23: Pulse Width Modulation chart [Group, n.d.] 36
Figure 24: Pulse Width Modulation measures using the oscilloscope [Group, n.d.] 36
Figure 25: Bandwidth test [Group, n.d.] 37
/4
5. I. Abstract
As part of the formal element for the Project module, the students are challenged with the
design and description of a Smart Home System device based on the Internet of Things (IoT)
devices.
This report will take a look at the design and development process of a smart home system
that will be able to remotely control devices in your home across the internet. The Particle
Photon microelectronic development platform will be used for the development of the smart
home system. This platform has an integrated micro-controller and microprocessor which has
the ability to send and receive data across the internet via on-board Wi-Fi capability. The
Particle Photon allows for the design and testing of a smart home device through the use of
the exposed Input and Output pins allowing for direct access to the development capabilities
of the particle photon platform. The Particle Photon will be connected to various sensors
which will read data from different parameters within a house and forward that data to a
cloud based server. The data from the server will then interface with a mobile device app,
developed on the Blynk app development platform, for presentation to the end user. The end
user will then be able to visualise different parameters of the smart home such as
temperature or light intensity, allowing the user to manually or automatically switch on or off
devices within the smart home.
By the end of this challenge and given the selection of components both hardware/software,
the system was developed as a proof of concept and is ready to scale towards a business
revenue model, if we so choose to follow a commercial approach.
This was also an important learning experience and it challenged the knowledge attained
during the course of the degree and we feel confident to say that the project goals were met
also due to the educational framework provided by all the modules in this DIT course.
/5
6. II. Introduction
The proposed concept of this project is to develop a system which will give a homeowner the
ability to control environmental aspects within a home such as lighting, heating and hot water
using a mobile application across the internet. Another area of the house we propose to be
able to control are parameters within a greenhouse attached to a home such as temperature,
humidity, soil moisture and a pump to supply water to the vegetation within the greenhouse.
Other goals of this project include the following:
• Having a fully working prototype model smart house for our presentation
• Including the means to be able to fully control and monitor systems present within the
smart home
• Incorporate the use of a mobile application allowing for full control of the systems within
the smart house
• Including the ability for the homeowner to be able to monitor parameters within the smart
home such as temperature, light intensity, etc.
• We aim to utilise the skills learned throughout our studies in the DT080A program such as
programming and microelectronics
The tasks needed to complete this project will be broken into sections between the two
members within our group:
Ricardo Pereira: implementation of smart greenhouse within the smart home to control
temperature, humidity, and water supply to vegetation within the greenhouse
Kevin Majewski: implementation of smart home system to control lighting, heating, hot
water, remote garage door access, etc.
/6
7. III. Background/ Research
The smart home system that can be developed throughout this project can
provide a homeowner the power to remotely manage systems and devices
inside their home through the employment of a mobile application on a
smart phone or tablet. Such systems within the smart home embrace
lighting, heating, hot water, garage access, and a smart greenhouse. This
will all be created through the utilisation of the Particle photon electronics development
platform. The Particle Photon operates with similar capabilities to other electronic platforms
such as an Arduino or a Raspberry Pi. The Particle Photon platform can be accustomed style a
system which can interface with sure devices and sensors like thermistors for reading
temperature, light dependent resistors for reading light intensity, a hygrometer detector for
reading humidity, and relays which can offer the Particle photon the power to regulate high-
voltage systems like lights or heat by using digital logic on the Particle photon. The Particle
Photon can be developed to communicate with an open-source, cloud-based server which
can interface directly with the Blynk application development platform giving the user the
power to remotely management and monitor the specified parameters among the smart
home.
3.1. The Particle Photon Development Platform
The Particle Photon Development Platform is a powerful, low-cost, low-power, Wi-Fi enabled
IoT (Internet of Things) hardware development kit. The Particle Photon platform includes
everything needed to build an internet connected smart device. The platform includes access
to the Particle Cloud which is a cloud based Integrated Development Environment (IDE) free
of charge with the purchase of a Particle Photon. The IDE includes numerous examples of
how to use the Particle Photon to read data from sensors or control digital logic devices
across the internet via the web-based IDE.
Figure 1: The Particle Photon Board [Particle Photon, n.d.]
/7
9. 3.2. The Blynk Mobile Application Development Platform (Android & iOS)
The Blynk development platform is an open-source platform used to manage a variety of
electronic hardware development systems like the Raspberry Pi, Arduino, Intel Galileo, and in
this case, the Particle Photon, using a mobile phone or different smart device. The platform
allows a hardware developer to build a graphical interface to read information from and to
manage electronic components connected to devices like the Particle photon. The Blynk
platform includes an open-source Netty [NIO] primarily based cloud server that is used to
send and receive information to and from any of the mentioned hardware development
platforms (and more that aren't listed above). The Blynk server is also accessible to download
and run on a Local Area Network (LAN) to cut back any latency in signal transmission and also
to offer the developer full access to the capabilities of the server for customisation of the
server for their specific development needs.
The Blynk platform provides an easy to use solution for providing control of internet
connected devices using the Particle Photon and other similar development hardware. Blynk
provides the means to be able to quickly connect to and communicate with endless numbers
of electronic components which read all types of real world parameters. The Blynk app
widgets allow for different types of interactivity with components which can be connected to
the Particle Photon, a few of which will be explained in more detail below:
The Blynk Button Widget
The button widget allows the end user to send a digital high or
low output to the Particle Photon to switch on or off a component
such as a relay or an LED. The button widget is able to function as
a push and release switch or an on/off switch.
!
/9
10. The Blynk Slider Widget
The slider widget functions like a potentiometer. It allows the end
user to vary an output signal to a component connected to a
Particle Photon. In the case of the Smart Home being developed
for this project the slider widget will be used to control the servo
which will open and close the garage door. As the servo requires
a digital PWM signal, the output sent to the servo will be a digital
value between 0 and 255.
!
The Blynk Gauge
The gauge widget provides a display to show real time values of
data being sent from various connected sensors. The gauges
allow the range of values to be displayed to be set to within a
custom range as needed for whatever the application may be.
The gauges are able to display a full digital value from 0 to 1023
as well as a mapped value which may be specified within the
widget settings.
!
The Blynk Timer
The timer widget provides a means to set a digital high or low
signal to be sent at any time that the end user specifies. Quite
useful for automatically controlling lights when needed or
automatically switching on and off a sprinkler system.
!
/10
11. The Blynk Value Display
The value display is able to show a numeric value from an input
component such as a thermistor or light dependent resistor. The
value display is customisable allowing for a digital output range
between 0 and 1023. The value display also allows for a mapped
value to be displayed which may be specified to meet a certain
output range such as a temperature between 0 and 50 degrees
Celsius.
!
The Blynk Graph
The Blynk graph widget provides either a bar or line graph on
which to display output parameters from a sensor. The graph
allows up to 4 separate data values to be displayed. This is very
useful to compare values such as temperature and humidity which
may be able to give a user a display of conditions within a
controlled environment.
!
/11
12. 3.3. Smart Home Device Components
The components used in the development of the Smart Home system for this project will
include relays to control high voltage systems within the smart home. Thermistors which are
sensors for reading temperature within the smart house will also be used. Light dependent
resistors (LDRs) will be used for reading the ambient light intensity in the smart house. A
servo motor will be used to replicate the controlling of a garage door in the smart house.
A hygrometer sensor will be used to read the relative humidity within the greenhouse area of
the smart house. A moisture sensor will also be used in the greenhouse to measure the
current moisture level of the soil within the greenhouse. A pump will be and interfaced with
the moisture sensor to supply water to the soil when needed. A fan will be used in the
greenhouse when the temperature within the greenhouse rises above a set threshold to help
regulate the greenhouse temperature. Light Emitting Diodes (LEDs) will also be used to
replicate the lighting systems within the smart home.
Figure 4: The 4 Channel Relay Module
Relay Inputs: The relay modules are supplied with power via the input pins labelled VCC and
ground. The relay internal circuits are switched on/off via the input pins labelled IN1, IN2, IN3
and IN4.
/12
13. Relay Outputs: The relay outputs have three contacts each. A common terminal labelled
COM, a normally closed terminal labelled NC and a normally open terminal labelled NO.
Figure 5: 4 Channel Relay Module Schematic
/13
14. The LM35 thermistors used in this project are integrated temperature sensors with a linear
output voltage directly proportional to the Centigrade Temperature. The LM35 thermistor is
typically accurate to within ± ¼ °C at room temperature and ± ¾ °C over a full temperature
range of −55°C to 150°C.
Figure 6: LM35 layout
Figure 7: LM35 Schematic
The DHT-11/22 will be used for measuring the humidity in the smart greenhouse as well as
the temperature within the greenhouse. The DHT-11/22 uses a single output digital
connection providing a digital output. The digital output from the DHT-11/22 is read on a
digital input pin on the Particle Photon and is presented within a graphical output gauge in
the Blynk app.
Figure 8: DHT11/22 Pinout and operating specifications
Operating Specifications
Working voltage 3.3-6V Input
Working current 1-1.5mA measuring current
Humidity Accuracy Humidity from 0-100% RH
Temperature Accuracy -40 - +80 degrees C temperature range
+-2% RH accuracy
+-0.5 degrees C
!
/14
15. The Light Dependent Resistors (LDRs) in this project will be used to measure the intensity of
ambient light intensity within the smart home. The LDRs vary the resistance of input voltage
by sensing the intensity of light which is read by the LDRs. The output of the LDRs will be
connected to an input analogue pin of the Particle Photon. The variance of input voltage
which is read by the input pin of the Particle Photon will then be displayed on the Blynk app
in graphical display for the user to be able to see the intensity of light present within the
smart home.
Figure 9: LDR Pinout and operating specifications
The Micro Servo used in this project will replicate the controlling of a garage door remotely
over the internet via the Blynk mobile application. The Micro Servo has the ability to rotate
180° which will be sufficient to replicate the operation of a garage door within the model
smart home. The input signal used to control the position of the servo will be a pulse width
modulated (PWM) signal sent from a digital PWM output pin on the Particle Photon. The
position of the servo will change depending on the variance of the timing of the PWM output
signal sent from the Particle Photon to the input of the micro servo. Position "0" (1.5 ms
PWM signal) is middle, "90" (~2 ms PWM signal) is all the way to the left and "-90" (~1ms
PWM signal) is all the way to the right.
Figure 10: Servo Pinout and operating specifications
Operating Specifications
Light
resistance (10
Lux) (KΩ)
Dark
resistance
(MΩ)
Y100-10 Response time (ms)
Increase Decrease
Ø 20
Series
5-10 1 0.6 30 30
10-20 2 0.6 30 30
20-30 3 0.7 30 30
30-50 5 0.7 30 30
50-100 8 0.8 30 30 !
Operating Specifications
Weight 9 g
Dimension 22.2 x 11.8 x 31 mm approx.
Operating speed 0.1 s/60 degree
Operating voltage 4.8 V (~5V)
Temperature range 0 ºC – 55 ºC
! !
/15
16. The Light Emitting Diodes (LEDs) used within the smart home will be used to replicate a
mains voltage lighting system within the smart home. The LEDs used will be both single
colour LEDs, either red green or blue, and RGB (Red, Green, Blue) LEDs which are able to
change their colour depending on the input signal they are receiving. The Blynk app will have
switch buttons to turn on/off the single colour LEDs and also an RGB selector to vary the
colour of the RGB LEDs.
Figure 11: LED Pinout and operating specifications
Operating Specifications
Parameter Symbol Rating Unit
Normal Led RGB
[Red]
RGB
[Green]
RGB
[Blue]
Operating
Temperature
TOPR -40 to +100 -25 to +85 -25 to +85 -25 to +85 ˚ C
Storage
Temperature
TSTG -40 to +100 -30 to +85 -30 to +85 -30 to +85 ˚ C
Soldering
Temperature
[Iron]
TSOL-I 240 for 5
sec
˚ C
Soldering
Temperature
[Flow]
TOPR 240 for 10
sec
˚ C
Continuous
Forward Current
IF 100 20 20 20 mA
Reverse Voltage VR 5 V
Reverse Current IR 10 10 10 uA
Power
Dissipation
PD 200 mW
Peak Forward
Current
IFP 1.5 A
Peak Emission
Wavelength
λ PH 625 520 467.5 nm
!
!
/16
17. IV. The Proposed Solution
4.1. Requirements of the Smart Home System
Numerous necessities of the electronic equipment required to be set upon previous to
getting used within the Smart Home System. Decisions required to be created in regards to
simulating a functioning Smart Home System. Certain electronic elements would be required
to demonstrate however the Smart Home would operate in a real life scenario. The use of
relays would be needed to indicate however the Particle Photon would be ready to remotely
manage a mains power-driven appliance, such as a light or a heater over the internet. It was
then decided that we'd use low voltage components inside the Smart Home model to
simulate mains power-driven systems which might apply in an exceedingly global Smart
Home. Single coloured and RGB coloured LEDs were chosen to replicate the management of
lighting inside the Smart Home. A micro servo was chosen to simulate the functioning of
garage door. A low-voltage pump and fan square measure to be used to simulate the
operation of devices utilised in a real world internet connected greenhouse. Other elements
such as the LM35 thermistors, the LDRs and the DHT 22 sensors are going to be used
specifically however they'd be in an exceedingly global scenario as they solely need an low
voltage supply of 5V to operate.
After experimenting and testing the functionality of the components to be used within the
Smart Home system, the overall functionality of the Smart Home needed to be decided upon.
The parameters of the Smart Home that needed to be measured, such as light intensity or
temperature needed to be considered. The functions that would be able to be controlled
remotely also needed to be chosen. While deciding the parameters to measure, and
functionality to add to the Smart Home, it was also necessary to decide how this would make
life easier for the end user in a real world situation. It was determined after great
consideration that parameters such as light intensity, temperature, and humidity within the
Smart Home and greenhouse were vital, and were to be measured and displayed on the
Blynk mobile application. It was also determined that being able to remotely control lighting,
heating, hot water, a garage door and a water supply to vegetation within the greenhouse
were the most beneficial aspects of the Smart Home to be able to controlled across the
internet.
/17
18. 4.2. How the circuitry and components will be used in the Smart Home
In order to replicate the real world functionality of a Smart Home System, the circuitry
needed to be considered and designed. In the wiring diagrams below, you will see how the
components that will be used in the Smart Home, will be connected to the Particle Photon.
Figure 12: AC Mains power device control diagram [Kevin Majewski, Fritzing Software, n.d.]
The current needed to power the action of the relays will be powered by the Particle Photon.
The Vcc and ground pins of the relay module will be connected to +5V and Ground on the
Particle Photon. The pump and the fan which will be controlled by the relay module, will
require an external power source to drive them. As the Particle Photon is only rated to supply
a maximum output current of 1A, externally powering devices where possible is much
preferable in order to protect the Particle Photon from any damage.
/18
19. The single colour LEDs will have the anode leg (negative – black wire) connected directly to a
ground pin on the Particle Photon and the cathode leg (positive – red wire) will be connected
to a 220 ohm resistor, to reduce the current to the LEDs, and then to the +5V pin on the
Particle Photon. The RGB LEDs have a common anode leg which will be connected directly to
the ground pin on the Particle Photon and the Red Green and Blue cathode legs will each be
connected to a 220 ohm resistor and then to +5V on the Particle Photon.
Figure 13: Single colour and RGB LED diagram [Kevin Majewski, Fritzing Software, n.d.]
The Micro Servo which will be used to simulate the operation of a garage door in the smart
home will require a digital pulse width modulated input control signal (yellow wire) connected
to an output pin on the Particle Photon. The Micro Servo also requires a 5V input to drive the
servo which will be connected to the +5V and ground pins on the Particle Photon.
Figure 14: Micro servo diagram [Kevin Majewski, Fritzing Software, n.d.]
/19
20. The DHT-11/22 will be powered by the +5V and ground pins of the Particle Photon. The data
pin of the DHT-11/22 will be connected to a digital input pin on the Particle Photon.
Figure 15: Temperature and Humidity sensor diagram [Ricardo Pereira, Fritzing Software, n.d.]
The LM35 Thermistor is an analogue component and will require an input voltage of 5V from
the +5V and ground pins on the Particle Photon. The output from the LM35 will be a varying
analogue voltage which will be connected to an analogue input pin on the Particle Photon.
Figure 16: LM35 Thermistor diagram [Kevin Majewski, Fritzing Software, n.d.]
Light dependent resistors will vary an input analogue voltage which will be read by Particle
Photon. The output voltage from the LDRs will be converted into a specific output value
range and displayed to the end user to represent the intensity of ambient light present within
different areas of the smart home. This will allow the user to visualise the intensity of light
within the smart home and decide to switch on lights if needed.
Figure 17: LDR diagram [Ricardo Pereira, Fritzing Software, n.d.]
/20
21. V. The “Implementation”
In this section, characterised by the Project Implementation Plan we will describe the steps
involved in preparing the hardware/software included in this project and we will also explain
the several device combinations used to achieve this smart home IoT system (including failed
attempts).
5.1. Project Concept
The project concept started in class when our lecturer
informed us of what was expected of this challenge. We
were asked to develop an IoT system on the topic of
smart home devices and given the shortage of
resources available (mainly MCU’s) we decided to enrol
individually to maximise the number of components we
would receive. We will now describe the 4 steps we went through
to define our project and the individual workload:
Step 01: Research
Picking up the topic where we left off “smart homes” we decided to create a project concept
around a real life application and considering we participated in the last Web Summit, where
we had the opportunity to liaise with the industry technologists and see what’s trending we
decided to do something with potential commercial applications. After several trial and errors
[detailed next chapter] with different board configurations we settled with the Particle
Photon board.
Step 02: Brainstorming
During the course of this project we had several brainstorming sessions, this was key for
success, as both myself and Kevin are technology driven and this sometimes can steer us of
course from the initial goals. It’s not easy to follow a simple path and stay loyal to your initial
idea when the amount of alternatives is readily available, to simply put it …
/21
01 02 03 04
“Simple can be harder than complex: You have to work hard to get your thinking clean to
make it simple. But it’s worth it in the end because once you get there, you can move
mountains.” - Steve Jobs
22. Step 03: Gearing Up
After all the debate it was time to roll up the sleeves and get the work done. We divided to
conquer and split the workload to facilitate the roll out of the project. Since we going for a
real life scenario, we portrayed a family house project and aimed to develop the automation
of several house components both indoor and outdoor. The following is the team workload
division:
Kevin Majewski: Indoor devices and applications [Lighting, environmental controls, garage
annex control, etc];
Ricardo Pereira: Outdoor devices and applications [Greenhouse sensors, water pumps,
temperature and humidity sensors, etc];
Teamwork: Local server, email and twitter interface notifications;
Step 04: From idea to reality… and more
Assembling needs testing and we sure did a load of testing in this project. From current and
voltage measuring to oscilloscope measuring of the Pulse Width Modulation, network testing
with Wireshark, ITT and ITP testing under linux OS, etc. The majority of these tests were done
to make sure all the different system components were performing within acceptable
parameters [in case you’re wondering we have a full section just for testing].
After testing we went from the prototype phase to the working model, this involved building
a house mock-up and wiring it to perfection. In the next chapters we will cover in depth the
trial phase, the assembly and the testing of this project.
Figure 18: Prototype/ Working model image [Group, n.d.]
/22
Prototype Working model
23. 5.2. Hardware selection
Before getting to the proof of concept product system we went through a stage where we
tested several boards looking for the best configuration for our product prototype. The
following is the checklist used to select the system on which we build our project:
1. Supply output current;
2. Wi-Fi capable;
3. Large base developer community;
4. Physical dimensions;
5. Server integration [local/ cloud based];
Board Selection Table
Supply output current 1 A [max]
Wi-Fi capable Yes [On board chip]
Large base developer
community
Yes
Physical dimensions 36.58mm x 20.32mm x 6.86mm
(5 grams)
Server integration Yes (Netty Java)
Supply output current 800 mA [max]
Wi-Fi capable Yes [On board chip]
Large base developer
community
Yes
Physical dimensions 73mm x 53mm x 17 mm
(32 grams)
Server integration Yes (several linux builds)
Supply output current 1.2A (switchable) + 800mA
Wi-Fi capable * Yes (usb dongle required)
Large base developer
community
Yes
Physical dimensions 85.60mm x 56mm x 21mm
Server integration Yes (several linux builds)
!
Particle Photon
! !
Raspberry PI + Arduino Uno
!
Arduino Yún
/23
24. Analysis
To start this analysis we are going to look at the last items from the list, that’s right “folks” we
connected a Raspberry PI to a Arduino Uno. The idea is simple you take the processing
power of the ARM Cortex MCU on the Raspberry PI and join it with the low cost but very
handy Arduino Uno and the possibilities are endless. We had a lot of fun with this setup, the
Raspberry PI runs on top of Raspbian [other distributions are available], the free operating
system based on Debian optimised for the PI hardware. After a couple hours, several scrolled
manuals and the configuration of the proper libraries, we got the first “Hello PI” sketch
running and it was beautiful. Our thoughts on this one, if you want the plug-and-play solution,
forget about it, this is more like plug-and-pray kind approach and you can expect to loose a
couple hours of sleep to get this running properly. After you understand the basics and clear
all “those issues” with serial comms baud rate, the GPIO voltage differences and any other
surprises you might get from the Linux environment, then everything will start to run
“automagically”. Now let’s check why this was not the option for our project, aside the fact
that putting the project running on top of this configuration would be a “mad pain” and that
it consumes twice as much power as the other boards, we simply didn't want to use the
ethernet port as the main network connection. As a proof of concept we are trying to use a
decentralised system based on wireless technology and of course we can purchase the USB
dongle but why bother given more affordable alternatives.
After this first analysis it’s time to move on to the Arduino Yún. This configuration was a real
surprise, the installation and setup was fairly simple and straightforward, and we had it up
and running in minutes. The Yún distinguishes itself from other Arduino boards in that it can
communicate with the Linux distribution onboard, offering a powerful networked computer
with the ease of Arduino. The Yún has a built-in USB communication, eliminating the need for
a secondary processor.
Figure 18: Arduino Yún internal bridge diagram [Arduino Yún , n.d.]
/24
25. The Arduino Yún, is easy to setup, runs Linux commands like cURL, allows shell and python
scripts for robust interactions and in terms of hardware it has all the traits we were looking
for, so it’s only fair to say that for a while it seemed the main contender, this was until we
noticed that we could not get a stable Wi-Fi connection. Everything works fine for a few
minutes (something like 5 to 35min), and then the connection network requests to the Yún
time out. There are several reported posts online and we even tried some of the
recommended “fixes” like updating to the new OpenWrt software version, but the results
were the same and after a lot of frustration you start wondering if you can’t get a better deal
rather than this “almost” perfect hybrid.
This leaves us with the main contender, the Particle Photon, this lightweight device packs a
heavy punch, it’s no bigger than your thumb, yet it runs an ARM M3 processor, it supplies
1Amp through all pins [analog/ digital], has on board Wi-Fi connection, it has a large
developer community with several libraries and integrations available and it just works. From
all the several boards we tested, like the Arduino, the Raspberry, the Intel Galileo and other
not worth mentioning we found this Particle Photon extremely functional, powerful and
considering we got the boards for free out of the last Web Summit, we might as well use
them.
The company behind this project started from a crowdfunding campaign and they seem
serious with their product and from a developer viewpoint they make a compelling argument
that with their system is extremely easy to go from prototype to scale production.
The Particle board uses “Wiring” the open-source programming framework for micro-
controllers and this means that most Arduino sketches will run without any modifications. It
also accepts C/C++ code since the firmware stack is open source. Interfacing with the
Particle board is extremely easy, it allows up to 5 Wi-Fi network pool list [managed by the
device] and there are multiple ways to upload the code, more common ones include via
Common Line Interface [Node.js required] or the Web IDE, a complete development
environment which allows to flash code over-the-air to the devices. Particle also provides a
mobile App called Tinker for initial setup and remote monitoring and a developer SDK for
coding a mobile App. We won’t cover these last 2 products since we are using a different
solution to interface with the server and mobile App called Blynk, which we will cover in the
following chapters.
/25
26. 5.3. Smart home - Design concept
Figure 19: 3D layout smart home [Ricardo Pereira, Sketchup, n.d.]
Using Sketchup we roughly design the layout for the mock-up we need to construct. This 3D
layout represents a concept to be applied in a family house with 3 indoor divisions [ground
floor, second floor and attic] a garage and an outdoor greenhouse. This smart house will
simulate the ability to control lights, pumps, sensors, servo motors, etc. The greenhouse will
host a variety of sensors and actuators that will respond to the surrounding environment and
provide the user with different levels of notifications[twitter and/ or email] and interactions
through a mobile app and we will store and process sensor data on a local/remote server and
provide the user with different levels of control.
/26
28. 5.5. Server side development
This project includes the integration of 2 servers to store and process sensor data, user
authentication and application interaction. We will first detail the remote server and the
technology behind it, that offers features for intensive I/O operations.
5.5.1. Blink Server - A Non-blocking I/O (Java) solution
Before we start the strip down of the Blynk server, let us point out a couple points we think
are relevant for this topic. This day and age there are several web servers available for
Internet of Things devices, like IBM Bluemix [with MQTT broker] and Microsoft Azure [with
REST]. These platforms are of course paid after a trial version period and defuse the purpose
of the project. There are other free platform available out there [like Nimbits], but these do
not offer the same level of integration as we have seen with the Blynk Server.
The Blynk Server is an Open Source Netty-based Java server, responsible for forwarding
messages between Blynk mobile application and various micro-controller boards. It uses the
Non-blocking I/O (Java) [NIO] client server framework which enables quick and easy
development of network applications such as protocol servers and clients. It greatly simplifies
and streamlines network programming such as TCP and UDP socket server.
Figure 21: NIO Architecture diagram [Netty project, n.d.]
/28
29. In general we use applications or libraries to communicate with each other. However, a
general purpose protocol or its implementation sometimes does not scale very well. It is like
we don't use a general purpose HTTP server to exchange big files, e-mail messages and
multiplayer game data. What's required is a highly optimised protocol implementation which
is dedicated to a specific purpose, this is where Netty comes in, it provides an asynchronous
event-driven network application framework and tools for rapid development of maintainable
high-performance, high-scalability protocol servers and clients.
5.5.2. Running Blink Server on a Raspberry PI
In this chapter we will be providing the details on how to run
the Blynk server locally on the Raspberry PI, to do this we
first need to install Java 8. From the PI console issue
the following commands :
Step 1: Install Java 8
Step 2: Check Java version
Step 3: Download Blynk server .jar file
Step 4: Run the server on default hardware port 8442 and default application port 8443 (SSL port)
The local Blynk Server is now running
/29
sudo apt-get install oracle-java8-jdk
java -version
Output: java version "1.8.0_40"
wget "https://github.com/blynkkk/blynk-server/releases/download/v0.15.3/server-0.15.3.jar"
java -jar server-0.15.3.jar -dataFolder /home/pi/Blynk
30. Administration UI
The Blynk server also has an administration panel where the user can monitor the server. It is
accessible via URL.
HTTP RESTful
The Blynk HTTP RESTful API allows to easily read and write values to/from Pins in Blynk apps
and Hardware (microcontrollers and microcomputers). Every PUT request will update Pin's
state both in apps and on the hardware. Every GET request will return current state/value on
the given Pin.
Enabling mail on Local server
In order to enable mail notifications on the Local server the users mail credentials need to be
provided. A file mail.properties needs to be created within the same folder where server.jar
exists. Mail properties :
/30
mail.smtp.auth=true
mail.smtp.starttls.enable=true
mail.smtp.host=smtp.gmail.com
mail.smtp.port=587
mail.smtp.username=kevmajew@gmail.com
mail.smtp.password=************
31. 5.5.3. Blynk mobile App
The Blynk allows the user to interfaces with the devices almost seamlessly using various pre-
defined widgets. This application works both on Android and IOS devices and receives
constant updates. The first step required to get things running is to download the app onto
the mobile device.
Step 1: Install the app on the mobile device
Step 2: Create a New Account [this will be required for both local and remote server]
Step 3: Create a New Project [In this case we have created 3 projects - 1 for each board]
Step 4: Copy the Authentication Token. This can be found under Project Settings [top right cage nut icon].
This token is unique per project an we do not recommend sharing this with anyone. The token will have to
be placed inside the code and we will detail this step on a different chapter.
/31
32. 5.6. Client side development
5.6.1. Greenhouse board - Code analysis
The greenhouse Particle board collects information from the sensors through the digital/
analog input pins and it then processes this data locally using an algorithm to trigger specific
events, like activating the water pump when the ground moisture reaches a set threshold or
pushing out a twitter notification to inform the user that the extractor fan was activated to
lower room temperature.
The sketch used in this board loads 2 different libraries, the DHT 11[temperature/ humidity
sensor] and the Blynk library. The sensors sampling time was set for 1/2 second. During the
test phase it was verified that Blynk does not handle well the delay() function.
/32
33. In the loop() function the data from the sensors is constantly monitored for changes in state
and several actions are taken dependent on the trigger set. The client app receives real time
information about the sensor activity but the system acts autonomously from user input to
maintain it's functions in place.
/33
34. The code includes a twitter feed notification when we call the function tweetOnButtonPress()
/34
35. VI. Results and Evaluation
There were a number of tests that we performed before and after the circuit assembly.
Bellow is the list of tests we conducted and the expected results.
6.1. Electronics
After assembling the circuits we started to measure the expected voltages across the Particle
Board. The circuits are powered using an external battery supply and the DC voltage is
between 0 and 3.3V with a current output varying between 500mA and 1A [max. with all
ports connected].
Figure 22: Electronics test phase [Group, n.d.]
Test # User Input Expected results Pass/ Fail
1 Electronic measures [Voltage/
Current and Pulse Width
Modulation]
Validate if the circuits are drawing the
expected current and verify PWM for the
servo motors
Pass
2 Network connection throuput Generate noise in the WLAN and check how
the client/ server messages perform
Pass
/35
36. Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means.
In our circuit we are using this technique to map the values across the servo motor [garage
door] between 0 and 130 with a Slider button, in order to create a 90 degree angle.
Digital control is used to create a square wave, a signal switched
between on and off. This on-off pattern can simulate voltages in
between full on (5 Volts) and off (0 Volts) by changing the portion
of the time the signal spends on versus the time that the signal
spends off. The duration of "on time" is called the pulse width.
The duration or period is the inverse of the PWM frequency.
Figure 23: Pulse Width Modulation chart [Group, n.d.]
This looks good on paper, now it’s time to compare with the oscilloscope measures. By
varying the values on the slider app button [1, 16, 48, 64, 96, and 112] we should visualise
different width values on the oscilloscope. This method allowed us to calibrate the servo
motor [garage door].
Figure 24: Pulse Width Modulation measures using the oscilloscope [Group, n.d.]
/36
37. 6.2. Network Connection
The network connection for this project is sustained by the use of a 3G router from Vodafone.
Since the values vary significantly based on the coverage area, an accurate throughput is
difficult to access, the following are values we were able to gather based on available online
tools[ex. speedtest].
Figure 25: Bandwidth test [Group, n.d.]
/37
38. VII. Summary
The initial aim of this report was to document all findings tied with the development of this
smart home system for the Internet of Things. The goals were simple, develop a full
functional solution without compromising system efficiency, bellow is the list of objectives:
• Remote interaction;
• High levels of power efficiency;
• Integration with mains AC systems;
• Affordable solution;
• User friendly;
• Reliable solution;
From a higher view of the project, all objectives were achieved. The hardware choice for this
project was critical and after several test stages we decided to work on the Particle Photon
powered by the Blynk Server[remote and local]. By doing so we were left with an advantage
over other configurations. This system is extremely efficient, for instance in terms of power
alone it consumes less 45% energy than it’s Raspberry PI counterpart over the same period of
time. It’s also very reliable when it comes to connectivity and the Blynk server provides the user
with a friendly interface to monitor/ control the sensors and actuators. The system also provides
the user with real live data inputs and notifications, using email or social media to present
certain triggers. Given the selection of components both hardware/software, the system was
developed as a proof of concept and is ready to scale towards a business revenue model, if we
so choose to follow a commercial approach.
This was also an important learning experience and it challenged the knowledge attained during
the course of the degree and we feel confident to say that the project goals were met also due
to the educational framework provided by all the modules in this DIT course.
/38
39. VIII. References
Anon, (2016). [online] Available at: http://www.ti.com/lit/ds/symlink/lm35.pdf [Accessed 6 May 2016].
Anon, (2016). [online] Available at: http://www.electroschematics.com/wp-content/uploads/2015/02/DHT22-datasheet.pdf
[Accessed 6 May 2016].
Daraghbyrne.github.io. (2016). [online] Available at: http://daraghbyrne.github.io/diotlabs/getting-started/images/
ParticlePhotonPin.png [Accessed 6 May 2016].
Docs.blynk.cc. (2016). Blynk. [online] Available at: http://docs.blynk.cc/#hardware-set-ups-particle-formely-spark [Accessed 6
May 2016].
Docs.blynk.cc. (2016). Blynk. [online] Available at: http://docs.blynk.cc/#blynk-server-how-to-run-local-blynk-server-how-to-
launch-blynk-server-on-raspberry-pi [Accessed 6 May 2016].
Docs.particle.io. (2016). Particle. [online] Available at: https://docs.particle.io/guide/getting-started/intro/photon/ [Accessed 6
May 2016].
Golisch, T. and →, V. (2015). Fritzing 4-channel relay part. [online] Aah, the pain of being an elitist. Available at: https://
timgolisch.wordpress.com/2015/09/12/fritzing-4-channel-relay-part/ [Accessed 6 May 2016].
Hackster.io. (2016). Private IoT with Blynk on Local Server. [online] Available at: https://www.hackster.io/rei-vilo/private-iot-with-
blynk-on-local-server-619926 [Accessed 6 May 2016].
Henry's Bench. (2015). 5 Volt 4 Channel Arduino Relay Module User Manual. [online] Available at: http://
henrysbench.capnfatz.com/henrys-bench/arduino-output-devices/5-volt-4-channel-arduino-relay-module-user-manual/
[Accessed 6 May 2016].
Kit, P., Photon, S., (Headers), P., Shield, S., RedBoard, S. and Shield, S. (2016). Particle Photon Kit - KIT-13345 - SparkFun
Electronics. [online] Sparkfun.com. Available at: https://www.sparkfun.com/products/13345 [Accessed 6 May 2016].
Lucidscience.com. (2016). LucidScience - Build the PULSED LED ILLUMINATOR - Page 2 of 9. [online] Available at: http://
www.lucidscience.com/pro-pulsed led illuminator-2.aspx [Accessed 6 May 2016].
RHT03, H., SHT15, S., BME280, S., TMP36, T., HIH6130, S., TMP102, S. and HIH-4030, S. (2016). Humidity and Temperature
Sensor - RHT03 - SEN-10167 - SparkFun Electronics. [online] Sparkfun.com. Available at: https://www.sparkfun.com/products/
10167 [Accessed 6 May 2016].
All stock photos not referenced in this report were purchased using a creative commons licence Attribution-NonCommercial-
ShareAlike [CC BY-NC-SA]
/39