text:
HC-SR04 ultrasonic sensor: How to check voltage on the ECHO pin
I'm using and ESP8266 with HC-SR04 ultrasonic sensor. The sensor requires 5v input and will also output to the GPIO pins at 5V.
ESP8266 has a strong recommendation to use 3.3V into the GPIO pins. I've found some setups online with people using voltage dividers to bring the ECHO pin voltage down.
Example on a PI: https://tutorials-raspberrypi.com/raspberry-pi-ultrasonic-sensor-hc-sr04/
I'm using a basic multimeter that i've found to be pretty accurate. When I put the BLACK cord on the ECHO and RED on the GROUND (of sensor pins), I get variable voltage readings. I'm trying to ensure a 3.3V coming from the ECHO into my ESP.
Questions:

Am I putting the black and red cords on the appropriate areas?
If yes to question 1, then why am i get such a variable of readings?
How can I test to ensure only 3.3V coming out of ECHO?

As Majenko already wrote, the black cord goes always to ground, so you have the leads backwards (though this just means, that your multimeter will report a negative voltage, if it is able to do so).
But besides that you cannot easily measure the echo pulse with a multimeter. A multimeter is build to measure either a DC voltage or a constant AC voltage. It is not build to measure the peak signal of a pulsed line. Some good multimeters may be able to do that, but it most of them (an definitely the basic ones) cannot do this. They are measuring the voltage over a relatively long period of time (longer than an echo pulse) with multiple measurements (to average out the noise). Also you cannot control, when exactly each measurement is taking place. So depending on the exact timing, the multimeter might have multiple pulses in the measurement (reading 5V there) or even missing pulses completely. That's the meaning of the Nyquist frequency, which states, that the measurement frequency must be higher than double of the signal frequency, or you will not be able to measure the signal correctly.
The echo pulse - if you receive one - will be rather short. With the maximum distance of most ultrasonic sensor boards of 3m, you will get a maximum pulse length of
3m / (300 m/s) = 0,01s = 10ms

You won't be able to correctly read that pulse with a multimeter. You would need an oscilloscope for that.
What to do now? If you want to make sure, that the used voltage divider divides 5V input to 3.3V output, you can connect the input to the 5V pin (but disconnect the echo pin first). Then measure the voltage at the output (which is now HIGH all the time, not just for the time of a pulse). If it's 3.3V, you can be sure, that the divider works correctly. As the ultrasonic sensor is provided with 5V, it won't output more than that. So you can be sure, that the ESP will only see 3.3V.

You have your leads backwards. But that doesn't matter, since there's nothing to measure. You'll only see a voltage (and even then only a brief pulse) when an echo is actually received.
You would need an oscilloscope to be able to read that voltage.

So what is my multimeter reading? It just keeps going up and down. It ranges between 0 and 5.

Are you actively pinging at the time? Then you may be seeing it react to the pulses.

Yes it's fully pinned. 5v source. So when it reacts to the pulses, it changes the bolt reading? Since the max reading is 5v, does that mean that my resistors aren't placed properly since the voltage max didn't drop?


text:
HTTP POST from Arduino/ESP8266/ESP32 How to send parameters (x-www-form-urlencoded)

EDIT: Thank you for the answer, also we had figured out how to do it Micropython too - I believe that it is relevant for the Arduino/ESP8266/ESP32 community to share this too.
https://github.com/46elks/46elks-getting-started/blob/master/code-examples/MicroPython/https_post_with_micropython.py
How should I include parameters from, to and message to http.post?
Is this the correct way to do it?
http.POST("'from:+XXXXX','to:+XXXXX','message:Hej'");
#include <M5StickC.h>
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiMulti.h>

#include <HTTPClient.h>

#define USE_SERIAL Serial

WiFiMulti wifiMulti;

void setup() {

    USE_SERIAL.begin(115200);

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

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

    wifiMulti.addAP("YYYY", "ZZZZZ");

}

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

        HTTPClient http;

        USE_SERIAL.print("[HTTP] begin...\n");
        // configure traged server and url

          http.begin("https://api.46elks.com/a1/sms");
          http.addHeader("Content-Type", "application/x-www-form-urlencoded");
          http.setAuthorization("XXXXX", "YYYYYY");
          int httpCode = http.POST("'from:+XXXXX','to:+XXXXX','message:Hej'");

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

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

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

        http.end();
    }

    delay(10000);
}

what does the server expect? x-www-form-urlencoded format is name=value&nextname=nextvalue. so with = as name value separator and & as name-value pairs separator.

What format of message does the server expect? As you send "x-www-form-urlencoded" it should probably look like:
 "from=+XXXXX&to=+XXXXX&message=Hej"

where the different parts are
 "param1=paramValue1&param2=paramValue2&param3=paramValue3"

 param .... Name of the expected parameter
 = .... divides the param pair
 paramValue .... Content/value of the parameter
 & .... links the param pairs

so in your case
 int httpCode = http.POST("from=+XXXXX&to=+XXXXX&message=Hej");

Note that, in x-www-form-urlencoded, the “+” character is used to encode a space. If you mean a literal “+”, you should encode it as “%2B”.

My friend and I figured out how to do this in micropython - can I make a question about it and answer it or should I post it here somehow?
https://github.com/46elks/46elks-getting-started/blob/master/code-examples/MicroPython/https_post_with_micropython.py

Place the link and short explanation as an EDIT to your question, this way everything is together and helps others Thank you

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Why does the LEDs affect Analog Input?
So I'm working for a project to control RGB Led Strip using microphone or sound sensor with Arduino Nano. I'm using 5050 RGB Led Strip around 120 LEDs, and I control them using simple transistor circuit to each channel R, G, and B, then I connect the base of the transistors to the resistors and PWM Outputs of the Arduino. And then I'm using KY-038 Sound Sensor (I'm using the Analog Output pin) and connect it to Arduino A0.
The problem is when I didn't connect the LEDs, the microphone worked correctly. I processed the analog input, put filter and threshold. When I connected the LEDs, the reading of the A0 is disturbed by the transition of the LED (for example from 0% PWM to 50% PWM or ON). As the result, my analog read detected it as a voltage swing and recognize it as a sound, and trigger the LEDs, then oscillating without any external sound. If I disconnected the LEDs, it worked correctly, for example I change it to Arduino Built-In LED, it turned on according to the external sound.
Why does this happen? I don't think they share the same timer, and I also use proper Power Supply and Capacitor to provide the enough power.
My project is similar to this project.

try using mosfets instead of bjt; they don't draw any/(ok, as much) current from the MCU.

I think it is because of power consumption.
If the LEDs consume lots of power, the LED on Arduino(typically mini red LED) will be off or faded.
So before you connect the  LEDs, check the  mini red LED which is on Arduino and after connection the LEDs, check ones again.
If the red LED is faded or off, the problem must be power consumption.
Connect 12v or 5v to vin to powering the Arduino, and also to LEDs
The important thing is you should not connect LEDs to Arduino 5v.

Which model of LED are you using? 5050 is just the form factor. However, I think the problem is related to power consumption. The well-known WS2812B (a.k.a. Neopixel from Adafruit), may consume about 50mA. Considering 120LEDs, you can reach an important level of current (circuit supporting more than 1A should be properly designed). The sudden change of current can easily change introduce noise on the entire circuit. The solution should use an external power supply dedicated for LED, sharing GND with your Arduino.

Not the WS2812B, only RGB LED 5050 with current limiting resistor, so it only has 4 pin for common anode, R, G, and B. I'm using 5v Power Supply with maximum 2A I believe, and I added Capacitor 100uF (didn't calculate this, only hope that it works, but it didn't). So the connection is from PC (for Serial Monitor) to Mini USB, and then VIN to 5V Power Supply. Does the use of breadboard also affect this?

Try removing the 5V from the power supply from the VIN pin. 5V is too low a voltage for the linear regulator anyway. And you already provide 5V via USB.

Yes Vin should be between 6-12V, otherwise, the regulator cannot work

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Activating a defined macro in a class from main.cpp
Sorry if this question been asked. I'm trying to activate certain function in a class using a macro defined in the class from main.cpp. I'm using jrowberg MPU6050 library if that matters.
main.cpp
#include "gyro.h"
gyro gyro(Serial);
#define OUTPUT_READABLE_EULER

void setup(){
...
}
void loop(){
...
}

gyro.cpp
  #include "gyro.h"
  #ifdef OUTPUT_READABLE_EULER
      // display Euler angles in degrees
      mpu.dmpGetQuaternion(&q, fifoBuffer);
      mpu.dmpGetEuler(euler, &q);
      serial_.print("euler\t");
      serial_.print(euler[0] * 180/M_PI);
      serial_.print("\t");
      serial_.print(euler[1] * 180/M_PI);
      serial_.print("\t");
      serial_.println(euler[2] * 180/M_PI);
  #endif

If I define OUTPUT_READABLE_EULER in gyro.h, it works. But I want to do it from main.cpp.

Try putting the define before you include the file.

You cannot not, but also you should not try to define a macro in a cpp file and use it in another cpp file.
Instead, you have to define it in a h (header) file, which is included in both cpp files.
Why would you define it in main.cpp or main.h anyway if you don't use it in those files?
You have mainly three options:

Define it in gyro.h so you include it in gyro.cpp where you use it. You can later use it in other files as well.
Define it in gyro.cpp so you can use it only in that file. This prevents the macro being used in other files (which can be safer).
Define it in a separate file, e.g. euler.h and include this header file everywhere you need it.

See also Juraj's comments below.

this applies if the define should by in a source file. this kind of defines is usually set on compiler command line as -D. the Arduino IDE doesn't have -D define configuration for a project.

@Juraj in that case it could be an option to create a specific header file with those macros (one in this case) and include them in every file.

yes. it is the way if the macro should be used only in the sketch's files (project). inconvenient is it for libraries. then the user must go to library folder and a modifiy a file there, but then it applies for all projects. if the setting is boards specific or one has a customized board definition for a project, then -D can be set in boards.local.txt as build.extra_flags. for example in Eclipse -D can be set in project's settings

@Juraj Thanks for that additional info. However, that doesn't work in the IDE I guess ?(as the Arduino IDE is not eclipse based)


text:
Arduino Mega keep states after reprogramming
Based on:
https://forum.arduino.cc/index.php?topic=440978.0
And some previous experience with Arduinos. What I would like to accomplish here is that I have a 8 channel relay board with the relays in different states. The Arduino is connected to a RaspberryPI via USB.
The first problem is well known the automatic reset of the Arduino which can be taken care of with a resistor or desoldering a pin on the Mega board so you can reconnect your Arduino as many time as you wish (while running on an external +5V power source) to the Raspberry and it will never reset.
However I also remember that doing this to the boards will also make them impossible to program because they cannot reset at the end when the sketch is uploaded.
I have think of a workaround:
1, Create a programming command on the arduino which is when it's received from the RPI it will connect that cut off pin with a relay which will make resetting possible again
2, Save all relay states to the EEPROM
3, After reset the Arduino always checks this programming flag in it's EEPROM and if it's present it either does not touch the relays or set them to the same position ON/OFF depending on the value it read back from the EEPROM
The last guy claims that: When the Arduino is in reset, all pins act like they aren't connected to anything. If you have an output which must be in a specific state during that period, you must add an external resistor to pull it up or down as required.
Is there any other solution for this problem? Like using a newer Arduino board which can keep pin states over reprogramming?

I had to solve a problem similar to this for an ESP32 based system. The solution I came up with was to use external D-type latches (flipflops) to store the state independently of the Arduino.
The Arduino has to actively load a new relay state into a latch in order for the relay to change state, and that state is retained regardless of what the Arduino does.
The outputs of the latches can also be connected to other input pins so the Arduino can find the current state of the relays at boot time.

simulate this circuit – Schematic created using CircuitLab
The Arduino keeps track of what the outputs should be (reading the current state at boot) and then changes a state when needed. It then loads all the states onto the output pins and pulses the LOAD pin (CLK on the chip) high to load those states into the latches.
I used the 74HC374 chip for this since it contains 8 latches tied to a single CLK pin.

You have basically 2 distinct problems here. The problem to somewhat automatically enable/disable the reset from USB and the problem to keep the relays at their set states over reprogramming.

Enable/disable reset: The easiest way is to use a jumper, that you disconnect everytime you want to program the board. If you want to do it remotely, you already described a valid way, though I think, that you don't need a relay for that. A transistor or MOSFET should be sufficient for it.
Keep the relay states:

Like using a newer Arduino board which can keep pin states over reprogramming?

I don't think, that something like that exists. It does not make sense for general purpose microcontrollers to do that; they all start from a clean state. So you need to save the state of the relays outside of the Arduino. What type of device you want to use for that is up to you. Majenko mentioned flipflops, which gives you the most basic functionality for this. You could also use devices, which are interfaces serially, like shift registers or even port expanders. Using flipflops will be the easiest way, since the programming does not change much. There are many examples how to use each of these devices with an Arduino on the web.

I use for this purpose (model railroading switching turnouts/signals with relays and coils) a simple and pin saving solution. An I2C bus shield/module with 16 I/O ports (and its daisy chainable - up to 64 modules theoretically, 16 practically due to address encoding pins)The 16-channel PCA9685/PCF8574 I/O extender module cost around 4-5 euro and requires beside GND/VCC only two data pins (SDA & SCL) to control the module. The I2C header has extra 10K pullup resistors and onboard of the module is a 25 MHz typical internal oscillator.
So after reseting, I first read the EEPROM/SPIFFS/SD-values and based on that stored set I work on. The Module(s) has(ve) a seperate power source which is not affected by the reset of the Arduino controlling them. The operating range of 2.3V to 5.5V allows the module to be powered from a range of power supplies and also used with 3.3V devices.The green terminal block in the picture is for use with servos - the extra power supply attaches to the I2C header (but common ground with Arduino).  Of course you have to use a lib (or like me write the functions you need) but once your into it its easy to use and also usable for other scenarios (LEDs, PWM generator, servos).

The PCA9685 is a 'free running' PWM controller. Tell it what to do,
  and it will keep doing that until you tell it to do something else. If
  you wanted to set the relays to a specific state and keep them
  there, you could disconnect the Arduino until you wanted the relays to
  do something else.


text:
Start VL53l0X measurement failed
The initialization of the ToF fails with this code. I'm trying to frankenstein it with Radiohead RFM69, so far no luck.
// rf69_reliable_datagram_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple addressed, reliable messaging client
// with the RHReliableDatagram class, using the RH_RF69 driver to control a RF69 radio.
// It is designed to work with the other example rf69_reliable_datagram_server
// Tested on Moteino with RFM69 http://lowpowerlab.com/moteino/
// Tested on miniWireless with RFM69 www.anarduino.com/miniwireless
// Tested on Teensy 3.1 with RF69 on PJRC breakout board

#include <RHReliableDatagram.h>
#include <RH_RF69.h>
#include <SPI.h>

#include "Seeed_vl53l0x.h"
Seeed_vl53l0x VL53L0X;

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

// Singleton instance of the radio driver
RH_RF69 driver;
//RH_RF69 driver(15, 16); // For RF69 on PJRC breakout board with Teensy 3.1
//RH_RF69 rf69(4, 2); // For MoteinoMEGA https://lowpowerlab.com/shop/moteinomega

// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver, CLIENT_ADDRESS);

void setup()
{
  VL53L0X_Error Status = VL53L0X_ERROR_NONE;
  Serial.begin(115200);
  if (!manager.init())
    Serial.println(F("init failed"));

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM

  // If you are using a high power RF69, you *must* set a Tx power in the
  // range 14 to 20 like this:
  // driver.setTxPower(14);

  Status = VL53L0X.VL53L0X_common_init();
  if (VL53L0X_ERROR_NONE != Status) {
    Serial.println(F("start vl53l0x mesurement failed!"));
    VL53L0X.print_pal_error(Status);
    while (1);
  }

  VL53L0X.VL53L0X_long_distance_ranging_init();

  if (VL53L0X_ERROR_NONE != Status) {
    Serial.println(F("start vl53l0x mesurement failed!"));
    VL53L0X.print_pal_error(Status);
    while (1);
  }

}

unsigned int findDistance() {
  VL53L0X_RangingMeasurementData_t RangingMeasurementData;
  VL53L0X_Error Status = VL53L0X_ERROR_NONE;

  memset(&RangingMeasurementData, 0, sizeof(VL53L0X_RangingMeasurementData_t));
  Status = VL53L0X.PerformSingleRangingMeasurement(&RangingMeasurementData);
  if (VL53L0X_ERROR_NONE == Status) {
    if (RangingMeasurementData.RangeMilliMeter >= 2000) {
      Serial.println(F("out of range!!"));
    } else {
      //Serial.print("Measured distance:");
      //Serial.print(RangingMeasurementData.RangeMilliMeter);
      //Serial.println(" mm");
      return RangingMeasurementData.RangeMilliMeter;
    }
  } else {
    Serial.print(F("mesurement failed !! Status code ="));
    Serial.println(Status);
    return 0;
  }
}

uint8_t data[] = "Hello..there";
// Dont put this in the stack:
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];

void loop()
{
  //Serial.println("Sending to rf69_reliable_datagram_server");

  // Send a message to manager_server
  if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
  {
    // Now wait for a reply from the server
    uint8_t len = sizeof(buf);
    uint8_t from;
    if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
    {
      Serial.print(F("got reply from : 0x"));
      Serial.print(from, HEX);
      Serial.print(F(": "));
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println(F("No reply, is rf69_reliable_datagram_server running?"));
    }
  }
  else
    Serial.println(F("sendtoWait failed"));
  delay(500);
}

Please try the  I2C Scanner sketch to check, if it can find the sensor on the standard address 0x29, which is used in the library. If it cannot find any device, the communication does not work.Then check the wiring, add strong pullup resistors to the I2C lines (4.7kOhm for example). And include your wiring in the question.

@chrisl thanks for your response, an important point to mention is that the code works when run alone, its only when I combine the sensor code with the radio module code i run into problems. Thanks again


text:
EspMQTTClient inside a class
I'm trying to use EspMQTTClient inside a class, called myIOT32.
An error, which I don't find the reason for is generated.
/home/guy/Documents/git/Arduino/libraries/myIOTesp32/myIOTesp32.cpp: In lambda function:
/home/guy/Documents/git/Arduino/libraries/myIOTesp32/myIOTesp32.cpp:25:5: error: 'this' was not captured for this lambda function
     client.publish("mytopic/test", "This is a message sent 5 seconds later");
     ^
/home/guy/Documents/git/Arduino/libraries/myIOTesp32/myIOTesp32.cpp:25:5: error: invalid use of non-static data member 'myIOT32::client'
In file included from /home/guy/Documents/git/Arduino/libraries/myIOTesp32/myIOTesp32.cpp:1:0:
/home/guy/Documents/git/Arduino/libraries/myIOTesp32/myIOTesp32.h:20:19: note: declared here
     EspMQTTClient client;
                   ^
Multiple libraries were found for "WiFi.h"
 Used: /home/guy/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi
 Not used: /home/guy/arduino-1.8.12/libraries/WiFi
exit status 1
Error compiling for board LOLIN D32.

.h file:
#ifndef myIOT32_h
#define myIOT32_h

// OTA libraries
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

#include "secrets.h"
#include "EspMQTTClient.h"
#include "Arduino.h"

class myIOT32
{
private:
    void onConnectionEstablished();  // <--- this is a must have function ( was taken as is from lib's built-in example

public:
    EspMQTTClient client;
    myIOT32(char *ssid, char *wifi_p, char *mqtt_broker, char *mqttU, char *mqttP, char *devTopic, int port = 1883);
};

#endif

.cpp file:
#include "myIOTesp32.h"

myIOT32::myIOT32(char *ssid, char *wifi_p, char *mqtt_broker, char *mqttU, char *mqttP, char *devTopic, int port)
    : client(ssid, wifi_p, mqtt_broker, mqttU, mqttP, devTopic, port)
{
}

void myIOT32::onConnectionEstablished()
{
  // Subscribe to "mytopic/test" and display received message to Serial
  client.subscribe("mytopic/test", [](const String & payload) {
    Serial.println(payload);
  });

  // Subscribe to "mytopic/wildcardtest/#" and display received message to Serial
  client.subscribe("mytopic/wildcardtest/#", [](const String & topic, const String & payload) {
    Serial.println(topic + ": " + payload);
  });

  // Publish a message to "mytopic/test"
  client.publish("mytopic/test", "This is a message"); // You can activate the retain flag by setting the third parameter to true

  // Execute delayed instructions
  client.executeDelayed(5 * 1000, []() {
    client.publish("mytopic/test", "This is a message sent 5 seconds later");
  });
}

Appreciate any help in constructing such a class

reordering Arduino.h did not solve.

For the fix, just add the reference capture and it should compile fine:
   // Execute delayed instructions
  client.executeDelayed(5 * 1000, [&]() {   // [&] instead []
    client.publish("mytopic/test", "This is a message sent 5 seconds later");
  });

I could not test, but you will have to apply to other functions as well.
[] Capture nothing
[&] Capture any referenced variable by reference
[=] Capture any referenced variable by making a copy


text:
F() messes with program
I'm working on command-handler library and I have a big problem with F() function.
Example sketch for library uses quite a lot of RAM, because it has to print a lot of text over UART. As before, I've used F() to lower RAM usage. It worked on first!
Lib works with help of strtok function. Command fomar is:

cmd1,..,paramN;..;cmdN,..,paramN

Commands are separated with ; while command parameters(params) are separated with ,
Library works without any problems, it returns memory address(char*) of any command and every param.
When I try to compare parameter/command with strcmp it works only if all commands are in uppercase.
Let's take LED command for example:
It works only with Led, LED or any case where is letter d in uppercase. led won't work, and it will say that command le doesn't exist. Yes, le, it won't print led. But, after DURATION command, it somehow start working.
Memory for serial buffer is dynamicly allocaed in object constructor, in global scope.
Why? All those problems are because F(). Can someone explain why? Here's the code and screenshot of serial monitor.
void execCmd(const char *set)
{
char *cmdParam = CMDHandler.find(set, CMD_PARAM);

if (!strcmp(cmdParam, "LED"))
{
    // ONE WAY TO CHECK IF COMMAND HAS PARAM(S) - BEFORE GETTING PARAM(S) == BETTER WAY
    if (!CMDHandler.count(CMDHandler.getNext(CMD_PARAM), CMD_PARAM))
    {
        Serial.print(F("->> Command LED: Current LED status is "));
        Serial.println(digitalRead(LED_PIN));
        return;
    }

    cmdParam = CMDHandler.find(nullptr, CMD_PARAM);
    LEDStatus = 0;
    uint8_t status = atoi(cmdParam);

    digitalWrite(LED_PIN, status);
    Serial.print(F("->> Command led: LED Status is "));
    Serial.println(status, DEC);
}
else if (!strcmp(cmdParam, "LOOP"))
{
    cmdParam = CMDHandler.find(nullptr, CMD_PARAM);

    // SECOND WAY TO CHECK IF COMMAND HAS PARAM(S) - AFTER GETTING EVERY PARAM
    if (cmdParam == nullptr)
    {
        Serial.println(F("->> Command LOOP: Expected one parameter!"));
        return;
    }

    uint8_t status = atoi(cmdParam);
    if (status)
    {
        LEDStatus = 2;
        digitalWrite(LED_PIN, HIGH);
        Serial.println(F("->> Command LOOP: LED Blink Loop is on!"));
        delay(blinkDuration);
    }
    else
    {
        LEDStatus = 0;
        digitalWrite(LED_PIN, LOW);
        Serial.println(F("->> Command LOOP: LED Blink Loop is off!"));
    }
}
else if (!strcmp(cmdParam, "DURATION"))
{
    if (!CMDHandler.count(CMDHandler.getNext(CMD_PARAM), CMD_PARAM))
    {
        Serial.print(F("->> Command DURATION: Current blink duration is "));
        Serial.print(blinkDuration, DEC);
        Serial.println("ms");
        return;
    }

    cmdParam = CMDHandler.find(nullptr, CMD_PARAM);
    blinkDuration = atoi(cmdParam);

    Serial.print(F("->> Command DURATION: New blink duration is "));
    Serial.print(blinkDuration, DEC);
    Serial.println("ms!");
}
else if (!strcmp(cmdParam, "HELP"))
{
    Serial.println(F("------ HELP ------\n-> LED [0/1] - Turns off/on LED on pin 13\n-> LOOP [0/1] - Stops/starts blink loop with LED on pin 13\n-> DURATION [X] - Changes duration of LED loop blink. Recommended values is 50-500ms\n"));
}
else
{
    Serial.print(F("->> Command "));
    Serial.print(cmdParam);
    Serial.println(F(" does not exist!"));
}

}
char *CMDHand::find(const char *input, uint8_t const type)
{
    char *found = nullptr;
    char separator = delimiter[type];

    if (input != nullptr) // FIRST CALL
    {
        constrain[type] = input + strlen(input) - 1;
        next[type] = input;
    }
    else if (next[type] > constrain[type]) return (nullptr);

    found = strtok(next[type], &separator); // FOR SOME REASON IT DOES NOT WORK IF I PUT &delimiter[type] INSTEAD OF &separator
    last[type] = next[type];
    next[type] += strlen(found) + 1;

    return (found);
}

To compare with F() macro encased strings you have to use special forms of the string functions that are suffixed with _P.  You also need to cast the string literals to the right type (PGM_P).
To do a case-insensitive comparison you should use strcasecmp instead of strcmp.
To put those together you end up with:
if (strcasecmp_P(cmdParam, (PGM_P)F("help")) == 0) {
    ...
}

There is a problem here:
found = strtok(next[type], &separator)

strtok takes a C string as a list of separators (must be NULL terminated). You're passing it the address of a single character. There may or may not (probably not) be a NULL in the next byte in memory, but everything else up to the first NULL found in memory will be taken as delimiter characters.

Are all these specific '_P' functions documented somewhere? I know a few but not all of them like strcasecmp_P.

@MichelKeijzers https://nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html

No, I've used F() for Serial.print() and Serial.println(), not for ˙strcmp(). Why I should used it in strcmp()` then?.

For the same reasons as in Serial.print. To save RAM.

Thank you very much (I already upvoted your answer).

@Majenko sorry, but no. It doesn't work as it should. led doesn't work because somehow led becomes le(I know because it says command le doesn't exist). LED works. I don't know why letter d(lowercase d) causes all those problems. No matter what command I type, if it has d, it will cause problem. Without F() in Serial.print/ln all works fine. Why?

@SilvioCro Then there is something strange happening in the mysterious CMDHandler class's find method. If your string is not parsing correctly you should look at the parser, not the comparison structure.

@Majenko added find method. Code works fine when I don't use F(), even I tried as C++ program. Seems like F() overrides part of the buffer for the Serial, since if I print text using next from find method, I can see part of the text that I didn't write.

You have a critical mistake in your find method. See my edit above.

Thanks a lot, now it works.


text:
Arduino UTFT Touch align RIGHT with margin
I am using a TFT Touch screen on an Arduino Mega, with UTFT and UTouch libraries.
When I use the code below, the text is aligning to right, all the way to the edge of the screen. Is it possible to give it a margin?
tft.print("Text", RIGHT,12)

Thank you,
Andi

tft.print("Text ", RIGHT,12)

That's interesting workaround. I realise now that I didn't think my question through, because I will also need it with integers. Is there a similar workaround I can do with those?


text:
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.

You did a shallow copy of the git repo:
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(){}

This fixed "fatal: No names found, cannot describe anything.", but there are still "undefined reference to `app_entry_custom()'".

Can you now ADD the current error message  to your question (edit it) - because error message have to be worked top down not bottom up -btw whats in the sketch apr*.ino? Are you using docker images?

apr*.ino is empty setup() and main(), I don't use docker.

See my edit in the answer

My *.ino is fine, this linker error mean that I lacking some shared object (I'm not sure if I can call it that in this case), but I have no clue which file it need and how to add it.


text:
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);
  }
}

I'm not sure I follow the question, "Where do I put the buttonState".  You are reading the button inside the function and letting that decide which status to take next.  That sounds perfectly reasonable.  What is happening or not happening right now that doesn't meet your expectations?  Compare and contrast the symptom and expected behavior a little.

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

Thanks for your advice Codebreaker. I will do that to complete my FSM and I found a solution that kinda does what you describe here. The yellowLight state returns with a simple: if (millis() - noDelayPause > 1000 || digitalRead(buttonPin) == LOW). Or after the time has passed it goes into the whiteLight state.

Be aware that the solution with going directly to read the pin in the function wont work in more complex scenarios due to processing time and other issues. Please close the question as solved/accepted

when comparing boolean values, do not use if (buttonState == true) ... use if ( buttonState ) or  if ( !buttonState )


text:
Gratuitious instantiation of `Serial`, why?
Let's take a very simple sketch, any simple one-.ino sketch. Say, just a led blinker like this

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?

I am sure there is some volatile in the implementation of Serial

@Juraj: What specific occurrence of volatile do you have in mind? The compiler is supposed to preserve each occurrence of volatile access. But if the function is never called, there's no access to preserve. If Serial makes volatile access in its constructor, then it should always be preserved, regardless of whether the client code uses Serial or not. This is not the behavior we are observing.

Did you check the command line for compiler and linker? There might be some option that stops the linker from discarding. And did you look into the object files to see what uses the space? objdump is a big help here.

at linking HardwareSerial.o is in an .a archive. if it would by a single .o on linker command line it would be always linked. if it is in .a it is linked only if it is required. this is not an answer, only a lead. I don't know how 'required' is determined

My guess (though I didn't check) is that it is a side effect of the fact
that the same file contains the instantiation of Serial and the
associated ISRs. The definition of the ISR macro looks roughly
like this (slightly simplified):
#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.

In my original program, foo.cpp is actually a part of my Arduino library. AFAIK, during Arduino build process libraries are compiled and archived into genuine static libraries. And then object files are pulled out of them only if they are needed (per standard ln behavior). So, in my example foo.o should not get pulled out of the library and therefore should not pull HardwareSerial0.o with it. However, the strange behavior still persists: once the library is used by a sketch, Serial immediately grabs a chunk of memory.

@AnT, has your library dot_a_linkage in library.properties? without it it .o files are put on linker command line

@Juraj: No, it did not have that. And this actually solves the problem immediately.

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.


text:
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 :)

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.

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.

I see, thanks!!

actually VIN (on non lo-lin nodeMCUs) is connected through a diode, so there's a voltage drop on the usb voltage, and heavy loads will heat the diode. 350mw is only 70ma, and that should be fine for the diode, as long as the heater doesn't mind 4.3v it will work.


text:
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:
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:

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", "
404: Not found
");
        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();
}

try to turn off the debug logs with "Debug level" None

tried that before, didn't help unfortunately

are you sure? do you have the same stack trace then? turn off Debug port too

Wow, I just tried it again - and you were right! It's working now! Maybe I had just turned down the level before... But why? Does that mean I can't look at my WiFi-Debug-Messages while using serveStatic()?

I've just done some testing and figured out that as soon as I include CORE in the debugging menu, it starts crashing. I would have never guessed this was the issue.

there must be some bug with logging. printf in stack trace was the clue

Great find! Shame I can't upvote you!

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 for helping me spot this one.

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 ...

Thats exactly what I have. I know that the files are there and are readable because reading the files individually from SPIFFS works. See my edit above.

I just changed my code to define a file individually but the error is still there :(

Thats a good hint, I will consider adjusting that before deploying. However, my static files (everything inside the data directory) are currently 1,4MB in size. That should be compatible with my current IDE settings, correct?

No its not - 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 in prgmem -your error message line two indicates that something should be loaded to prgmem and cant We ruled out all other reasons so ...

But if that was an issue, how come handling static file reads not through server.serveStatic() but through server.on(...)with a custom handler function that streams the file over works? See my second edit for reference.

Also, can you maybe provide me with a link to a resource that shows me how to remove the OTA partition space? I just googled for a while and I cant seem to find anything useful...

That would be a new question


text:
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,

Sure, you can do that by making all of the devices log on to the same Wifi network (provided by your router presumably) as a client. You can then exchange data between them. But what is your actual question?

@StarCat That I have done already - that was simple. Now, I cannot find any sample code how to send my data from one client to another one - that is my problem. How to send it over?

I can find many example sketches that feature two ESP8266's talking to each other. You might need to be clearer about what kind of data you want to exchange and what you're having difficulty with.

@StarCat Thank you for your help. You are right, apparently I have been missing some concepts. Now i am good to go. Thank :)

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.

Thank you for the answer! It clarifies everything! Now I know what to do! :)


text:
Trying to use Timer0 on Arduino Mega
I've recently been looking at Timers and I'm trying to generate a PWM frequency at 250000Hz using Timer0 on PIN 4. When I set OCR0A = 63 I get nothing from the light however when I set OCR0A = 125 it turns on ( 128000Hz - according to the formula in the datasheet unless I've been working it out wrong). What's the reason for it not working when OCR0A = 63
#include <DmxSimple.h>

void setup() {
  // put your setup code here, to run once:
  Serial.begin(250000);
  pinMode(2,OUTPUT);  // SHIELD DRIVER OUTPUT ENABLE
  digitalWrite( 2 , HIGH); // SHEILD DE HIGH
  DDRG |= bit(DDG5);

  TCCR0A = 0;
  TCCR0B = 0;
  TCNT0 =  0;

  TCCR0A = bit(COM0A1)| bit(COM0B1)| bit(WGM01)| bit(WGM00);
  TCCR0B = bit(WGM02) | bit(CS00);
  OCR0A = 63 ;
  OCR0B = 31;

}

void loop() {
  // put your main code here, to run repeatedly:

(1,PORTG |= (1<<5));
(1,PORTG &= ~(1<<5));

}

Except for the loop code (that shouldn't be affecting anything, as it's using alternate pin function) and pointless COM0A1, I can't see any problem. Well, except one of my multimeters showed the wrong frequency, second one shows correct 248.76kHz and 50% pulse width.

@KIIV Could the DmxSimple library be causing a problem ? . I don't have an oscilloscope or multimeter to check the output frequency  but your multimeter showed 250kHz when OCR0A = 63 ?

DmxSimple uses Timer2 so it shouldn't be a problem. At least as far as you don't use anything millis related, like delay or so (because it's updated by Timer0 overflow and it won't happen with that changes)

I've made sure to leave any delays out . I'm not sure what the issue could be . Would it worth changing to see if it works in Fast PWM mode when TOP = 0xff

Btw, what light? Why do you need such short period?

It's a non branded DMX light that I had . The period is not necessary . I'm just trying to get a distinct modulated that signal that can be picked up by the photodiode. I was previously trying to get OOK modulation to work but was unable so I'm now trying PWM . Any suggestions would be much appreciated


text:
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.

thanks. I'm having difficulty previewing.

reinstall the library

@Juraj - That works. Why?

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.


text:
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?

https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ

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


text:
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 .

Doesn't sound like you would need to configure an extra timer for that. Have you thought about using millis()?

a timer conflict on AVR creates a compilation error.

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


text:
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:
#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);
}

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

I checked and it is telling me it that it cant read from the sensor. I beginning to think that this might be a hardware malfunction. I tried the sensor without the LCD and it worked fine, but the addition of it gives me errors. Is there a reason for this?

See my edit above

As Codebreaker mentions, it looks like you are missing a call to  dht.begin() in your setup function (and you need to check for NAN values)

This is better because I have a visual feedback message. It just constantly says DHT not ready. It makes me think it might be a hardware issue (with the Arduino I think). I just want to rule out every other possible problem before I assume it is an Arduino hardware issue.

Have you initialized correctly See my edit DHT dht(DHT11_PIN, DHT11); AND dht.begin(); IN setup() AND check wether you use resistors see above its unlikely that the sensor is NOT working

So I tried to do the same thing, but this time I used an LCD with an I2C bus on it. It only takes two analog signal connections, 5v, and ground. I tried it with the DHT11 and it worked. I think it may be a something with connections because with the original LCD I had a lot of connections which could be interrupting the DHT11.