Arduino uploading blank entries to Thingspeak? | Arduino | Forum

The ThingSpeak community site has been upgraded to a new site. This site is currently in read-only mode. You can ask questions or post and read discussions on the new site.
Avatar

Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Arduino uploading blank entries to Thingspeak?
No permission to create posts
January 18, 2016
9:26 am
Avatar
abhishekjacob21

Silver
Members
Forum Posts: 9
Member Since:
November 6, 2015
sp_UserOfflineSmall Offline

Hi there!
I'm using an ESP8266 wifi shield to upload some data to Thingspeak, and while it does show something is being uploaded (the number of entries increases indicating it's getting something), but the entry is completely blank and doesn't have the number it's supposed to have received.. I'm using the ThingSpeak library that was newly introduced. Is this a problem anyone else has faced?
thanks!

January 18, 2016
1:17 pm
Avatar
Rob Purser
Natick, MA

MathWorks
Members
Forum Posts: 47
Member Since:
August 22, 2015
sp_UserOfflineSmall Offline

Hi abhishekjacob21,

Sorry to hear you're having trouble. Would you post the code that you're using to post?

-Rob

Senior Development Manager for IoT and Hardware Interfacing for MATLAB at MathWorks.  Visit ThingSpeak.com to explore the IoT Analytic platform that speaks MATLAB made for engineers and scientists.  You can collect, analyze, and act in 5 minutes or less!

January 18, 2016
3:26 pm
Avatar
abhishekjacob21

Silver
Members
Forum Posts: 9
Member Since:
November 6, 2015
sp_UserOfflineSmall Offline

Rob,
So while doing some troubleshooting, I deleted the rest of the void loop just in a n attempt to simplify things. Unfortunately that didn't have a positive effect on the results.. When I upload it, though, it says "Low memory available, stability problems may occur." Could that be a cause?

Here's the code I have:

#include

#include

// The SparkFunESP8266WiFi library uses SoftwareSerial
// to communicate with the ESP8266 module. Include that
// library first:
#include
// Include the ESP8266 AT library:
#include

MS5803 sensor(ADDRESS_HIGH);

//////////////////////////////
// WiFi Network Definitions //
//////////////////////////////
// Replace these two character strings with the name and
// password of your WiFi network.
const char mySSID[] = "IFH Loft";
const char myPSK[] = "ifhJanuary";

ESP8266Client client;

//////////////////////////
// Thingspeak Constants //
//////////////////////////

unsigned long myChannelNumber = 64341;
const char * myWriteAPIKey = "4JRIMA3GJF3PIQKE";

///////////////////
//Time Retrieval //
///////////////////

////////////////////////
//Variable Definitions//
////////////////////////
int Calc;
volatile int NbTopsFan;
unsigned long copyCount = 0;
unsigned long lastRead = 0;
unsigned long interval = 1000;
unsigned long thingspeakInterval = 16000;
unsigned long lastThingspeak = 0;
int hallsensor = 3;
unsigned long lastThingspeak2 = 0;
unsigned long thingspeakInterval2 = 40000;

float temperature_c, temperature_f;
double pressure_abs, pressure_relative, altitude_delta, pressure_baseline;
float atmPressure = 101300;
float depth;
float rho = 1000.0; // units: kg/m^3
float g = 9.8; // units: m/s^2
float currentPressure;
float depthft;

double base_altitude = 1655.0; // Altitude of SparkFun's HQ in Boulder, CO. in (m)

const int redPin=5;
const int greenPin=10;
const int bluePin=6;

const int max_red=255;
const int max_green=255;
const int max_blue=255;

byte colors[3]={0, 0, 0};
byte lineEnding = 0x0A;
byte redVal=0;
byte greenVal=0;
byte blueVal=0;

void rpm(){
NbTopsFan++;
}

void setup()
{
pinMode (hallsensor, INPUT);
pinMode (redPin, OUTPUT);
pinMode (greenPin, OUTPUT);
pinMode (bluePin, OUTPUT);
attachInterrupt(1, rpm, RISING);

int status;
Serial.begin(9600);

// To turn the MG2639 shield on, and verify communication
// always begin a sketch by calling cell.begin().
status = esp8266.begin();
if (status <= 0)
{
Serial.println(F("Unable to communicate with shield. Looping"));
while(1) ;
}

esp8266.setMode(ESP8266_MODE_STA); // Set WiFi mode to station
if (esp8266.status() <= 0) // If we're not already connected
{
if (esp8266.connect(mySSID, myPSK) = thingspeakInterval){
ThingSpeak.writeField(myChannelNumber, 2, depthft, myWriteAPIKey);
lastThingspeak = millis();
}
Serial.println(depthft);
delay(1000);

}

January 18, 2016
8:28 pm
Avatar
abhishekjacob21

Silver
Members
Forum Posts: 9
Member Since:
November 6, 2015
sp_UserOfflineSmall Offline

I'm sorry Rob but for some reason the code didn't copy properly. Below is the void setup and loop functions:
void setup()
{
int status;
Serial.begin(9600);

// To turn the MG2639 shield on, and verify communication
// always begin a sketch by calling cell.begin().
status = esp8266.begin();
if (status <= 0)
{
Serial.println(F("Unable to communicate with shield. Looping"));
while(1) ;
}

esp8266.setMode(ESP8266_MODE_STA); // Set WiFi mode to station
if (esp8266.status() <= 0) // If we're not already connected
{
if (esp8266.connect(mySSID, myPSK) < 0)
{
Serial.println(F("Error connecting"));
while (1) ;
}
}

// Get our assigned IP address and print it:
Serial.print(F("My IP address is: "));
Serial.println(esp8266.localIP());

ThingSpeak.begin(client);
setTime(9, 27, 59, 18, 02, 2015);

}

void loop()
{
Calc = 7;
ThingSpeak.writeField(myChannelNumber, 1, Calc, myWriteAPIKey);
}

January 19, 2016
1:54 am
Avatar
abhishekjacob21

Silver
Members
Forum Posts: 9
Member Since:
November 6, 2015
sp_UserOfflineSmall Offline

So an update: I kept removing pieces of the code above and eventually it just started working..And when I added the code that I took out back, it continued to work..
Do you think it has something to do with the "Low Memory" issue?

January 20, 2016
9:40 am
Avatar
Rob Purser
Natick, MA

MathWorks
Members
Forum Posts: 47
Member Since:
August 22, 2015
sp_UserOfflineSmall Offline

Hi abhishekjacob21,
Yes -- that is almost certainly the cause. The ESP8266 doesn't have a whole lot of memory to work with. I tried to keep the memory footprint of the write functions as low as I could, but many of the string operations needed to construct the HTTP post will fail silently once we're low on memory.

One option would be to rip apart the library and only take the absolute minimum for what you need. It is flexible, and as such it uses more memory than a dedicated implementation might use.
-Rob

Senior Development Manager for IoT and Hardware Interfacing for MATLAB at MathWorks.  Visit ThingSpeak.com to explore the IoT Analytic platform that speaks MATLAB made for engineers and scientists.  You can collect, analyze, and act in 5 minutes or less!

January 21, 2016
5:39 pm
Avatar
abhishekjacob21

Silver
Members
Forum Posts: 9
Member Since:
November 6, 2015
sp_UserOfflineSmall Offline

Because I don't know C++ or much about programming for that matter, can you give me an idea of what I can remove from the code so that it reduces the SRAM usage? The only lines in the code using the library are:
-ThingSpeak.begin(client)
-ThingSpeak.writeField(myChannelNumber, 2, depthft, myWriteAPIKey); (this line uses approximately 13% of the memory)
I'm also exploring ways to reduce memory used by other libraries. (The one for using the ESP8266 is also quite substantial)
thanks for the help!

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
37 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

kusmumichael, petersmith99, Rambant, blakeharriss09, optisol, Niyonzima Fils

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457