SmartHome: Lab 1

Hello everybody,

This week’s course was planned to work on our project.

Here is a schematic view of our project:

New Chart

To explain it here is a picture of what we did:


First of all, we had to use a serial connection between the Raspberry Pi and the Arduino to make the link between the user, by internet, and the room’s light, by the lighting sensor (Arduino).

Currently, we are using the Raspberry directly by working on it. The next step will consist on trying to create an interface with a website to control the data about luminosity of the room. This interface will record the data and this data would be viewable at any time by the user. Moreover the user would be able to impose a set point of luminosity whenever he or she wants it.

To complete these functions, we have to create a database in SQL to store the data about luminosity and to display it on a website that will be the interface.

To use the Raspberry, we need a router to put it on the network and to work on it with our computer. So we had to find the IP address of the Raspberry to communicate with it.

The router and the Raspberry are powered by the grid.

The lighting sensor is simulated by a potentiometer. Thus, we can edit the luminosity by editing the potentiometer’s value. When the automatic option is chosen, we can see that by editing the potentiometer, the LEDs react and light in adapting the intensity. In manual mode, the user can choose the intensity value and he can enter the value into the Raspberry and make the LEDs on with the wanted intensity. The user sends information about the mode and the intensity by the Python code.

The Arduino is powered by the Raspberry. It receives the information about the sensor (here the potentiometer for the simplicity) and sends it to the Raspberry. The Raspberry manages the information and resends information about the necessary action to reach the set point or continue to just record the data in the database.

Here is the Python code that reads data coming from the Arduino and allowing communicating with it:

#!/usr/bin/env python

# -*- coding: utf-8 -*-

import serial

import time

while True:

port = “/dev/ttyACM0”

serialFromArduino = serial.Serial(port,9600)


input = serialFromArduino.readline()

inputAsInteger = float(input)


ser = serial.Serial(‘/dev/ttyACM0’, 9600)

time.sleep(4)   #on attend un peu, pour que l’Arduino soit prêt.

“     ser.write(‘3.20\n’)


time.sleep(1)               # on attend pendant 1 secondeser = serial.Serial() “

The initialization imports the information about the serial link and the time. It allows the synchronization and the adaptation to the bit rate. The code reads the information that comes from the Arduino and puts it into a variable. The variable is then displayed in a window. The waiting times are necessary to let enough time to the devices to be ready again.

That’s it for this week. See you in three weeks. Bye

The Smarthome Team

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s