So you're a Noob? Post your questions here until you graduate! Don't be shy.
User avatar
By VzqSmooth56
#65084 Hey guys so im having an issue,

i have the esp8266 module working with the arduino mega and they are communicating fine.
I am having issues sending information to thingspeak automatically when i run my code.

what i mean by this is that i am able to send data to thingspeak (thingspeak will display my data correctly) if i manually give the esp8266 AT commands.


GET /update?key=MYKEYHERE&field1=10

But once my program starts to run, serial monitor/plotter will display my data, but thingpseak isnt receiving anything.

this is the code i have written so far.

Please excuse me if i have not written this post in the correct way, this is my first post ever on here.

Code: Select all#include <SoftwareSerial.h>
#include <stdlib.h>
#define SSID "iPhone"
#define PASS "cristian890"

//  Variables

int PulseSensorPurplePin = 0;        // Pulse Sensor PURPLE WIRE connected to ANALOG PIN 0
int LED13 = 13;   //  The on-board Arduion LED

int Signal;                // holds the incoming raw data. Signal value can range from 0-1024
int Threshold = 550;            // Determine which Signal to "count as a beat", and which to ingore.

String GET = "**MYAPIKEY**";
SoftwareSerial ser(9, 10); //RX, TX

// The SetUp Function:

void setup() {
  pinMode(LED13, OUTPUT);        // pin that will blink to your heartbeat
  Serial.begin(9600);         // Set's up Serial Communication at certain speed.

  // reset ESP8266

// The Main Loop Function

void loop() {

  Signal = analogRead(PulseSensorPurplePin);  // Read the PulseSensor's value.
                                                               // Assign this value to the "Signal" variable.

  Serial.println(Signal);       // Send the Signal value to Serial Plotter.

  if (Signal > Threshold) {         // If the signal is above "550", then "turn-on" Arduino's on-Board LED.
    digitalWrite(LED13, HIGH);
  } else {
    digitalWrite(LED13, LOW);      //  Else, the sigal must be below "550", so "turn-off" this LED.

boolean connectWiFi()
  String com = "AT+CWJAP=\"";
  com += SSID;
  com += "\",\"";
  com += PASS;
  com += "\"";
  //TCP connection

  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += ""; //
  cmd += "\",80";

  if (ser.find("Error")) {
    Serial.println("AT+CIPSTART error");

  // prepare GET string
  String getStr = "GET /update?api_key=";
  getStr += GET;
  getStr += "&field1=";
  getStr += String(Signal);
  getStr += "\r\n\r\n";

  // send data length
  cmd = "AT+CIPSEND=";
  cmd += String(getStr.length());

  if (ser.find(">")) {
  else {
    // alert user