DWEET.IO ENERGIA TI CC3200(CODE INCLUDED
IOT FREE THINGS
CODE FOR DWEET YOUR ANALOG INPUT DATA TO DWEET SERVER AND SEE VISUALLY
//#include <SPI.h>
#ifndef __CC3200R1M1RGC__
#endif
#include <WiFi.h>
// your network name also called SSID
char ssid[] = "SSID OF WIFI";
// your network password
char password[] = "PSWD OF WIFI";
int status = WL_IDLE_STATUS;
IPAddress server(3,213,104,195); // DWEET.IO SERVER
// Initialize the client library
// Dweet parameters
#define thing_name "jktest"
WiFiClient client;
int temperature=0;
void setup() {
Serial.begin(9600);
Serial.println("Attempting to connect to WPA network...");
Serial.print("SSID: ");
// attempt to connect to Wifi network:
Serial.print("Attempting to connect to Network named: ");
// print the network name (SSID);
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED) {
// print dots while we wait to connect
Serial.print(".");
delay(300);
}
Serial.println("\nYou're connected to the network");
Serial.println("Waiting for an ip address");
while (WiFi.localIP() == INADDR_NONE) {
// print dots while we wait for an ip addresss
Serial.print(".");
delay(300);
}
// if you get a connection, report back via serial:
}
void loop() {
temperature=analogRead(2);
// String urlq="http://static.wixstatic.com/media/34531b_8cbeb3f38b3042bb9f2fc53345277414.png_srz_p_350_195_75_22_0.50_1.20_0.00_png_srz";
if (client.connect(server, 80)) {
Serial.println("connected");
Serial.print(F("Sending request... "));
client.print(F("GET /dweet/for/"));
client.print(thing_name);
client.print(F("?temperature="));
client.print(temperature);
client.print(F("&url="));
// client.print(urlq);
client.println(F(" HTTP/1.1"));
client.println(F("Host: dweet.io"));
client.println(F("Connection: close"));
client.println(F(""));
Serial.println(F("done."));
}
else {
Serial.println(F("Connection failed"));
return;
}
Serial.println(F("Reading answer..."));
while (client.connected()) {
while (client.available()) {
char c = client.read();
Serial.print(c);
}
}
Serial.println(F(""));
delay(3000);
}
Comments
Post a Comment