code with Arduino platfrom
//ARDUINO 1.0+ ONLY
#include <Ethernet.h>
#include <SPI.h>
#include "DHT.h"
#define DHTPIN 3 // what pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
const int analogInPin = A0;
////////////////////////////////////////////////////////////////////////
//CONFIGURE
////////////////////////////////////////////////////////////////////////
byte server[] = { 192,168,137,1 }; //ip Address of the server you will connect to
IPAddress ip(192,168,137,11);
//The location to go to on the server
//make sure to keep HTTP/1.0 at the end, this is telling it what type of file it is
String location = "88339D61-2FFF-41BF-B35A-9C70E85E80A4?value=12000&text=this%20is%20a%20message HTTP/1.0";
String TokenTemp="88339D61-2FFF-41BF-B35A-9C70E85E80A4?value=";
String HttpTemp="&text=this%20is%20a%20message HTTP/1.0";
String TokenHumidity="866956B7-7885-4783-9ED8-251F9754CD33?value=";
String HttpHumidity="&text=this%20is%20a%20message HTTP/1.0";
String L3="";
// if need to change the MAC address (Very Rare)
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
////////////////////////////////////////////////////////////////////////
EthernetClient client;
char inString[32]; // string for incoming serial data
int stringPos = 0; // string index counter
boolean startRead = false; // is reading?
void setup(){
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
digitalWrite(2, LOW);
digitalWrite(4, HIGH);
Ethernet.begin(mac, ip);
Serial.begin(9600);
}
void loop(){
float h = dht.readHumidity();
// Read temperature as Celsius
float t = dht.readTemperature();
// Read temperature as Fahrenheit
//float f = dht.readTemperature(true);
Serial.println("connecting...");
//port 80 is typical of a www page
if (client.connect(server, 5050)) {
Serial.println("connectedt");
client.print("GET ");
L3 =TokenTemp+t+HttpTemp;
Serial.println(L3);
client.println(L3);
L3="";
//client.print("&text=this%20is%20a%20message HTTP/1.0");
//client.println(location);
client.println();
client.stop();
client.flush();
Serial.println("disconnecting.");
//Connected - Read the page
//return readPage(); //go and read the output
}else{
Serial.println("connection failed");
}
if (client.connect(server, 5050)) {
Serial.println("connectedh");
client.print("GET ");
L3 =TokenHumidity+h+HttpHumidity;
Serial.println(L3);
client.println(L3);
L3="";
//client.print("&text=this%20is%20a%20message HTTP/1.0");
//client.println(location);
client.println();
client.stop();
client.flush();
Serial.println("disconnecting.");
//Connected - Read the page
//return readPage(); //go and read the output
}else{
Serial.println("connection failed");
}
//Serial.println(pageValue); //print out the findings.
delay(2000); //wait 5 seconds before connecting again
}