Sending data to Thingpseak using Wifibee

Hi,

long time since I asked before…
I have Uno, Mega , and Nano…
I would like to collect data from sensors ( mainly sht10 and am2301 ) and send the sensor values to Thingspeak api server.
I have checked thinsgpeak offical lib here:

I have Tinysine Wifibee and xbee shield:
http://www.tinyosshop.com/index.php?route=product/product&path=65_107&product_id=640
http://www.tinyosshop.com/index.php?route=product/product&product_id=681
Configuring the wifibee itself is not a problem.

How can I send data to thingspeak server with this wifibee?

I haven’t tested but with Ethernet it should look like this:

#include "ThingSpeak.h"
#include <SPI.h>
#include <Ethernet.h>
#include <SHT1x.h>
#include <dht.h>

#define codeVersion 1 

//sht10 definitions
int sht10temp;
int sht10humid;
#define dataPin  12
#define clockPin 13
SHT1x sht1x(dataPin, clockPin);

//AM2301 definition
#define DHT21_GARAZS_PIN 41
#define DHT21_KAMRA_PIN  42
#define DHT21_ASZALO_PIN 43
dht DHT_GARAZS;
dht DHT_KAMRA;
dht DHT_ASZALO;

int kulter_ho;
int kulter_para;
int garazs_ho;
int garazs_para;
int kamra_ho;
int kamra_para;
int aszalo_ho;
int aszalo_para;

int ledPin = 10;

unsigned long MINUTE = 60000UL;

unsigned long szenzorjelen = 0;
unsigned long szenzormult = 0;
const unsigned long szenzoridozites = 1UL * MINUTE;

unsigned long thingspeakjelen = 0;
unsigned long thingspeakmult = 0;
const unsigned long thingspeakidozites = 5UL * MINUTE;


//ethernet definitions
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
EthernetClient client;

//thingspeak definitions
unsigned long myChannelNumber = 123456789;
const char * myWriteAPIKey = "XXXXXXXXXXXXXXXX";


//**************************SETUP*****************************
void setup() {
Serial.begin(9600); 
Ethernet.begin(mac);

Serial.println(F("IP: "));
Serial.print(Ethernet.localIP());
if (!Ethernet.localIP())
digitalWrite(ledPin, LOW);
else digitalWrite(ledPin, HIGH);
  
ThingSpeak.begin(client);

pinMode(ledPin,OUTPUT);     
digitalWrite (ledPin, LOW); 

Serial.println(F("CodeVersion="));
Serial.print(codeVersion);
}


//**************************LOOP*****************************
void loop() {

szenzorolvas();
thingspeak();
}

//*******************************************ROUTINES,FUNCTIONS*************************************************

void read_kulter(){
kulter_ho = sht1x.readTemperatureC();
kulter_para = sht1x.readHumidity();
Serial.println(F("kulter_ho = "));
Serial.print(kulter_ho);
Serial.println(F("kulter_para = "));
Serial.print(kulter_para);

ThingSpeak.setField(1,kulter_ho);
ThingSpeak.setField(2,kulter_para);
}

void read_garazs(){
  Serial.print(F("DHT21-GARAZS, \t"));
    int chkgarazs = DHT_GARAZS.read21(DHT21_GARAZS_PIN);
    switch (chkgarazs)
    {
    case DHTLIB_OK:
        Serial.print(F("OK,\t"));
        break;
    case DHTLIB_ERROR_CHECKSUM:
        Serial.print(F("Checksum error,\t"));
        break;
    case DHTLIB_ERROR_TIMEOUT:
        Serial.print(F("Time out error,\t"));
        break;
    case DHTLIB_ERROR_CONNECT:
        Serial.print(F("Connect error,\t"));
        break;
    case DHTLIB_ERROR_ACK_L:
        Serial.print(F("Ack Low error,\t"));
        break;
    case DHTLIB_ERROR_ACK_H:
        Serial.print(F("Ack High error,\t"));
        break;
    default:
        Serial.print(F("Unknown error,\t"));
        break;
    }
garazs_ho=DHT_GARAZS.temperature;
garazs_para=DHT_GARAZS.humidity;
Serial.println(F("garazs_ho = "));
Serial.print(garazs_ho);
Serial.println(F("garazs_para = "));
Serial.print(garazs_para);

ThingSpeak.setField(3,garazs_ho);
ThingSpeak.setField(4,garazs_para);
}

void read_kamra(){
  Serial.print(F("DHT21-KAMRA, \t"));
    int chkkamra = DHT_KAMRA.read21(DHT21_KAMRA_PIN);
    switch (chkkamra)
    {
    case DHTLIB_OK:
        Serial.print(F("OK,\t"));
        break;
    case DHTLIB_ERROR_CHECKSUM:
        Serial.print(F("Checksum error,\t"));
        break;
    case DHTLIB_ERROR_TIMEOUT:
        Serial.print(F("Time out error,\t"));
        break;
    case DHTLIB_ERROR_CONNECT:
        Serial.print(F("Connect error,\t"));
        break;
    case DHTLIB_ERROR_ACK_L:
        Serial.print(F("Ack Low error,\t"));
        break;
    case DHTLIB_ERROR_ACK_H:
        Serial.print(F("Ack High error,\t"));
        break;
    default:
        Serial.print(F("Unknown error,\t"));
        break;
    }
kamra_ho=DHT_KAMRA.temperature;
kamra_para=DHT_KAMRA.humidity;
Serial.println(F("kamra_ho = "));
Serial.print(kamra_ho);
Serial.println(F("kamra_para = "));
Serial.print(kamra_para);

ThingSpeak.setField(5,kamra_ho);
ThingSpeak.setField(6,kamra_para);  
}

void read_aszalo(){
  Serial.print(F("DHT21-ASZALO, \t"));
    int chkaszalo = DHT_ASZALO.read21(DHT21_ASZALO_PIN);
    switch (chkaszalo)
    {
    case DHTLIB_OK:
        Serial.print(F("OK,\t"));
        break;
    case DHTLIB_ERROR_CHECKSUM:
        Serial.print(F("Checksum error,\t"));
        break;
    case DHTLIB_ERROR_TIMEOUT:
        Serial.print(F("Time out error,\t"));
        break;
    case DHTLIB_ERROR_CONNECT:
        Serial.print(F("Connect error,\t"));
        break;
    case DHTLIB_ERROR_ACK_L:
        Serial.print(F("Ack Low error,\t"));
        break;
    case DHTLIB_ERROR_ACK_H:
        Serial.print(F("Ack High error,\t"));
        break;
    default:
        Serial.print(F("Unknown error,\t"));
        break;
    }
aszalo_ho=DHT_ASZALO.temperature;
aszalo_para=DHT_ASZALO.humidity;
Serial.println(F("aszalo_ho = "));
Serial.print(aszalo_ho);
Serial.println(F("aszalo_para = "));
Serial.print(aszalo_para);

ThingSpeak.setField(7,aszalo_ho);
ThingSpeak.setField(8,aszalo_para);
}

void thingspeak(){
thingspeakjelen = millis();
if (thingspeakjelen - thingspeakmult >= thingspeakidozites) {
thingspeakmult = thingspeakjelen;
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
}
}

void szenzorolvas(){
szenzorjelen = millis();
if (szenzorjelen - szenzormult >= szenzoridozites) {
szenzormult = szenzorjelen;
read_kulter();
read_garazs();
read_kamra();
read_aszalo(); 
checkipaddress();   
       }
  
}

void checkipaddress(){
Serial.println(F("IP: "));
Serial.print(Ethernet.localIP());
if (!Ethernet.localIP())
digitalWrite(ledPin, LOW);
else digitalWrite(ledPin, HIGH);
}

As TinySine said, the wifly or wiflyHQ library is not ok for this wifibee module…Are there any example for this?

The thingspeak server doesn't know, or care, if you are using a Wifi shield to talk to your router or an ethernet shield to talk to your router.

That's clear. The wifibee module connects to router after configuring, also clear. But what to do in the code to send data? As TinySine said, the shield is just connects the Wifibee to the Arduino board... Do I need AT commands? Or just use from the thingspeak library:

ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);

?

Should create http post request to serial maybe? Can somebody show an example?

But what to do in the code to send data?

I don't know. It would depend on how you use your shield to talk to the router (and beyond). Whatever that process is is the same regardless of what server you are sending data to.

Or just use from the thingspeak library:

The thinkspeak library will need to use the appropriate mechanism to talk to the router (and beyond).

Tried to check RN-XV manual...But still figured out how to do that...I think I should send POST command to serial... Is here anybody who did this before?

I have done the followings:

set the module for wifi connection - OK - connected to wifi router

telnet on serial com port

$$$

than

set ip proto 18 set dns name api.thingspeak.com set ip host 0 set ip remote 80

set com remote GET$/update?key=XXXXXXX&field1=15

save reboot

after reboot $$$

open

than come back open

same with requestbin address...

not sent the get request

anybody?

I have received a library from Tinysine, thanks to Tim. Attached to this reply.
I am now managed to assoicate and tovvent to the router, but still need help to sending out a test data…
Can anybody help?

WiFi_Shield-master.zip (19.6 KB)

I am now managed to assoicate and tovvent to the router

Once more, in English, please.

Sorry for the mistake. I mean : Wifibee connected to the router... I have tried the wifly_test sketch...

I have tried the wifly_test sketch...

Which does very little useful. Communicating with thingspeak is similar to communicating with xively. So, I'd start with a different example.