I have tried using the thingspeak-arduino library and tested some of the examples:

#include <WiFi.h>
#include <WiFiClient.h>
#include <SPI.h>
#include <ThingSpeak.h>
char ssid[] = "Benok4G";    //  your network SSID (name)
char pass[] = "password";   // your network password
WiFiClient  client;

unsigned long myChannelNumber = 344468;
const char * myReadAPIKey = "xxxxxxxxx";

void setup() {
  // put your setup code here, to run once:
  WiFi.begin(ssid, pass);

void loop() {
  // put your main code here, to run repeatedly:
  float voltage = ThingSpeak.readFloatField(myChannelNumber, 1, myReadAPIKey);

  Serial.print("Latest voltage is: ");


When i run this code, I get this on the Serial Monitor. enter image description here

Why is it 0.00? It's supposed to be 24.0

Did I do something wrong? I am very frustrated because I've tried a lot of methods already just to fetch the data from ThingSpeak to my Arduino using ESP8266. I can send but when receiving I am really lost and confused.

  • Are you sure that those libraries support ESP8266 over AT commands? Is WiFi.begin even successful?
    – gre_gor
    Oct 13, 2017 at 18:54
  • I have a similar problem. Arduino Mega + Exp8266 connected to Serial1 (RX1, TX1). With WiFiEsp.h library, it connects to the router but no reading on thingspeak, always timeout 605. I wonder if you can post the working program. Thanks and good job.
    – FixEsp
    Feb 3, 2018 at 16:57

1 Answer 1

#include <WiFi.h>

From the WiFi library reference page:

With the Arduino WiFi Shield, this library allows an Arduino board to connect to the internet.

From the Arduino WiFi Shield product page:

It is based on the HDG204 Wireless LAN 802.11b/g System in-Package. An AT32UC3 provides a network (IP) stack capable of both TCP and UDP.

But you're not using an Arduino WiFi Shield or anything compatible. You're using an ESP8266 which is completely different. Thus you can't use the WiFi library for your project.

Instead you will need to use the appropriate ESP8266 library. If you are programming the ESP8266 directly that will be the ESP8266WiFi library, which is bundled with the ESP8266 core for Arduino. If you are using the ESP8266 as a WiFi module controlled via AT commands that will be the WiFiEsp library

  • 1
    Thank you for your response. I have solved my problem. I included the WiFiEsp library and set the SoftwareSerial Serial1(6, 7); // RX, TX and set the baud rate at 9600. Works like charm. Thank you again.
    – Duckbenok
    Oct 14, 2017 at 6:42
  • Just a follow up. It worked but sometimes I get "Timed Out" response and Sending the data takes too long than doing AT commands. Is this normal?
    – Duckbenok
    Oct 14, 2017 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.