text:
Arduino Nano Every USB Connection not working
I have two original (designed and assembled in Italy) Arduino Nano Every Boards from a German Web Shop. They came sealed in original packaging. When I try to connect them to my PC, they don't power up.
What I've tried so far:

6 different USB cables
1 Desktop PC with Arch Linux as well as Windows 10, all USB Ports available (front headers, back side motherboard)
1 Laptop PC with Arch Linux
1 Google Pixel 4 XL using a USB-B to -C adapter

No combination of the USB cables with any of the aforementioned USB Ports / Machines / Operating Systems allow the Arduino Nano Every Boards to boot up (no LEDs flashing).
I tried powering the boards using a 9V battery block on the V_in and GND pins, which works. I also tried powering the boards using a 9V battery block and then connecting the USB, but the aforementioned machines / operating systems do not recognize a new device connected via USB, despite the boards being powered (LEDs flashing).
I also triple-checked the physical connection of the USB cables on both ends to be sure they are inserted properly. I can use the aforementioned USB cables, USB ports, machines, and operating systems to charge other devices or transfer data with other devices (like, e.g., smartphones, e-book readers, USB flash memory sticks, external hard drives, ...).
What should I try next to get the Arduino Nano Every working?
Please let me know which extra information I should provide. Thanks!
Note: As far as I can see, using lsusb on Linux should always list connected USB devices, regardless of the groups my user's in. Nevertheless, I also loaded the cdc_acm module and added SUBSYSTEMS=="usb-serial", TAG+="uaccess" to a udev rule located at /etc/udev/rules.d/01-ttyusb.rules, and reloaded the udev rules, to no avail.

try to install the megaAVR boards package in IDE. it installs drivers too

thanks @Juraj, afaik the kernel module cdc_acm drives devices which support the Communication Device Class Abstract Control Model interface already. Apart from this, since the Arduino Nano Every boards I have do not even start, driver issues are of low probability imho.

Just to be really certain, in the case that you are USB-powering the boards, does the power LED light solidly?

Regarding Juraj's comment, I believe it is significant with respect to your Windows 10 testing, which I'm guessing is all he intended to related to. My memory that Windows requires the Arduino "driver" in some (all?) cases despite being a CDC-ACM interface. There's no driver proper in it though; no .sys file. It's just an .INF file that associates a built-in CDC-ACM .sys driver to the VID:PID/interface of the Arduino. It's just not entirely automatic in Windows as it is in Linux. That said, it need only enumerate on USB (even without "drivers") to at least list in some way in Device Manager.

Nope, there's no sign of life at all from the boards if USB is connected as described.

On the underside of the board there are test points for the D+ and D- signals near the USB connector and D12. I would voltage test these to GND while powered by VIN and take note of what voltages appear on them. Then unpower the board an continuity test each to the host end of a USB cable.

I've ordered an Arduino Nano (not "Every") from a different web shop now, and it powers up as soon as I connect to USB. Since the Arduino Nano uses mini-USB (the Arduino Nano Every uses micro-USB), I'm using a different cable from the ones I tried on the two Arduino Nano Every boards I have. But given that I tried multiple cables that also work with other devices, I'm confident now that the two boards I have are just broken. I've had bad luck.

These types of questions often requires considerable trouble shooting until the cause is found.  In order to make this useful to as many people as possible, let us compile a list of actions. (Add a comment if any have additional actions to try and I'll add them to the list.)

"...powering the boards using a 9V battery block on the V_in and GND pins..."

Confirm the 9V supply is connected to VIN. An internal voltage regulator will then provide the necessary 5V and 3V3 to the rest of the Nano-Every. Consider if 9V was accidentally connected to either the 5V or 3V3 pins, parts of the Nano-Every my be damaged.

"using lsusb on Linux should always list connected USB devices"

Yes, it should. If "lsusb" is typed before and after plugging in the Nano Every there should be an additional USB device listed.  If there is no change, there may be something physically wrong (bad cable or incorrect cable (i.e. charging only), bad Nano or burnt out part).
Also, "lsusb" normally does not require root privileges. But consider trying "sudo lsubs" to confirm all USB devices are seen.
Here is an example output of "lsusb" run when an Nano-Every was connected to a Ubuntu computer:
$ lsusb
...
Bus 001 Device 004: ID 2341:0058 Arduino SA Arduino Nano Every

"I also loaded the cdc_acm module ..."

Inspecting a Ubuntu system that can successfully program a Nano-Every, I see no package with the words cdc_acm in it installed.
(I'm going to have to look into the above. While Ubuntu's package manager does manage cdc-acm.ko, cdc-acm.ko exists.)

"...and added SUBSYSTEMS=="usb-serial", TAG+="uaccess" to a udev rule located at /etc/udev/rules.d/01-ttyusb.rules"

Be aware that adding a udev rule with a low value such as "01*" is likely to be obscured by any udev rule with a higher number should a match be found. Most developers add udev rules which start with a high number such as "99*" to mitigate this problem.
This said, it is unlikely a modification to udev rules is necessary. Most if not all Linux distributions will handle a USB/CDC type of peripheral adequately with out modifications. Plugging in a Nano-Every into the above mentioned Ubuntu computer generates a new device at /dev/ttyACM0.

"I tried powering the boards using a 9V battery"

Avoid using PP3 type 9 Volt batteries. They can be problematic when their lower current capacity has been reached.  At which point their output voltage may drop. Leading to unexpected results. If such a battery is necessary, pay close attention to current needs adding up all the expected maximum currents. In brief, lower powered processor on Arduino boards built using an LDO (Low DropOut regulator) have the best chance of working as expected. Other Arduino boards may not work as well and high current components such as a motor, solenoid or relay will likely not work.

you write: "there may be something physically wrong (bad cable or incorrect cable (i.e. charging only), bad Nano or burnt out part)."
Yes, exactly, that's why I tried 2 different arduino nano every boards using 5 different USB cables on 3 different machines using 3 different operating systems, where all of the mentioned items actually work apart from the 2 arduino nano every boards.

the cdc_acm is a kernel module that drives devices which support the
Communication Device Class Abstract Control Model interface (look into ls -l /lib/modules/$(uname -r), see also https://www.kernelconfig.io/config_usb_acm or https://www.keil.com/pack/doc/mw/USB/html/group__usbh__cdcacm_functions.html

I made a somewhat generic list of things to try so others might benefit too. I saw where you tried several cables. I wanted to ask if they were identical (perhaps all charging only) or from different manufactures. I see cdc-acm.ko now. I used "sudo dpkg -l | grep cdc | grep acm" which shows no such package on Ubuntu. I like @KIIV's idea of checking the 5V and 3V3 while supplying power through USB and also after switching to your 9V battery at VIN. That should tell us if the Nano-Every's regulators and power diode is working. Also, avoid using low current PP3 9V batteries.

It's some regression in linux core and 1200baud touch doesn't work properly (it seems it's used switching between updi mode and serial link).
I started using script mentioned in https://github.com/arduino/ArduinoCore-megaavr/issues/124 and i was able to upload it in most cases (but better than mostly failing) when I execute it few seconds before the upload.
For example curiosity nano board with Atmega4809 works perfectly as it's emulating debugger+serial+mass storage (but needs correct VID/PID in udev rules or connecting storage)
Mentioned script:
#!/usr/bin/python3
#   Run this script to reset the Arduino Nano Every
#   eg. sudo python3 mcu_reset.py
#
# Note: You must install pyserial first; i.e. sudo pip3 pyserial

import serial
import os, sys
# total arguments
n = len(sys.argv)
if n >= 2:
    port = sys.argv[1]
else:
    port = '/dev/ttyACM0'

print("Port: {}".format(port))

#re-enable hupcl temporarily (necessary for arduino reset using serial port)
os.system('sudo /bin/stty -F {} hupcl'.format(port))

try:
    #perform Arduino Nano Every reset "handshake"
    ser = serial.Serial()
    ser.baudrate = 1200
    ser.port = port
    ser.open()
    ser.close()

except serial.SerialException:
    print("Error: serial.SerialException")
    exit()

Thanks for your answer! Unfortunately, if the Board doesn't even turn on, isn't recognized by lsusb, and the USB to serial chip on the board doesn't run - how should setting a baudrate on that serial port help?

And it won't turn on even on USB charger? How about using 5V pin (with 5V input)? If first doesn't work and second works (which probably does as Vin is going through 5V too), then the protection diode between Vusb and +5V might be reversed or destroyed or the USB connector is somehow damaged

Maybe also check 3V3, it's powering the com chip Nano Every Schematics


text:
Is there a maximum length of an array in ROM?
Consider the following code:
    #include <Arduino.h>

    unsigned char testimage [] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ... many more rows ...
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    };

    void setup()
    {
        Serial.begin(115200);
        while(!Serial);

        Serial.println("start");

        for (int i = 0; i < 10; i++) {
            Serial.println((int)(testimage[i]));
        }

        Serial.println("stop");

    }
    void loop()
    {}

I found out that then the array gets a certain size, there is nothing being sent to the serial monitor. It looks like the entire program freezes. I do not even see the start message appear.
I haven't tried to find the exact size, but it is somewhere between 4500 and 8000. (When sized around 4500, it works, when around 8000 it doesn't).
When I do not address the array though, I do see the start and stop messages appear.
I am using an Arduino ATMega2560.

does not work is a vague description of a problem ... what happens exactly? ... what were you expecting to happen? ... please add the info to the question ... do not write a comment

Mega has 8000 bytes large SRAM

It isn't clear whether you meant to put your array in ROM as your question implies, but the code you presented assigns it to RAM. That would surely restrict to your array to less than the 8K of of RAM minus whatever is needed by (globals + your libraries' statics + your code's statics + the stack).
Update:

I assumed the data section of the code would end up in ROM.

In fact, an image of the initialized data section does become part of the ROM image. The initial values need to be saved somewhere so RAM can be initialized each time the program is(re-)started but it is not accessed from ROM during run-time. (Note we're not talking about PROGMEM data here, which is kept in ROM and accessed from there even at run-time.)

Thanks. I assumed the data section of the code would end up in ROM. I guess the example code seems to be completely wrong ;).

In this case the RAM size is the limit. And you'd need some space for stack/heap,..
If you use non-const array, it'll be copied from flash to RAM at the startup
On the mega2560 even using const it still be copied into the RAM as each FLASH/RAM/EEPROM has different address space
Only way would be using PROGMEM and it can't be used directly (again different address spaces for flash/ram)
You can guess the mega2560 has 8KB RAM and you should keep some RAM for runtime. If there isn't enough of space, the stack and heap will be smashing each other and it would behave completely unpredictably (overwritten return addresses, runaway code and so on)

source: Stack Exchange

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

sort: votes


text:
PubSubClient hanging on ESP32C3
I may have done some things incorrectly here, but this I what I have for publishing image that I read from serial camera to the MQTT broker:
void capturePicture() {
  if (!cam.takePicture())
    client.publish("info", "Failed to snap!");
  else
    client.publish("info", "Picture taken!");

  char length[21];
  uint32_t jpglen = cam.frameLength();

  sprintf(length, "buffer length: %d", jpglen);
  client.publish("info", length);

  byte wCount = 0;  // For counting # of writes
  client.publish("info", "transfer about to begin");
  client.beginPublish("picture", jpglen, false);
  client.publish("info", "after beginPublish");

  while (jpglen > 0) {
    uint8_t* buffer;
    uint8_t bytesToRead = min((uint32_t)16, jpglen);  // change 32 to 64 for a speedup but may not work with all setups!
    buffer = cam.readPicture(bytesToRead);

    client.write(buffer, bytesToRead);

    jpglen -= bytesToRead;
  }

  client.endPublish();
  client.publish("info", "transfer should have ended;");
}

I know the board is working, I am connected to the broker and I can receive messages.
In the loop I am reading few sensors and pushing the string into the topic
void loop() {
  delay(1000);

  if (count == 5) capturePicture();

  if (!client.connected()) {
    reconnect();
  }

  int multi = analogRead(A2);
  int odor = analogRead(A1);
  int voc = analogRead(A0);

  char name[21];
  sprintf(name, "%d;%d;%d", multi, odor, voc);

  bool pubScss = client.publish("measurement", name);

  count++;
  client.loop();
}

and all that works fine.
what happens when capturePicture() gets executed is this:
Picture taken!
buffer length: 49048
transfer about to begin

--that's what I see on the topic's subscriber side, then it freezes for about 10secs and then it continues with sending messages from the loop.
So it seems like it never gets past client.beginPublish("picture", jpglen, false); call.
I'm setting PubSubClient's buffer size to client.setBufferSize(10235);
What can be happening here? Something I can further test??
Thanks for advices!

The short form of the below is something like: "After calling .beginPublish(), call .endPublish() before making a call to either .publish() or .beginPublish().

We don't have your actual code. And that makes things difficult.
However, this is a source of problems in what you have shown:
  client.beginPublish("picture", jpglen, false);
  client.publish("info", "after beginPublish");
  ...
  client.endPublish();

It kind of looks like you may intended the second publish to help you debug the initial problem. But again, we don't have your code. I don't know if this (or something just like it) is in your original. In any case, it's not doing you any good as a debug aid.

The .beginPublish()/[.write()-type stuff]/.endPublish() constructs a message in the MQTT protocol as you make these calls.
By inserting .publish() call between them you are corrupting the communication. In short, you're embedding an MQTT message part way inside of another MQTT message.
Something a bit like saying
HowHello. are you today?

instead of
Hello. How are you today?

This is confusing something, probably the server. Perhaps also the library itself and any client that receives whatever the server ends up passing along.

I tested with a few variations on this code:
//#define CAUSE_TROUBLE

void one_shot_message() {
  client.publish(MQTT_TOPIC, "[hi]");
}

void do_test() {
  static const char part1[] = "<Hello";
  static const char part2[] = " World>";
  static const char both_parts_length = // just being very explicit
      (sizeof part1 - 1) // part1 sans null terminator
    + (sizeof part2 - 1);// part2 sans null terminator
                       // the .publish accepting strings doesn't null terminate, so we aren't.

#ifndef CAUSE_TROUBLE
  one_shot_message(); // okay before beginPublish or after endPublish
#endif

  client.beginPublish(MQTT_TOPIC, both_parts_length, false);
#ifdef CAUSE_TROUBLE
  one_shot_message(); // not okay between beginPublish/endPublish
#endif
  client.print(part1);
  // tested with one_shot_message() called here (not-okay location) as well
  client.print(part2);
  client.endPublish();
}

What happens in the case of #define CAUSE_TROUBLE (at the least with server I'm using and the client I've written on a PC) is that a single corrupt-looking message comes through and then the ESP32 client reconnects to the server. Probably the server is closing the connection. It does this on a cycle of about 6 seconds. The corrupt message has the correct topic, which makes some sense because the topic is written as part of the .beginPublish() before there's an opportunity to corrupt the message. This may not be exactly what you're seeing, but I don't have good cause to think I should be seeing exactly what you're seeing; not the same exact code, client, server. It is similar anyway.

So, you can have client.publish("info", "before beginPublish");
or a client.publish("info", "after endPublish"); at those locations, but not between the begin and end calls. If you wanted to try doing something like that, you probably could probably do so by creating a second PubSubClient so that you could fire off these smaller messages in a separate protocol stream while in the middle of constructing/sending a larger message on the main stream.  However the messages may not arrive in order, either because the of how the library works or because of timing in the network. So if you want to do that you may also want to send a counter value with each message so you can reconstruct the timeline in the sending code.
An aside regarding sprintf vs snprintf:
  char name[21];
  snprintf(name, sizeof name, "%d;%d;%d", multi, odor, voc);

sprintf() is something that exists to support very old code or very old compilers.  There's otherwise no use case involving sprintf() that would not be better using snprintf()

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


text:
Feather M0 doesn't show up as a COM or Serial port
I am trying to upload a simple blink program on my Adafruit Feather M0 Radio with LoRa Radio Module to ensure that it connects to my PC. So far, I have:

Gone through 4 data cables
Tested for connection on 3 different devices (laptop on Windows 11, desktop on Windows 10, and computer running CentOS respectively)
Followed the direction for using the board with the IDE here and here

But the Port submenu is greyed out and when it isn't, it just doesn't have the port that recognizes my Feather. When going into Device Manager, I can't see it in the list of devices even when I refresh.

At some point did you double-tap reset?

Yes, many times. The problem persisted afterwards

Had it ever had anything uploaded to it successfully in the past? Is there anything connected it apart from the USB cable?

@timemage No, since I received my feather, I haven't had any success uploading anything to it

When you double-tap reset do you get the fade-in-fade-out indication on the pin13 LED?

Turns out the bootloader/USB firmware wasn't loaded in, which is why the double-tap reset wasn't working. I looked into the option of using another board as a programmer to get the bootloader in my Feather, but it proved to be more of a hassle than I thought so I'm just going to get a replacement. Hope this helps someone out in the future.


text:
Need Digistump library for QWERTY keyboard and Fixes for my issues!
Hello there I am trying to install Digistump library to support ATTiny85 by digispark. But I am encountering a problem when trying to install Digistump AVR boards after adding an additional board URL preference as the library doesn't shows up after searching.I dont know what's the problem even after I tried from the fixes from other solutions across the web.

So, I made an alternative method to work the board by installing ATTinyCore library. But it doesn't support DIGIKEYBOARD actions. So when I try to download from library manager there is only packages for AZERTY & Belgian AZERTY layout.

So for me I need a package that support QWERTY layout. How to install the library.?

The description of DigiKeyboardFr says it is “based on
DigisparkKeyboard library”, and gives the link to that library.
DigisparkKeyboard doesn't seem to be available from the Arduino library
manager: you will most likely have to install it manually. Manual
installation of Arduino libraries is widely documented.

May I know how to install it manually?? for the specified keyboard layout..


text:
I want the Arduino to be in sleep mode by default and have a button wake it up
I saw a library called LowPower_LowPowerLab that can set the Arduino in sleep mode. In their example they put the Arduino to sleep using an external button, is there anyway to invert this behavior? I want the Arduino to save battery power by being in sleep mode and then when I need it, hold a button down to keep the Arduino awake and then release the button to put it back to sleep. In their example below I have tried changing the attachInterrupt to HIGH/RISING/FALLING with no change. Also coul
LowPowerLab's Example:
#include "LowPower.h"

// Use pin 2 as wake up pin
const int wakeUpPin = 2;

void wakeUp()
{
    // Just a handler for the pin interrupt.
}

void setup()
{
    // Configure wake up pin as input.
    // This will consumes few uA of current.
    pinMode(wakeUpPin, INPUT);
}

void loop()
{
    // Allow wake up pin to trigger interrupt on low.
    attachInterrupt(0, wakeUp, LOW);

    // Enter power down state with ADC and BOD module disabled.
    // Wake up when wake up pin is low.
    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);

    // Disable external pin interrupt on wake up pin.
    detachInterrupt(0);

    // Do something here
    // Example: Read sensor, data logging, data transmission.
}

Looks like you're missing something after "Also coul".

In their example they put the Arduino to sleep using an external button, is there anyway to invert this behavior?

Of course. Put the Arduino to sleep in setup and make the button wake it up.
Some tips here.
Also, I wouldn't use LOW, I would use FALLING. LOW keeps interrupting the processor, so while you hold the button down it keeps entering the interrupt, which would make it unresponsive.


text:
Arduino read thermocouple Type K with ADS1115
I ordered a ADS1115 so I could measure temperature of a type K thermocouple, but I am not managing to get accurate readings. I had it working while having a normal A0 pin, but since the type K table shows pretty low voltages, the 0-1023 scale is not accurate.
When the thermocouple is at room temperature (around 22°c), it shows 00.0 millivolts on the multimeter (which I dont understand since it does not match with the table), and my program outputs a value of around -40 and a voltage of -0.005. When I heat it up until I measure 10.0 millivolts (around 250°c according table), the Arduino prints a value of 53 and a millivolts of 300.
What am I doing wrong? I suspect something with the calculation, but I am not able to find out how I should do it, I know very little about millivolts.
Can someone help me out what I am doing wrong here and what I should do?
I have the thermocouple and ADS1115 connected as shown in the image below.

The code I am using is as following
#include <Adafruit_ADS1X15.h>

const int analogFruitPin = 0;

Adafruit_ADS1115 ads;

void setup()
{
  Serial.begin(9600);
  ads.begin();
  ads.setGain(GAIN_FOUR);
  ads.setDataRate(RATE_ADS1115_860SPS);
}

void loop()
{
  int sensorValue = ads.readADC_SingleEnded(analogFruitPin);
  float voltage = sensorValue * (5.0 / 32768.0);
  Serial.println(voltage,3);
  Serial.println(sensorValue);
  delay(500);
}

it shows 00.0 millivolts on the multimeter ... how did you measure this?

I just measure at the + and - of the thermocouple with a normal multinmeter, it does increase the measurement of the multimeter when i heat it up

See the library function computeVols() on how the voltage is calculated versus your sensorValue * (5.0 / 32768.0).

@Bart, when you get around to it, you should accept an answer that addresses your question or rephrase your question.  That will trigger emails to all so far involved to give them a chance to rephrase their answer.  Also, if you were wondering why bother w/a thermocouple if you need a 2nd more conventional temperature sensor ... well, thermocouples can work in extreme heat (like a pottery kiln) and they are inexpensive.

Welcome! Interesting but expected. Thermocouples need what is called a cold junction compensation. That is a circuit or another thermonuclear that compensates for the thermocouple effect where the lead wires are connected to your measuring device. These thermocouple lead wires should be the same metallic material as the wires in the thermocouple. The metals are different where you connect to the measuring device and will generate a voltage as the temperature changes regardless of the sensing probe, that is how the thermocouple works. This link will help: https://www.tegam.com/what-exactly-is-cold-junction-compensation/
For more information check this link: https://randomnerdtutorials.com/arduino-k-type-thermocouple-max6675/

So, this means I could never measure it with some sort of accuracy?

... not w/o a cold reference.  For example, a DMM with a thermocouple feature has an additional temperature sensor close to where the thermocouple wire connects to the wires (creating the 2nd junction) that then connect to the ADC.  Ideally we want to know the temperature of the 2nd junction.  You should up-vote or accept @Gil's answer.  But I'll add an answer pointing you to an Adafruit product that contains both the ADC and the cold junction temperature sensor.

To simplify your thermocouple temperature sensor project, consider using an ADC which also contains a cold junction temperature sensor.  This product from Adafuit.com integrates both into one package by using a Microchip.com MCP9601 integrated circuit.
In short, thermocouples generate small amounts of voltage where dissimilar metals touch. This is true where the thermocouple wires are touching each other. And is also true where the thermocuple wires are touching the metal connecting them to the ADC circuit (commonly called the "cold junction"). To find the temperature where the thermocouple wires are touching we need to subtract the effects of the "cold junction". To do that, we need to first know the temperature of the "cold junction". We commonly do this with a second temperature sensor as it is a more practical (and portable) solution than a traditional zero centigrade ice bath (likely where the term "cold junction" came from).


text:
Connect to wifi works only without password (Problem around WPA security)
I have an ESP32 Joy-it - SBC NodeMCU-ESP32 that should be use with board "ESP32 Dev Module". IDE says : Chip is ESP32-D0WDQ6 (revision v1.0).
Website product: https://joy-it.net/en/products/SBC-NodeMCU-ESP32
When I make a wifi scan, I find my AP, but if I connect with SSID + Password (both WPA (Internet box router - Freebox Crystal France) and WPA2 Personal (Xiaomi A2 Lite)), it doesn't work.
So I tried to make an AP without password on my phone, and ESP32 can connect without problem.
To do that, I used the default sketch "Wifi -> Wifi Client". My SSID and my password contain only letters/numbers (Only ASCII chars).
I tried to burn the bootloader, but nothing change.
I am using :

IDE Arduino 2.2.1
esp32 by espressif 2.0.14

Does somebody have an idea ?

I tried to burn the bootloader ... what does that mean?

Click on Tools -> Burn bootloader in Arduino IDE GUI :)

Have you tried older esp32 core?

Solution, I'm using an old Freebox, which has only Open or WPA security,
Just add : WiFi.setMinSecurity(WIFI_AUTH_WPA_PSK); to allow connection to my router.
For people with WEP security, just use WIFI_AUTH_WEP

"which has only Open or WPA security" ... WIFI_AUTH_WEP.  You meant "open or WEP" right?

In fact, I copy paste line before move minmal security to wpa, my bad


text:
Change USB VID and PID (Leonardo)
I'm new to using electronic boards, and have followed a guide online for printing a 6 DoF (degree of freedom) mouse. I'm stuck on an optional step that requires me to change the PID and VID of a "Arduino Leonardo" board.
I've located the appropriate "boards.txt" file, but I'm not sure which line to change. I've edited a few, but I'm worried I'll mess things up (a tutorial for it mentions they had destroyed 3 trying to rename it, and is back from 2009), and the ones I've changed do not result in a change.
I have checked out previous questions people have made regarding this topic, but quite frankly I can't understand the technical terms used in those.
This is the code in question I'm trying to compile, and lists example PID and VIDs as well.
I would love a clear explanation on which PID/VID I need to edit in the "boards.txt", so I can safely modify the board to be read as the space mouse in the code.

The Vendor ID (i.e. Logitech, Zerbra, ect) and Product ID (i.e. Specific Mouse made by Logitech, specific bar code reader by Zebra, ect) are values paid for by companies who manufacture USB peripherals.  When you use one of these VID/PID combinations you are telling your computer "your device is their device".  It's probably not on the up-n-up and you likely can't openly sell your USB product w/ "their VID/PID values". That said, you can probably make almost any VID/PID work on a Linux computer. On a Windows computer you probably have to masquerade as the USB peripheral you are imitating.

I see, that's understandable, selling products like that would fit pretty well under scamming and deceiving people. This is for a 3D printed project for my own personal use. Is it possible to change the right PID though, or is it sort of a territory where people aren't willing to openly discuss it since there's no real way to prove I'm not using it to mislead others?

I don't see a problem doing this for personal use.  Your question sounded like you didn't know what VID and PID numbers were used for.  So, a little background.  I'd write an answer ... but I'm still not clear if just knowing what a VID/PID number answered your question.
As for bricking your Arduino, well, if there is only 1 USB on your Arduino and you change the VID/PID away from being a USB/CDC device, then the connected computer will likely not talk to it.  But this has more to do w/with the processor (or USB interface device) used in your particular Arduino.

Welcome to SE/Arduino! Please take the [tour] to learn how this site works, and read "[ask]". This is not a forum. Then come back and [edit] your question for clarification. -- I will not look into externally linked sources on some website. Can't you show a minimal example? -- The tutorial is not for the Leonardo, AFAIK the Leonardo does not use an FTDI chip for USB. -- What is this "boards.txt" you mention? -- Why do you need to change the VID/PID at all? -- Please provide a link to this "guide online".

I'm stuck on an optional step that requires me to change the PID and VID of a "Arduino Leonardo" board. - If it's optional and you are stuck, I suggest ignoring that step. If it's optional it can hardly require you to do it.

@thebusybee What is this "boards.txt" you mention? - Really? boards.txt is a well-known file that specifies baud rates, processor types, fuse settings and so on, generally used during the process of uploading code to a board. I'm not sure of the exact way it is used, but my guess is that the IDE reads that file in, populates its list of supported boards, and then when you choose one, sets up various defines used in the compile and uploading process.

I need to edit in the "boards.txt", so I can safely modify the board to be read as the space mouse in the code. - What's a "space mouse"?

@NickGammon This code makes your Arduino act as a 3DConnexion SpaceMouse. The "space mouse" is the "6 DoF (degree of freedom) mouse" they mentioned.

@NickGammon "The tutorial is not for the Leonardo, AFAIK the Leonardo does not use an FTDI chip for USB. " Pretty sure the idea is that the FTDI chip seems to contraindicate a normal Leonardo and by extension the normal boards.txt. That is, the busybee is NOT asking "what is this boards.txt thing you speak of?".  They're asking the OP to positively identify the specific boards.txt, which may or may not wind up being the on you've linked to. And that will potentially answer half a dozen questions. That's what I get out of it anyway.

C:\Users\%USERNAME%\AppData\Local\Arduino15\packages\arduino\hardware\avr

leonardo.build.mcu=atmega32u4
leonardo.build.f_cpu=16000000L
leonardo.build.vid=0x2341     <--- here
leonardo.build.pid=0x8036
leonardo.build.usb_product="Arduino Leonardo"

leonardo.build.vid=0x256f
leonardo.build.pid=0xc631
leonardo.build.usb_product="SpaceMouse Pro Wireless (cabled)"


text:
6v High Torque Servo Won't Function On Motor Shield?

I have only ever been able to get this servo to “somewhat” work when connected to 5v pin on the shield, the ground on the shield, and the signal line attached to whatever pin. But 5v is not enough and 9v is too much. I'm trying a million different ways to power this thing, but I don't understand why I give it an appropriate voltage from X source (while still having the signal line connected of course), and it doesn't want to move at all.
So currently my Arduino is powered via USB. The shield/motor is powered from a 12v 2a power supply, which with a simple voltage divider circuit gets me 6.29V. Multimeter seems to show this works. Also the “Vin Connect” jumper on back was cut to make the screw terminals a dedicated power line for the motor, per Arduino website. I tried this set up without cutting the jumper too, same - no result.
Can anyone help me out? All I want to do is power my arduino with shield, and motor, however that has to happen, and be able to run the "Servo Sweep" example code.
https://docs.arduino.cc/hardware/motor-shield-rev3
https://www.amazon.com/ANNIMOS-Digital-Voltage-Stainless-Waterproof/dp/B07KTSCN4J

Hints: ohms law, voltage divider without and with load (also take into account different modes of operation).  For example expected impedance when servo takes 2A ->  R = U/I = 6V/2A = 3Ohm. Your voltage divider ratio 2000 : 2.9955 ( (12V / 2002.9955) * 2.9955 = 17.9mV (if you just replace servo with "equivalent" resistor, not with real servo)

It may pay to think about current required as well as voltage. Looking at a data sheet I found online (data sheet link) it refers to a stall current of 3.5A when running at 6V.
What do you mean by “somewhat”? Can you give more detail on the behavior you see? It may be useful to hook your multimeter up as an ammeter to get an idea of whether current draw is approaching the limit of the wall plug (2A) used.

The gauge of wire and the power rating of the resistors used in the voltage divider will also impact the available current.

It would be useful to add photographs or a circuit diagram; as well as your code; and observed behavior to your question.

I’m not sure what function you’re expecting from the Motor shield? I believe it may be extraneous. My understanding is that you need connections of: 6V 4A supply + and - to servo. Shared ground and PWM signal from Arduino to servo, separate USB power to Arduino. Motor shield not required. Any comments from other readers?

Thank you for all your ideas. Yes perhaps the Amperage is the main culprit here. The wires are quite thin also, something that never occurred to me. - "a stall current of 3.5A when running at 6V" does this mean that I need more than 3.5A to move it at all? That makes sense to me EXCEPT the fact that it does perform a 180 degree sweep with the 5V onboard plugin, powered soley through USB. I would just naturally assume the USB does not have that kind of amps. When I say "somewhat" I mean, I can get it to move, but it lacks the advertised torque - by a lot. Can't lift nearly enough.

Stall current is the maximum current drawn, when the motor is applying its maximum torque, either because it is being prevented from moving entirely or because it can no longer accelerate given the load it is under. https://robotics.stackexchange.com/questions/613/what-is-stall-current-and-free-current-of-motors#:~:text=Short%20answer,the%20load%20it%20is%20under.


text:
DHT20 and OLED display not working together
I am trying to get my DHT20 and OLED (both from the Arduino Sensor Kit) to work at the same time. I am able to get them working separately with their respective test codes, but when I try to combine the codes the OLED display no longer works. Both are I2C connections but I checked and each device has a different address so that shouldn't be a problem.
Here is my DHT20 test code:
#include "Arduino_SensorKit.h"

//uncomment line below if using DHT20
#define Environment Environment_I2C

void setup() {
  //uncomment line below if using DHT20
  Wire.begin();
  Serial.begin(9600);
  Environment.begin();
}

void loop() {
  Serial.print("Temperature = ");
  Serial.print(Environment.readTemperature()); //print temperature
  Serial.println(" C");
  Serial.print("Humidity = ");
  Serial.print(Environment.readHumidity()); //print humidity
  Serial.println(" %");
  delay(2000);
}

Here is my OLED display test code:
#include "Arduino_SensorKit.h"

void setup() {
  Oled.begin();
  Oled.setFlipMode(true);
}

void loop() {
  int random_value = random(0, 1023); // create a random value
  Oled.setFont(u8x8_font_chroma48medium8_r);
  Oled.setCursor(0, 3);
  Oled.print("Value: ");
  Oled.print(random_value);
  delay(1000);
}

This is the code where I tried to get both devices working at the same time:
#include "Arduino_SensorKit.h"

#define Environment Environment_I2C

void setup() {
  Oled.begin();
  Oled.setFlipMode(true);
  Wire.begin();
  Serial.begin(9600);
  Environment.begin();
}

void loop() {
  Oled.setFont(u8x8_font_chroma48medium8_r);
  Oled.setCursor(0, 3);
  Oled.print("Testing");
  Serial.print("Temperature = ");
  Serial.print(Environment.readTemperature()); //print temperature
  Serial.println(" C");
  Serial.print("Humidity = ");
  Serial.print(Environment.readHumidity()); //print humidity
  Serial.println(" %");
  delay(2000);
}

When I use this code the temp and humidity values are printed in the serial monitor but the OLED does not display anything.
Any help is much appreciated!

what happens if you reverse the order of the two module intialization in setup()?

Unfortunately reversing the order of the initialization in setup() doesn't change anything.

The basic problem
I don't have this sensor kit. But am able to observe what you're describing with substitutes and stand-ins. There seem to be two things you can do.
The basic problem is that the Arduino_SensorKit library is written to use software/bit-banged I2C for the display. Or rather, it tells U8G2LIB to do this, for what reason I don't know. When the ATmega328P I2C peripheral is enabled the GPIO hardware is no longer driving the pins. So the moment you enable the hardware I2C (via the DHT20 code) the GPIO bit-banging code in U8G2LIB cannot work correctly.
So, there are at least two ways this can be made to work.

Modifying your code so it works with how the Arduino_SensorKit library is written.

The other is modifying the Arduino_SensorKit library to use hardware I2C, in which case your original code works verbatim.

Modifying the sketch
You can modify your sketch as follows:
#include "Arduino_SensorKit.h"
#define Environment Environment_I2C

void setup() {
  Oled.begin();
  Oled.setFlipMode(true);

  Serial.begin(9600);

  Wire.begin(); // only here to match the subsequent .end()
}

void loop() {
  Wire.end();  // make I2C release control back to GPIO
  {
    Oled.setFont(u8x8_font_chroma48medium8_r);
    Oled.setCursor(0, 3);
    Oled.print(millis()); //Oled.print("Testing");
  }
  Wire.begin(); // re-enable I2C for use by DHT20 ("Environment")

  Serial.print("Temperature = ");
  Serial.print(Environment.readTemperature()); //print temperature
  Serial.println(" C");
  Serial.print("Humidity = ");
  Serial.print(Environment.readHumidity()); //print humidity
  Serial.println(" %");

  delay(2000);
}

For the most part the AVR Wire library doesn't care if you use repeated begin() or repeated end() calls. It may affect your speed setting though. The braces around the Oled usage are just there for visual effect.
Anyway, it works when you make sure Oled can use GPIO.
Modifying Arduino_SensorKit
With the following changes to Arduino_SensorKit library version 1.2.1 (current as of writing) I am able to use your sketch code verbatim. I also modified it to print millis() rather than "Testing" to be sure it was continuing to update the display.
Arduino_SensorKit.h
On line 24 of the libraries Arduino_SensorKit.h file, change:
extern U8X8_SSD1306_128X64_NONAME_SW_I2C Oled;

to
extern U8X8_SSD1306_128X64_NONAME_HW_I2C Oled;

Note HW (hardware) rather than SW (software).
Arduino_SensorKit.cpp
Likewise make the counterpart change to the definition of Oled corresponding to above change in extern declaration of Oled, from:
U8X8_SSD1306_128X64_NONAME_SW_I2C Oled(/* clock=*/ _PIN_SCL, /* data=*/ _PIN_SDA, /* reset=*/ U8X8_PIN_NONE);

to:
U8X8_SSD1306_128X64_NONAME_HW_I2C Oled(/* clock=*/ _PIN_SCL, /* data=*/ _PIN_SDA, /* reset=*/ U8X8_PIN_NONE);

You can probably remove the arguments from the constructor call here; the ATMega328P has no options with respect to configuring TWI/I2C for more than one set of pins.

There's also nothing stopping you from leaving it as U8X8_SSD1306_128X64_NONAME_SW_I2C, but changing the pins so that the software I2C uses pins other than A4/A5 so as not to conflict with the DHT20 libraries use of hardware I2C.

For reference the U8G2LIB version I tested with was 2.33.15. arduino-cli version 0.32.2. arduino:avr core 1.8.7. I don't think you need these. I'm just being complete in case someone finds this 5 years from now or whatever.

Thank you so much! I modified the sketch and it works perfectly now!

I use a variable to store the readings.
#include "Arduino_SensorKit.h"

#define Environment Environment_I2C

void setup() {
  Oled.begin();
  Oled.setFlipMode(true); // Sets the rotation of the screen
  // uncomment line below if using DHT20 (black sensor)
  Wire.begin();
  // uncomment line below if you're connecting your DHT20 to pin a different than 3
  Serial.begin(9600);
  Environment.begin();
}

void loop() {
  Wire.begin();

  // You need variable to keep the reading because Enviroment will not work when LED in operation
  float temp= Environment.readTemperature();
  float hum= Environment.readHumidity();
  Serial.print("Temperature = ");
  Serial.print(temp); //print temperature
  Serial.println(" C");
  Serial.print("Humidity = ");
  Serial.print(hum); //print humidity
  Serial.println(" %");

  delay(2000);

  // int random_value = analogRead(A0);
  Wire.end();

  {
    Oled.setFont(u8x8_font_chroma48medium8_r);
    Oled.setCursor(0, 0);    // Set the Coordinates
    Oled.print("temp: ");
    Oled.print(temp); // Print the Values

    Oled.setCursor(0, 3); // Set the Coordinates
    Oled.print("Humidity: ");
    Oled.print(hum); // Print the Values
    Oled.refreshDisplay(); // Update the Display
  }
}


text:
Alternative to polling interrupt flag from main loop?
I am using an ISR, which is written to be as minimal as possible:
volatile bool interrupt1{};

void ISR1() {
    interrupt1 = true;
}

The interrupt is handled by polling the interrupt1 variable in loop():
if (interrupt1 == true) {

// Do stuff

interrupt1 = false;
}

Even though the interrupt signal coming in on the gpio isn't polled, the method described above is instead polling the interrupt variable from loop().
As an alternative to the above, is it possible to use some kind of push logic on the software side whenever an interrupt occurs, instead of continuously polling the interrupt variable? I hesitate to handle the full task from the ISR, as it's performing a lot of things.
What are my options here?

if (interrupt1 == true)  the true is redundant ... use  if (interrupt1) instead

volatile bool interrupt1{}; - what are the braces for?

@NickGammon This is an empty braced-init-list, I think blindly added or because of source code guidelines.

@Nick Gammon Uniform initialization

@jsotola I know it's redundant, but i prefer the verbosity in this case

Depending on what you need to do, you may reach the limits of what Arduino can do here, and you may be better off using an RTOS and threads (and queues or locks or mutexes to wait until the condition is met). On some platforms Arduino is built on top of an RTOS and there are libraries to expose that. No idea if that applies to the Teensy (though that possibly depends on which model).

If the task is pretty short and time sensitive, your best option is to
put it in the interrupt handler.
If the task is big and not too urgent (like: it could well wait for a
millisecond or so), your approach of polling the flag within loop() is
the best one, provided the main program is non-blocking.
If the task is both big and urgent... you may have a difficult problem.
You could try both approaches and see which one works best. Or you may
try to split the task into a top half (short and urgent) and a bottom
half (long but not so urgent). The interrupt handler would then perform
the top half and set a flag, whereas the main loop would poll the flag
and perform the bottom half.
Edit: for a short discussion on the top half / bottom half approach,
see the first paragraphs of this article on Linux kernel
development.

Thanks for your reply. Last portion is particularly interesting. I might be able to refactor the responsibilities for a better tradeoff between timing and heavy lifting, so to speak...

It can be tricky to think about what part of a task is "urgent". The ISR handler should take care of anything that will go wrong if you wait (like anything that's necessary to prepare the hardware for another event, if it arrives before you've finished with this one.)

Since you tagged it Teensy: You could also reduce the priority of the interrupt, so that it can be interrupted by higher priority interrupts. Thus you can implement interrupts with longer durations without blocking important system functions.
Here is an example using the GPT1 and GPT2 timers running at different priorities:
#include "Arduino.h"
#include "TeensyTimerTool.h"

using namespace TeensyTimerTool;

PeriodicTimer loPrioTimer(GPT1);
PeriodicTimer hiPrioTimer(GPT2);

void onLowPrioTimer() // some long task running from interrupt with low prio
{
    Serial.printf("  Start low prio isr @t=%d ms\n", millis());

    for (int i = 0; i < 10; i++)
    {
        Serial.printf("    lowPriority task %d\n",i);
        delay(10);
    }

    Serial.println("  Stop low prio isr");
}

void onHiPrioTimer() // high prio, will interrupt the low prio isr
{
    Serial.printf("high priority @t=%d ms\n", millis());
}

void setup()
{
    while (!Serial) {}

    loPrioTimer.begin(onLowPrioTimer, 500ms); // GPT1
    hiPrioTimer.begin(onHiPrioTimer, 50ms);   // GPT2

    NVIC_SET_PRIORITY(IRQ_GPT1, 128); // lowest prio
    NVIC_SET_PRIORITY(IRQ_GPT2, 16);  // high prio
}

void loop()
{
}

which prints:
high priority @t=1057 ms
high priority @t=1107 ms
high priority @t=1157 ms
high priority @t=1207 ms
high priority @t=1257 ms
high priority @t=1307 ms
high priority @t=1357 ms
high priority @t=1407 ms
high priority @t=1457 ms
high priority @t=1507 ms
  Start low prio isr @t=1507 ms
    lowPriority task 0
    lowPriority task 1
    lowPriority task 2
    lowPriority task 3
    lowPriority task 4
high priority @t=1557 ms
    lowPriority task 5
    lowPriority task 6
    lowPriority task 7
    lowPriority task 8
    lowPriority task 9
high priority @t=1607 ms
  Stop low prio isr
high priority @t=1657 ms
high priority @t=1707 ms
high priority @t=1757 ms
high priority @t=1807 ms
high priority @t=1857 ms
high priority @t=1907 ms
high priority @t=1957 ms
high priority @t=2007 ms
  Start low prio isr @t=2007 ms
    lowPriority task 0
    lowPriority task 1
    lowPriority task 2
    lowPriority task 3
    lowPriority task 4
high priority @t=2057 ms
    lowPriority task 5
    lowPriority task 6
    lowPriority task 7
    lowPriority task 8
    lowPriority task 9
high priority @t=2107 ms
  Stop low prio isr
high priority @t=2157 ms
high priority @t=2207 ms
high priority @t=2257 ms
high priority @t=2307 ms

This shows that the high priority timer (running at 50 ms interval) intercepts the low priority ISR which runs every 500 ms for about 100 ms.

Thanks for your reply. I've never used interrupt priority. Wanna elaborate?

@Erik  added an example

Very interesting, thank you!

What if an interrupt of the same kind occurs? For example, if it was counting something, wouldn't it miss a count increment (it presumably isn't a reentrant ISR)?

What baud rate was used for 'Serial'?

If an interrupt of the same kind occurs while the first one is serviced it will set the interrupt flag again and the isr will be called again (unless you delete the flag at the end of the ISR). However, this can not handle more than one interrupt request while an isr runs. Here some information about the ARM Nested Interrupt System: https://microcontrollerslab.com/nested-vectored-interrupt-controller-nvic-arm-cortex-m/

Baud rate: there is no such thing as a baud rate for "usb-Serial" aka CDC. The data will always be transmitted with the full USB bandwidth. (Up to some 20MByte/s on a T4x). Also, Serial.begin() is just some compatibility function. It used to be empty. These days it provides some waiting for connection code, I prefere a simple while(!Serial){}


text:
How to properly declare a random URL in ESPAsyncWebServer?
I'm trying to make a onetime URL with a random string to for example give a user onetime access to a house with a smart lock. I have a function to make a fixed 8-character string and the following code with the address that is randomly made.
  controlserver.on(userurl, HTTP_GET, [](AsyncWebServerRequest *request){
   if(urlactive==true){
   if(request->authenticate("admin","admin")){
      running=true;
      request->send(200);

      Serial.println("entered");
      urlactive=false;
      }else {
       return request->requestAuthentication();
      }
   }else{
       generateRandomString();
       request->send(200, "text/html", HTML_CSS_STYLING+ ""
    "

LInk is not valid!
" );

   }
  });

the following function generates the userurl which is a const char* because the requirement of ESPAsyncWebServer library.
void generateRandomString() {
  const char specialChars[] = "0123456789";
  const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  String randomStringurl = "";
  String keppmyuserpass = "";
  randomStringurl += letters[random(26, 51)];
  for (int i = 0; i < 6; i++) {
    randomStringurl += letters[random(0, 51)];
  }
  randomStringurl += specialChars[random(0, 9)];
  Serial.println(randomStringurl);
  userurl = randomStringurl.c_str();

}

everything works fine when I enter the generated string that I convert into const char* using c_str() but I noticed an error when I copied the string partially by accident and too much to my surprise, I saw that the popup for the username and password showed up and I didn't expecte it, because I have a notFound function that will show an error when the entered URL doesn't exist. entered different strings but the problem is persistent. I think there is a problem with my string conversion to const char* using c_str(). but is it?
Here is compliable code, the wifi mode is STA WiFi.mode(WIFI_STA); :
#include <Arduino.h>
#ifdef ESP32
#include <WiFi.h>
#include <AsyncTCP.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#endif
#include <ESPAsyncWebServer.h>

const char* userurl;
String  randomStringurl = "";
String  keppmyuserpass = "";

AsyncWebServer server(80);

const char* ssid = "your_ssid";
const char* password = "your_password";

const char* PARAM_MESSAGE = "message";

void notFound(AsyncWebServerRequest *request) {
    request->send(404, "text/plain", "Not found");
}
void generateRandomString() {
  const char specialChars[] = "0123456789";
  const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  randomStringurl = "";
  keppmyuserpass = "";
  randomStringurl += letters[random(26, 51)];
  for (int i = 0; i < 6; i++) {
    randomStringurl += letters[random(0, 51)];
  }
  randomStringurl += specialChars[random(0, 9)];
  Serial.println(randomStringurl);
  userurl = randomStringurl.c_str();
  keppmyuserpass = randomStringurl;
  keppmyuserpass += letters[random(26, 51)];
  keppmyuserpass += specialChars[random(0, 9)];
  Serial.println(keppmyuserpass);

}
void setup() {

    Serial.begin(115200);
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, password);
    if (WiFi.waitForConnectResult() != WL_CONNECTED) {
        Serial.printf("WiFi Failed!\n");
        return;
    }

    Serial.print("IP Address: ");
    Serial.println(WiFi.localIP());

    server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
        request->send(200, "text/plain", "Hello, world");
    });

    // Send a GET request to <IP>/get?message=<message>
    server.on(userurl, HTTP_GET, [] (AsyncWebServerRequest *request) {
        String message;
        if (request->hasParam(PARAM_MESSAGE)) {
            message = request->getParam(PARAM_MESSAGE)->value();
        } else {
            message = "No message sent";
        }
        request->send(200, "text/plain", "Hello, GET: " + message);
    });

    // Send a POST request to <IP>/post with a form field message set to <message>
    server.on("/post", HTTP_POST, [](AsyncWebServerRequest *request){
        String message;
        if (request->hasParam(PARAM_MESSAGE, true)) {
            message = request->getParam(PARAM_MESSAGE, true)->value();
        } else {
            message = "No message sent";
        }
        request->send(200, "text/plain", "Hello, POST: " + message);
    });

    server.onNotFound(notFound);

    server.begin();
    generateRandomString();
}

void loop() {
}

And here is the code from ESPAsyncWebServer.h library, that required the url to be a  const char* uri what am I doing wrong?
AsyncCallbackWebHandler& on(const char* uri, WebRequestMethodComposite method, ArRequestHandlerFunction onRequest, ArUploadHandlerFunction onUpload, ArBodyHandlerFunction onBody);

New Update: So, I forgot to add a "/" before the URL, by doing so it solved the problem and here is the new function:
void generateRandomString() {
  const char specialChars[] = "0123456789";
  const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  randomStringurl = "";
  keppmyuserpass = "";
  randomStringurl +="/";
  randomStringurl += letters[random(26, 51)];
  for (int i = 0; i < 6; i++) {
    randomStringurl += letters[random(0, 51)];
  }
  randomStringurl += specialChars[random(0, 9)];
  Serial.println(randomStringurl);
  userurl = randomStringurl.c_str();
  keppmyuserpass = randomStringurl;
  keppmyuserpass += letters[random(26, 51)];
  keppmyuserpass += specialChars[random(0, 9)];
  OTUPC = keppmyuserpass.c_str();
  Serial.println(keppmyuserpass);

}

But when I renew the link, the new link is not recognized and the first generated link was working. I think that @6v6gt might be right about this: "Could it also be that the value of userurl must be known when setup() runs and the callback is registered?"

useurl will point to a char array, that is no longer there, as the local String randomStringurl object is created on the stack and destroyed when the function exits. The dynamically created array inside of it will also be deleted. So this will only work as long as that memory portion won't be overwritten (which you cannot know).

Though your problem doesn't really fit that. Please show us a minimal compilable example code that shows the problem, not just some snippets.

@chrisl I made the randomStringurl global String but the problem is still persistanat. I added a compliable code. Isn't the null terminated character at the end of char the problem maker? because normally I define the URL's like "/someurl" not just by passing a const chr* someurl.

const char* userurl; . . . ; userurl = randomStringurl.c_str(); This is not preserving a copy of the String variable's contents. It is simply keeping a copy of a pointer to an area which may vanish (as has been pointed out). You have to create a global (or static) buffer something like char userurl[80] and then use strcpy() to populate it. Could it also be that the value of userurl must be known when setup() runs and the callback is registered?.

@6v6gt how can I know that the value of userurl must be known?

is random() useful here? you should use the CSPRNG of the ESPs, if not for the generation then at least for randomSeed()...

6v6gt is right, that the URI for the handler must be known, when you use the on() function to set the handler. Inside the library, the on() function calls setUri(const String& uri), which which saves the uri in the classes interal String member variable. Thus the handle will not notice, if the originally used variable changes.
I think the most elegant solution here would to be to use a regular expression for your handler URI (A regular expression is a string expression, that describes a template that can match other strings). That will let the handler match any URI, that fits that regex. Inside the handler you can then get the relevant part of the URI and check, if it is currently valid. If yes, you serve your content, otherwise you serve an error (for example a 404 Not Found).
The third answer to this question has a code snippet for this:
#include <uri/UriRegex.h>

web_server.on(UriRegex("/home/([0-9]+)/first"), HTTP_GET, [&]() {
    web_server.send(200, "text/plain", "Hello from first! URL arg: " + web_server.pathArg(0));
});

The part of the URI, that's between the brackets, is the regex group, that is then made available via web_server.pathArg(0). Your current code creates a string with one capital letter, 6 lower case letters and one digit, thus a regex group ([A-Z][a-z]{6}[0-9]). You can read about how regex work online.
When you look at this repo of ESPAsyncWebServer (I'm not sure, which version you have), in the Readme right at the end under "path variable" you find this snippet:
server.on("^\\/sensor\\/([0-9]+)$", HTTP_GET, [] (AsyncWebServerRequest *request) {
  String sensorId = request->pathArg(0);
});

And a note, that regex support must be enabled.
As I didn't test this, I suggest you try both methods and see, what works for you.


text:
Why is my variable giving the wrong value?
I'm making a program to show numbers in a WS2812 LED and TM1637. I'm also using a common 4x4 keypad.
The WS2812 LED is just DIY with 25 x 10. Only two values can be displayed in a LED matrix just now. Without the LED part of the program, just the TM1637 and keypad connected to the Arduino, everything is fine. But adding the LED part of the program, I found out that entering 2 on keypad puts  an erroneous value in my variable (-256 to exact). I tried debugging my code and found out that replacing the last iteration
for (int i = 225; i <= 231; i++) {
with this line
for (int i = 225; i <= 230; i++) {
mysteriously solved my problem. Any thoughts why this is happening?
#include <Keypad.h>
#include <Arduino.h>
#include <TM1637Display.h>
#include <Wire.h>
#include <FastLED.h>
// Module connection pins (Digital Pins)
#define CLK 2
#define DIO 3
#define NUM_LEDS  225
#define LED_PIN   12
CRGB leds[NUM_LEDS];
TM1637Display display(CLK, DIO);
int DisplayNos=0;
int KeyNum;
char key;
boolean NewKey = false;
boolean DeleteAll=false;
int SavedNum;
// for 3 digits
int ExtractDigit[3] = {0, 0, 0};
byte DigitPoint= 1;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {11, 10, 9, 8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad
//Create an object of keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
  Serial.begin(9600);
  FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setBrightness(250);
}
void loop(){
int k;
//  uint8_t data[] = { 0x0, 0x0, 0x0, 0x0 };
//  uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 };
  display.setBrightness(0x0f);
  key = keypad.getKey();// Read the key
  // Print if key pressed
  if (key){
    Serial.print("Key Pressed : ");
    Serial.println(key);
    if (isDigit(key)){
      KeyNum = key-48;
      Serial.println(key);
      Serial.println(DisplayNos);
      if (DigitPoint==1){
        DisplayNos = 0;
        DisplayNos = KeyNum;
      }
      if (DigitPoint==2){
        DisplayNos = KeyNum + (DisplayNos*10);
      }
      if (DigitPoint==3){
        DisplayNos = KeyNum + (DisplayNos*10);
      }
      DigitPoint= DigitPoint+1;
      if (DigitPoint==4){
        DigitPoint=1;
      }
    }
      if (key=='*'){   // asterist key cancels all char
      DisplayNos = 0;
      DigitPoint = 1;
    }
    if (key=='#'){   // asterisk key cancels all chars

    }
    NewKey = true;
  }
  display.showNumberDec(DisplayNos,false,3,0);
  if (NewKey == true){
    DisplayLED();
    FastLED.show();
  }
}
void DisplayLED(){
int LedNum;
byte digitnos;
NewKey = false;
  ExtractDigit[3] = (DisplayNos/100)%10;
  ExtractDigit[2] = (DisplayNos/10)%10;
  ExtractDigit[1] = (DisplayNos)%10;
  for (int digitnos= 1; digitnos <= 3; digitnos++) {
    LedNum = (digitnos-1)*9;
    if (ExtractDigit[digitnos] == 1){
      leds[21-LedNum]= CRGB::Blue;
      leds[28+LedNum]= CRGB::Blue;
      leds[29+LedNum]= CRGB::Blue;
      leds[71-LedNum]= CRGB::Blue;
      leds[78+LedNum]= CRGB::Blue;
      leds[121-LedNum]= CRGB::Blue;
      leds[128+LedNum]= CRGB::Blue;
      leds[171-LedNum]= CRGB::Blue;
      leds[178+LedNum]= CRGB::Blue;
      leds[221-LedNum]= CRGB::Blue;
      leds[229+LedNum]= CRGB::Blue;
      leds[228+LedNum]= CRGB::Blue;
      leds[227+LedNum]= CRGB::Blue;
    }
    if (ExtractDigit[digitnos] == 2){
      for (int i = 20; i <= 22; i++) {
        leds[i-LedNum] = CRGB::Blue;
      }
      leds[26+LedNum]= CRGB::Blue;
      leds[30+LedNum]= CRGB::Blue;
      leds[68-LedNum]= CRGB::Blue;
      leds[74-LedNum]= CRGB::Blue;
      leds[76+LedNum]= CRGB::Blue;
      leds[122-LedNum]= CRGB::Blue;
      leds[128+LedNum]= CRGB::Blue;
      leds[170-LedNum]= CRGB::Blue;
      leds[180+LedNum]= CRGB::Blue;
      leds[218-LedNum]= CRGB::Blue;
      leds[225+LedNum]= CRGB::Blue;
      leds[226+LedNum]= CRGB::Blue;
      leds[227+LedNum]= CRGB::Blue;
      leds[228+LedNum]= CRGB::Blue;
      leds[229+LedNum]= CRGB::Blue;
      for (int i = 225; i <= 231; i++) {
        leds[i-LedNum] = CRGB::Blue;
      }
    }
  }
  }

#define NUM_LEDS  225
...
CRGB leds[NUM_LEDS];
...
  leds[225 + LedNum] = CRGB::Blue;
  leds[226 + LedNum] = CRGB::Blue;
  leds[227 + LedNum] = CRGB::Blue;
  leds[228 + LedNum] = CRGB::Blue;
  leds[229 + LedNum] = CRGB::Blue;

Your RGB matrix has 225 LEDs, but you're writing to RAM out of range and destroying their stored data and/or variables.

many thanks never think of that i will try to replace the value now...

better rewrite complete digit creation, as an independent function or use neomatrix lib

just curious Mykolaha99, what is wrong with my question, looks like somebody downvoted it..is it not related to this stack exchange? Sorry, i'm new to this and just want to improve next time my questions..

@LesterTherr Just ignore them. There are some people here who just go around downvoting questions. I've had my stuff downvoted, and I am a moderator. Someone liked your question enough to answer it, and that is what counts. :)

@NickGammon, thanks for the explanation.


text:
Some of my <include> statements do not work
I'm trying to include the thing...
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>

BLEServer* pServer = NULL;

void setup() {
  // put your setup code here, to run once:

}

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

}

But it simply doesn't see what's inside the .h files:
C:\Users\void\AppData\Local\Temp\.arduinoIDE-unsaved20231028-7016-1na7gr9.y1do\sketch_nov28b\sketch_nov28b.ino:6:1: error: 'BLEServer' does not name a type; did you mean 'Server'?
 BLEServer* pServer = NULL;                        // Pointer to the server
 ^~~~~~~~~
 Server

May it be, I bought the wrong board? I've set it as lolin s2 mini.

The thing.....?

Yes, the thing!

Many of the ESP32 variants have Bluetooth/BLE support. The ESP32-S2 board/module you're trying to use does not. The module has WiFi, but not Bluetooth.

So you need another board, Lolin seems to have an -S3 version of your board. But many other boards would work.
The majority of the <BLEServer.h> header's contents are conditionally compiled based on whether or not CONFIG_BLUEDROID_ENABLED is #defined.
And this only done for modules that have support for Bluetooth. The Lolin S3 version of the Mini would have Bluetooth support and in the configuration file it would use you can see it defined. In the one for the S2 board you are trying to use it is missing.
In effect, although you're including the header, it is as though it were blank. So no definition of the BLEServer type. It would have been nice if they'd handled this a different way, but this is not uncommon.

They told me it supports BLE... Thank you anyway.

LOL. I understand the frustration. I wouldn't put it quite that way though. That same group of people also makes the datasheets. While their technical documentation is something I've railed about before, there's no mention of Bluetooth/BLE in the ESP32S2 datasheet. I'd be surprised if Expressif would tell you they support BLE support. Ebay/alibaba/amazon-markplace/dx/etc/etc, not so much.


text:
ESP32 SPI Mutual Communication
I have two ESP32 cards. I want to set one of these cards as Master and the other as Slave and communicate via SPI. I have done this before on Arduino Uno, but I cannot do this on ESP32.
Below are my Master and Slave codes that I have prepared simply. I can't get what I want in any way. Can anyone help?
Master Code:
#include <SPI.h>

#define CS_PIN 5  // Choose the appropriate pin for Chip Select (CS)

void setup() {
  Serial.begin(115200);
  SPI.begin();
}

void loop() {
  char dataToSend = 'A';

  digitalWrite(CS_PIN, LOW); // Start communication with the slave
  SPI.transfer(dataToSend); // Send data to the slave
  digitalWrite(CS_PIN, HIGH); // End communication with the slave

  delay(2000); // Delay for demonstration purposes
}

Slave Code:
#include <SPI.h>

#define CS_PIN 5  // Choose the appropriate pin for Chip Select (CS)

void setup() {
  Serial.begin(115200);
  SPI.begin();
}

void loop() {
  if (digitalRead(CS_PIN) == LOW) {  // Check if CS (Chip Select) is LOW, meaning the device is selected
    char receivedData = SPI.transfer(0); // Read received data from the master

    // Display received data on the serial monitor
    Serial.println("Received Data: " + String(receivedData));

    delay(1000);  // Optional delay for demonstration purposes
  }
}

New Code - New Problem:
I tried to adapt the codes at https://microcontrollerslab.com/esp32-spi-communication-tutorial-arduino/. From what I understand it uses the following pins for SPI: MISO-12; MOSI-13; SCLK-14; SS-15.
I set my connections the same way, but I cannot get the output I expected from the Slave. It remains waiting at the slave.wait line.
Master Code:
#include <SPI.h>

// Define ALTERNATE_PINS to use non-standard GPIO pins for SPI bus

  #define HSPI_MISO   MISO
  #define HSPI_MOSI   MOSI
  #define HSPI_SCLK   SCK
  #define HSPI_SS     SS

static const int spiClk = 1000000; // 1 MHz

//uninitalised pointers to SPI objects
SPIClass * hspi = NULL;

void setup() {
  //initialise instance of the SPIClass attached to HSPI
  hspi = new SPIClass(HSPI);

  //initialise hspi with default pins
  //SCLK = 14, MISO = 12, MOSI = 13, SS = 15
  hspi->begin();

  pinMode(HSPI_SS, OUTPUT); //HSPI SS
}

// the loop function runs over and over again until power down or reset
void loop() {
  hspi_send_command();
  delay(100);
}

void hspi_send_command() {
  byte data_on = 0b00000001; // data 1 to turn on LED of slave
  byte data_off = 0b0000000; // data 0 to turn off LED of slave

  hspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
  digitalWrite(HSPI_SS, LOW);
  hspi->transfer(data_on);
  digitalWrite(HSPI_SS, HIGH);
  hspi->endTransaction();

  delay(1000);

  hspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
  digitalWrite(HSPI_SS, LOW);
  hspi->transfer(data_off);
  digitalWrite(HSPI_SS, HIGH);
  hspi->endTransaction();
  delay(1000);

}
*/

Slave Code:
#include <ESP32SPISlave.h>

ESP32SPISlave slave;

static constexpr uint32_t BUFFER_SIZE {32};
uint8_t spi_slave_tx_buf[BUFFER_SIZE];
uint8_t spi_slave_rx_buf[BUFFER_SIZE];

#define LED 2

void setup() {
    Serial.begin(115200);
    delay(2000);
    pinMode(LED, OUTPUT);
    // begin() after setting
    // HSPI = CS: 15, CLK: 14, MOSI: 13, MISO: 12 -> default
    // VSPI = CS:  5, CLK: 18, MOSI: 23, MISO: 190
    slave.setDataMode(SPI_MODE0);
    slave.begin();
    // slave.begin(VSPI);   // you can use VSPI like this

    // clear buffers
    memset(spi_slave_tx_buf, 0, BUFFER_SIZE);
    memset(spi_slave_rx_buf, 0, BUFFER_SIZE);
}

void loop() {
    // block until the transaction comes from master
    Serial.println("Initialize...");

    slave.wait(spi_slave_rx_buf, spi_slave_tx_buf, BUFFER_SIZE);

    Serial.println("*********************");

    // if transaction has completed from master,
    // available() returns size of results of transaction,
    // and buffer is automatically updated
    char data;
    while (slave.available()) {
        // show received data
         Serial.print("Command Received: ");
         Serial.println(spi_slave_rx_buf[0]);
         data = spi_slave_rx_buf[0];
         slave.pop();
    }
    if(data == 1 )
    {
        Serial.println("Setting LED active HIGH ");
        digitalWrite(LED, HIGH);
    }
    else if(data == 0 )
    {
        Serial.println("Setting LED active LOW ");
        digitalWrite(LED, LOW);
    }
}

For ESP32, unless the exact board variant is specified, by default the macros for MISO, MOSI, SCK and SS are defined as follows and are used for VSPI(i.e. SPI0):
static const uint8_t SS    = 5;
static const uint8_t MOSI  = 23;
static const uint8_t MISO  = 19;
static const uint8_t SCK   = 18;

This can be seen in the source code and HSPI is automatically configured to use SCLK 14, MISO 12, MOSI 13 and SS 15 when SPI.begin() is called, see this part of the source code.
Since you defined HSPI_SS as #define HSPI_SS SS, when you do pinMode(HSPI_SS, OUTPUT);, you are actually setting pin 5 as output, not the pin 15 that you thought it was.
There are two ways to properly set up the HSPI port.

What you can do is to define the macros as follows and call hspi->begin(); by passing your configuration:

#define HSPI_MISO   12
#define HSPI_MOSI   13
#define HSPI_SCLK   14
#define HSPI_SS     15

void setup() {
  hspi = new SPIClass(HSPI);
  hspi->begin(HSPI_SCK, HSPI_MISO, HSPI_MOSI, HSPI_SS);
  // rest of your setup code
}

As you can see from the source code shown in the above link, if you don't explicitly pass the pins as parameters when calling SPI.begin(), the library will automatically assign the pins based on whether VSPI is used (SCLK 18, MISO 19, MOSI 23, SS 5), or HSPI is used (SCLK 14, MISO 12, MOSI 13 and SS 15). So all you need to define is your HSPI_SS pin:

#define HSPI_SS     15

void setup() {
  hspi = new SPIClass(HSPI);
  hspi->begin();
  // rest of your setup code
}

Thank you so much. I managed to send a string expression. Below you can see the Slave-Master codes that send messages from Master to Slave using the "Hello From Master" string.

You can see the Slave-Master codes that send messages from Master to Slave using the "Hello From Master" string.
Master Code:
#include <SPI.h>

#ifdef ALTERNATE_PINS
  #define VSPI_MISO   19
  #define VSPI_MOSI   23
  #define VSPI_SCLK   18
  #define VSPI_SS     5
#else
  #define VSPI_MISO   MISO
  #define VSPI_MOSI   MOSI
  #define VSPI_SCLK   SCK
  #define VSPI_SS     SS
#endif

static const int spiClk = 1000000; // 1 MHz

char input;

const int size_arr = 25;
char buf[size_arr];
String sendData = "Hello from Master";

//uninitalised pointers to SPI objects
SPIClass* vspi = NULL;

void setup() {
    Serial.begin(115200);

    vspi = new SPIClass(VSPI);

#ifndef ALTERNATE_PINS
    vspi->begin();
#else
    vspi->begin(VSPI_SCLK, VSPI_MISO, VSPI_MOSI, VSPI_SS);
#endif

    pinMode(VSPI_SS, OUTPUT); //HSPI SS

    vspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
}

void loop() {
    input = Serial.read();

    if(input == 's'){
      sendData.toCharArray(buf, size_arr);
      spi_transmis(VSPI_SS, buf);
    }
    delay(50);
}

void send_spi(int selectPin, byte pram) {
    digitalWrite(selectPin, LOW);
    vspi->transfer(pram);
    digitalWrite(selectPin, HIGH);
    vspi->endTransaction();
    delayMicroseconds(75);
}

void spi_transmis(int selectPin, char buf[]) {
  for (int i = 0; i < size_arr; i++) {
    send_spi(selectPin, buf[i]);
  }
  send_spi(selectPin, '\n');
}

Slave Code:
#include <ESP32SPISlave.h>

ESP32SPISlave slave;

static constexpr uint32_t BUFFER_SIZE { 1 };
uint8_t spi_slave_tx_buf[BUFFER_SIZE];
uint8_t spi_slave_rx_buf[BUFFER_SIZE];

const int size_arr = 151;
char buf[size_arr];

volatile int pos = 0;
volatile bool active;
volatile bool process;

String received;

void setup() {
    Serial.begin(115200);
    slave.setDataMode(SPI_MODE0);
    slave.begin(VSPI);

    memset(spi_slave_tx_buf, 0, BUFFER_SIZE);
    memset(spi_slave_rx_buf, 0, BUFFER_SIZE);
}

void loop() {
    recvHandle();
    spiHandler();
}

void spiHandler() {
  slave.wait(spi_slave_rx_buf, spi_slave_tx_buf, BUFFER_SIZE);

  while (slave.available()) {
      char c = spi_slave_rx_buf[0];
      if (c == '\n') {
        buf[pos] = '\0';
        process = true;
      } else {
        buf[pos++] = c;
      }
      slave.pop();
  }
}

void recvHandle() {
  if (process) {
    received = String(buf);
    process = false;
    pos = 0;
    Serial.println(received);
    delayMicroseconds(20);
  }
}


text:
L298n driver with Arduino with 2 motors won't work
I connected the 12v power supply with 9v battery. The problem is that when i run 1 motor at time from any side (out 1, 2 out 3, 4) it works perfectly, but when I try to run both of them, only one will run and the other won't. They work if I run one motor at a time.
Is this a problem with not enough power? The motors are DC gear motors. This is the code:
int in1 = 12;
int in2 = 13;
int in3 = 8;
int in4 = 9;
int en1 = 11;
int en2 = 10;
void setup() {
   pinMode(in3, OUTPUT);
   pinMode(in4, OUTPUT);
   pinMode(en1, OUTPUT);
   pinMode(in1, OUTPUT);
   pinMode(in2, OUTPUT);
   pinMode(en2, OUTPUT);
}

void loop() {
   analogWrite(en1, 255);
   digitalWrite(in1, LOW);
   digitalWrite(in2, HIGH);
   analogWrite(en2, 255);
   digitalWrite(in3, LOW);
   digitalWrite(in4, HIGH);
}

Yes, most likely. Motors can draw a lot of power and your 9v battery is probably struggling to output enough voltage. 50-100 mA is about the max current you want to draw from a 9v. 9v batteries have a high internal resistance and the voltage will drop potentially well below 9v when you draw a lot of current from them. Used to make Altoids tin USB chargers back in the day with a 9v but cellphones now need multiple Amps of power and so do motors.
Here's a couple things you can do to check:
Set up your code to run both motors. Connect a motor to one side and see if it works. Then connect it to the other side (without changing the program or other wiring.) If that motor runs on both sides, check the other motor. This will make sure both motors are good and that both channels on the driver are good. Check the voltage on the battery and the motor and write down the values each time.
If the current you measure with a single motor is much higher than 25-50 mA, 2 motors will exceed the limit. Note the motor (label them) and the channel it is connected to.
If that seems to check out, connect both motors. We know they don't both spin, but take this time and measure battery voltage and motor voltage. Measure the current if possible too. If you are getting greater than 50-100mA from the battery, you are likely going to have issues.


text:
How can I connect my ESP32-WROOM-32 to Arduino IDE?
I'm using this 'ESP32-WROOM-32' but I can't find the correct board in the IDE. I see the esp32-wroom-DA (edit, i took it to the store where i bought it and it worked fine with theirs. they were on windows and im on mac. also they told me to use 'DOIT esp32 devkit' but im getting the same errors) but when I use that with this board it gives errors while compiling.

Arduino: 1.8.18 (Mac OS X), Board: "ESP32-WROOM-DA Module, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, Core 1, Core 1, None, Disabled"
[2074] Error loading Python lib '/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/_MEIDMFx0d/libpython3.8.dylib': dlopen: dlopen(/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/_MEIDMFx0d/libpython3.8.dylib, 10): Library not loaded: @loader_path/libintl.8.dylib
Referenced from: /var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/_MEIDMFx0d/libpython3.8.dylib
Reason: no suitable image found. Did find:    >/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/_MEIDMFx0d/libintl.8.dylib: cannot load 'libintl.8.dylib' (load command 0x80000034 is unknown)
/private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/_MEIDMFx0d/libintl.8.dylib: cannot load 'libintl.8.dylib' (load command 0x80000034 is unknown)
exit status 255
/private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/arduino-builder returned 255
Error compiling for board ESP32-WROOM-DA Module.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

And when I enabled show verbose output:

Arduino: 1.8.18 (Mac OS X), Board: "ESP32-WROOM-DA Module, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, Core 1, Core 1, None, Disabled"
/private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/hardware -hardware /Users/drayeshahakim/Library/Arduino15/packages -tools /private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/tools-builder -tools /private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/drayeshahakim/Library/Arduino15/packages -built-in-libraries /private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/libraries -libraries /Users/drayeshahakim/Documents/Arduino/libraries -fqbn=esp32:esp32:esp32da:PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,LoopCore=1,EventsCore=1,DebugLevel=none,EraseFlash=none -vid-pid=0000_0000 -ide-version=10818 -build-path /var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/arduino_build_386453 -warnings=none -build-cache /var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/arduino_cache_107457 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.esptool_py.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/esptool_py/4.5.1 -prefs=runtime.tools.esptool_py-4.5.1.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/esptool_py/4.5.1 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.mklittlefs.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933 -prefs=runtime.tools.mklittlefs-3.0.0-gnu12-dc7f933.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.riscv32-esp-elf-gcc.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.riscv32-esp-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.dfu-util.path=/Users/drayeshahakim/Library/Arduino15/packages/arduino/tools/dfu-util/0.11.0-arduino5 -prefs=runtime.tools.dfu-util-0.11.0-arduino5.path=/Users/drayeshahakim/Library/Arduino15/packages/arduino/tools/dfu-util/0.11.0-arduino5 -prefs=runtime.tools.riscv32-esp-elf-gdb.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.riscv32-esp-elf-gdb-11.2_20220823.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.openocd-esp32.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/openocd-esp32/v0.11.0-esp32-20221026 -prefs=runtime.tools.openocd-esp32-v0.11.0-esp32-20221026.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/openocd-esp32/v0.11.0-esp32-20221026 -prefs=runtime.tools.xtensa-esp-elf-gdb.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.xtensa-esp-elf-gdb-11.2_20220823.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.mkspiffs.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/mkspiffs/0.2.3 -prefs=runtime.tools.mkspiffs-0.2.3.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/mkspiffs/0.2.3 -verbose /private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/examples/01.Basics/Blink/Blink.ino
/private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/hardware -hardware /Users/drayeshahakim/Library/Arduino15/packages -tools /private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/tools-builder -tools /private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/drayeshahakim/Library/Arduino15/packages -built-in-libraries /private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/libraries -libraries /Users/drayeshahakim/Documents/Arduino/libraries -fqbn=esp32:esp32:esp32da:PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,LoopCore=1,EventsCore=1,DebugLevel=none,EraseFlash=none -vid-pid=0000_0000 -ide-version=10818 -build-path /var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/arduino_build_386453 -warnings=none -build-cache /var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/arduino_cache_107457 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.esptool_py.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/esptool_py/4.5.1 -prefs=runtime.tools.esptool_py-4.5.1.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/esptool_py/4.5.1 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.mklittlefs.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933 -prefs=runtime.tools.mklittlefs-3.0.0-gnu12-dc7f933.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.riscv32-esp-elf-gcc.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.riscv32-esp-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.dfu-util.path=/Users/drayeshahakim/Library/Arduino15/packages/arduino/tools/dfu-util/0.11.0-arduino5 -prefs=runtime.tools.dfu-util-0.11.0-arduino5.path=/Users/drayeshahakim/Library/Arduino15/packages/arduino/tools/dfu-util/0.11.0-arduino5 -prefs=runtime.tools.riscv32-esp-elf-gdb.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.riscv32-esp-elf-gdb-11.2_20220823.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.openocd-esp32.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/openocd-esp32/v0.11.0-esp32-20221026 -prefs=runtime.tools.openocd-esp32-v0.11.0-esp32-20221026.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/openocd-esp32/v0.11.0-esp32-20221026 -prefs=runtime.tools.xtensa-esp-elf-gdb.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.xtensa-esp-elf-gdb-11.2_20220823.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/xtensa-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.mkspiffs.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/mkspiffs/0.2.3 -prefs=runtime.tools.mkspiffs-0.2.3.path=/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/mkspiffs/0.2.3 -verbose /private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/examples/01.Basics/Blink/Blink.ino
Using board 'esp32da' from platform in folder: /Users/drayeshahakim/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11
Using core 'esp32' from platform in folder: /Users/drayeshahakim/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11
bash -c "[ ! -f "/private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/examples/01.Basics/Blink"/partitions.csv ] || cp -f "/private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/examples/01.Basics/Blink"/partitions.csv "/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/arduino_build_386453"/partitions.csv"
bash -c "[ -f "/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/arduino_build_386453"/partitions.csv ] || [ ! -f "/Users/drayeshahakim/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/variants/esp32da"/partitions.csv ] || cp "/Users/drayeshahakim/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/variants/esp32da"/partitions.csv "/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/arduino_build_386453"/partitions.csv"
bash -c "[ -f "/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/arduino_build_386453"/partitions.csv ] || cp "/Users/drayeshahakim/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11"/tools/partitions/default.csv "/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/arduino_build_386453"/partitions.csv"
bash -c "[ -f "/private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/examples/01.Basics/Blink"/bootloader.bin ] && cp -f "/private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/examples/01.Basics/Blink"/bootloader.bin "/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/arduino_build_386453"/Blink.ino.bootloader.bin || ( [ -f "/Users/drayeshahakim/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/variants/esp32da"/bootloader.bin ] && cp "/Users/drayeshahakim/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/variants/esp32da"/bootloader.bin "/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/arduino_build_386453"/Blink.ino.bootloader.bin || "/Users/drayeshahakim/Library/Arduino15/packages/esp32/tools/esptool_py/4.5.1"/esptool --chip esp32 elf2image --flash_mode dio --flash_freq 80m --flash_size 4MB -o "/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/arduino_build_386453"/Blink.ino.bootloader.bin "/Users/drayeshahakim/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/tools/sdk/esp32"/bin/bootloader_qio_80m.elf )"
[2164] Error loading Python lib '/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/_MEIXurqHc/libpython3.8.dylib': dlopen: dlopen(/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/_MEIXurqHc/libpython3.8.dylib, 10): Library not loaded: @loader_path/libintl.8.dylib
Referenced from: /var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/_MEIXurqHc/libpython3.8.dylib
Reason: no suitable image found.  Did find:
/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/_MEIXurqHc/libintl.8.dylib: cannot load 'libintl.8.dylib' (load command 0x80000034 is unknown)
/private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/_MEIXurqHc/libintl.8.dylib: cannot load 'libintl.8.dylib' (load command 0x80000034 is unknown)
exit status 255
/private/var/folders/sz/zm5vw9m92t9_07j6scr85q400000gn/T/AppTranslocation/F61C5E6A-0B57-4967-97C2-77C38540CF2B/d/Arduino.app/Contents/Java/arduino-builder returned 255
Error compiling for board ESP32-WROOM-DA Module.

also im using macos 10.13.6, the store i got it from (and it worked fine for them) was on windows

what errors? ... please copy all of the error message and paste it into your question ... do not paste a picture ... do not paste into a comment

What program are you compiling? The blink sketch or one with some special (possibly unsupported) libraries? When you "verify" (compile and link) a program in the Arduino IDE the real hardware does not even need to be connected so there is no possibility for the system to identify a mismatch between the board you select in the IDE and the real board you have in your hand. Only when you attempt to upload the (compiled) program can some rudimentary checks be performed. If the verify fails with the "blink" sketch, suspect an IDE installation problem otherwise suspect your code.

6v6gt I get the same error for any code i try to run, even the blink sketch.


text:
First Uses of Digispark can't get past upload error
Windows 7 (64Bit) Parallels VM on Macbook Pro running BigSur. Arduino version 1.18.19, Digispark ATtiny85 Micro USB.
Loaded Boards Manager http://digistump.com/package_digistump_index.json and updated all.
Installed Windows Driver DPinst64 from digistump.
Device Manager shows:

libusb-win32 USB Devices
Digispark Bootloader

This a first-time use of Digispark.
I have written a couple of successful programs for the ESP32 devkit v1.
Test Program

    void setup() {
      // initialize the digital pin as an output.
      pinMode(0, OUTPUT); //LED on Model B
      pinMode(1, OUTPUT); //LED on Model A
    }

    // the loop routine runs over and over again forever:
    void loop() {
      digitalWrite(0, HIGH); // turn the LED on (HIGH is the voltage level)
      digitalWrite(1, HIGH);
      delay(5000); // wait for a second
      digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
      digitalWrite(1, LOW);
      delay(5000); // wait for a second
    }

Compiles OK. Upload immediately goes to the following error: (with the Digispark not plugged in).

Running Digispark Uploader...
Plug in device now... (will timeout in 60 seconds)
Assertion failed: res >= 4, file library/micronucleus_lib.c, line 100

I can find no relevant information on the error, I need help.

Welcome to SE/Arduino! Please take the [tour] to learn how this site works. You might want to read some of the pages of the [help], too, while you wait for an answer. -- Granted, my experiences with Digisparks on Windows 10 and Linux are limited. But this error, especially since it appears immediately, points to a problem between the VM and one of the drivers, not the Digispark. Did you consider to use native drivers? -- Please [edit] your question to add new information, this is not a forum.

The device is only in bootload mode for a brief moment after power-up, therefore you have to unplug the device before hitting upload, and only connect it once it tells you to. This way the programmer can hit the bootloader in time to halt normal bootup, before execution is handed off to your code.
Literally stumbled over the same issue today, dunno why it won't just tell you this in the console right away.

This "brief" moment is about 5 seconds long, IIRC. ;-)

However, since the OP did not connect the Digispark at all, this does not answer the question. The posted error appeared immediately.


text:
Unable to get keypad key in while loop
I'm a beginner into Arduino so I have a little problem where I'm trying to do a countdown on LCD using while loop but I'm also trying to get a key input inside that same while loop. Problem is that its hard to get a input in that while because there are delay because of timer. Tried to look around the internet for solution but didn't find one. If anybody got a good solution I would be great full if you post it :) Thanks again!
Here is my code:
while (gameInProgress) {

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Until boom! ");
    lcd.print(timer);
    lcd.setCursor(0, 1);
    lcd.print(passwordInputed);

    char key = keypad.getKey();
    if (key && gameInProgress) {
      passwordInputed += key;
    }

    analogWrite(buzzerPin, 145);
    delay(200);
    analogWrite(buzzerPin, 0);
    delay(800);
    timer--;
    if (timer == 0){
      gameInProgress = false;
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Boom happend!");
      lcd.setCursor(0, 1);
      lcd.print("You lost :(");
    }
  }

Write non blocking code: https://docs.arduino.cc/built-in-examples/digital/BlinkWithoutDelay

Go learn the Blink Without Delay style of timing.  If you want to have an easier time of it, put this code aside for a bit until you really understand what's going on with that style of timing.  Then come back and add it here.  If you try to just copy that code without understanding how it works then you're going to have a bad time.

Why did you mark it solved? What is the solution? This isn't a forum, solutions (aka answers) are posted below.

I’m voting to close this question because [SOLVED] is not an answer.

I removed [SOLVED] from the subject line - it doesn't make any sense.

Tried to look around the internet for solution but didn't find one - You didn't stumble across a post I wrote about this exact thing?

In general, when a program needs to perform two or more functions (for example, counting off seconds and reacting to a button press that could happen at any moment) a state machine programming pattern will provide an optimal solution.
Essentially, remove all calls to delay(). Instead, record the value returned from millis() outside the loop. If tracking a, say, 1 second (1000ms) interval, add 1000 to the recorded value. Each time through the loop, check if mills() is greater then the recorded value.  When it is, change the state, add 1000 to the recorded value again and do what ever is needed when the state indicating 1 second has elapsed has changed.  Now clear the state and wait for the cycle to repeat.
As this loop with out calls to delay() is being executed as fast as possible, a scan for a button press can be added and the necessary reaction to that button press can be very responsive.
Add states as needed for more complex behavior. Remember, in most state machines, outputs normally happen upon state changes. And there are no delays within the loop.  Tests to trigger state changes are run as fast as possible each time through the loop.