Revision: 49599
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 26, 2011 06:16 by parkerkrhoyt
Initial Code
#include "WiFly.h" #include "Credentials.h" Client client( "ketnerlake.com", 80 ); int looped = 0; void setup() { Serial.begin( 9600 ); WiFly.begin(); if( !WiFly.join( ssid, passphrase ) ) { Serial.println( "Association failed." ); while( 1 ) { // Hang on failure. } } } void loop() { String data = "data=$,WEATHER,79.5,51,59.7,29.366,2.8,0.0,270,0.00,0.00,*"; if( client.connect() ) { Serial.println( data ); client.println( "POST /sensors/intercept.cfm HTTP/1.1" ); client.println( "Host: www.ketnerlake.com" ); client.println( "Content-Type: application/x-www-form-urlencoded" ); client.println( "Connection: close" ); client.print( "Content-Length: " ); client.println( data.length() ); client.println(); client.print( data ); client.println(); } delay( 5000 ); }
Initial URL
Initial Description
This snippet will send an HTTP POST from an Arduino using the WiFly library. The library is in early alpha, and is a port from the ethernet shield library. The code here should work with either. The critical part is the size of the data to send, and the line-breaks in the right places.
Initial Title
HTTP POST from Arduino (WiFly Library)
Initial Tags
http, post
Initial Language
C