This project forms part of a larger project for an automation system and was modified to demonstrate the underlying communication concepts used to control the system. The project demonstrates how to set up and ESP32 (XinaBox CW02) as a server with multiple ESP8266 (XinaBox CW01) clients. The software can easily be modified to accommodate various sensors and outputs to be connected to this system with as many clients as the WiFi Access Point can handle.
As a demonstration I set up this system to use a LM75B Temperature Sensor (XinaBox SW10) as a sensor client and a Solid State Relay (XinaBox OC03) as an output client. The server gathers the temperature data from the SW10 client and sets the output of the OC03 on/off according to a pre-defined temperature set-point.
The CW02 server also acts as an WiFi Access Point (AP) for the clients in order to create an isolated system. The software can easily be modified to connect to your home WiFi instead.
What you will needApart from the set of xChips, you will need Arduino installed and the following libraries downloaded from GitHub.
- ESP8266 Board Driver from Arduino Board Manager
- ESP32 Board Driver from Arduino Board Manager
- xCore (XinaBox Library)
- xOC03 (XinaBox Library)
- xSW10 (XinaBox Library)
Click in an IP01 xChip onto the CW01 or CW02 using an XC10 connector and plug into a USB port on your computer. Connect as shown in the picture below.
Open Arduino and under Tools select Board: "XinaBox CW01" and set the rest of the settings the same as in the picture below, select the correct COM port, then upload the sketch, which I will provide in the code section of this page. You can repeat these steps to program the CW02 by selecting the "XinaBox CW02" in the board drop down and keeping the default settings.
The xChips make this step very easy, simply click them together with the XC10 connectors until the CW02 server unit and two CW01 client units match the picture below.
The only thing to bare in mind, the small XinaBox logos with chip name must all face the same direction, the bus at the top and bottom of the board are NOT the same. Usually the boards have a large logo at the bottom.
Connect the three units to any from of USB power and watch the system come to life. The green LEDs on each unit will indicate that the WiFi connections are active.
If you quickly want to see how it works, you can hold your finger on the temperature sensor and the Output Status LED on the OC03 will light up after a little while (Temperature lag at play). The default set-point is set to 25 degrees Celsius and can be changed in the code.
You can make this system functional by connecting a fan to the OC03 and control the temperature of something around your home.
Future PlansIn near future I plan to implement either a UDP channel to communicate with the clients from the server or move over to a mesh network. This should drastically reduce the communication turn-around time of the system.
Comments