Not getting data uploaded to my channel | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





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

Register Lost password?
sp_Feed sp_TopicIcon
Not getting data uploaded to my channel
Avatar
DeYulia
New Member
Forum Posts: 2
sp_UserOfflineSmall Offline
1
April 27, 2017 - 12:33 pm
sp_Permalink sp_Print

I have successfully compiled and loaded my code to a ESP8266-01S module and believed the data was being uploaded to my ThingSpeak channel, but the channel indicates zero entries.

I have an external power regulator delivering 3.3v power to the ESP8266, and 13.5v power to my Hall effect sensor.  The data wire of my sensor is connected to the GPIO 2 pin of the ESP8255-01S.  The sensor output is in the form of a pulsating square wave.  The code translates this input to a floating point number which is sent to the ThingSpeak channel.

My code follows:

[code]
/*
H2O_Flo_WiFi

Measures the flow rate of water flowing through a 3/4-inch PVC pipe using a DIGITEN Hall effect sensor and displaying results on thingspeak.com using an ESP8266-01S
Sensor date wire connected to Uno pin D2
The sensor output is in the form of the duration in milliseconds of a square wave pulse and the relationship to the water flowrate is:

F = 4.8 * Q ( in liters per minute)

ThingSpeak ( https://www.thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize and
analyze live data streams in the cloud.

Documentation for the ThingSpeak Communication Library for Arduino is in the extras/documentation folder where the library was installed.

*/

#include <ESP8266WiFi.h>

#include <ThingSpeak.h>

 

// WiFi SSD and Password

char ssid[] = "tracy";

char password[] = "Mange161";

char server[] = "api.thingspeak.com";

//Initialize the client library
WiFiClient client;

#include <SPI.h>

const int sensdatapin = 2;

String apiKey = "0ZUS9CDG08ZU6VJ2";

unsigned long myChannelNumber = 255517;

void setup() {

unsigned long duration;
float dursec;
float pulsefreq;
float flolit;
float flolitr;
float flogal;
float flocuft;

 

pinMode(sensdatapin, INPUT);

Serial.begin(115200);

delay(10);

// init done

WiFi.begin(ssid, password);

Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

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

ThingSpeak.begin(client);

}

void loop() {

const unsigned long duration = pulseIn(sensdatapin, HIGH);
//Pulse duration in microseconds

float dursec = duration / 1000000.0;
//Pulse duration in seconds

float pulsefreq = 10.0;

if ( duration != 0 )
{
pulsefreq = 1.0 / dursec;
}
else
{
pulsefreq = 0.0;
}

//Pulse frequency in Hz

float flolit = (pulsefreq / 4.8);
float flolitr = 60.0 * flolit;
//Flow rate in Liters/hour

float flogal = flolitr * .26417;
//Flow rate in Gallons/hour
float flocuft = flolitr * .035315;
//Flow rate in cu ft/hour

 

// Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different
// pieces of information in a channel. Here, we write to field 1.

ThingSpeak.writeField( 255517, 1, flogal, "0ZUS9CDG08ZU6VJ2");

delay(20000);
// ThingSpeak will only accept updates every 15 seconds.

}

 

[/code]

Avatar
cstapels

Gold
Forum Posts: 126
sp_UserOnlineSmall Online
2
April 27, 2017 - 3:00 pm
sp_Permalink sp_Print

It is possible that you have used your user API key instead of your Write API key.  You could try testing requests using the POSTMAN (https://www.getpostman.com/) chrome extension, and see if they successfully add data to your channel.

See the instructions here on how to post using HTTP requests: https://www.mathworks.com/help/thingspeak/update-channel-feed.html (in POSTMAN use x-www-form-urlencoded) and put your Write api_key in the body.  

As a side note, when you share your API keys, you may give access to others being able to change your account information or post to a private channel. You can change your user api key here: https://thingspeak.com/account/profile

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: cstapels
17 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

Nsneilotof

angieus2

goldiepw11

BinanceoSt

gnarender123@gmail.com

edenderest

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee