Build your own Cloud-based Internet of Things!

Big Thanks to my friends in Jelastic (a PaaS Cloud solution) for hosting a short tutorial on how to use their Cloud hosting service for developing an IoT application.

The tutorial presents all essential steps for configuring the Cloud environment and building a J2EE application that can receive sensor readings and visualize them!

For this setup I have used Tomcat and MySQL.

A similar example is presented in the book that utilizes Google App Engine instead.

To send sensor data to the Cloud application all you need to do is instruct your Arduino to invoke a simple web request like this one:

http://sensorcloud.jelastic.servint.net/add?sensor=temp&value=20

The following Arduino code uses the Ethernet Library to do so:

 

#include <SPI.h>

#include <Ethernet.h>

// Enter a MAC address for your controller below.
byte mac[] = {  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
char serverName[] = "arduino.jelastic.servint.net";
// Initialize the Ethernet client library
EthernetClient client;

void setup() {
// start the serial library:
Serial.begin(57600);
//start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
}

}

void loop() {

int temperature = analogRead(0);
String s = String(temperature,DEC);

if (client.connect(serverName, 80)) {
// Make a HTTP request:
client.println("GET /add?sensor=temp&value="+s+" HTTP/1.0");
client.println("Host:arduino.jelastic.servint.net");
client.println();
client.stop();
}

delay(60000);
}

To visualize the data just invoke http://sensorcloud.jelastic.servint.net/?sensor=temp in your browser. You should get a graph like the following:

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>