Lets create a mobile app to control our relay. To develop multiplatform application we will use Xamarin. Why? Because I have no idea how it works and I want to try 🙂
Our software must support 4 actions, toggling on and off both channels. To make layout as simple as possible lets stick with four buttons. I used xaml to create UI, it is a file which describe layout and widgets. I’m not sure what is better: write UI in code or use xaml.
Pressing one button will broadcast a JSON message with our event.
Xamarin has few types of application. Today Forms Portable is my choice for project.
I wont digg into installing Visual Studio and Xamarin or setting phone to developer mode. It is easy to find on the net.
Another update today:) Once again update to new boilerplate. After this new main.lua is only 25 lines long (including empty rows:P)
Instead of decoding and validation we call one function:
message = network_message.decodeMessage(message)
Get new code from GitHub
Live forced me to create a light switch controlled via phone. My mom needs one. It is also a good opportunity to play little more with ESP.
We will work on circuit and software. Last time we use ESP as a client broadcaster (to control Piader), this time we will use it as a server.
How to power this ? This time it is not a prototype and it should quickly be installed. We will take power for chipset and relay from 5V charger. This time I’m using NodeMCU v3. Why v3? Because it has one important difference comparing to v2. One pinout is 5V from USB. This is what we need to power coil. To power optotriac we will use GPIO.
As software goes we will start from boilerplate and add UDP server. This one will listen to broadcast packets and respond to defined events.
Get source code from GitHub