Introduction: FPiDroid House Beta : an Advanced Smart House

FPiDroid House represents a monitoring and control network for smart houses, using FPGAs, embedded systems and web technologies. The main purpose of this project is to have a possibility to add and connect dinamically a lot of devices (each of them having their own state machine). These state machines are implemented over FPGA as modules , which work in parallel. Before implementing this project, or even develop it further you MUST know the following:

· HDL design (medium);

· Computer Architecture knowledge (medium to high);

· Microcontrollers (medium);

· C, Python, HTML, CSS, Javascript (medium);

There are a lot of steps to implement this project, but i will try to explain as much as I can. Some helpful information can be found at the following links :

http://www.arm.com/products/processors/cortex-m/cortex-m-system-design-kit.php

http://infocenter.arm.com/help/topic/com.arm.doc.ddi0432c/DDI0432C_cortex_m0_r0p0_trm.pdf

http://infocenter.arm.com/help/topic/com.arm.doc.dui0497a/DUI0497A_cortex_m0_r0p0_generic_ug.pdf

http://nineways.co.uk/ARM_IHI0033A_AMBA_AHB-Lite_SPEC.pdf

http://www.arm.com/products/designstart/index.php

https://www.digilentinc.com/Data/Products/NEXYS3/Nexys3_rm.pdf

NOTE : This project is still in beta mode, still has a few bugs and other minor issues ( such as uncommented code, untranslated variable and function names), but I will update as soon as possible the final version of it. This project is the result of a few months intensive work and more than an year of studying computer architecture, programming languages and other things, so it won't be easy to understand and replicate everything, or make it functionally from the first hit.

Step 1: Get/purchase the Items You Need

· For the lighting system: LEDs, PCB, cables;

· For the window blinds : a cartridge sliding mechanism, L298N IC, 8 x 1N4001 Diodes, 2 x 100 nF capacitor, 2 x 0.47 Ohm 1W resistor, 2x Sharp GP2Y0D805Z0F, PCB, cables, 12 V 600-1000 mA power supply;

· For the temperature sensor board : DS1620 IC, 3x 200 ohm resistors, 1 x 100 nF capacitor, PCB, cables;

· For the heating system : 100 Watt incandescent Light Bulb, 1 x JQX-15F ( 220 V 20 A, or any compatible relay), 2x 1Kohm resistors, 1x 10Kohm resistor, 2N3904 transistor, 1N4148 diode, 1 LED, connectors, PCB, cables;

· For the cooling system : 12 V PC FAN, 1 x LEG-5 or any compatible relay, 2x 1Kohm resistors, 1x 10Kohm resistor, 2N3904 transistor, 1N4148 diode, 1 LED, connectors, PCB, cables, 12v 500 mA power supply;

· For the alarm : 1x buzzer, resistors ( 1K, 2.7K, 0.47K, 0.1K, 0.27K, 0.27K, 47K, 47K, 0.27K, 0.18K, 10K), diodes ( 3x 1N4148), pins, sockets, transistors ( BC547), capacitors (0.015 uF, 100uF, 0.01uF, 0.047uF, 100uF, 2.2uF, 473nF, 4.7uF), potentiometer, LED (LD274), fototransistor (BPW40), BS-115C relay, NE555 IC, LM741 IC, PCBs, cables , 12V 500 mA power supply;

· 1,2 or more Nexys 3 FPGA boards (one should be enough to simulate the smart house);

· 1 Raspberry Pi for each FPGA board, power supplies.

· For the remote control : TSOP 4838 38KHz IR receiver, and a NEC format remote control;

Step 2: Install Xilinx ISE 14.2 and Digilent Adept 2.15.3 .

You have to install Xilinx ISE 14.2 in order to modify the FPGA project, and Digilent Adept 2.15.3 to program the FPGA board.

Step 3: Create a Test Program

Create a test program (which will be useful to modify you IR module from Verilog, according to your remote control). Add irreceiver.v and irreceiver.ucf and connect TSOP4838 pins to corresponding constraint ( see irreceiver.ucf and Nexys 3 reference manual).

Load the .bit file to FPGA (with Digilent Adept) and test. NOTE: you will need a NEC format remote control.

Write down the binary values (showed on LEDs) by each button you press. you will need the values to modify the main project ( you have to adjust the code according to your remote control, otherwise local control won't be available).

Step 4: Create the Circuits

Create the circuits from the following schemas and solder components.

More details how to make the H-Bridge : https://www.instructables.com/id/Dual-H-Bridge-L298-Breakout-Board-Homemade/

Connect circuits to power supplies, to FPGA pins ( they are written on the schemas, see reference manual for more details ).

Step 5: Xilinx Project

Open the following project and modify irreceiver module. Synthetize, translate and generate programming file. NOTE: in order for this project to work , you need to obtain Cortex-M0 DesignStart IP core.

Step 6: Install Keil MDK5 and Cortex M0 Processor Support

Step 7: Test the Local Control of the House.

I have put a reference photo of Digilent Adept software. Upload xilinx project .bit file on SPI memory (select SPI flash, at FPGA programming file to flash , browse for .bit file, and then hit "Program") and .bin file from MDK project on BPI memory ( select BPI flash, browse for .bin file, put address 0 at start address, choose Hex, and hit Write) . Test devices, and their local control.

Step 8: Raspberry Pi Setup

Instal raspbian on an SD card.

Raspberry Pi installation

Install sleekXmpp from git repo : sleekxmpp

Install python from repository;

Install pyserial : pyserial

Install Apscheduler from here : https://pypi.python.org/pypi/APScheduler/2.1.2

Step 9: Install OpenFire Server

Install OpenFire XMPP server following this tutorial :

Installation

Configuration

Create at least two users using admin panel : http://localhost:9090/ .

Step 10: Raspberry PI Script Setup

Setup configuration file ( uploaded in archive ).

Step 11: Apache and Website

Setup apache on Raspberry Pi.

Copy the website on the corespondent apache folder.

Step 12: Make Some Final Tests and Enjoy!

Load Xilinx and Keil MDK projects to FPGA boards. Connect the FPGA to raspberry pi (through Nexys 3 USB-UART port). Open a terminal on raspberry pi or connect with SSH or Putty. Browse to the script folder and start python script from the command line with the following command : python script.py -c configuration. Make sure that xmpp and apache are running before starting the script. Take a smartphone, tablet or PC and login to the website (http://[raspberryPi IP address]/[folder of web application]). Login and start testing. (controllers ID must be a list of smart houses IDs separated by comas , e.g. rpi1,rpi2,rpi3 or user1 etc).

If you need any help for configurations and additional steps (until i will upload the final version) do not hesitate to contact me! Thanks for watching and enjoy!

Step 13: Youtube Videos