Create your first object connected to the Cloud

adminIoT1 Comment

Let’s connect the thing

Add a “System.Http” reference to the Gadgeteer project.

Make the following modification to the existing code:
– Declare variables for the connection state, the Timer and the web server URL
– Initialize the network adpater
– Create a Timer to execute code at regular interval.

When the network adpater network address change, update the status of the connection.
Each time the timer event is fired, we create a web API call to get the desired state of the LED.

When the button is pushed, we make an web API call to update the state of the LED on the server.

Add a “LightOn” property. Each time we change its value, the LED module is updated

Congratulation, you made it \o/ Open the web site on any smartphone, tablet or PC. The Switch button should light on/off your device .

Your project should look like this.

For those who want to go a little further and enhance this very simplistic example, I’ll give you some improvement ideas.

Related posts

  • Hello, it’s the first time I see something like:
    LightOn = s == “true”;
    What does that do exactly? Does this coding trick has a name? (in order to search for it on Google…)?
    Thank you