Black Lives Matter - Action and Equality. ... Adafruit joins the Stop Hate for Profit campaign.
0

[SOLVED] Error writing value to feed
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

[SOLVED] Error writing value to feed

by huguescmoi on Tue Feb 02, 2016 4:30 pm

Hello,
Just starting with the Adafruit IO ESP8266 Arduino example. I use the example sketch, without any modifications (except my own ssid, password, AIO key and feed name. I do not succeed to write any values to the feed.

My feed that I created to test has the following parameters:
name : poules
key: poules-temperature


Running the script gives this ouput on serial monitor:

Adafruit IO ESP8266 test!
Connecting to (masked)
.......
WiFi connected
IP address:
192.168.1.30
Ready!
Error writing value to feed!
Waiting 10 seconds and then reading the feed value.
Received value from feed:
Waiting 10 seconds and then writing a new feed value.


The script I run is (with ssid/password masked):

// Adafruit IO REST API access with ESP8266
//
// For use with ESP8266 Arduino from:
// https://github.com/esp8266/Arduino
//
// Works great with ESP8266 modules like the Adafruit Huzzah ESP:
// ----> https://www.adafruit.com/product/2471
//
// Written by Tony DiCola for Adafruit Industries.
// MIT license, all text above must be included in any redistribution.
#include <ESP8266WiFi.h>
#include "Adafruit_IO_Client.h"


// Configure WiFi access point details.
#define WLAN_SSID "***"
#define WLAN_PASS "***"

// Configure Adafruit IO access.
#define AIO_KEY "***"


// Create an ESP8266 WiFiClient class to connect to the AIO server.
WiFiClient client;

Adafruit_IO_Client aio = Adafruit_IO_Client(client, AIO_KEY);

Adafruit_IO_Feed testFeed = aio.getFeed("poules","poules-temperature");


// Global state to increment a number and send it to the feed.
unsigned int count = 0;

void setup() {
// Setup serial port access.
Serial.begin(115200);
delay(10);
Serial.println(); Serial.println();
Serial.println(F("Adafruit IO ESP8266 test!"));

// Connect to WiFi access point.
Serial.print("Connecting to ");
Serial.println(WLAN_SSID);

WiFi.begin(WLAN_SSID, WLAN_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();

Serial.println("WiFi connected");
Serial.println("IP address: "); Serial.println(WiFi.localIP());

// Initialize the Adafruit IO client class (not strictly necessary with the
// client class, but good practice).
aio.begin();

Serial.println(F("Ready!"));
}

void loop() {
// Increment the count value and write it to the feed.
count += 1;
// To write a value just call the feed's send function and pass it the value.
// Send will create the feed on Adafruit IO if it doesn't already exist and
// then add the value to it. Send returns a boolean that's true if it works
// and false if it fails for some reason.
if (testFeed.send(count)) {
Serial.print(F("Wrote value to feed: ")); Serial.println(count, DEC);
}
else {
Serial.println(F("Error writing value to feed!"));
}

// Now wait 10 seconds and read the current feed value.
Serial.println(F("Waiting 10 seconds and then reading the feed value."));
delay(10000);

// To read the latest feed value call the receive function on the feed.
// The returned object will be a FeedData instance and you can check if it's
// valid (i.e. was successfully read) by calling isValid(), and then get the
// value either as a text value, or converted to an int, float, etc.
FeedData latest = testFeed.receive();
if (latest.isValid()) {
Serial.print(F("Received value from feed: ")); Serial.println(latest);
// By default the received feed data item has a string value, however you
// can use the following functions to attempt to convert it to a numeric
// value like an int or float. Each function returns a boolean that indicates
// if the conversion succeeded, and takes as a parameter by reference the
// output value.
int i;
if (latest.intValue(&i)) {
Serial.print(F("Value as an int: ")); Serial.println(i, DEC);
}
// Other functions that you can use include:
// latest.uintValue() (unsigned int)
// latest.longValue() (long)
// latest.ulongValue() (unsigned long)
// latest.floatValue() (float)
// latest.doubleValue() (double)
}
else {
Serial.print(F("Failed to receive the latest feed value!"));
}

// Now wait 10 more seconds and repeat.
Serial.println(F("Waiting 10 seconds and then writing a new feed value."));
delay(10000);
}

What do i do wrong ? HELLP
Last edited by huguescmoi on Wed Feb 03, 2016 2:19 pm, edited 1 time in total.

huguescmoi
 
Posts: 13
Joined: Sat Jan 23, 2016 12:29 pm

Re: Error writing value to feed

by huguescmoi on Wed Feb 03, 2016 2:14 pm

For memory and help others, the mistake was due to the fact that Adafruit IO does not support spaces in the name of a feed.
Should be written in BOLD LETTERS in the tutorial to avoid loosing hours of troubleshooting for something we can't make up without documentation.

huguescmoi
 
Posts: 13
Joined: Sat Jan 23, 2016 12:29 pm

Please be positive and constructive with your questions and comments.