So you're a Noob? Post your questions here until you graduate! Don't be shy.
User avatar
By glassreef
#77605 I have the code shown below, on a SP8266 NodeMCU V.1E The code works very well. It just passes a request to my website and passes 2 parameters to a .php file. The .php file sends me an email.

My problem is that, this Esp8266 functionality is meant to be added to a large sketch on an Arduino Mega 2560. When a particular error occurs on the Mega, the code on the ESP should be executed after 2 string params are passed for inclusion in the email.

Can someone tell me if this is possible? If yes, perhaps a short explanation? BTW: I did do a lot of searching for an answer but, all I could find was a lot about using AT commands and I don't think that can be used for my problem.


Code: Select all// Code taken from various examples online
// Resides on NodeMCU V.1

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "MYSSID";
const char* password = "MYPWD";
void setup () {

  WiFi.begin(ssid, password);


  if (WiFi.status() != WL_CONNECTED)  {
  else {
void loop() {
   if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
    HTTPClient http;  //Declare an object of class HTTPClient
    String dataline = " Error";
    bool httpResult = http.begin(dataline); 
    int httpCode = http.GET();                                                                 

      Serial.println("Invalid HTTP request:");
      int httpCode = http.GET();
      if (httpCode > 0)
    { // Request has been made
      Serial.printf("HTTP status: %d Message: ", httpCode);
      //String payload = http.getString();
    { // Request could not be made
      Serial.printf("HTTP request failed. Error: %s\r\n", http.errorToString(httpCode).c_str());
    if (httpCode > 0) { //Check the returning code
      //String payload = http.getString();   //Get the request response payload
      //Serial.println(payload);                     //Print the response payload
     http.end();   //Close connection