message:
Esp8266: Linux - fatal: No names found and undefined reference to `app_entry_custom()'

as Gentoo user I build everything from sources, but I have problem with building toolchain for esp8266. I came up with this script:

    #!/bin/sh

    # note: eselect python2 before, because of gcc

    # prepare board
    mkdir -p ~/Arduino/hardware/esp8266com
    cd ~/Arduino/hardware/esp8266com
    git clone --recursive --depth 1 https://github.com/esp8266/Arduino.git esp8266

    # use system python3
    mkdir esp8266/tools/python3
    ln -s /usr/bin/python3 esp8266/tools/python3/python3

    # build toolchain
    cd ~/Arduino
    git clone --recursive --depth 1 https://github.com/pfalcon/esp-open-sdk.git
    cd esp-open-sdk
    sed -i "193s/.*/                     |\$EGREP '^GNU bash, version (3\\.[1-9]|4|5)')/" crosstool-NG/configure.ac # add bash5 support
    echo CT_DEBUG_gdb=n >> crosstool-config-overrides # don't build gdb
    make STANDALONE=n

    # "install" esp-open-sdk
    ln -sf ~/Arduino/esp-open-sdk/xtensa-lx106-elf ~/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf

It builded successfully, but I get errors during building project:

    (…)
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/python3/python3 /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/makecorever.py --build_path /tmp/arduino_build_179995 --platform_path /home/urhen/Arduino/hardware/esp8266com/esp8266 --version unix-2.7.0-dev
    fatal: No names found, cannot describe anything.
    (…)
    Linking everything together...
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -CC -E -P -DVTABLES_IN_FLASH /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/ld/eagle.app.v6.common.ld.h -o /tmp/arduino_build_179995/local.eagle.app.v6.common.ld
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -fno-exceptions -Wl,-Map -Wl,/tmp/arduino_build_179995/sketch_apr19a.ino.map -g -Wall -Wextra -Os -nostdlib -Wl,--no-check-sections -u app_entry -u _printf_float -u _scanf_float -Wl,-static -L/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/lib -L/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/lib/NONOSDK22x_190703 -L/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/ld -L/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/libc/xtensa-lx106-elf/lib -Teagle.flash.4m2m.ld -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read -o /tmp/arduino_build_179995/sketch_apr19a.ino.elf -Wl,--start-group /tmp/arduino_build_179995/sketch/sketch_apr19a.ino.cpp.o /tmp/arduino_build_179995/core/core.a -lhal -lphy -lpp -lnet80211 -llwip2-536-feat -lwpa -lcrypto -lmain -lwps -lbearssl -laxtls -lespnow -lsmartconfig -lairkiss -lwpa2 -lstdc++ -lm -lc -lgcc -Wl,--end-group -L/tmp/arduino_build_179995
    /tmp/arduino_build_179995/core/core.a(core_esp8266_main.cpp.o):(.text.app_entry+0x0): undefined reference to `app_entry_custom()'
    /tmp/arduino_build_179995/core/core.a(core_esp8266_main.cpp.o): In function `app_entry':
    /home/urhen/Arduino/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_main.cpp:318: undefined reference to `app_entry_custom()'
    collect2: error: ld returned 1 exit status
    exit status 1
    Error compiling for board LOLIN(WEMOS) D1 R2 & mini.

What am I missing?

Log:

    /usr/share/arduino/arduino-builder -dump-prefs -logger=machine -hardware /usr/share/arduino/hardware -hardware /home/urhen/Arduino/hardware -tools /usr/share/arduino/hardware/tools/avr -libraries /home/urhen/Arduino/libraries -fqbn=esp8266com:esp8266:d1_mini:xtal=80,vt=flash,exception=legacy,ssl=all,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600 -ide-version=10807 -build-path /tmp/arduino_build_418955 -warnings=all -prefs=build.warn_data_percentage=75 -verbose /tmp/untitled878766377.tmp/sketch_apr19a/sketch_apr19a.ino
    /usr/share/arduino/arduino-builder -compile -logger=machine -hardware /usr/share/arduino/hardware -hardware /home/urhen/Arduino/hardware -tools /usr/share/arduino/hardware/tools/avr -libraries /home/urhen/Arduino/libraries -fqbn=esp8266com:esp8266:d1_mini:xtal=80,vt=flash,exception=legacy,ssl=all,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600 -ide-version=10807 -build-path /tmp/arduino_build_418955 -warnings=all -prefs=build.warn_data_percentage=75 -verbose /tmp/untitled878766377.tmp/sketch_apr19a/sketch_apr19a.ino
    Using board 'd1_mini' from platform in folder: /home/urhen/Arduino/hardware/esp8266com/esp8266
    Using core 'esp8266' from platform in folder: /home/urhen/Arduino/hardware/esp8266com/esp8266
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/python3/python3 /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/makecorever.py --build_path /tmp/arduino_build_418955 --platform_path /home/urhen/Arduino/hardware/esp8266com/esp8266 --version unix-2.7.0-dev
    Detecting libraries used...
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -I/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/include -I/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/lwip2/include -I/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/libc/xtensa-lx106-elf/include -I/tmp/arduino_build_418955/core -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -ffunction-sections -fdata-sections -fno-exceptions -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10807 -DARDUINO_ESP8266_WEMOS_D1MINI -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_WEMOS_D1MINI\"" -DFLASHMODE_DIO -DESP8266 -I/home/urhen/Arduino/hardware/esp8266com/esp8266/cores/esp8266 -I/home/urhen/Arduino/hardware/esp8266com/esp8266/variants/d1_mini /tmp/arduino_build_418955/sketch/sketch_apr19a.ino.cpp -o /dev/null
    Generating function prototypes...
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -I/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/include -I/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/lwip2/include -I/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/libc/xtensa-lx106-elf/include -I/tmp/arduino_build_418955/core -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -ffunction-sections -fdata-sections -fno-exceptions -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10807 -DARDUINO_ESP8266_WEMOS_D1MINI -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_WEMOS_D1MINI\"" -DFLASHMODE_DIO -DESP8266 -I/home/urhen/Arduino/hardware/esp8266com/esp8266/cores/esp8266 -I/home/urhen/Arduino/hardware/esp8266com/esp8266/variants/d1_mini /tmp/arduino_build_418955/sketch/sketch_apr19a.ino.cpp -o /tmp/arduino_build_418955/preproc/ctags_target_for_gcc_minus_e.cpp
    /usr/bin/arduino-ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /tmp/arduino_build_418955/preproc/ctags_target_for_gcc_minus_e.cpp
    Compiling sketch...
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/python3/python3 /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/signing.py --mode header --publickey /tmp/untitled878766377.tmp/sketch_apr19a/public.key --out /tmp/arduino_build_418955/core/Updater_Signing.h
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -I/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/include -I/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/lwip2/include -I/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/libc/xtensa-lx106-elf/include -I/tmp/arduino_build_418955/core -c -Wall -Wextra -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -MMD -ffunction-sections -fdata-sections -fno-exceptions -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10807 -DARDUINO_ESP8266_WEMOS_D1MINI -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_WEMOS_D1MINI\"" -DFLASHMODE_DIO -DESP8266 -I/home/urhen/Arduino/hardware/esp8266com/esp8266/cores/esp8266 -I/home/urhen/Arduino/hardware/esp8266com/esp8266/variants/d1_mini /tmp/arduino_build_418955/sketch/sketch_apr19a.ino.cpp -o /tmp/arduino_build_418955/sketch/sketch_apr19a.ino.cpp.o
    Compiling libraries...
    Compiling core...
    Using previously compiled file: /tmp/arduino_build_418955/core/cont.S.o
    Using previously compiled file: /tmp/arduino_build_418955/core/umm_malloc/umm_info.c.o
    Using previously compiled file: /tmp/arduino_build_418955/core/umm_malloc/umm_integrity.c.o
    Using previously compiled file: /tmp/arduino_build_418955/core/umm_malloc/umm_local.c.o
    Using previously compiled file: /tmp/arduino_build_418955/core/umm_malloc/umm_poison.c.o
    Using previously compiled file: /tmp/arduino_build_418955/core/Esp-frag.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/core_esp8266_postmortem.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/WMath.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/heap.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/core_esp8266_sigma_delta.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/WString.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/libc_replacements.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/core_esp8266_si2c.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/gdb_hooks.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/core_esp8266_timer.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/spiffs_api.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/Stream.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/abi.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/Esp.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/Esp-version.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -I/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/include -I/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/lwip2/include -I/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/libc/xtensa-lx106-elf/include -I/tmp/arduino_build_418955/core -c -Wall -Wextra -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -MMD -ffunction-sections -fdata-sections -fno-exceptions -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10807 -DARDUINO_ESP8266_WEMOS_D1MINI -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_WEMOS_D1MINI\"" -DFLASHMODE_DIO -DESP8266 -I/home/urhen/Arduino/hardware/esp8266com/esp8266/cores/esp8266 -I/home/urhen/Arduino/hardware/esp8266com/esp8266/variants/d1_mini /home/urhen/Arduino/hardware/esp8266com/esp8266/cores/esp8266/Updater.cpp -o /tmp/arduino_build_418955/core/Updater.cpp.o
    Using previously compiled file: /tmp/arduino_build_418955/core/core_esp8266_spi_utils.cpp.o
    [cut due to characters limit]
    Using previously compiled file: /tmp/arduino_build_418955/core/Schedule.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/Esp-frag.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/Esp-version.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/Esp.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/FS.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/FSnoop.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/FunctionalInterrupt.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/HardwareSerial.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/IPAddress.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/MD5Builder.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/Print.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/Schedule.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/StackThunk.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/Stream.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/StreamString.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/Tone.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/Updater.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/WMath.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/WString.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/abi.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/base64.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/cbuf.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/cont.S.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/cont_util.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_app_entry_noextra4k.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_eboot_command.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_features.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_flash_utils.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_i2s.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_main.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_noniso.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_phy.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_postmortem.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_si2c.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_sigma_delta.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_spi_utils.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_timer.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_waveform.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_wiring.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_wiring_analog.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_wiring_digital.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_wiring_pulse.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_wiring_pwm.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/core_esp8266_wiring_shift.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/crc32.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/debug.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/flash_hal.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/gdb_hooks.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/heap.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/libb64/cdecode.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/libb64/cencode.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/libc_replacements.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/sntp-lwip2.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/spiffs/spiffs_cache.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/spiffs/spiffs_check.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/spiffs/spiffs_gc.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/spiffs/spiffs_hydrogen.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/spiffs/spiffs_nucleus.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/spiffs_api.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/sqrt32.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/time.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/uart.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/umm_malloc/umm_info.c.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/umm_malloc/umm_integrity.c.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/umm_malloc/umm_local.c.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/umm_malloc/umm_malloc.cpp.o
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru /tmp/arduino_build_418955/core/core.a /tmp/arduino_build_418955/core/umm_malloc/umm_poison.c.o
    Linking everything together...
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -CC -E -P -DVTABLES_IN_FLASH /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/ld/eagle.app.v6.common.ld.h -o /tmp/arduino_build_418955/local.eagle.app.v6.common.ld
    /home/urhen/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -fno-exceptions -Wl,-Map -Wl,/tmp/arduino_build_418955/sketch_apr19a.ino.map -g -Wall -Wextra -Os -nostdlib -Wl,--no-check-sections -u app_entry -u _printf_float -u _scanf_float -Wl,-static -L/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/lib -L/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/lib/NONOSDK22x_190703 -L/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/ld -L/home/urhen/Arduino/hardware/esp8266com/esp8266/tools/sdk/libc/xtensa-lx106-elf/lib -Teagle.flash.4m2m.ld -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read -o /tmp/arduino_build_418955/sketch_apr19a.ino.elf -Wl,--start-group /tmp/arduino_build_418955/sketch/sketch_apr19a.ino.cpp.o /tmp/arduino_build_418955/core/core.a -lhal -lphy -lpp -lnet80211 -llwip2-536-feat -lwpa -lcrypto -lmain -lwps -lbearssl -laxtls -lespnow -lsmartconfig -lairkiss -lwpa2 -lstdc++ -lm -lc -lgcc -Wl,--end-group -L/tmp/arduino_build_418955
    /tmp/arduino_build_418955/core/core.a(core_esp8266_main.cpp.o):(.text.app_entry+0x0): undefined reference to `app_entry_custom()'
    /tmp/arduino_build_418955/core/core.a(core_esp8266_main.cpp.o): In function `app_entry':
    /home/urhen/Arduino/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_main.cpp:318: undefined reference to `app_entry_custom()'
    collect2: error: ld returned 1 exit status
    exit status 1
    Error compiling for board LOLIN(WEMOS) D1 R2 & mini.

body:
You did a shallow copy of the git repo:<br>
The solution is to ensure that the initial clone of the repo in the build environment was not a shallow clone (i.e. the git clone command was not used with --depth, --shallow-since or --shallow-exclude parameters).
 so change your

    git clone --recursive --depth 1 https://github.com/esp8266/Arduino.git esp8266
    ....
    git clone --recursive --depth 1 https://github.com/pfalcon/esp-open-sdk.git

to

    git clone --recursive https://github.com/esp8266/Arduino.git esp8266
    ....
    git clone --recursive https://github.com/pfalcon/esp-open-sdk.git

and make sure your *.ino contains at least

     setup(){}

AND

    loop(){}


sender: user

message:
Correct position for buttonState in my FSM

I wrote a FSM with the help of some tutorials through out the world wide web and so far it does what I want to do with it.

But one thing that is not the way I want to be, is to exit the state noLightPause during the non blocking delay with the button to enter the yellowLight state again.
I cannot figure out where to put the buttonState inside my code, if it should be that simple to exit that state, because it was hard enought for me to get my machine going to that point :D.

Do not get confused, I soldered the button from ground to the pin, so LOW gets the input :).

Hope you guys can help me with that problem to get me further with my machine.

Thanks in advance for all your help, here is my code:

    #include <FastLED.h>

    #define NUM_LEDS 16

    CRGB ledStrip [NUM_LEDS];

    const int buttonPin = 4;
    const int ledStripPin = 8;
    const int ledOnBoard = 13;
    const int interval = 100;

    int buttonState = 0;
    int lastButtonState = 0;

    int ledOnBoardState = LOW;

    unsigned long previousMillis = 0;
    static unsigned long noDelayPause;

    enum statusType {whiteLight, yellowLight, noLightPause, noLight};

    statusType currentStatus = whiteLight;

    void setup() {

      pinMode(buttonPin, INPUT_PULLUP);
      pinMode(ledStrip, OUTPUT);
      pinMode(ledOnBoard, OUTPUT);

      FastLED.addLeds<NEOPIXEL, 8>(ledStrip, NUM_LEDS).setCorrection(DirectSunlight);
      FastLED.show();
    }

    void loop() {

      //----------------------------------------
      // just to see if the machine is blocking something

      unsigned long currentMillis = millis();

      if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;

        if (ledOnBoardState == LOW) {
          ledOnBoardState = HIGH;
        } else {
          ledOnBoardState = LOW;
        }
        digitalWrite(ledOnBoard, ledOnBoardState);
      }

      //----------------------------------------

      switch (currentStatus) {

        case whiteLight:
          currentStatus = whiteLightFunction();
          break;

        case yellowLight:
          currentStatus = yellowLightFunction();
          break;

        case noLightPause:
          noDelayPause = millis();
          currentStatus = noLightPauseFunction();
          break;

        case noLight:
          if (millis() - noDelayPause > 1000) {
            currentStatus = noLightFunction();
            break;
          }
      }
    }

    statusType whiteLightFunction() {

      if (digitalRead(buttonPin) == LOW) {

        return (yellowLight);

      } else {

        fill_solid(ledStrip, NUM_LEDS, CRGB::White);
        FastLED.setBrightness(100);
        FastLED.show();

        return (whiteLight);
      }
    }

    statusType yellowLightFunction() {

      if (digitalRead(buttonPin) == LOW) {

        fill_solid(ledStrip, NUM_LEDS, CRGB::Yellow);
        FastLED.setBrightness(100);
        FastLED.show();

        return (yellowLight);

      } else {

        return (noLightPause);
      }
    }

    statusType noLightPauseFunction() {

      fill_solid(ledStrip, NUM_LEDS, CRGB::Black);
      FastLED.show();

      if (digitalRead(buttonPin) == LOW) {

        return (yellowLight);

      } else {

        if (digitalRead(buttonPin) == HIGH) {

          return (noLight);
        }
      }
    }

    statusType noLightFunction() {

      if (digitalRead(buttonPin) == LOW) {

        return (yellowLight);

      } else {

        return (whiteLight);
      }
    }

sender: assistant

body:
You should also introduce a button state to have the FSM working as a FSM

     bool buttonState = false;

in the loop you check for the press/release and change the state:

    if (digitalRead(buttonPin) == LOW && buttonState == true) buttonState == false;
    if (digitalRead(buttonPin) == HIGH && buttonState == false) buttonState == true;

inside your function you only go for buttonState eg

    statusType noLightFunction() {
    if (buttonState == false) {  // Button is NOT pressed

        return (yellowLight);

      } else {       // Button is pressed

        return (whiteLight);
      }
    }

The button acts as a toogle switch as long as you keep it pressed (or released) nothing will change only the state changes caise an action to happen. I personally use "speaking" vars I still know years later so instead of
`buttonState` I use `buttonIsPressed` but thats flavour


message:
Gratuitious instantiation of `Serial`, why?

Let's take a very simple sketch, any simple one-.ino sketch. Say, just a led blinker like this
<!-- language-all: lang-cpp -->

    void setup()
    {
      pinMode(LED_BUILTIN, OUTPUT);
      digitalWrite(LED_BUILTIN, LOW);
    }

    void loop()
    {
      static bool on;
      digitalWrite(LED_BUILTIN, (on = !on) ? HIGH : LOW);
      delay(1000);
    }

Once compiled in Arduino IDE, compiler reports using 10 bytes for global variables. This is perfect for our purposes.

Now let's add an extra `.cpp` file to it. Let's call it `foo.cpp`. The file looks like follows

    #include <Arduino.h>

    int foo()
    {
      return Serial.available();
    }

Compile it all together. Now the compiler reports using 185 bytes for globals. But why?!

Clearly, this extra global memory usage is `Serial`. It is brought in by the fact that global object `Serial` is referenced from `foo`. In the original sketch `Serial` is not instantiated (or discarded) by the linker as an unreferenced symbol. In this case it is referenced from `foo`, so the linker keeps it.

But... But GCC linker is usually smarter than this. I'd expect it to see that symbol `foo` is not referenced anywhere, so the reference to `Serial` inside `foo` also "doesn't count" and should not require an instance of `Serial` in final code.

In fact, if I tried using my own "heavy" class, my own global variable of that class and reference it in `foo` (instead of `Serial`), GCC would work as expected: regardless of how "heavy" my global variable is, GCC linker would discard my global variable from the final code and report the same 10 bytes for globals, as expected. The global memory usage would remain at 10 until I'd actually reference `foo` from somewhere.

But `Serial` is somehow special. Even an "unused" mention of `Serial` causes it to appear in global memory. What is so special about it? What makes it behave that way?

body:
I compiled the examples with the microCore/attiny13 which has a different Serial implementation there the compiler behaves as expected.

So reducing in `HardwareSerial.h` the

     #define SERIAL_RX_BUFFER_SIZE 64

     to

    #define SERIAL_RX_BUFFER_SIZE 0

does exactly 121 bytes used (which is 185-64) the same for

     #define SERIAL_TX_BUFFER_SIZE 64

     to

    #define SERIAL_TX_BUFFER_SIZE 0

gives 57 bytes (121-64). This is used by `Stream protected`:

    unsigned char _rx_buffer[SERIAL_RX_BUFFER_SIZE];
    unsigned char _tx_buffer[SERIAL_TX_BUFFER_SIZE];

I did not go through all the used libs to find the rest, but I guess its the global defines (buffers) for the global object Serial. The microCore lib has all buffers set to 0 so thats how I found it.


body:
My guess (though I didn't check) is that it is a side effect of the fact
that [the same file][serial0] contains the instantiation of `Serial` and the
associated ISRs. The [definition of the ISR macro][ISR] looks roughly
like this (slightly simplified):

```c++
#define ISR(vector) extern "C" \
    void __attribute__((signal, used, externally_visible)) vector(void)
```

The key here is the “used” attribute. It tells the compiler that the
symbol should be considered to be used, even though no code calls the
ISR (for a good reason: it's called by the hardware).

When your program is linked, the object file foo.o pulls in
HardwareSerial0.o. The linker then sees the serial ISRs which are
labeled as “used”. These in turn make use of the `Serial` object which
then appears to also be used.

[serial0]: https://github.com/arduino/ArduinoCore-avr/blob/1.8.2/cores/arduino/HardwareSerial0.cpp
[ISR]: http://svn.savannah.gnu.org/viewvc/avr-libc/tags/avr-libc-2_0_0-release/include/avr/interrupt.h?revision=2516&view=markup#l135


message:
NodeMCU V2 ESP8266 - Use 5VIN as power for heater of a MQ-9 Sensor

Right now I'm trying to understand how I could (easily) power the heater of my MQ-9 carbon monoxid and gas sensor.

Here is the datasheet: http://www.haoyuelectronics.com/Attachment/MQ-9/MQ9.pdf

It needs 5V for some gases, so I thought I could maybe power the heater via the 5VIN pin (while plugged via usb), since the other output pins have a max. voltage of only 3.3 V?

And to control the power, I could then add a relay switch, which would cut the circuit between heater and VIN (if I only want to measure the gases)?

Or am I completely wrong?

P.S: And no - I don't want to add a 5V power supply additional to the normal USB plugging on VIN :)

body:
The VIN pin is **NOT** directly connected to the USB's 5V supply as it is an **VIN PIN** for powering the MCU from an external source other than the USB - this means the **pin cannot be used** as a 5V supply output.

  - Never ever connect VIN to a power source **AND** connect the USB plug. That can destroy the USB port in your computer. There is zero back-powering protection on the MCU board.

<br>According to the datasheet the sensor (heater) needs upto 350mW which IMHO makes powering via an extra power board (which can also power the MCU) a necessity.


message:
Crash when serving static files width ESP8266WebServer

For the past two days, I've been trying to set up an ESP8266WebServer to serve my static web app files from SPIFFS. But as soon as I make a call to `serveStatic`, the ESP crashes. This is the exact code I'm running:

    #include <FS.h>
    #include <ESP8266WebServer.h>

    ESP8266WebServer s;

    void setup() {

        Serial.begin(115200);

        if(!SPIFFS.begin()){
            Serial.println("An Error has occurred while mounting SPIFFS");
            return;
        }

        s.serveStatic("/", SPIFFS, "/static/");
        s.begin();
    }

    void loop() {
      s.handleClient();
    }

I know that this is example does not allow me to access the files in any way because I don't have WiFi configured, but this is enough for me to crash the ESP. This is the error that I keep seeing:

```SDK:2.2.2-dev(38a443e)/Core:2.6.3=20603000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-16-ge23a07e/BearSSL:89454af
SPIFFSImpl: allocating 512+240+1400=2152 bytes
SPIFFSImpl: mounting fs @100000, size=2fa000, block=2000, page=100
SPIFFSImpl: mount rc=0

Fatal exception 28(LoadProhibitedCause):
epc1=0x4021407a, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000

Exception (28):
epc1=0x4021407a epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffca0 end: 3fffffc0 offset: 01a0
3ffffe40:  3ffefaf8 00000000 3ffffea0 402127b1
3ffffe50:  00000001 ffffffff 4020a9dc 00000000
3ffffe60:  3ffe8304 00000000 0000000a 40216e21
3ffffe70:  402497e1 00000000 00000000 4020b414
3ffffe80:  3ffffee0 3ffffed0 00000008 402497e3
3ffffe90:  402497e2 3ffe8304 3ffefaf8 402171ec
3ffffea0:  00000000 ffffffff 00000000 00000000
3ffffeb0:  00000001 00000041 3f302073 40212d8e
3ffffec0:  3ffffee0 3ffffed0 00000004 40209c90
3ffffed0:  3fffff10 00000000 00000017 3fff0580
3ffffee0:  00308658 3fffff20 3ffef85c 4020a3e9
3ffffef0:  000018c0 3ffee6b0 00000000 40208120
3fffff00:  3fffff60 3fffff50 00000014 00000001
3fffff10:  00000009 00000001 00000001 40207c65
3fffff20:  40100b04 00001000 00002000 3fff0580
3fffff30:  3ffe8658 402497a4 3ffe8304 40212d8e
3fffff40:  3fffff60 3fffff50 00000004 40100476
3fffff50:  3ffe8658 3ffe8658 3ffe865f 00000000
3fffff60:  00000000 00000000 3fff056c 4020ffa5
3fffff70:  3fffdad0 3ffee690 3fff056c 40201325
3fffff80:  3ffe865f feefeffe feefeffe feefeffe
3fffff90:  feefeffe feefeffe feefeffe 3ffee610
3fffffa0:  3fffdad0 00000000 3ffee5d0 40206aa0
3fffffb0:  feefeffe feefeffe 3ffe84f4 40101245
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1392, room 16
tail 0
chksum 0xd0
csum 0xd0
v3d128e5c
~ld
```

I have also analyzed the stack trace using ESP exception decoder, which didn't get me any further though. Here is the output of that tool:

```

Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads
PC: 0x4021407a: pgm_read_byte_inlined at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/sys/xtensa/sys/pgmspace.h line 72
EXCVADDR: 0x00000000

Decoding stack results
0x402127b1: _printf_i at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf_i.c line 226
0x4020a9dc: spiffs_object_find_object_index_header_by_name_v(spiffs*, spiffs_obj_id, spiffs_block_ix, int, void const*, void*) at /Users/alex/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/spiffs/spiffs_nucleus.cpp line 1664
0x40216e21: __sfputs_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c line 433
0x4020b414: spiffs_obj_lu_scan(spiffs*) at /Users/alex/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/spiffs/spiffs_nucleus.cpp line 439
0x402171ec: _vfprintf_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c line 667
0x40212d8e: printf at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/printf.c line 61
0x40209c90: SPIFFS_mount(spiffs*, spiffs_config*, u8_t*, u8_t*, u32_t, void*, u32_t, spiffs_check_callback) at /Users/alex/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/spiffs/spiffs_hydrogen.cpp line 138
0x4020a3e9: SPIFFS_stat(spiffs*, char const*, spiffs_stat*) at /Users/alex/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/spiffs/spiffs_hydrogen.cpp line 769
0x40208120: spiffs_impl::SPIFFSImpl::_tryMount() at /Users/alex/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/spiffs_api.h line 320
0x40207c65: spiffs_impl::SPIFFSImpl::exists(char const*) at /Users/alex/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/spiffs_api.cpp line 80
0x40100b04: get_poisoned(void*, size_t) at /Users/alex/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/umm_malloc/umm_poison.c line 112
0x40212d8e: printf at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/printf.c line 61
0x40100476: pvPortMalloc(size_t, char const*, int) at /Users/alex/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/heap.cpp line 267
0x4020ffa5: fs::FS::exists(char const*) at /Users/alex/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/FS.cpp line 363
0x40201325: setup() at /Users/alex/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h line 75
0x40206aa0: loop_wrapper() at /Users/alex/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_main.cpp line 177

```
These are my settings in the Arduino IDE:

[![Sketch settings in IDE][1]][1]

  [1]: https://i.stack.imgur.com/T2XSa.jpg

To flash the data to the ESP, im using the latest version of this tool for the Arduino-IDE: https://github.com/esp8266/arduino-esp8266fs-plugin

I'm probably making a stupid mistake but I've been scratching my head for hours now and can't see where the issue could be. Any help would be greatly appreciated!

**EDIT #1:**

The data is definitely available on the ESP, since this snippet works fine:

```
#include <FS.h>
#include <ESP8266WebServer.h>

ESP8266WebServer s;

void setup() {

    Serial.begin(115200);

    if(!SPIFFS.begin()){
        Serial.println("An Error has occurred while mounting SPIFFS");
        return;
    }

    /*s.serveStatic("/", SPIFFS, "/static/");
    s.begin();*/
}

void loop() {
  //s.handleClient();

    delay(5000);

    File f = SPIFFS.open("/static/index.html", "r");

    String s = f.readString();

    Serial.println(s);

    f.close();
}
```

**EDIT #2**

Serving the files by registering the function below as a handler (```server.on("/", myHandler)```works:

```
void myHandler(){

    String file = "/static/index.html";

    Serial.println("[INFO] requested file " + file);

    if(!SPIFFS.exists(file)){

        server.send(404, "text/plain", "<h1>404: Not found</h1>");
        return;
    }

    String contentType = "text/plain";

    if(file.endsWith(".html")){
        contentType = "text/html";
    } else if(file.endsWith(".css")){
        contentType = "text/css";
    } else if(file.endsWith(".js")){
        contentType = "application/javascript";
    }

    File f = SPIFFS.open(file, "r");

    server.streamFile(f, contentType);

    f.close();
}
```

body:
Probably you have no SPIFFS uploaded.
So after flashing the program you have to use ESP8266DataUpload and in your Dir containing the *.ino there has to be a "data" directory in which the file you serve or the dir in your case "/static/" has to exist.

**EDIT** No the file is not existing ;-) use

     serveStatic("/", SPIFFS, "/static");  //=> no trailing '/'

or use (Be aware that serving dirs static is not working properly. I have every large file in a single static statement including the ageing

     serveStatic("/", SPIFFS, "/static/index.html");

Not knowing the size of your static files flash with 2MB FS / or 1MB FS / the problem is that if you don't need OTA you always waste space. I created my personal partition schemes with e.g. 2MB Spiffs/2MB flash/No OTA for the prog.

Your memory should be sized as follows prog size + var size (seen in IDE) + size of the largest (static) files * 1.2 (safety margin) should fill "App memory" around 80%.
 As an example your usage is at the moment as follows:

You have at the moment max 400kb for the app AND serving (static) files. You use

  - 3 MB for SPIFFS file system,
  - 512 for OTA,
  - min 100kb for your Debug level

=> how could it keep/load e.g a 300kb file into flash?

Your error code 28 is normally connected to out of memory problems, the error message line two indicates that something should be loaded to memory and cant, We ruled out all other reasons so ...


body:
Turns out the ESP crash is caused by the debug settings in the Arduino IDE. As soon as the CORE-level is included, the error occurs. There seems to be a bug in the firmware somewhere. Including other levels seems to be fine.

A huge thanks to [Juraj](https://arduino.stackexchange.com/users/37622/juraj) for helping me spot this one.


message:
ESP8266 to ESP8266 via home rooter

I would like to ask how to build a star topology network with several ESP8266s, pc and a home wifi router?
I would like to connect my computer (as a client) and ESP8266s (as clients) together via a wifi router and exchange data between them.

Thanks in advance,

Best,

body:
The sending / receiving of data has nothing to do with the topology. In fact, when you have one ESP8266 as an access point and another as a station that is no different to having two ESP8266's as stations communicating through an access point.  The topology is transparent to the communication of user data as that is a completely different (lower) layer of the OSI model and as such is hidden from the layers above.

You communicate in *exactly the same way* regardless of your topology.  That is - one end opens a socket of some form and the other end connects to (for TCP) and sends data to (for both TCP and UDP) that socket. For TCP the "server" socket can then also send data back through the same connection. For UDP there is no "server" as such, but just two peers that send data to each other and for two-way communication both ends need to be a "server" to receive data.

What you need to do is define what data you want to send and what method of sending that data will be most suitable for your system - be that simple UDP packets, or something more complex like one of the many HTTP-based API systems.


message:
pubsubclient won't compile in Arduino and VSCode IDEs

I've compiled successfully a year ago in Arduino IDE, but lately I'm getting fatal errors:

    /Users/davidjeffers/Documents/Arduino/libraries/PubSubClient/src/PubSubClient.cpp: At global scope:
    /Users/davidjeffers/Documents/Arduino/libraries/PubSubClient/src/PubSubClient.cpp:473:8: error: redefinition of 'size_t PubSubClient::write(uint8_t)'
    size_t PubSubClient::write(uint8_t data) {
    ^

    In file included from /Users/davidjeffers/Documents/Arduino/libraries/PubSubClient/src/PubSubClient.cpp:7:0:
    /Users/davidjeffers/Documents/Arduino/libraries/PubSubClient/src/PubSubClient.h:160:19: error: 'virtual size_t PubSubClient::write(uint8_t)' previously defined here
    virtual size_t write(uint8_t) {};
    ^

I've tried using VSCode. I've tried opening an issue on GitHub.

Thanks for any thoughts.

body:
The library is somehow modified. There should be no {} in `virtual size_t write(uint8_t) {};` or the whole line shouldn't be in this .h.

Reinstall the library.


message:
How are libraries added to the Arduino library manager?

Who curates the list of libraries in the `Tools / Manage Libraries` menu, and what is the procedure for submitting code for consideration?

body:
You have to [submit a ticket][1] to the Arduino GitHub page. If you want to do this in an automated fashion, you can use [this python program][2]. Make sure beforehand that your library fits the [Arduino library specification][3].

  [1]: https://github.com/arduino/Arduino/issues
  [2]: https://github.com/PowerBroker2/Arduino_IDE_Issue_Maker
  [3]: https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ


message:
can we use Software serial and timer one at the same time or this software use also timer one?

i am using timer1 and software serial for gps data i need to see if we have a problem with connection .
So i made a timer1 that's start before the loop that will wait the gps sending and after 3s if we didn't receive data we will exit the loop of waiting and going to make diffrent thing .

body:
According to [Answer][1] software serial only you pinchange interrupt and CPU  delay loop. which means it not effect any timer but it might freeze system while transmission.

  [1]: https://arduino.stackexchange.com/questions/35032/does-softwareserial-use-hardware-timer


message:
DHT11 Humidity/Temp Sensor showing incorrect values

So I am trying to use a humidity sensor with an LCD, but have run into this problem I have yet to fix. My problem is that when it is turned on, it returns the values `Humidity: 255%` and `Temp: 255C`. I know for sure that I am getting a signal from the sensor and that is working 100% (I have tested it without an LCD display). I have asked about this in the Adafruit Discord server and someone brought up the possibility of the data being clipped somewhere in the data collection/signal processing/printing chain. Still very confused about how I can fix this, I ask for help.

Here is some code:
```c
#include <dht11.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

dht11 DHT;

#define DHT11_PIN 7

void setup(){
  lcd.begin(16, 2);
}

void loop()
{
  int chk = DHT.read(DHT11_PIN);
  lcd.setCursor(0,0);
  lcd.print("Temp: ");
  lcd.print(DHT.temperature);
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0,1);
  lcd.print("Humidity: ");
  lcd.print(DHT.humidity);
  lcd.print("%");
  delay(1000);
}
```

body:
Obviously the DHT sensor has not acquired data to make sure do as follows:

    void loop() {
      float h = dht.readHumidity();
      float t = dht.readTemperature();

      if (isnan(h) || isnan(t) ) {
       lcd.setCursor(0,0);
        lcd.println("DHT not ready!");
        return;
      }
     lcd.setCursor(0,0);
      lcd.print("Temp: ");
      lcd.print(t);
      lcd.print((char)223);
      lcd.print("C");
      lcd.setCursor(0,1);
      lcd.print("Humidity: ");
      lcd.print(h);
      lcd.print("%");
      delay(1000);
    }

Make sure you connected the DHT the right way and **initialized**

    DTH11

        Pin1 --> 5v and 10k ohm resistor

        Pin2 --> Arduino Pin7 and 10k ohm resistor

        Pin3 --> no connection

        Pin4 --> Gnd

Initialize correctly

        DHT dht(DHT11_PIN, DHT11);

and in setup() you have to start like

     dht.begin();

Now test and report back


message:
Serial comunication with HC-05 - Arduino UNO

I am new to the site and this is my first question. I'm going to try to describe my issue the best I can.

I got the following code for my project which consists basically of getting a car to have 2 driving mode, automatic and manual.

As far as I can tell, I got it all working except it's not. I got an HC-05 connected to my L293D motor shield (attached to an Arduino UNO), as well as 2 dc motors, an ultrasonic sensor HC-SR04 and a LED. The circuit part is not the problem, I’ve managed to connect it all and it's working (I tested the obstacle avoiding part by itself, before adding the mode selection code, so I know the motors and sensor do their job). I should also mention that I’m sending the information through the BT from an app I made in APP Inventor. The app is working fine, and I do receive the correct data in the Serial Monitor.

What’s puzzling me is, why can’t I get to assign the Serial.read(); value to my response variable (resp). I’m going to try to explain this a bit further. In my serial monitor I get the intended chars from the app buttons, however, my “resp” variable doesn’t seem to be getting any value from Serial.read(); for some reason, because when it gets to the switch statement, even though the char is printed on the monitor the cases don’t start, for instance, and I might be completely off here, once I get ‘1’ on the monitor I should also start getting the distance measurement printed in the monitor and it’s not.

For what I gather, I believe the issue is between the Serial.write() and the Serial.println()/.read(); since the serial.write() seems to be taking priority over all others, since setting this lines as comments don’t affect the writing in the monitor:

```
if(Serial.available()>0){
//resp = Serial.read();
//Serial.println(resp);
```

I’m out of ideas so, any help or guidance towards the right direction will be greatly appreciated.

```
//Incluir librerias para controlar motor shield y sensor ultrasonico.
#include <AFMotor.h>
#include <NewPing.h>
#include <SoftwareSerial.h>

//Definir constantes y variables.
#define TRIG_P A4
#define ECHO_P A5
#define MAX_DIST 300
#define MAX_Vel 200
int led = A0;
int speedSet;
int iteraciones = 5;
float distancia, duracion;
char resp;

//Inicializar objetos del sensor y motores.
NewPing sonar(TRIG_P, ECHO_P, MAX_DIST);
AF_DCMotor motorD(2);
AF_DCMotor motorI(1);
SoftwareSerial BTSerial(A1, A2); // RX | TX

void setup() {
  Serial.begin(9600);
  pinMode(led, OUTPUT);
  BTSerial.begin(9600);
}

void loop() {

  //Lee información del BT y la escribe en el monitor serial.
  if (BTSerial.available()){
    Serial.write(BTSerial.read());
    Serial.write('\n');
  }

  delay(24); //Tiempo maximo que tarda en recibir una medición.

      /*Calcular la distancia frente al sensor utilizando la duración de la señal,
      la cual mide ida y vuelva por lo cual se divide entre 2
      y se multiplica por la velocidad del sonido (343 m/s).
      */

      duracion = sonar.ping_median(iteraciones);
      distancia = (duracion/2)*0.0343;

  if(Serial.available()>0){
    resp = Serial.read();
    Serial.println(resp);

    switch(resp){

      case '1':

      delay(24); //Tiempo maximo que tarda en recibir una medición.

      /*Calcular la distancia frente al sensor utilizando la duración de la señal,
      la cual mide ida y vuelva por lo cual se divide entre 2
      y se multiplica por la velocidad del sonido (343 m/s).
      */

      duracion = sonar.ping_median(iteraciones);
      distancia = (duracion/2)*0.0343;

      Serial.print("Distancia: ");
      Serial.print(distancia);
      Serial.println(" cm");

      if(distancia!=0 && distancia<=20){
        digitalWrite(led,HIGH);
        ALTO();
        delay(100);
        REVERSA();
        delay(400);
        IZQUIERDA();
        delay(100);
      }else
        digitalWrite(led,LOW);
        ADELANTE();
      break;

      case '2':
      ALTO();

        switch(resp){

          case 'A':
            ADELANTE();
          break;
          case 'R':
            REVERSA();
          break;
          case 'I':
            IZQUIERDA();
          break;
          case 'D':
            DERECHA();
          break;
          case 'O':
            ALTO();
          break;
        }
        break;
       }
    }
 }

  // Inician metodos que definen las acciones del carro.

void ADELANTE(){
   motorD.run(FORWARD);
   motorI.run(FORWARD);
    for (speedSet = 0; speedSet < MAX_Vel; speedSet +=2){
      motorD.setSpeed(speedSet + 20);
      motorI.setSpeed(speedSet - 20);
    }
  }

void REVERSA(){
   motorD.run(BACKWARD);
   motorI.run(BACKWARD);
    for (speedSet = 0; speedSet < MAX_Vel; speedSet +=2){
      motorD.setSpeed(speedSet + 20);
      motorI.setSpeed(speedSet - 20);
    }
  }

void DERECHA() {
   motorD.run(RELEASE);
   motorI.run(FORWARD);
   delay(300);
   motorD.run(FORWARD);
   motorI.run(FORWARD);
  }

void IZQUIERDA() {
   motorD.run(FORWARD);
   motorI.run(RELEASE);
   delay(300);
   motorD.run(FORWARD);
   motorI.run(FORWARD);
  }

void ALTO(){
   motorD.run(RELEASE);
   motorI.run(RELEASE);
  }

```

Here is an image of what I get on my serial monitor.
[![Serial Monitor with BT readings.][1]][1]

  [1]: https://i.stack.imgur.com/MwYgo.png

UPDATE:

As suggested by @chrisl, I'm now looking at it from a different approach.

I was sending the BT information to the serial monitor when the idea in the first place is having the car run around without being connected to the pc at all.

So instead of sending the information to serial monitor and trying to take it from there, I simply asigned the value from BTSerial to my variable and it kinda works as intended now.

"Automatic mode" is working, my switch statement recognises the resp value and starts measuring and prints the distance, however, once I push '2', the first command activates and the motors stop but all the other instructions don't work. I even changed my second switch statemate to if's but that didnt help either.

Here's my new Serial output (9600 / Newline / COM5):
```
1
Distancia: 46.84 cm
Distancia: 154.74 cm
Distancia: 154.33 cm
Distancia: 154.68 cm
Distancia: 154.33 cm
Distancia: 155.70 cm
Distancia: 13.09 cm
Distancia: 12.74 cm
Distancia: 155.16 cm
Distancia: 155.77 cm
Distancia: 155.22 cm
Distancia: 154.81 cm
Distancia: 155.29 cm
Distancia: 155.22 cm
Distancia: 155.22 cm
2
A
R
I
@
D
O
1
Distancia: 155.43 cm
Distancia: 155.50 cm
Distancia: 155.57 cm
Distancia: 155.50 cm
Distancia: 155.09 cm
Distancia: 155.50 cm
Distancia: 155.09 cm
Distancia: 156.32 cm
Distancia: 155.57 cm
Distancia: 155.16 cm
Distancia: 155.09 cm
Distancia: 155.09 cm
Distancia: 155.50 cm
2
```
And my updated code:
```
//Incluir librerias para controlar motor shield y sensor ultrasonico.
#include <AFMotor.h>
#include <NewPing.h>
#include <SoftwareSerial.h>

//Definir constantes y variables.
#define TRIG_P A4
#define ECHO_P A5
#define MAX_DIST 300
#define MAX_Vel 200
int led = A0;
int speedSet;
int iteraciones = 5;
float distancia, duracion;
char resp;

//Inicializar objetos del sensor y motores.
NewPing sonar(TRIG_P, ECHO_P, MAX_DIST);
AF_DCMotor motorD(2);
AF_DCMotor motorI(1);
SoftwareSerial BTSerial(A1, A2); // RX | TX

void setup() {
  Serial.begin(9600);
  pinMode(led, OUTPUT);
  BTSerial.begin(9600);
}

void loop() {

  //Lee información del BT y la escribe en el monitor serial.
  if (BTSerial.available()){
    resp = BTSerial.read();
    Serial.println(resp);
  }

//  if(Serial.available()>0){
//    resp = Serial.read();
//    Serial.println(resp);

    switch(resp){

      case '1':

      delay(24); //Tiempo maximo que tarda en recibir una medición.

      /*Calcular la distancia frente al sensor utilizando la duración de la señal,
      la cual mide ida y vuelva por lo cual se divide entre 2
      y se multiplica por la velocidad del sonido (343 m/s).
      */

      duracion = sonar.ping_median(iteraciones);
      distancia = (duracion/2)*0.0343;

      Serial.print("Distancia: ");
      Serial.print(distancia);
      Serial.println(" cm");

      if(distancia!=0 && distancia<=20){
        digitalWrite(led,HIGH);
        ALTO();
        delay(100);
        REVERSA();
        delay(400);
        IZQUIERDA();
        delay(100);
      }else
        digitalWrite(led,LOW);
        ADELANTE();
      break;

      case '2':
      ALTO();

       if(resp == 'A'){
         ADELANTE();
       } else if (resp == 'R'){
         REVERSA();
       } else if (resp == 'I'){
         IZQUIERDA();
       } else if (resp == 'D'){
         DERECHA();
       } else if (resp == 'O'){
         ALTO();
       }
      break;
       }
    }
// }

  // Inician metodos que definen las acciones del carro.

void ADELANTE(){
   motorD.run(FORWARD);
   motorI.run(FORWARD);
    for (speedSet = 0; speedSet < MAX_Vel; speedSet +=2){
      motorD.setSpeed(speedSet + 20);
      motorI.setSpeed(speedSet - 20);
    }
  }

void REVERSA(){
   motorD.run(BACKWARD);
   motorI.run(BACKWARD);
    for (speedSet = 0; speedSet < MAX_Vel; speedSet +=2){
      motorD.setSpeed(speedSet + 20);
      motorI.setSpeed(speedSet - 20);
    }
  }

void DERECHA() {
   motorD.run(RELEASE);
   motorI.run(FORWARD);
   delay(300);
   motorD.run(FORWARD);
   motorI.run(FORWARD);
  }

void IZQUIERDA() {
   motorD.run(FORWARD);
   motorI.run(RELEASE);
   delay(300);
   motorD.run(FORWARD);
   motorI.run(FORWARD);
  }

void ALTO(){
   motorD.run(RELEASE);
   motorI.run(RELEASE);
  }
```

body:
I guess the main problem is, that you write your commands from the bluetooth app, but the HC-05 module is connected to `BTSerial`. Here you are reading from it and forwarding the data to `Serial` (serial monitor on your PC):

    if (BTSerial.available()){
        Serial.write(BTSerial.read());
        Serial.write('\n');
    }

You are not doing anything else with the bluetooth serial data, so you cannot change the `resp` variable over bluetooth. Instead you are doing this with `Serial` (not `BTSerial`). But as long, as you don't type the commands into the serial monitor, that code will never run. Thus the distance code will never be executed.

If you want to control the program from the bluetoooth app, you need to actually work with the data from the right serial interface.

---

Btw: Your serial monitor is configured for a newline as line ending character. Your `Serial` code does not discard these, so you might get undesired behavior there, when `resp` becomes `\n`.

---

About your new problem: This problem actually existed also with the old code, but you couldn't see it, because the you were reading from the wrong serial interface. Try to read this (compressed) snipped of your (old) code:

    switch(resp){
       case '1':
           ...
           break;
       case '2':
           switch(resp){
               case 'A':
                   ...

With the first switch statement you are checking the value of `resp`. If it is `'2'`, you will enter the second case. In there you are again checking the value of `resp` for the values `'A'`, ... . But when you already know, that `resp` is equal to `'2'`, how can it ever be equal to `'A'` or one of the other subcommands, since you don't change `resp` in between. Thus the code inside the second switch statement is unreachable.

**What to do now?** I guess you want the first switch statement to handle the modes and the second one to handle the move commands, while in second mode. For that you need to restructure your code, in the best case to an FSM (Finite State Machine). I already once wrote a good descriptions of how an FSM works in my answer to [this question][1].

Introduce a state variable, which gets used in the first switch statement, and a command variable, that gets used in the second one. I would suggest a structure like this:

    enum State {AUTOMATIC_MODE, MANUAL_MODE};

    State state = AUTOMATIC_MODE;
    char command = 0;

    void loop(){
        if(BTSerial.available()){
            resp = BTSerial.read();
            Serial.println(resp);
            switch(resp){
                case '1':
                    state = AUTOMATIC_MODE;
                    break;
                case '2':
                    state = MANUAL_MODE;
                    break;
                case 'A':
                case 'R':
                case 'I':
                case 'D':
                case 'O':
                    command = resp;
                    break;
            }
        }

        switch(state){
            case AUTOMATIC_MODE:
                ...
                break;
            case MANUAL_MODE:
                switch(command){
                    case 'A':
                        ...
                }
                break;
        }
    }

Here the serial input will be put into the `state` or `command` variable, depending, on what exactly was send. The part with the main code comes after that. Depending on the state, the corresponding code is executed. When in manual mode, the code will look at the `command` variable to check, which function to execute.

  [1]: https://arduino.stackexchange.com/questions/63488/wanted-to-control-2-servos-with-serial-read


message:
New to Arduino and I have a WIP code for a class. ERROR with LEDs working?

(EDIT) My goal with this code is to use two potentiometers, pot0 and pot1 respectively, to control 8 leds. Pot0 controls which sequence the leds are running (1, 2, or 3) and pot1 controls which LEDs within each sequence are active. Currently, I am having a problem because I am running Sequence 1 (the first if statement) to my arduino, but I can't seem to make the LEDs light up when being called out by the potentiometer. The only LED that works is LED 0, and that's only if both potentiometers were in the proper positions when the code begins running.

    int pot0 = 0;
    int pot1 = 1;
    int led[] = {7, 6, 5, 4, 3, 2, 1, 0};

    void setup() {

    for (int i = 0; i < led; i++){
      pinMode(led, OUTPUT)
    ;}
    }
    void loop() {
      int potread = analogRead(pot0);
      int val = analogRead(pot1);
      int potR = map(val, 0, 1023, 0, 7);

    if (potread <= 341) {
      for (int i; i == potR;)
      digitalWrite(led[i], HIGH);

    }

    else if (potread <= 682) {

    }
    else {

    }
    }

body: For this, you should be using `map()`. Instead of `int potR = val % 8;` try `int potR = map(val, [minimum pot value], [maximum pot value], 0, 7)`. Also, I'm pretty sure you don't need the for loop if all you're doing is `led[i]`. In that case, you could use `led[potR]`.


body:
I spoke to someone the other night while working on this who was able to help me, and have since resolved all of my issues. Thank you to everyone who helped me fix the issues that I was having!

For those interested in how my final code came out ->

    int pot0 = 0;
    int pot1 = 1;
    int led[] = {7, 6, 5, 4, 3, 2, 8, 9};
    const int DelayPeriod = 100;

    void setup() {
    pinMode(pot0, INPUT);
    pinMode(pot1, INPUT);
    for (int i = 0; i < led; i++){
      pinMode(led, OUTPUT)
    ;}
    }
    void loop() {
      int potread = analogRead(pot0);
      int val = analogRead(pot1);
      int potR = map(val, 0, 1023, 0, 7);
    if (potread <= 341) {
      for (int i = 0; i <= led; i++){
        if (i == potR){
          digitalWrite(led[i], HIGH);
        }
        else {
          digitalWrite(led[i], LOW);
        }
      }

    }
    else if (potread <= 682) {
      for (int i = 0; i <= led; i++){
        if (i <= potR){
          digitalWrite(led[i], HIGH);
        }
        else {
          digitalWrite(led[i], LOW);
        }
      }

    }
    else {
      for (int i = 0; i <= led; i++){
        if ((i <= (potR + 1)) && (i >= (potR - 1))){
          digitalWrite(led[i], HIGH);
        }
        else {
          digitalWrite(led[i], LOW);
        }
      }
    }
    }


message:
Burn bootloader finishes with "avrdude done. Thank you." but bootloader didn't actually get flashed

I've built a a stripped down version of the Arduino Nano that has some peripherals removed and three connectors for analog sensors I want to use. I'm trying to burn the Arduino Nano bootloader onto this custom board using the sparkFun AVR Pocket Programmer and from the Arduino IDE console it seems to say that it was burned successfully. But when I plug the board back into the computer it still shows up as a COM port instead of an Arduino device. This is the output I get in the console after I press burn bootloader with "USBtinyISP" selected as programmer and Arduino Nano as the board.

```C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cusbtiny -Uflash:w:C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/optiboot/optiboot_atmega328.hex:i -Ulock:w:0x0F:m

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: bus-0:\\.\libusb0-0001--0x1781-0x0c9f
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, https://learn.adafruit.com/usbtinyisp
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: Using SCK period of 10 usec
avrdude: reading input file "C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/optiboot/optiboot_atmega328.hex"
avrdude: writing flash (32768 bytes):

Writing | ################################################## | 100% -0.00s

avrdude: 32768 bytes of flash written
avrdude: verifying flash memory against C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/optiboot/optiboot_atmega328.hex:
avrdude: load data flash data from input file C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/optiboot/optiboot_atmega328.hex:
avrdude: input file C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/optiboot/optiboot_atmega328.hex contains 32768 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 32768 bytes of flash verified
avrdude: reading input file "0x0F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0F:
avrdude: load data lock data from input file 0x0F:
avrdude: input file 0x0F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
```

The burning is pretty much over instantly and you can see the reading and writing take 0.00s, it should be closer to a minute rather than an instantly. It's faster than uploading a simple sketch to the Arduino. When I unplug the programmer and plug the device back via USB, it just shows up as a COM port instead of "Arduino Nano" - which doesn't allow me to program it via the Arduino IDE.

What is very strange to me is that I can program the device over the command line. If I follow the AVR Pock Programmer instructions ["Using AVRDUDE via Command Line"][1] and use a hex file generated from the Arduino IDE, the code uploads fine and runs fine. I wrote a sketch that prints the ADC values over the command line and after flashing via command line it's running as expected.

I've tried to upload the Arduino booatloader via command line as shown in [this tutorial][2] under "Uploading Code - Hard Way" and this time it takes over 43 seconds to write to flash and 30 seconds to read from flash so I thought it worked. However when I plug it back in, it STILL just comes up on my computer and the Arduino IDE as COM9.

This is the output I get when trying to flash the bootloader via command line:

```
C:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders\optiboot
λ avrdude -b 19200 -c usbtiny -p m328p -v -e -U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m

avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"

         Using Port                    : lpt1
         Using Programmer              : usbtiny
         Overriding Baud Rate          : 19200
         AVR Part                      : ATMEGA328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5
avrdude: erasing chip
avrdude: Using SCK period of 10 usec
avrdude: reading input file "0x05"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
avrdude: load data efuse data from input file 0x05:
avrdude: input file 0x05 contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xD6"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xD6:
avrdude: load data hfuse data from input file 0xD6:
avrdude: input file 0xD6 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D6
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

C:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders\optiboot
λ avrdude -b 19200 -c usbtiny -p m328p -v -e -U flash:w:optiboot_atmega328.hex -U lock:w:0x0F:m

avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"

         Using Port                    : lpt1
         Using Programmer              : usbtiny
         Overriding Baud Rate          : 19200
         AVR Part                      : ATMEGA328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D6
avrdude: safemode: efuse reads as 5
avrdude: erasing chip
avrdude: Using SCK period of 10 usec
avrdude: reading input file "optiboot_atmega328.hex"
avrdude: input file optiboot_atmega328.hex auto detected as Intel Hex
avrdude: writing flash (32768 bytes):

Writing | ################################################## | 100% 43.63s

avrdude: 32768 bytes of flash written
avrdude: verifying flash memory against optiboot_atmega328.hex:
avrdude: load data flash data from input file optiboot_atmega328.hex:
avrdude: input file optiboot_atmega328.hex auto detected as Intel Hex
avrdude: input file optiboot_atmega328.hex contains 32768 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 30.69s

avrdude: verifying ...
avrdude: 32768 bytes of flash verified
avrdude: reading input file "0x0F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0F:
avrdude: load data lock data from input file 0x0F:
avrdude: input file 0x0F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D6
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK

avrdude done.  Thank you.
```
I've reviewed my schematic multiple times, comparing it to the [actual Nano schematic][3] but I can't see anything that would cause it to fail - it's almost identical ! I've built two of these boards and they behave the same exact same way. Schematic shown below.

[![enter image description here][4]][4]

  [1]: https://learn.sparkfun.com/tutorials/pocket-avr-programmer-hookup-guide/all
  [2]: https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader#uploading-code---hard-way
  [3]: https://www.arduino.cc/en/uploads/Main/Arduino_Nano-Rev3.2-SCH.pdf
  [4]: https://i.stack.imgur.com/pDRSz.png

body:
The Arduino 'device' is identified by the USB device code of the USB to TTL Serial on Arduino or by core code in case of MCU with native USB. The USB ids are written to the USB chip in factory or are part of the firmware/core and they are listed in boards.txt file so that the IDE then knows what Arduino is attached. If you use a common FTDI it doesn't have this Arduino vid and pid codes, which identifies the device as Arduino.

Note: I think you asked a different question then your real problem is, because you assumed that the name of the port not showing Arduino is the reason why the upload doesn't work. It is so called X->Y problem. You have a problem X but asked about problem Y. I answered the question asked.


message:
Solution needed for sending HTTPs requests from multiple Arduino units in the field

I'm using the [Arduino Wifi Nina Library][1] to connect an [Arduino Uno Wifi Rev2][2] to wifi and then using the [Arduino HTTP Client library][3] to make HTTP post calls to the internet. It is working. However when I switch from HTTP to HTTPs (ie: switching the port to 443 from 80) the code below fails. I understand This is because I don't have a cert on the Arduino. I need to purchase/obtain a cert and download it to the Arduino.

I need to find a solution to this problem that meets the following constraints I have:

 1. I will only be sending https requests to one URL:
    https://api.mailgun.net
 2. The amount of memory storage available on Arduinos is severely constrained
 3. I plan to deploy this Arduino into the field. After I deploy it, I will no longer be able to physically access it to manually update any expired certificates. But the Arduino unit must be able to send HTTPs requests to https://api.mailgun.net in perpetuity.
 4. I plan to deploy not just this Arduino unit, but a fleet of similarly functioning Arduino units with the same functionality. And I need to keep the costs of any certificate(s) to an absolute minimum.

```
    #include <WiFiNINA.h>
    #include <ArduinoHttpClient.h>

    #define REMOTE_SERVER_DOMAIN "api.mailgun.net"
    #define REMOTE_SERVER_PORT 443
    #define MAILGUN_USER "my-user"
    #define MAILGUN_PASSWORD "my-secret"

    bool sendEmailViaHTTPS()
    {
        WiFiClient wifiClient;
        HttpClient httpClient = HttpClient(wifiClient, REMOTE_SERVER_DOMAIN, REMOTE_SERVER_PORT);
        httpClient.beginRequest();
        httpClient.post("/v3/sandbox7d1aaf2f157f42d8844b1ac4c38a0ef7.mailgun.org/messages");
        httpClient.sendHeader("Content-Type", "application/x-www-form-urlencoded");
        httpClient.sendBasicAuth(MAILGUN_USER, MAILGUN_PASSWORD);
        String postData = String("from=Mailgun Sandbox <postmaster@sandbox7d1aaf2f157f42d8844b1ac4c38a0ef7.mailgun.org>&to=Me <myemail@gmail.com>&subject=Hello World1&text=Hello World2");
        httpClient.sendHeader("Content-Length", postData.length());
        httpClient.beginBody();
        httpClient.print(postData);
        httpClient.endRequest();
        int statusCode = httpClient.responseStatusCode();
        String response = httpClient.responseBody();
        Serial.print("Status code: ");
        Serial.println(statusCode);
        Serial.print("Response: ");
        Serial.println(response);
        return statusCode == 200;
    }
```

What is the best solution to enabling my Arduino to send HTTPs requests as stated above with the least cost and friction?

  [1]: https://www.arduino.cc/en/Reference/WiFiNINA
  [2]: https://store.arduino.cc/usa/arduino-uno-wifi-rev2
  [3]: https://github.com/arduino-libraries/ArduinoHttpClient/blob/master/examples/SimplePost/SimplePost.ino

body:
For secure TCP connection with WiFiNINA library use WiFiSSLClient instead of WiFiClient.

The Arduino firmware in the NINA ESP32 module has certificates of well known CA authorities so the server's certificate verification should work. If necessary, you can [add][1] public keys of server certificates to NINA.

  [1]: https://www.arduino.cc/en/Tutorial/FirmwareUpdater


message:
ADXL345 gives wiring error in SPI mode

I get the following output from serial monitor when trying to use the ADXL345 with Arduino Uno in SPI mode (I2C mode works fine):

    CA
    Ooops, no ADXL345 detected ... Check your wiring!

See photos for wiring. I have tried it with another breakout board, and that produces the same results.
Interestingly this tutorial says the breakout should work in SPI mode, but it's only illustrated for I2C.
https://learn.adafruit.com/adxl345-digital-accelerometer?view=all#assembly-and-wiring

    #include <Wire.h>
    #include <Adafruit_Sensor.h>
    #include <Adafruit_ADXL345_U.h>
    /* Assign a unique ID to this sensor at the same time */
    Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(13,12,11,9);
    //Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified();

    //Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(clock,miso,mosi,cs,sensorID);
    void displaySensorDetails(void)
    {
      sensor_t sensor;
      accel.getSensor(&sensor);
      Serial.println("------------------------------------");
      Serial.print  ("Sensor:       "); Serial.println(sensor.name);
      Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
      Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
      Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" m/s^2");
      Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" m/s^2");
      Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" m/s^2");
      Serial.println("------------------------------------");
      Serial.println("");
      delay(500);
    }

    void displayDataRate(void)
    {
      Serial.print  ("Data Rate:    ");

      switch(accel.getDataRate())
      {
        case ADXL345_DATARATE_3200_HZ:
          Serial.print  ("3200 ");
          break;
        case ADXL345_DATARATE_1600_HZ:
          Serial.print  ("1600 ");
          break;
        case ADXL345_DATARATE_800_HZ:
          Serial.print  ("800 ");
          break;
        case ADXL345_DATARATE_400_HZ:
          Serial.print  ("400 ");
          break;
        case ADXL345_DATARATE_200_HZ:
          Serial.print  ("200 ");
          break;
        case ADXL345_DATARATE_100_HZ:
          Serial.print  ("100 ");
          break;
        case ADXL345_DATARATE_50_HZ:
          Serial.print  ("50 ");
          break;
        case ADXL345_DATARATE_25_HZ:
          Serial.print  ("25 ");
          break;
        case ADXL345_DATARATE_12_5_HZ:
          Serial.print  ("12.5 ");
          break;
        case ADXL345_DATARATE_6_25HZ:
          Serial.print  ("6.25 ");
          break;
        case ADXL345_DATARATE_3_13_HZ:
          Serial.print  ("3.13 ");
          break;
        case ADXL345_DATARATE_1_56_HZ:
          Serial.print  ("1.56 ");
          break;
        case ADXL345_DATARATE_0_78_HZ:
          Serial.print  ("0.78 ");
          break;
        case ADXL345_DATARATE_0_39_HZ:
          Serial.print  ("0.39 ");
          break;
        case ADXL345_DATARATE_0_20_HZ:
          Serial.print  ("0.20 ");
          break;
        case ADXL345_DATARATE_0_10_HZ:
          Serial.print  ("0.10 ");
          break;
        default:
          Serial.print  ("???? ");
          break;
      }
      Serial.println(" Hz");
    }

    void displayRange(void)
    {
      Serial.print  ("Range:         +/- ");

      switch(accel.getRange())
      {
        case ADXL345_RANGE_16_G:
          Serial.print  ("16 ");
          break;
        case ADXL345_RANGE_8_G:
          Serial.print  ("8 ");
          break;
        case ADXL345_RANGE_4_G:
          Serial.print  ("4 ");
          break;
        case ADXL345_RANGE_2_G:
          Serial.print  ("2 ");
          break;
        default:
          Serial.print  ("?? ");
          break;
      }
      Serial.println(" g");
    }

    void setup(void)
    {
    #ifndef ESP8266
      while (!Serial); // for Leonardo/Micro/Zero
    #endif
      Serial.begin(9600);
      Serial.println("Accelerometer Test"); Serial.println("");
      pinMode(9,OUTPUT);
      /* Initialise the sensor */
      if(!accel.begin())
      {
        /* There was a problem detecting the ADXL345 ... check your connections */
        Serial.println("Ooops, no ADXL345 detected ... Check your wiring!");
        while(1);
      }

      /* Set the range to whatever is appropriate for your project */
      accel.setRange(ADXL345_RANGE_16_G);
      // displaySetRange(ADXL345_RANGE_8_G);
      // displaySetRange(ADXL345_RANGE_4_G);
      // displaySetRange(ADXL345_RANGE_2_G);

      /* Display some basic information on this sensor */
      displaySensorDetails();

      /* Display additional settings (outside the scope of sensor_t) */
      displayDataRate();
      displayRange();
      Serial.println("");
    }

    void loop(void)
    {
      /* Get a new sensor event */
      sensors_event_t event;
      accel.getEvent(&event);

      /* Display the results (acceleration is measured in m/s^2) */
      Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print("  ");
      Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print("  ");
      Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print("  ");Serial.println("m/s^2 ");
    //  delay(500);
    }
[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/7jsH6.jpg

body:
I got it to work using the Sparkfun library in stead of the Adafruit library, and by inserting a couple of delay(100) statements in the setup (without them the output was continuously -13365, -13365, -13365). I still don't fully understand why the delay statements would be necessary in the first place though.

    /*  *********************************************
     *  SparkFun_ADXL345_Example
     *  Triple Axis Accelerometer Breakout - ADXL345
     *  Hook Up Guide Example
     *
     *  Utilizing Sparkfun's ADXL345 Library
     *  Bildr ADXL345 source file modified to support
     *  both I2C and SPI Communication
     *
     *  E.Robert @ SparkFun Electronics
     *  Created: Jul 13, 2016
     *  Updated: Sep 06, 2016
     *
     *  Development Environment Specifics:
     *  Arduino 1.6.11
     *
     *  Hardware Specifications:
     *  SparkFun ADXL345
     *  Arduino Uno
     *  *********************************************/

    #include <SparkFun_ADXL345.h>         // SparkFun ADXL345 Library

    /*********** COMMUNICATION SELECTION ***********/
    /*    Comment Out The One You Are Not Using    */
    ADXL345 adxl = ADXL345(9);           // USE FOR SPI COMMUNICATION, ADXL345(CS_PIN);
    //ADXL345 adxl = ADXL345();             // USE FOR I2C COMMUNICATION

    /****************** INTERRUPT ******************/
    /*      Uncomment If Attaching Interrupt       */
    //int interruptPin = 2;                 // Setup pin 2 to be the interrupt pin (for most Arduino Boards)

    /******************** SETUP ********************/
    /*          Configure ADXL345 Settings         */
    void setup(){

      Serial.begin(9600);                 // Start the serial terminal
      Serial.println("SparkFun ADXL345 Accelerometer Hook Up Guide Example");
      Serial.println();

      adxl.powerOn();                     // Power on the ADXL345
      delay(100);
      adxl.setRangeSetting(16);           // Give the range settings
                                          // Accepted values are 2g, 4g, 8g or 16g
                                          // Higher Values = Wider Measurement Range
                                          // Lower Values = Greater Sensitivity
      delay(100);
      adxl.setSpiBit(0);                  // Configure the device to be in 4 wire SPI mode when set to '0' or 3 wire SPI mode when set to 1
                                          // Default: Set to 1
                                          // SPI pins on the ATMega328: 11, 12 and 13 as reference in SPI Library
      delay(100);
    //  Set SPI mode to that matching ADXL345 (I guess this would be in here by default? )

      adxl.setActivityXYZ(1, 0, 0);       // Set to activate movement detection in the axes "adxl.setActivityXYZ(X, Y, Z);" (1 == ON, 0 == OFF)
      adxl.setActivityThreshold(75);      // 62.5mg per increment   // Set activity   // Inactivity thresholds (0-255)

      adxl.setInactivityXYZ(1, 0, 0);     // Set to detect inactivity in all the axes "adxl.setInactivityXYZ(X, Y, Z);" (1 == ON, 0 == OFF)
      adxl.setInactivityThreshold(75);    // 62.5mg per increment   // Set inactivity // Inactivity thresholds (0-255)
      adxl.setTimeInactivity(10);         // How many seconds of no activity is inactive?

      adxl.setTapDetectionOnXYZ(0, 0, 1); // Detect taps in the directions turned ON "adxl.setTapDetectionOnX(X, Y, Z);" (1 == ON, 0 == OFF)

      // Set values for what is considered a TAP and what is a DOUBLE TAP (0-255)
      adxl.setTapThreshold(50);           // 62.5 mg per increment
      adxl.setTapDuration(15);            // 625 μs per increment
      adxl.setDoubleTapLatency(80);       // 1.25 ms per increment
      adxl.setDoubleTapWindow(200);       // 1.25 ms per increment

      // Set values for what is considered FREE FALL (0-255)
      adxl.setFreeFallThreshold(7);       // (5 - 9) recommended - 62.5mg per increment
      adxl.setFreeFallDuration(30);       // (20 - 70) recommended - 5ms per increment

      // Setting all interupts to take place on INT1 pin
      //adxl.setImportantInterruptMapping(1, 1, 1, 1, 1);     // Sets "adxl.setEveryInterruptMapping(single tap, double tap, free fall, activity, inactivity);"
                                                            // Accepts only 1 or 2 values for pins INT1 and INT2. This chooses the pin on the ADXL345 to use for Interrupts.
                                                            // This library may have a problem using INT2 pin. Default to INT1 pin.

      // Turn on Interrupts for each mode (1 == ON, 0 == OFF)
      adxl.InactivityINT(1);
      adxl.ActivityINT(1);
      adxl.FreeFallINT(1);
      adxl.doubleTapINT(1);
      adxl.singleTapINT(1);

    //attachInterrupt(digitalPinToInterrupt(interruptPin), ADXL_ISR, RISING);   // Attach Interrupt

    }

    /****************** MAIN CODE ******************/
    /*     Accelerometer Readings and Interrupt    */
    void loop(){

      // Accelerometer Readings
      int x,y,z;
      adxl.readAccel(&x, &y, &z);         // Read the accelerometer values and store them in variables declared above x,y,z

      // Output Results to Serial
      /* UNCOMMENT TO VIEW X Y Z ACCELEROMETER VALUES */
      Serial.print(x);
      Serial.print(", ");
      Serial.print(y);
      Serial.print(", ");
      Serial.println(z);

    //  ADXL_ISR();
      // You may also choose to avoid using interrupts and simply run the functions within ADXL_ISR();
      //  and place it within the loop instead.
      // This may come in handy when it doesn't matter when the action occurs.

    }

    /********************* ISR *********************/
    /* Look for Interrupts and Triggered Action    */
    void ADXL_ISR() {

      // getInterruptSource clears all triggered actions after returning value
      // Do not call again until you need to recheck for triggered actions
      byte interrupts = adxl.getInterruptSource();

      // Free Fall Detection
      if(adxl.triggered(interrupts, ADXL345_FREE_FALL)){
        Serial.println("*** FREE FALL ***");
        //add code here to do when free fall is sensed
      }

      // Inactivity
      if(adxl.triggered(interrupts, ADXL345_INACTIVITY)){
        Serial.println("*** INACTIVITY ***");
         //add code here to do when inactivity is sensed
      }

      // Activity
      if(adxl.triggered(interrupts, ADXL345_ACTIVITY)){
        Serial.println("*** ACTIVITY ***");
         //add code here to do when activity is sensed
      }

      // Double Tap Detection
      if(adxl.triggered(interrupts, ADXL345_DOUBLE_TAP)){
        Serial.println("*** DOUBLE TAP ***");
         //add code here to do when a 2X tap is sensed
      }

      // Tap Detection
      if(adxl.triggered(interrupts, ADXL345_SINGLE_TAP)){
        Serial.println("*** TAP ***");
         //add code here to do when a tap is sensed
      }
    }