There is a large class of applications known as IoT (Internet of Things) when the hardware connects to the Internet to send or receive data from some server. For example, log the temperature and moisture for smart greenhouses, get the current time, weather, send third-party service API request, and so on.
In this chapter, we are going to fetch the current date/time from the XOD Cloud API.
The xod-cloud/basics/now
node sends a request to the XOD Cloud, parses the response, and outputs it as a datetime
type value.
This node has an input pin INET
. This pin has to be connected to an internet provider. The Internet can be provided:
Note, we’ve placed a select
node here to get a reasonable value until we receive the result from the cloud. Otherwise, we would get a default datetime value, which is equal to 1970-01-01 00:00:00
, and it might be confusing.
Update the current datetime value by sending pulses.
tweak-pulse
node.INIT
pinwatch
node properly, you need to provide the third possible value "Waiting pulse"
. Drag the handle of the select
node to the right to add one more pair of input pins"Waiting pulse"
and “On Boot” to the latest pair of pins.tweak-pulse
to the S2
pintweak-pulse
node.