In this post I want to show my current status of the project and what I achieved. Below you able to see my main screen of home control panel, the similar screen also available through mobile phone and I can manage my home devices remotely through internet. Wow, future is here!
As a many others enthusiasts I’ve started my game from existing hardware solution and I bought couple of Sonoff modules from China.
When I received my modules I even didn’t want to use their solution and immediately flashed them to NodeMCU and then uploaded my Lua code. They worked stable and switched my floor lamps in the house, but using NodeMCU I wasn’t able to use reliable Over The Air (OTA) updates and also was hard to bring easy way to initial setup of the device. Finally I decided to switch to native C and Android Studio, it was simple for me as I have huge experience in different programming languages.
Now those devices works on my own firmware, have initial mode to setup them and connect to MQTT server. The button on device allows manually switch light if you are not able to use application. The same button is using to clear settings of device and make initial setup again in cases when you changed your MQTT server or WiFi credentials.
Here is an Arduino code
This is working IoT project that allows me manage 8 relays and each relay can switch my outside lights in the garden.
First of all I started to use NodeMCU framework and Lua as programming language but after some period of time I’m stuck with some restrictions of the framework and I decided to switch to native C code using Arduino Studio. Native C code allows you do more magic things instead of NodeMCU, also you can control memory consumption more efficiently.
So, current implementation has initial mode when ESP8266 chip works as Wi-Fi access point and you able to configure module to connect to your home Wi-Fi network and MQTT server. After configuration will be set this module will be rebooted and it starts listening messages from your MQTT server. This solution uses all possible GPIO outputs in ESP8266.
Please remember that ESP8266 works at 3.3V but relays have to use 5V. I put there also transistors and LEDs to see when relay is switched ON or OFF.
Here is a full code of solution.
Some time ago I decided to start my own home automation project to manage most of devices in my home. At that point I didn’t know a lot about technologies, protocols and other things around. I also didn’t know what I have to automate and where I will have technical, software or any other restrictions.
Now I understand much clearly what I want to do and how it should looks like, this way wasn’t simple and I spent a lot of nights without sleep, but now my picture is sharp as 4K video, this is a result of many my personal mistakes. I’d like to share my achievements with enthusiasts like me and any other people who have interests in this area.
Let me roll the film one year back of this project. Continue reading “Starting home automation project”