1

I am new to the concept of nodemcu and thingspeak. I am doing a project on irrigation. I need to send data to thingspeak through the nodemcu.

The code I uploaded in the nodemcu is shown below:

#include <ThingSpeak.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
const char* ssid = "xxx"; //Your Network SSID
const char* password = "xxxx"; //Your Network Password
int val1;
//int val2;

#define input = 5;
//#define input = 4;

WiFiClient client; 
unsigned long myChannelNumber = xxxx; //Your Channel Number (Without Brackets) 
const char * myWriteAPIKey = "xxxx"; //Your Write API Key 
void setup() 
{
Serial.begin(115200);
delay(10);
//Connect to WiFi network 
WiFi.begin(ssid, password);
ThingSpeak.begin(client); 
} 
void loop() 
{ 
val1 = analogRead(5);//Read Analog values and Store in val variable 
val1 = val1/3;
Serial.println(val1);
//val2 = analogRead(4);//Read Analog values and Store in val variable 
//val2 = val2/100;

delay(1000); 
ThingSpeak.writeField(myChannelNumber, xxx,val1, myWriteAPIKey); //Update in ThingSpeak 
//ThingSpeak.writeField(myChannelNumber, xxx,val2, myWriteAPIKey); //Update in ThingSpeak

delay(100); 
}

I tried this code. Here my problem is the data is not sent to thingspeak. Can anyone help me solve this issue? Thank You.

  • Did you replace the //Your Network SSID and other such lines with your info? Did you set up your Thingspeak Channel? Did you install the Thingspeak library in Arduino? – anonymous2 Apr 18 at 18:08
  • Yes, I did everything – MAKHAM NAGA BHAVANI Apr 24 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.