Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WiFiClient.h>
- #include <ESP8266WebServer.h>
- #include <ESP8266HTTPClient.h>
- int Integer = 0 ;
- void sendHttpRequest( String _serverHost,String _name, int _data ) {
- String _send;
- HTTPClient http;
- _serverHost="http://"+_serverHost+"/";
- http.begin(_serverHost);
- http.addHeader("Content-Type", "application/x-www-form-urlencoded");
- _send = _name+ "="+ String(_data);
- Serial.println("- data stream: "+_send);
- http.POST(_send);
- http.writeToStream(&Serial);
- http.end();
- }
- void setup()
- {
- Serial.begin(9600);
- WiFi.begin ( "RESEAU", "12345678" );
- while ( WiFi.status() != WL_CONNECTED ) {
- delay ( 500 );
- Serial.print ( "." );
- }
- Serial.println ( "" );
- Serial.print ( "Connected to " );
- Serial.println ( "RESEAU" );
- Serial.print ( "IP address: " );
- Serial.println ( WiFi.localIP() );
- }
- void loop()
- {
- Integer = random( 0 , 100 ) ;
- sendHttpRequest( "192.168.4.1","Nom",Integer );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement