I have a internet connected IoT device (let's say advanced internet connected weather sensor, which can send sensor data and perform some advanced operations like rotating, switching on, opening valves/and few other operations).
EDIT:
The device is wall powered (electricity socket), and has mobile internet connection standard wired Ethernet connection (just plug in Cat5 cable)
I need to be able to get status (approx 500bytes of data) of the device, AND want to be able to send simple commands like:
rotate-180-deg
turn-lights-on
turn-lights-off
open-valve-1
switch-sensor-X-on
switch-sensor-X-off
Currently my device is sending a HTTP request every (2minutes) to my central server with it's status. This works perfectly for getting readings of the devices sensors. However this approach becomes more problematic when I want to send commands to the devices. Eg. if I want to send command rotate-180-degrees
, my central server has to wait until it is contacted by the device and in the Response for the HTTP request - I can put some command, so when the device receives the response, it will actually execute the command.
However this approach has flaws:
- it is not real time (I have to wait for 2-3 minutes before I have a chance to send a command)
- i do not know whether the command was received by the device or not (eg. in case of network error)
- i do not know whether the device has acknowledged or executed the command (neither the status)
What could be the solutions for this problem?
UPDATE: As @mhopeng suggested, the most flexible solution seems to be turning the device into a "server", so that it can accept incoming connections. However, because the considerations of security, firewalls and complexity we cannot go this way. Also device needs to be simple to install: third party maintenance stuff should be able to simply plug the device into wall and ethernet, and it should work. (No need for configuring port forwarding, firewalls, etc).
FYI We also use PIC microcontrollers in this device.