Home Automation With Raspberry Pi

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Home automation with Raspberry

Pi, Node and React


J U N E 2 4 , 2 0 17
R A S P B E R RY P I J AVA S C R I P T N O D E J S R E A C T H O M E
A U T O M AT I O N H A R D WA R E

Introduction
Since a kid Ive been passionate about electronic and computers.
Previously Ive done different smallr projects with arduino, like handbrake
for my gaming steering wheel, custom LED tachometer for my car, voice
controlled LEDs, flower watering system. Few months ago I bought
Raspberry PI 3 and around all the IoT hype, I started automating my home.
In the begining I didnt even thought about making it public, but in the end
I uploaded the source to Github. After most of my to-do list was done, I
posted a link from my github repo to my facebook wall and 2 times in
reddit, then I went to sleep. When I woke up in morning, I already had
about 100 github stars with over 50 upvotes on reddit and few of my
friends gave really position feedback about it. By the end of the day the
stars were over 300 and suddenly they started increasing on each refresh
and few minutes later, one of my co-workers told me that my project is 3rd
on the Hacker News homepage. When I woke up next morning there were
over 2000 stars, I found many positive emails in my inbox and bunch of
comments on every post. After that my project led github trending for 3
sequential days. I basically couldnt believe what just happened and I
didnt even intend to share my code in the begining. By the time I write
this post my Github repository has over 2500 stars, 129 forks and over
500 upvotes in the reddit posts combined.
(video at bottom)

The Technology Stack


Since Im pretty familiar with javascript and its ecosystem I decided to
create my own phone app via reactnative and connect it
via websockets to NodeJS backend. Im using ImmutableJSs Records for
consistency of the data structure and the performance of the mobile app.
The data is transferred between the client and the server via JSON strings,
which are converted back to Immutable records, when received on both
sides. Ive separated the shared modules(between client and server) to a
separate local npm packages - home-records and home-config. For GPIO
controlling (pins of the raspberry) Ive used piblaster library, together
with wiringPi. Good thing about pi-blaster is that it add hardware-like PWM
support to any GPIO. Since I couldnt find codes for my AC, Ive recorded
them by myself and added them to lirc config file. Duckdns (with 5 minute
cron) is used as dynamic dns, because my IP address changes periodically
and I wont have to recompile the whole app or change config each time.
The server broadcasts the changes to all connected users in realtime. The
phone app is located in /phone-app folder, the server is located in /server.
Why dont you take a look?

The Hardware
RaspberryPi3 is the controlling unit. High-power devices, such as LED
strips, are powered via external 12V5Apowersupply (shared ground with
the PI). The AC is controlled via 950nm infrared LED. The heating system is
wired via relay (on and off) and servo for the thermostat as I was avoid
disassembling. Both white LED strip and the RGB strip are connected
via IRLZ34N logical transistors to the PI. There is also IR receiver, just in
case I want to record anything else. Temperature is measured via DS18B20
temperature sensor.
The wiring looks like:
Software dependencies
o Node & Npm
o Pi-Blaster
o WiringPi
o Lirc

Video

You might also like