Can't upload data to ThingSpeak using ESP8266-01

Hey guys, how you doing? Hope that everything goes well!

So I’m trying to upload data to my channel to ThingSpeak using these set of sensors (Moisture sensor, Light sensor “TSL2561”, and Temperature & Humidity sensor “DHT22”) with an arduino uno with ESP8266-01.

Here are my connection for ESP

GND >> GND
RXD >> Pin 3
TXF >> Pin 2
CH_PD & VCC >> 3.3v

And the sensors connection are good! I guess!!

Here is the code I'm using
        `#include<SoftwareSerial.h>


SoftwareSerial esp8266(2, 3);
bool isDebug = false;


String writeAPIKey = ""; // Here you will write you API Write Code

//-- IoT Information
#define SSID ""; //Here your wirless name
#define PASS "" // Your Password
#define IP "184.106.153.149" // ThingSpeak IP Address: 184.106.153.149
String GET = "GET /update?key="+writeAPIKey;


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  esp8266.begin(115200); 
  connectWiFi();

}
String res;
void loop() {
  // put your main code here, to run repeatedly:
  //YOUR LOGIC

  //-------------------
   String x;
   String y;
   String z;
     updateTS(x,y,z);

}

void updateTS( String T, String L , String H)
{
  // ESP8266 Client
  String cmd = "AT+CIPSTART=\"TCP\",\"";// Setup TCP connection
  cmd += IP;
  cmd += "\",80";
  sendData(cmd,false);
  delay(2000);
  if ( esp8266.find( "Error" ) )
  {
    Serial.print( "RECEIVED: Error\nExit1" );
    return;
  }
  //Here you will repeat for each filed in your channel

  cmd = GET + "&field1=" + T + "&field2=" + L + "&field3=" + H + "\r\n";
  esp8266.print( "AT+CIPSEND=" );
  esp8266.println( cmd.length() );
  if (esp8266.find( ">" ) )
  {
    Serial.print(">");
    Serial.print(cmd);
    esp8266.print(cmd);
  }
  else
  {
    sendData( "AT+CIPCLOSE",false);//close TCP connection
  }
  if ( esp8266.find("OK") )
  {
    Serial.println( "RECEIVED: OK" );
  }
  else
  {
    Serial.println( "RECEIVED: Error\nExit2" );
  }
}
String sendData(String cmd, bool isDebug) {
  String resp = "";
  esp8266.println(cmd);
  while (esp8266.available()) {
    char c = esp8266.read();
    resp += c;

  }
  if (isDebug) {
    Serial.print(resp);
  }
  return resp;

}

boolean connectWiFi()
{
  sendData("AT+CWMODE=1", true); //WiFi STA mode - if '3' it is both client and AP
  delay(2000);
  //Connect to Router with AT+CWJAP="SSID","Password";
  // Check if connected with AT+CWJAP?
  String cmd = "AT+CWJAP=\""; // Join accespoint
  cmd += SSID;
  cmd += "\",\"";
  cmd += PASS;
  cmd += "\"";
  sendData(cmd, true);
  delay(5000);
  if (esp8266.find("OK"))
  {
    //esp8266.println("RECEIVED: OK");
    Serial.println("Connected");
    return true;
  }
  else
  {
    // debug.println("RECEIVED: Error");

    Serial.println("ERROR HERE");

    return false;
  }

  cmd = "AT+CIPMUX=0";// Set Single connection
  sendData(cmd, false);
  if ( Serial.find( "Error") )
  {
    // debug.print( "RECEIVED: Error" );
    return false;
  }
  Serial.println("CONNECTED");
}

And the sketch is run so well, but NO data sent to my channel … Any one can help?! :slight_smile:

Should I change between RX, and TX while compiling the sketch or changing their pins in arduino

The red light of ESP only exist, the blue doesn’t work!

I am pretty sure that you know this is a Particle community. :wink:

Asking this at the correct forum might get you the help required.

3 Likes

What forums do you mean tho?

Google tells me it’s this:
http://www.esp8266.com
The Arduino forums wouldn’t be a bad place either…