Hi,
I would suggest looking at ESPEasy platform. It provides connectivity to various relays, sensors and other devices and connect them with well known IoT platforms like Domoticz, OpenHAB, Thingspeak etc.
You can have a look at following GitHub link for their code.
https://github.com/letscontrolit/ESPEasyThingspeak version was quite limiting in their original code so I modified it to achieve more flexibility. You can view my modified plugins at following links:
_C004.ino - Modified Thingspeak Controller Plugin
https://github.com/omair-suria/ESPEasyP ... /_C004.ino_P150_ThingspeakReader.ino - Thingspeak Reader Plugin
https://github.com/omair-suria/ESPEasyP ... Reader.inoIf you use both of these controllers together, you will have following feature:
- Controller Plugin publishes your data to 8 fields on the registered channel. It has the capability of buffering the data received and publishing together as a batch (original version did not provide buffering).
- Reader Plugin will read status from thingspeak to retrieve and execute commands. For example, we can send command like "RELAY,1, 0" (to close Relay 1) or "RELAY,1,1" (to open Relay 1).
I made these plugins for a smart thermostat project I am working on, but have made it available to public if anyone finds it useful.
Coming to your question about controlling the relay from Internet. Thingspeak connectivity will allow you to control your relay and also view the current status (and history) of the relay and other parameters if you are measuring them via Thingspeak channel fields. Thingspeak provides a HTTP API for writing data to its channel, so you can use that to write command to the status field of the channel.
This methodology will only involve creating a free thingspeak account and a channel, and use it directly.
I hope you find this useful.
Cheers!!!