Problème "WiFly_PachubeClient" - UNO + RN-XV

Bonjour à tous,

J'essaie de configurer mon Arduino UNO et ma carte Wifi "RN-XV Wifly" pour envoyer des données sur Pachube, j'ai essayé avec la librairie "GitHub - jcrouchley/WiFly-Shield: WiFly Shield", ou il y a un sketche dédié pour Pachube "WiFly_PachubeClient". J'ai cette erreur de compilation :

WiFly_PachubeClient.cpp: In function 'void loop()':
WiFly_PachubeClient:70: error: 'client' was not declared in this scope

à propos de la ligne :

// Using Pachube API V2
Client client("api.pachube.com", 80);

Je ne vois pas ou est le problème, est-ce que quelqu'un a déjà rencontré ce problème ou aurait une idée ?

Merci !

Nicolas

Salut, si tu utilises une version 1.0 à mon avis c'est normal le code n'est pas adapté prend une version inférieure.

++

Merci pour ton retour. Donc, la version "1.0" ne prend pas en compte cette ligne de commande d'après toi ?
J'y ai pensé et j'ai testé avec une version "0022", je sais que cela n'a pas fonctionné (je n'ai pas gardé les erreurs pour les poster).
Est-ce que tu penses que je pourrais essayer avec encore une autre version ?

Finalement j'ai pu testé :

Avec les versions "0022" et "0023" : j'ai cette erreur et beaucoup d'autres (1 page complète !)
Avec la version "1.0" , je n'ai que ça :

WiFly_PachubeClient.pde:-1: error: 'Client' does not name a type
WiFly_PachubeClient.cpp: In function 'void loop()':
WiFly_PachubeClient.pde:-1: error: 'client' was not declared in this scope
WiFly_PachubeClient.pde:-1: error: 'client' was not declared in this scope
WiFly_PachubeClient.pde:-1: error: 'client' was not declared in this scope

= ci dessous le sketche

// WiFly Pachube Client
// Send data to a Pachube Feed
// (Based on Ethernet's WebClient Example)
// (based upon Sparkfun WiFly Web Client example)
// Sparkfun WiFly library updated and can be found here
// GitHub - jcrouchley/WiFly-Shield: WiFly Shield
// Built using Arduino IDE V0.22

#include "WiFly.h"

// using NewSoftSerial V11 beta
// downloaded from here NewSoftSerial 11 (beta) | Arduiniana
// this will be included as Software Serial in Arduino IDE 1.0
#include <SoftwareSerial.h>

// Wifly RN-XV (XBee shaped) module connected
// WiFly Tx to pin 2 (SoftSerial Rx)
// WiFly Rx to pin 3 (SoftSerial Tx)
SoftwareSerial mySerial(2, 3);

// Edit credentials.h to provide your own credentials
#include "Credentials.h"

// Using Pachube API V2
Client client("api.pachube.com", 80);

void setup() {

pinMode(8,OUTPUT);
digitalWrite(8,HIGH);
// lots of time for the WiFly to start up and also in case I need to stop the transmit
delay(10000);

Serial.begin(115200); // nice and fast
mySerial.begin(9600); // default WiFly baud rate - good enough for this

WiFly.setUart(&mySerial); // Tell the WiFly library that we are not using the SPIUart

Serial.println("Wifly begin");

WiFly.begin(); // startup the WiFly

Serial.println("Wifly join");

// Join the WiFi network
if (!WiFly.join(ssid, passphrase, WEP_MODE)) {
Serial.println("Association failed.");
while (1) {
// Hang on failure.
}
}

}

uint32_t timeLastUpdated;
int i;
char buff[64];

void loop() {
if (millis() - timeLastUpdated > TIMETOUPDATE)
{ // time for the next update
timeLastUpdated = millis();

// prepare the data to send
// format (API V2)
// multiple lines each with ,
// feedID can be the datastream name of the numberic ID
sprintf(buff,"0,%d\n1,%d",i++,analogRead(0));
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.print("PUT /v2/feeds/"); // APIV2
client.print(PACHUBEFEED);
client.println(".csv HTTP/1.1");
client.println("Host: api.pachube.com");
client.print("X-PachubeApiKey: ");
client.println(APIKEY);

client.println("User-Agent: Arduino (WiFly RN-XV)");
client.print("Content-Type: text/csv\nContent-Length: ");
client.println(strlen(buff));
client.println("Connection: close");
client.println();

client.print(buff);
client.println();

} else {
Serial.println("connection failed");
}

delay(2000);
while (client.available()) {
// TODO verify success (HTTP/1.1 200 OK)
Serial.write(client.read()); // display the result
}
Serial.println();

if (client.connected()) {
Serial.println("disconnecting.");
client.stop();
Serial.println("disconnected.");
}
}
}

Bonjour

j'utilise pratiquement la même configuration avec la version 0.23 d'Arduino sous XP, sans probleme de compilation :
carte compatible UNO + module WiFi RN-XV + librairie "jCrouchley" de décembre 2010 + DS18S20 --> Pachube
ça doit passer en 0.22, il faut revoir les messages d'erreur
ci joint mon fichier pde test

Wifly_PachubeTempLogger.pde (3.25 KB)

Bonjour,

La librairie Wifly que tu nous link est faite pour supporter l'ide arduino 1.0 (depuis le 5janv d'aprés le changelog de github).
Le développeur en charge de la librairie a mis à jour la librairie mais pas les exemples, comme le prévois l'api arduino 1.0 il n'y a plus de classe client, à la place il y a (dans ce cas) WiFlyClient.
Il faut donc remplacer Client par WiFlyClient sinon ça ne compilera pas :wink:

OK, merci pour ton aide, je vais retester !

Merci également, skywodd, pour cette info sur la mise à jour de la librairie WiFly
peu à peu mes 'attaches' côté 0.22/0.23 disparaissent !!!

+Petites photos des essais d'amélioration d'antenne, car l'antenne 'fil' du module RN-XV le plus courant est très insuffisante..... une bonne dizaine de dB perdus !!

Le module WiFi RN-171 surclasse à mon avis nettement le module Microchip qui équipe les Wishield/Blackwidow : fonctionnalités, protocoles pris en charge (le SMTP arrive), documentation idéale, mise à jour du module directement en FTP... 2 mises à jour depuis la fin décembre...

http://www.rovingnetworks.com/products/RN_171
Pour ne pas avoir à souder le module cms je me suis rabattu sur sa version 'montée XBEE'
http://www.rovingnetworks.com/products/RN_XV (20£ hors taxes autour de Noel chez ciseco.co.uk)

Si en plus les librairies Arduino suivent !!!

antenne Fonera.jpg

pigtail.jpg

Avec "WiFlyClient" ça marche nickel sur la version "1.0", merci beaucoup !!

Entre temps, j'ai carrément demandé au concepteur du script son avis, et il confirme

John Crouchley


The examples have not yet been updated for Arduino 1.0
Where you have a line that says
Client client("api.pachube.com", 80);
Change it to
WiFlyClient client("api.pachube.com", 80);

Best regards
John

C'est vrai que le RN171 est très pratique à utiliser. En plus les mises à jour du firmware sont assez fréquentes, et il a beaucoup gagné en stabilité et en fiabilité au cours des derniers mois :slight_smile:

en plus pas trop cher, les docs disponibles sont nombreuses....