ESP32 compile errors

I’ve just done all what is required for the ESP32 to work with the IDE and wifiscan works ok. However, with a different sketch I get all these warnings ; :confused:

The sketch is this one I’m trying to use: GitHub - zarya/esp32PulseCounter: A pulse counter for the ESP32 with mqtt backend

Any ideas please ?

Dave.

C:\Users\dave\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src\WiFiMulti.cpp: In member function 'uint8_t WiFiMulti::run()':

C:\Users\dave\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src\WiFiMulti.cpp:128:27: warning: variable 'mac' set but not used [-Wunused-but-set-variable]

                 uint8_t * mac;

                           ^

C:\Users\dave\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src\WiFiSTA.cpp: In static member function 'static void WiFiSTAClass::_smartConfigCallback(uint32_t, void*)':

C:\Users\dave\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src\WiFiSTA.cpp:626:30: warning: unused variable 'type' [-Wunused-variable]

         smartconfig_type_t * type = (smartconfig_type_t *)result;

                              ^

C:\Users\dave\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi\src\WiFiSTA.cpp:637:26: warning: unused variable 'ip' [-Wunused-variable]

             ip4_addr_t * ip = (ip4_addr_t *)result;

                          ^

In file included from C:\Users\dave\Documents\Arduino\hardware\espressif\esp32\libraries\Update\src\Updater.cpp:5:0:

C:\Users\dave\Documents\Arduino\hardware\espressif\esp32/tools/sdk/include/bootloader_support/esp_image_format.h:44:3: warning: 'esp_image_spi_freq_t' defined but not used [-Wunused-variable]

 } esp_image_spi_freq_t;

   ^

C:\Users\dave\Documents\Arduino\libraries\PubSubClient\src\PubSubClient.cpp: In member function 'boolean PubSubClient::subscribe(const char*, uint8_t)':

C:\Users\dave\Documents\Arduino\libraries\PubSubClient\src\PubSubClient.cpp:473:13: warning: comparison is always false due to limited range of data type [-Wtype-limits]

     if (qos < 0 || qos > 1) {

             ^

Archiving built core (caching) in: C:\Users\dave\AppData\Local\Temp\arduino_cache_1238\core\core_espressif_esp32_esp32_FlashMode_qio,FlashFreq_80,FlashSize_4M,UploadSpeed_921600,DebugLevel_none_5f6a387184da3404d597c112ad981f52.a
Sketch uses 598350 bytes (45%) of program storage space. Maximum is 1310720 bytes.
Global variables use 41908 bytes (14%) of dynamic memory, leaving 253004 bytes for local variables. Maximum is 294912 bytes.
esptool.py v2.1
Connecting........_
Chip is ESP32D0WDQ6 (revision 1)
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...

Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 6553.6 kbit/s)...
Hash of data verified.
Compressed 14128 bytes to 9196...

Writing at 0x00001000... (100 %)
Wrote 14128 bytes (9196 compressed) at 0x00001000 in 0.1 seconds (effective 966.0 kbit/s)...
Hash of data verified.
Compressed 599504 bytes to 345063...

Writing at 0x00010000... (4 %)
Writing at 0x00014000... (9 %)
Writing at 0x00018000... (13 %)
Writing at 0x0001c000... (18 %)
Writing at 0x00020000... (22 %)
Writing at 0x00024000... (27 %)
Writing at 0x00028000... (31 %)
Writing at 0x0002c000... (36 %)
Writing at 0x00030000... (40 %)
Writing at 0x00034000... (45 %)
Writing at 0x00038000... (50 %)
Writing at 0x0003c000... (54 %)
Writing at 0x00040000... (59 %)
Writing at 0x00044000... (63 %)
Writing at 0x00048000... (68 %)
Writing at 0x0004c000... (72 %)
Writing at 0x00050000... (77 %)
Writing at 0x00054000... (81 %)
Writing at 0x00058000... (86 %)
Writing at 0x0005c000... (90 %)
Writing at 0x00060000... (95 %)
Writing at 0x00064000... (100 %)
Wrote 599504 bytes (345063 compressed) at 0x00010000 in 5.7 seconds (effective 838.9 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 122...

Writing at 0x00008000... (100 %)
Wrote 3072 bytes (122 compressed) at 0x00008000 in 0.0 seconds (effective 2234.2 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting...

You can probably just ignore it. It's a good idea to fix all warnings in your own code whenever possible but sometimes other people don't hold their work to such high standards.

If those errors concern you I guess you never used the ESP8266 core. Talk about a lot of warnings! I was hoping they'd have none this time around since they actually have one of the warning levels in File > Preferences set to treat warnings as errors.

I guessed as much, The only problem is the sketch doesn't work, it keeps resetting ? the ESP32 has this coming out of it every few seconds.

ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:956
load:0x40078000,len:0
load:0x40078000,len:13076
entry 0x40078a58

Really I suppose it's a question for the code developer rather than here, but I thought it was best to start here. No I don't have an ESP8266 yet, I ordered the ESP32 and some other things from China and the ESP32 was the first to arrive yesterday.

Dave.

It really isn't a good idea to name the sketch main.ino. That they did suggests that extreme caution is the order of the day.

What is actually connect to the ESP?

Ok, I’ll renamed it to something else, thanks. The ESP32 isn’t connected to anything at all - other than than the USB cable of course

I don't have any experience with the ESP32. On the ESP8266 if you have some code that blocks too long the watchdog times out and resets the microcontroller. That doesn't happen with delay() because it calls yield(), which resets the watchdog timer. The "SW_CPU_RESET" mentioned in the output could be referring to a reset triggered by a watchdog timeout, though I would expect that to have "WDT" in it somewhere.

PaulS: It really isn't a good idea to name the sketch main.ino. That they did suggests that extreme caution is the order of the day.

Actually that's no problem with any recent version of the Arduino IDE because the generated file will be named main.ino.cpp but for backwards compatibility it's best not to use that name.

However, recently I have been seeing a lot of these platformio users publish what are labeled as "Arduino sketches" but have a file named main.cpp with setup and loop functions but no main() and there are no function prototypes and the folder name doesn't match the file name. If they're going to call it "Arduino" it should work with the Arduino IDE. If they're going to use the .cpp extension it should be valid C++ (that's the whole point of the .ino extension).

I think the code was originally made with Platformio so I might try that, but that entails learning a new platform :roll_eyes: As I mentioned before the example sketch wifiscan works ok with the Arduino IDE