Since a kid I’ve been passionate about electronic and computers. Previously I’ve done different smallеr 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 didn’t 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 couldn’t believe what just happened and I didn’t 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
react native and connect it via
NodeJS backend. I’m using ImmutableJS’s 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. I’ve 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) I’ve used
pi-blaster library, together with
wiringPi. Good thing about pi-blaster is that it add hardware-like PWM support to any GPIO. Since I couldn’t find codes for my AC, I’ve 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 won’t 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 don’t you take a look?
Raspberry Pi 3 is the controlling unit. High-power devices, such as LED strips, are powered via external
12V 5A power supply (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:
- Node & Npm