Irwin:
Bonjour,
Je me présente, je fais partie de la startup eGreen et je viens pour vous aider à utiliser notre plateforme pour pouvoir suivre vos consommations
Je me permet de continuer ce topic pour vous dire qu'on a mis en place une doc pour aider à utiliser notre webservice, avec des exemples, nottament avec l'arduino.
Le lien de la doc c'est : http://egreen.fr/wiki/api
Petite information mais qui a son importance, l'utilisation de la plateforme avec vos propres capteurs est gratuite
N'hésitez pas à me poser des questions si vous aves des problèmes d'utilisation, ou si vous voulez plus d'informations
Bonne journée,
Irwin
Bonjour
ça à l'air interessant , mais je vais faire une petite remarque qui peut sembler desagreable , mais ce veut essentiellement constructive
il n'y a rien de plus penible que de recuperer un code exemple qui déjà ne compile pas !
le code pour l'arduino et shield ethernet , ne compile pas (ceci etant , ce n'est pas tres etonnant 8) )
un reflexe naturel peux vite survenir : "attitude pas serieuse, je passe mon chemin"
/*
Web client
This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe, based on work by Adrian McEwen
modified 27 March 2014
by Irwin Lourtet
*/
#include
#include
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
void setup() {
//Initialise variables
String sensor_id = String("YOUR SENSOR ID");
String energy_type = String("electricity");
String api_key = String("YOUR API KEY");
String api_secret = String("YOUR API SECRET");
String rec_date = String("YYYY-MM-dd");
String rec_time = String("HH:ii");
//Compute sig
//Use an md5 library like https://github.com/tzikis/ArduinoMD5
String data = String("apiKey="+api_key+"&sensorId="+sensor_id+"&energyType="+energy_type+"&recTime"+rec_time+"&recDate="+rec_date);
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip);
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect("diy.egreen.fr", 80)) {
client.println( "POST http://diy.egreen.fr/energy/create HTTP/1.1" );
client.println( "Host: diy.egreen.fr" );
client.println("User-Agent: Arduino/1.0");
client.println( "Content-Type: application/x-www-form-urlencoded" );
client.println( "Connection: close" );
client.print("Content-Length: ");
client.println(strlen(data));
client.println();
client.print(data);
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
while(true);
}
}