FreeSoC2 controlling the AC devices.

It’s time to do something with the 230V AC that is the normal hot line that is powering the appliances in every home, SO our FreeSoC is going to control those gadgets. It can be done from your android mobile wirelessly. It’s an interesting setup that’s requires a 5V relay, the FreeSoC2 board and ESP8266.

So you can start controlling your lights or other things in and around your home with this setup that is going to be demonstrated.

The connections has 230V AC line that is interfered so please be cautious while handling the high potential lines, and use rubber foot wear and make sure that the work bench you use is not a conductive material as a Iron table, so please use insulation mats to avoid shocks and Risk of life. And children who try out this should be assisted by Adults and should not be tried alone.


Make the connections as shown in the above diagram. ie connect the TX and Rx of the ESP8266 to the FreeSoC2 pins P2.0 and P2.1 respectively.

The Relay positive and negative pins are connected to the 5V and the ground. And the signal pin is connected to the P2.4 of the FreeSoC2.

Now connect the Neutral of the line to the common of the Relay and the “NO” which is normally open to one end of the bulb.

Note: try to use the insulated holder and the cables for better protection or you can make out one of your own.

“DONOT TURN ON” any of the AC lines until all the setup is done.

Once after you complete the wiring, then it’s time for programming the FreSoC2

Double click on the workspace file that is attached with the blog, download the code to your system from link below, and extract the code. 

It will open in the PSoC creator software. You can see the screen shot below. (Please install PSOC software)


Now uncomment the lines that are written on the code and change the YOUR_SSID with your Wi-Fi SSID and the YOUR_PASSWORD with your Wi-Fi password.


Now click on the program button that is on the left side of the IDE, which is circled in red color.


Once it is programmed leave the entire setup for 30 seconds plus so that the ESP8266 will get connected to the Access point and will get a IP for itself.

Now again comment the lines that are commented and then program as the above steps.


Go to play store and download the applications that are needed for the setup, you can find the links below.

After this find the IP of the module from the Network IP scanner application so configure the TCP client application with the same IP and the port as 9999.

So once you click on it should connect to the FreeSoC2 module. Send the following command to turn ON or OFF the appliance.

Sno. Command Function Response
1 NL To Turn On the Light The Light is turned on
2 FL To Turn OFF the Light The Light is turned OFF

And that’s all it’s done, you can control your AC devices of your choice and make a smart choice for your switch.

Note:                                                                                                                                                                                                                       ->Check out the rating of your relay that is connected to avoid blasting of circuits.                                     

              -> be sure that you connect a 5V relay if its 9V or a 12 V it will require additional circuits if you connect it                        directly then there are chances that you can cook your I/O port with the wrong voltage

Posted in Dev Boards, IOT and tagged , , , , .