Introduction: No PCB WiFi Smart Switch W/ ESP8266 and Ubidots
I know that a well done electronic project needs it own PCB to assamble it. In the best-case scenario we can afford a custom PCB order from a company as JLCPCB as an examble, but this is not always the case, sometimes we are just trying to build a prototype that we consider do not need a PCB to do what it meant to do, and we need it for now so we don't have time to waiting things to arrive.
That's why I consider that knowing that we can replicate or build our projects with Perfboards is important, so I build this tutorial to show you how do I made my Perfboard version of a PCB project that I've done years ago.
If you are a visual learner I know that a video worth more than 1000 words, so here is a Tutorial video. (I am a Spanish speaker, so please consider turning on English subtitles):
Hope you to enjoy the project!.
Step 1: Skills Needed
As you could noticed, nothing looks very difficult on this project, but you will need some basics knowings about:
-Using the Arduino IDE.
-Welding.
-Wiring.
Disclaimer: notice that this project works with main voltajes, please don't do anything if you don't know how to handle this securetely.
Step 2: Components and Parts List
A good place I can recommend to find your components, it's MakerFocus, it's an Open Source Hardware Store!
Step 3: Circuit Diagram
The circuit is simple, it has the ESP8266 connector, that has all the resistors to set up the ESP on boot mode. The Triac Switching stage that handle the main voltajes and the current of the load to control, and the Power Supply that converts 120-220Vac to 3.3v DC to power up the ESP8266.
Schematic PDF attached.
Step 4: Circuit Assembly on Perfboard
The thing with this project is to use a perfboard to assemble it, I usually use custom PCBs made by JLCPCB as you can notice on my other projects, so lets get through this.
- Clean the surface of your perfboard with sandpaper.
- Place the components and solder their pads.
- Make the connections with a strip of wire in the digital stage (low voltage).
- Make the connections with an isolated wire in the Power Stage (Main Voltage).
- You are done.
If you want to build the PCB version of this project you can order it on JLCPCB, they manufacture really fast and best quality in the market Printed Circuit Boards:
Step 5: Programming the ESP8266 and Testing
To properly program our ESP8266 we need a USB to TTL interface, it could be an Arduino (w/o the atmega), or a USB to TTL converter, in my case I made my own USB to TTL adapter circuit to program specifically the ESP8266, you can see it here and make yours:
First of all, create your Ubidots Account (could be the STEM free student version).
- Open the code (Download here).
- Select the ESP8266 Board.
- Select the right COM port.
- Set your Ubidots Token in the Code.
- Set your WiFi credentials.
- In this case the device name is "wifiswitch" (you can change this).
- The variable that is controlling the switch is called "light"
- The output pin of the ESP8266 is the GPIO0.
- The input pin for the external push button is the GPIO2.
Once you program your ESP8266, test it, verify it connectivity to the network and use the Serial Monitor to see if it subscribe properly to the device "wifiswitch" and the variable "light" and show you every detail as you can see in the picture attached.
Step 6: Ubidots Settings
If you have turned on your esp8266 and it connects properly to the internet, it should create automaticaly the device and the variable on your Ubidots account, if not, you can create them manually.
Now is time to create a dashboard and put a button widget on it to control the light.
Go to Data>Dashboards:
Create a new Dashboard, name it as you want, click on add a widget, select the switch option, select the variable "light" of the device "wifiswitch" and done.
Step 7: Wiring and Test It
Warning: make all the connections without energy.
Look at the first picture and make the wiring this way. Line, Neutral, Load (Neutral is shared).
Connect the power cord to the outlet.
Wait the wifi connection and test it.
When you push the switch on Ubidots your light bulb should change it state.
Step 8: App Control and Final Test
Go to PlayStore and search for "MCM-Switch", download it.
Open the app.
Go to settings.
Select the Industrial version (Also if you have STEM, select the Industrial).
Paste your Ubidots Token, and write the device name "wifiswitch".
Save it, and go back to the main interface.
Now you must be able to control your light just by clicking on the button and you should see the real feedback on your light bulb app color.