UNICON - True Home Automation Controller
by PADMALAYA RAWAL in Circuits > Microcontrollers
825 Views, 16 Favorites, 0 Comments
UNICON - True Home Automation Controller
So, when it comes to controlling home appliances we usually smartphone as the only option because it has Bluetooth and wifi inbuilt, right? You picked up your smartphone to control an appliance, pin pong! New Instagram notification and you got distracted. So, an appliance control has converted into a regret. Sounds familiar, right?
But not anymore, introducing UNICON, a truly portable and rechargeable home automation controller that allows you to control appliances. But that's not it, it can simultaneously control appliances of multiple rooms. In this build, we will control 1 appliance of two different rooms, but you can extend it further as per your needs. ENJOY!
Supplies
- UNIHIKER - 1Pc
- ESP32 C3 Mini (or any other ESP Board) - 2Pcs
- Wireless charging coil - 1Pc
- TP4056 module - 1Pc
- Slide Button- 1Pc
- Boost converter - 1Pc
- LEDs (Just for prototype) - 2 Pcs
- Potentiometer (Just for prototype) - 2Pcs
- Brass threaded inserts(M3*6mm) - 3 Pcs
- Allen Countersunk screws(M3*6mm) - 3 Pcs
- Circular Magnets(8mm * 1.3mm) - 8 Pcs
- USB C breakout - 1 Pc
- Relay Module (Single channel) - 2 Pcs
- LM35 Temperature sensor - 2 Pcs
Prototyping Setup
But why to prototype? This is to save time debugging at the later stages. As it is the crude form of our project so it allows to make changes faster. We will first begin by prototyping our setup on a breadboard to meet our expectations. For prototyping, I am using two ESP32 boards with one LED and one potentiometer connected to both of them. But why?
I want to keep the prototype as simple as possible and wanted to test out whether I can trigger a digital device connected to one pin that will later act as a relay controller, along with whether I can receive analog value from the ESP32 board connected to an analog pin on the UNIHIKER which will later act as Temperature sensor(or any other analog sensor of your choice)
Here, I am using one ESP32 WROOM Dev board and one ESP32 C3 Mini Bettle. You can use any of the ESP32 and they should work fine too. Here are the connection diagrams that I am following for this prototype setup.
Firmware Development
Here is the firmware for the ESP32 development boards and the UNIHIKER board. I tried to add comments as much as I could so that you can understand why I did what I did.
What's the difference between the two codes for ESP32s?
Difference 1:
In Line 11, 1st code has
IPAddress local_IP(192,168,1,51); // Set your static IP
Whereas the 2nd code has
IPAddress local_IP(192,168,1,50); // Set your static IP
Difference 2:
In Line 18, 1st code has
const int sensorPin = 34; // change to pin on which your connecting sensor
whereas the 2nd code has
const int sensorPin = 1; // change to pin on which your connecting sensor
Also, please don't forget to change the Wifi credentials in both the codes
const char* ssid = "Padmalaya Rawal"; //Change with your WiFi Name
const char* password = "PureCon"; //Change with your WiFi Password
Replace the name “Padmalaya Rawal” with the name of your WiFi and “PureCon” with the password. And now it's time for UNIHIKER. Now let's have a look at the UNIHIKER's firmware which is written in Python.
Note that the IP address in lines 15 and 16 is the same as we added in Code 1 and Code 2. If you wish to change it, make sure to do it all the mentioned lines in all 3 codes to avoid any errors.
Firmware Uploading
You can skip this step if you have already completed the ESP32 boards set up in ARDUINO IDE, but if not, stick with me, this is to make your life easier. Follow along:
1. Download Arduino IDE from https://www.arduino.cc/en/software as per your machine(PC).
2. Simply follow the instructions and install it. Once installed, fire it up
3. ESP32 boards setup, add the below link in preference:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
4. Install ESP32 boards from the boards' manager
6. Select board - DF ROBOT bettle and upload code
7. Select board - ESP32 Dev board and follow the above steps again, press boot button when the code starts uploading (not compiling) or you can add a 10uF cap b/w GND and EN pin.
UNIHIKER SETUP:
Now Let's set up UNIHIKER, there are various methods by which you can program UNIHIKER but the one that I prefer needs the least time to start uploading code. I hope you don't want to skip this step because there is not much detailed tutorial available on UNIHIKER that can guide you through.
1. Connect UNIHIKER board to your PC via TYPE-C data cable included in the package.
2. Once UNIHIKER booted up, visit http://10.1.2.3 in your browser that will open up the following window:
3. Go to Network settings and add your Wi-Fi credentials. This will allow UNIHIKER to connect to the network. Make sure it's the same Wi-Fi as used in ESP32 codes, else it won't work.
4. Now go to toggle service and click “Open Page” under Jupyter section
You will see the below page:
5. Let's make a new python file, rename it and upload the code to UNIHIKER.
Click here to rename the file.
In the highlighted section, we will write our code.
Now copy and paste the code mentioned above and after pasting the code & renaming the file it should look something like this. Notice that, “NOT CONNECTED” should not appear on the top, it indicates that UNIHIKER is not connected with your PC. If it appears, double check that you are using Data cable (preferably the one included in the kit) not the power cable. Once verified, hit “NOT CONNECTED” Label and it will connect successfully which in indicated in next image.
6. Now in a new tab open the below homepage, you can follow the steps listed above and upload DF ROBOT logo named as "logo.png" using the button as shown below. Once uploaded, move back to the previous tab.
Download this image and rename it as “logo” and it should be in .png extension:
7. Hit the “RUN” button and boom, you will see UI on UNIHIKER. You will be able to control the LED on both ESP32s and also you will see values changing if you rotate the potentiometer.
Final Schematic Explanation
DO NOT MISS THIS STEP ELSE IT MIGHT BURN UP YOUR UNIHIKER
If you are using the same Boost convertor Module, make sure to remove resistors A and B to get 5V on output.
When the receiver coil is energized by the transmitter coil, it begins charging the battery via the TP4056 charging module. When the button is turned on, it turns on the boost converter and powers up UNIHIKER. Please do not connect cable to UNIHIKER When it is powered by battery else you may end up burning your UNIHIKER board.
CAD & 3D Printing
The CAD is designed using Fusion 360 and the whole project is divided into two parts, one is the UNIHIKER case and the other is the charging Dock. The parts are designed in such as way that you don't need to waste a single gram of filament on support material. I used Black PLA+ filament for all the parts.
Important Specs that you might for setting up your 3D printer:
- Printer: AnyCubic Kobra Neo
- Layer height: 0.2mm
- Nozzle Size: 0.4mm
- Slicer: Prusa Slicer
- Infill- 60%
- Support - No
- Print one part at a time - yes
Here are all the 3D-printed parts needed for this build
Assembly
Remember to solder the sufficiently large wires so that you can open the LID without breaking connections but not too much because that might reduce the current delivered to UNIHIKER. Here is the assembled view of the UNIHIKER Case. Place the 2 mounts and screw them in place before closing the LID. I have kept the tolerance of the Case LOW so that the LID can stay in place without the use of any screws or glue.
Final Look & Working With Prototype Setup
Here is the final look of our project:
Final Implementation
for the final implementation, replace LED with a relay module and potentiometer with LM35 temperature sensor by following the below circuit diagrams. If you want to use any other sensor instead of LM35, make sure to change the code on all three devices by adding the required libraries.
There is no change required for UNIHIKER. I have installed this setup in the switch box of two rooms at my home.
Conclusion and Future Improvemts
In a world full of distractions, UNICON will help you to stay distraction-free while staying smart. Control and monitor multiple rooms of your home, office, or arsenal altogether just at your fingertips. This is what we call the true smart home automation setup.
Future improvements
The device can be made even more compact by replacing all the modules with a custom-designed PCB. Also, I have planned a lot of features for the next version which are as follows
1. When the USB is plugged in, UNIHIKER should not be powered by the Boost converter
2. When USB is not connected, UNIHIKER should be powered by a Boost converter
3. When UNIHIKER is on the charging Dock, UNHIKER should not be powered by a boost convertor instead it should be powered by a Wireless coil.
4. When UNIHIKER is on the charging Dock, and USB is plugged in, it should only be powered by USB cable while the battery keeps on charging via Wireless charging.
5. Addition of more buttons to control more appliances
6. Addition of more room controls and a drop-down menu to select the room
7. Sleep mode, shutdown screen to save power when the device is inactive for a specific time and wakes up when the device is moved which is detected by the inbuilt IMU.
We have just scratched the surface, possibilities are endless.
Happy Learning!