Unable to upload data to thingspeak | ESP Wi-Fi | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | 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
Unable to upload data to thingspeak
No permission to create posts
March 29, 2019
1:02 pm
Avatar
geeha
New Member
Members
Forum Posts: 1
Member Since:
March 29, 2019
sp_UserOfflineSmall Offline

hi, i hope someone can reply me . first of all, before this i can upload data to thingspeak perfectly. i able so send every data to thingspeak, but suddenly thingspeak does not receive the data that i send. i don't know what happened. i hope someone can help me solve the problem

#include
#include
#include

String apiKey = "xxxxxxxxxxxx"; // Enter your Write API key from ThingSpeak
const char* ssid = "xxxxxxxx";
const char* password = "xxxxxxxx";
const char* server = "api.thingspeak.com";
WiFiClient client; // Server class Fn Call: set web server port number to 80
const int sensorIn = A0;
float Cal=0.01;
int Delta_Count;
int readADC;
double AmpsRMS1 = 0;
int new_delta;
double power = 0;
double Etotal = 0;

void setup(){
Serial.begin(115200);
pinMode(16, OUTPUT); // CD4051 addr=A
pinMode(5, OUTPUT); // CD4051 addr=B

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

WiFi.begin(ssid, password);

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

void loop(){

//ambil mux 0

for(int i=0; i<5; i++)
{
digitalWrite(16,LOW); // MUX chan select
digitalWrite(5,LOW);
delay(10);
readADC = getADC();
//new_delta = Delta_Count - 0;
AmpsRMS1 = Cal * Delta_Count;
power = (AmpsRMS1 * 230)/1000;
Etotal = Etotal + power;
Serial.print(Delta_Count);
Serial.println(" ET1 ");
}
Serial.print(Etotal);
Serial.println(" ETotal1 10 saat");
if (client.connect(server,80)) // "184.106.153.149" or api.thingspeak.com
{

String postStr = apiKey;
postStr +="&field1=";
postStr += String(Etotal);
postStr += "

";

client.print("POST /update HTTP/1.1
");
client.print("Host: api.thingspeak.com
");
client.print("Connection: close
");
client.print("X-THINGSPEAKAPIKEY: "+apiKey+"
");
client.print("Content-Type: application/x-www-form-urlencoded
");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("

");
client.print(postStr);
}
client.stop();

// wait 20 seconds and post again
delay(20000);
Etotal=0;

}

int getADC()
{

int readValue; //value read from the sensor
int maxValue = 0; // store max value here
int minValue = 1024; // store min value here

uint32_t start_time = millis();
while((millis()-start_time) maxValue)
{
/*record the maximum sensor value*/
maxValue = readValue;
}
if (readValue < minValue)
{
/*record the maximum sensor value*/
minValue = readValue;
}
}

// Subtract min from max
Delta_Count = maxValue - minValue;
}

March 29, 2019
4:45 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 861
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Add some delay between these lines:
client.print(postStr);
}
client.stop();

1 second should do, probably less. See this post for more information:
https://community.thingspeak.com/forum/thingspeak-api/the-recording-to-thingspeak-suddenly-stopped-working/

As they suggest in that post, we recommend using the ThingSpeak Communication Library if possible.

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
17 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:

khanhNguyen_CT, susyburr, quijano__, meosuckhoe, briskpanda, Dejw0089

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457