Problem for run new code on esp32 based board

#ifdef ESP8266
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#elif defined(ESP32)
#include <WiFi.h>
#include <ESPmDNS.h>
#else
#error "Board not found"
#endif

#define LED1 15
#define LED2 12

char webpage[] PROGMEM = R"=====(

My Home Automation

LED 1

OnOff

LED 2

OnOff

)=====";

// ipaddress/led1/on
//ipaddress/led1/off

// ipaddress/led2/on
//ipaddress/led2/off
#include <ESPAsyncWebServer.h>

AsyncWebServer server(80); // server port 80

void notFound(AsyncWebServerRequest *request)
{
request->send(404, "text/plain", "Page Not found");
}

void setup(void)
{

Serial.begin(115200);
pinMode(LED1,OUTPUT);
pinMode(LED2,OUTPUT);

WiFi.softAP("techiesms", "");
Serial.println("softap");
Serial.println("");
Serial.println(WiFi.softAPIP());

if (MDNS.begin("ESP")) { //esp.local/
Serial.println("MDNS responder started");
}

server.on("/", [](AsyncWebServerRequest * request)
{

request->send_P(200, "text/html", webpage);
});

server.on("/led1/on", HTTP_GET, [](AsyncWebServerRequest * request)
{
digitalWrite(LED1,HIGH);
request->send_P(200, "text/html", webpage);
});

server.onNotFound(notFound);

server.begin(); // it will start webserver
}

void loop(void)
{
}

Uploading this code on my esp32 board. But it ran properly! Now if I upload any other code the upload works fine but, don't go The web server created by the above code runs. Is there any solution to this?

Welcome to the forum

Can you see the mess that has been made of your code because some of it has been interpreted as HTML commands ?

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

In my experience this is the easiest way to tidy up the code and add the code tags

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

It sounds like the code is not being uploaded

Please turn on all warnings for compiling and uploading in your IDE Preference, upload the code and post the output that is produced, using code tags when you do

Code is successfully updated but the problem is code note start working on ESP 32 board. It's petty sure that the code is currect and uploaded successfully on the board without any error.

<!DOCTYPE html>
<html>
<body>

<center>
<h1>My Home Automation</h1>

<h3> LED 1 </h3>
<button onclick="window.location = 'http://'+location.hostname+'/led1/on'">On</button><button onclick="window.location = 'http://'+location.hostname+'/led1/off'">Off</button>
<h3> LED 2 </h3>
<button onclick="window.location = 'http://'+location.hostname+'/led2/on'">On</button><button onclick="window.location = 'http://'+location.hostname+'/led2/off'">Off</button>

</center>
</body>
</html>

If the code that was already on the board continues to run after new code is uploaded then the upload was not successful.

Please post the details that I requested

Yes sure

Which info I provide for your requirement

The full text of the compilation and upload messages at the bottom of the screen when you upload a sketch that does not replace the one that is running

What exactly is the code fragment that you posted in reply #5 ?

#5 reply is the html code It has been converted to web format

I flashed the .bin file meaning the precompiled code. Then I uploaded the example of Blink which is in Arduino IDE.

These came up when I compiled..

/sdkEsp32/tools/xtensa-esp32-elf-gcc/1.22.0/bin/xtensa-esp32-elf-g++ --sysroot /sdkEsp32/tools/xtensa-esp32-elf-gcc/1.22.0/xtensa-esp32-elf/sysroot/ -iprefix /sdkEsp32/tools/xtensa-esp32-elf-gcc/1.22.0/lib/gcc/xtensa-esp32-elf/5.2.0/ -DESP_PLATFORM -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DHAVE_CONFIG_H -std=gnu++11 -Os -g3 -Wpointer-arith -mlongcalls -nostdlib -w -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -c -DF_CPU=240000000L -DARDUINO=10812 -DARDUINO_ESP32_DEV -DARDUINO_ARCH_ESP32 -DARDUINO_BOARD=ESP32_DEV -DARDUINO_VARIANT="esp32" -DESP32 -DCORE_DEBUG_LEVEL=0 /build/blink.cpp -o /build/blink.cpp.o /sdkEsp32/tools/xtensa-esp32-elf-gcc/1.22.0/bin/xtensa-esp32-elf-gcc --sysroot /sdkEsp32/tools/xtensa-esp32-elf-gcc/1.22.0/xtensa-esp32-elf/sysroot/ -iprefix /sdkEsp32/tools/xtensa-esp32-elf-gcc/1.22.0/lib/gcc/xtensa-esp32-elf/5.2.0/ -B /sdkEsp32/tools/xtensa-esp32-elf-gcc/1.22.0/lib/gcc/ -nostdlib -L/sdkEsp32/hardware/esp32/1.0.3/tools/sdk/lib -L/sdkEsp32/hardware/esp32/1.0.3/tools/sdk/ld -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -T esp32.rom.libgcc.ld -T esp32.rom.spiram_incompatible_fns.ld -u ld_include_panic_highint_hdl -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority -u __cxa_guard_dummy -u __cxx_fatal_exception -Wl,--start-group /build/blink.cpp.o /coreBuild/core.a -lgcc -lesp32 -lphy -lesp_http_client -lmbedtls -lrtc -lesp_http_server -lbtdm_app -lspiffs -lbootloader_support -lmdns -lnvs_flash -lfatfs -lpp -lnet80211 -ljsmn -lface_detection -llibsodium -lvfs -ldl_lib -llog -lfreertos -lcxx -lsmartconfig_ack -lxtensa-debug-module -lheap -ltcpip_adapter -lmqtt -lulp -lfd -lfb_gfx -lnghttp -lprotocomm -lsmartconfig -lm -lethernet -limage_util -lc_nano -lsoc -ltcp_transport -lc -lmicro-ecc -lface_recognition -ljson -lwpa_supplicant -lmesh -lesp_https_ota -lwpa2 -lexpat -llwip -lwear_levelling -lapp_update -ldriver -lbt -lespnow -lcoap -lasio -lnewlib -lconsole -lapp_trace -lesp32-camera -lhal -lprotobuf-c -lsdmmc -lcore -lpthread -lcoexist -lfreemodbus -lspi_flash -lesp-tls -lwpa -lwifi_provisioning -lwps -lesp_adc_cal -lesp_event -lopenssl -lesp_ringbuf -lfr -lstdc++ -Wl,--end-group -Wl,-EL -o /build/blink.cpp.ino.elf
Creating partitions BIN file /build/blink.cpp.partitions.bin using /sdkEsp32/hardware/esp32/1.0.3/tools/partitions/default.csv
Creating BIN file /build/blink.cpp.bin using /build/blink.cpp.ino.elf

Sketch uses 205049 bytes, global variables use 15152 bytes

Note I selected the correct board

When start uploading Then the following lines are shown

Connecting ...
Writing at 0x0000e000 ... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000
Leaving ...
Writing at 0x00001000 ... (100 %)
Wrote 15552 bytes (10150 compressed) at 0x00001000
Leaving ...
Writing at 0x00010000 ... (14 %)
Writing at 0x00014000 ... (28 %)
Writing at 0x00018000 ... (42 %)
Writing at 0x0001c000 ... (57 %)
Writing at 0x00020000 ... (71 %)
Writing at 0x00024000 ... (85 %)
Writing at 0x00028000 ... (100 %)
Wrote 205168 bytes (105016 compressed) at 0x00010000
Leaving ...
Writing at 0x00008000 ... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000
Leaving ...
Hard resetting via RTS pin ...

When I turn on the serial monitor and press the rst button, the following text is coming.

01:41:11.930 -> ets Jul 29 2019 12:21:46
01:41:11.941 ->
01:41:11.948 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
01:41:11.956 -> configsip: 0, SPIWP:0xee
01:41:11.963 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
01:41:11.970 -> mode:DIO, clock div:1
01:41:11.976 -> load:0x3fff0018,len:4
01:41:11.982 -> load:0x3fff001c,len:928
01:41:11.985 -> ho 0 tail 12 room 4
01:41:11.988 -> load:0x40078000,len:8740
01:41:11.991 -> load:0x40080400,len:5788
01:41:11.994 -> entry 0x4008069c
01:41:12.330 -> softap
01:41:12.342 ->
01:41:12.351 -> 192.168.4.1
01:41:12.361 -> MDNS responder started

What exactly do you mean by this ?
Which .bin file ?

Compiled binary file

We know what it is, that is not the question asked.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.