espcomm_upload_mem failed

hi

i am using uno+wifi R3 Atmega328p board
and esp8266 inbuild in the board

i have flashed new firmware in the board and i am able to get replya of at command AT,AT+RST and AT+GMR is working but rest Command are not working.

and if i try to upload any ESP8266 wifi server code then it gives espcomm_upload_mem faiiled.

and guidance will be helpfull.

We need more details.

gourish:
i have flashed new firmware in the board

How did you do that?

gourish:
if i try to upload any ESP8266 wifi server code

How are you attempting to do that?

gourish:
it gives espcomm_upload_mem faiiled.

One cause of that would be if you are trying to upload to the Uno instead of the ESP8266.

How did you do that?

I flashed new official firmware from here: https://espressif.com/en/support/download/sdks-demos

I used Flash Download Tools v3.4.4 tool from here: https://espressif.com/en/support/download/other-tools

inorder to update the AT firware i toggle the switch 5,6,7 ON and rest all off after i finished the update i toggled the switch 7 off and 5,6 ON so that CH340 connect to ESP8266 .then i uploaded the sketch

One cause of that would be if you are trying to upload to the Uno instead of the ESP8266.

how to upload to ESP8266 then?

gourish:
how to upload to ESP8266 then?

By switching the same switches, etc. on the board as you did when you updated the AT firmware.

You should be aware that what you're doing is uploading a new firmware to the ESP8266. The AT firmware will be erased and you will no longer be able to control the ESP8266 via AT commands unless the sketch you're uploading happens to implement that communication system. If that's not your intent then you need to explain exactly what you're trying to accomplish.

i am trying to upload a sketch in the esp

#include <Arduino.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

#include <ESP8266HTTPClient.h>

#define USE_SERIAL Serial

ESP8266WiFiMulti WiFiMulti;

void setup() {

    USE_SERIAL.begin(115200);
   // USE_SERIAL.setDebugOutput(true);

    USE_SERIAL.println();
    USE_SERIAL.println();
    USE_SERIAL.println();

    for(uint8_t t = 4; t > 0; t--) {
        USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
        USE_SERIAL.flush();
        delay(1000);
    }

    WiFi.mode(WIFI_STA);
    WiFiMulti.addAP("SSID", "PASSWORD");

}

void loop() {
    // wait for WiFi connection
    if((WiFiMulti.run() == WL_CONNECTED)) {

        HTTPClient http;

        USE_SERIAL.print("[HTTP] begin...\n");
        // configure traged server and url
        //http.begin("https://192.168.1.12/test.html", "7a 9c f4 db 40 d3 62 5a 6e 21 bc 5c cc 66 c8 3e a1 45 59 38"); //HTTPS
        http.begin("http://192.168.1.12/test.html"); //HTTP

        USE_SERIAL.print("[HTTP] GET...\n");
        // start connection and send HTTP header
        int httpCode = http.GET();

        // httpCode will be negative on error
        if(httpCode > 0) {
            // HTTP header has been send and Server response header has been handled
            USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);

            // file found at server
            if(httpCode == HTTP_CODE_OK) {
                String payload = http.getString();
                USE_SERIAL.println(payload);
            }
        } else {
            USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
        }

        http.end();
    }

    delay(10000);
}

the sketch is uploading but m not able to browse this url http://192.168.1.12/test.html

later.....

i need to enter some random text on to the site and that text need to be displayed on the display connected to board.

OK, just wanted to be sure since sometimes people don't understand which microcontroller they're uploading to.

gourish:
the sketch is uploading

So are you now able to successfully upload to the ESP8266?

gourish:
but m not able to browse this url

Try checking the return value of http.begin() in your sketch:

if(http.begin("http://192.168.1.12/test.html") == false) {
  USE_SERIAL.println("http.begin() failed");
}

@gourish please accept my answer on stackoverflow. I see it helped

do you have a web server and page test.html at 192.168.1.12 running?

So are you now able to successfully upload to the ESP8266?

yes i am able to upload successfully to ESP8266

Try checking the return value of http.begin() in your sketch:

this gives me [HTTP] GET... failed, error: connection refused in serial monitor

do you have a web server and page test.html at 192.168.1.12 running?

so on my pc in www folder ie if using apache server i need to have a test.html page??

thanks a lot everyone for the help.

solved this issue. 8)

i need to enter some random text on to the site and that text need to be displayed on the display connected to board.

any help for this.

gourish:
i need to enter some random text on to the site and that text need to be displayed on the display connected to board.

The web development part is complex. Do you have some web development experience?

The page would be on a webserver or on the Arduino?

To send text from web page, HTML FORM or AJAX is used. To receive it, a WebServer must be running on Arduino. See WebClient example in esp8266 examples.

With your board the WebServer can run on esp8266 or in Atmega.

The page would be on a webserver or on the Arduino?

right now it will be on arduino ie RobotDyn

The web development part is complex. Do you have some web development experience?

i am intermediate kind off web devloper.

till now i m already done with uploading the sketch in the ESP8266 and successfully able to retrieve the message sent from the webpage by the client.

now i only need to display this message on my LED p10 display.

here is the code:-

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WiFiMulti.h> 
#include <ESP8266mDNS.h>
#include <ESP8266WebServer.h>

ESP8266WiFiMulti wifiMulti;     // Create an instance of the ESP8266WiFiMulti class, called 'wifiMulti'

ESP8266WebServer server(80);    // Create a webserver object that listens for HTTP request on port 80

void handleRoot();              // function prototypes for HTTP handlers
void handleLogin();
void handleNotFound();

void setup(void){
  Serial.begin(115200);         // Start the Serial communication to send messages to the computer
  delay(10);
  Serial.println('\n');

  wifiMulti.addAP("DIGISOL", "edot2017");   // add Wi-Fi networks you want to connect to
  Serial.println("Connecting ...");
  while (wifiMulti.run() != WL_CONNECTED) { // Wait for the Wi-Fi to connect: scan for Wi-Fi networks, and connect to the strongest of the networks above
    delay(250);
    Serial.print('.');
  }
  Serial.println('\n');
  Serial.print("Connected to ");
  Serial.println(WiFi.SSID());               // Tell us what network we're connected to
  Serial.print("IP address:\t");
  Serial.println(WiFi.localIP());            // Send the IP address of the ESP8266 to the computer

  if (MDNS.begin("esp8266")) {              // Start the mDNS responder for esp8266.local
    Serial.println("mDNS responder started");
  } else {
    Serial.println("Error setting up MDNS responder!");
  }

  server.on("/", HTTP_GET, handleRoot);        // Call the 'handleRoot' function when a client requests URI "/"
  server.on("/login", HTTP_POST, handleLogin); // Call the 'handleLogin' function when a POST request is made to URI "/login"
  server.onNotFound(handleNotFound);           // When a client requests an unknown URI (i.e. something other than "/"), call function "handleNotFound"

  server.begin();                            // Actually start the server
  Serial.println("HTTP server started");
}

void loop(void){
  server.handleClient();                     // Listen for HTTP requests from clients
}

void handleRoot() {                          // When URI / is requested, send a web page with a button to toggle the LED
  server.send(200, "text/html", 
  "<form action=\"/login\" method=\"POST\"><input type=\"text\" name=\"data\" placeholder=\"Enter text to display\">
<input type=\"submit\" value=\"Display\"></form>");
}

void handleLogin() {                         // If a POST request is made to URI /login
  String message = "";        
  if( ! server.hasArg("data") || server.arg("data") == NULL ){ // If the POST request doesn't have username and password data
    server.send(400, "text/plain", "400: Invalid Request");         // The request is invalid, so send HTTP status 400
    return;
  }
   message += server.arg("username");  //Get the name of the parameter
   Serial.println(message);
    
}

void handleNotFound(){
  server.send(404, "text/plain", "404: Not found"); // Send HTTP status 404 (Not Found) when there's no handler for the URI in the request
}

you have a rocket start :slight_smile:

sorry, I have no experience with displays

With your board the WebServer can run on esp8266 or in Atmega.

how to run the webserver on atmega and communicate through esp at the same time??

help me out for this one thing plz.

its great if m able to run web server on atmega and communicate with esp at the smame time because
displaying part using atmega i already completed..

gourish:
how to run the webserver on atmega and communicate through esp at the same time??

help me out for this one thing plz.

its great if m able to run web server on atmega and communicate with esp at the smame time because
displaying part using atmega i already completed..

rigth, the LCD is connected to Atmega.

let the webserver in esp and send the text to Atmega sketch over Serial.

Set switches 1 & 2 ON and the Serial interface of Atmega and esp8266 will be connected (USB is out, no upload or Serial Monitor).

let the webserver in esp and send the text to Atmega sketch over Serial.

so first i need to upload the code of webserver on to the esp by toggling 5,6,7 on

then i need to switch 1,2 ON and rest all off to code the atmega.

how will i get message that the client will send from the webpage?

how to get the message from serial monitor of the esp8266 into atmega??

I just read your Blynk post.

gourish:
so first i need to upload the code of webserver on to the esp by toggling 5,6,7 on

yes

gourish:
then i need to switch 1,2 ON and rest all off to code the atmega.

no, first you upload your Atmega sketch which handles the LCD. With switches ~~2,~~3*,4* ON. For the test you switch set 1,2 ON

gourish:
how will i get message that the client will send from the webpage?

you write it to Serial in esp8266 and read it from Serial in Atmega sketch

gourish:
how to get the message from serial monitor of the esp8266 into atmega??

yes, that the inconvenience and I give you the solution in the stackoverflow answer

no, first you upload your Atmega sketch which handles the LCD. With switches 2,3 ON. For the test you switch set 1,2 ON

oh sorry
i uploaded the sketch for display in atmega by toggling 3 and 4 ON actually.
right?

yes, that the inconvenience and I give you the solution in the stackoverflow answer

k

for Serial communication - Serial Input Basics

I recommend you to not ask so much but search and read.

k sorry

thank you