Hi guys
I am new to arduino and COSM and I got some troubles on my work
I am using Arduino UNO and RN-131C by sparksfun
I have created a COSM account and I got API Key and Feed
I am using the example to try out my project
However, I can't find any data uploaded to my COSM
I have checked the connections of WiFi is okay and I have used wifi tester to confirm my connection
So what should I do first to check the problem?
Many Thanks !
this is my code thx
#include SPI.h
#include WiFi.h
#include HttpClient.h
#include Cosm.h
char ssid[] = "fyp2013"; // your network SSID (name)
char pass[] = "2496054321"; // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0; // your network key Index number (needed only for WEP)
int status = WL_IDLE_STATUS;
// Your Cosm key to let you upload data
char cosmKey[] = "oZy9HnWvWl1i3CRtl4mSeR2JASaSAKxuNkplczZtMElsMD0g";
// Analog pin which we're monitoring (0 and 1 are used by the Ethernet shield)
int sensorPin = 2;
// Define the strings for our datastream IDs
char sensorId[] = "sensor_reading";
CosmDatastream datastreams[] = {
CosmDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};
// Finally, wrap the datastreams into a feed
CosmFeed feed(120202, datastreams, 1 /* number of datastreams */);
WiFiClient client;
CosmClient cosmclient(client);
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Starting single datastream upload to Cosm...");
Serial.println();
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
Serial.println("Connected to wifi");
printWifiStatus();
}
void loop() {
int sensorValue = analogRead(sensorPin);
datastreams[0].setFloat(sensorValue);
Serial.print("Read sensor value ");
Serial.println(datastreams[0].getFloat());
Serial.println("Uploading it to Cosm");
int ret = cosmclient.put(feed, cosmKey);
Serial.print("cosmclient.put returned ");
Serial.println(ret);
Serial.println();
delay(15000);
}