text:
How to configure watchdog for the arduino Nano 33 BLE Sense board?
For the arduino Nano 33 BLE Sense board, the standard avr/wdt.h is not available. And it seems that no standard library provides it. How to use the watchdog system for this board ? I found no full information about it.
I've found the page https://www.mysensors.org/apidocs/group__avr__watchdog.html which allow to configure the reboot mode. And it works. But no way to configure the interruption mode with ISR() function. Moreover, there's no explanation about the manipulation of used register/variables for any fine configuration.
Simple code example with regular asynchronous stuff using the watchdog ISR() mechanism. It which works well with ATmega328 (e.g.UNO). But I do not find equivalent configuration for the Nano 33 BLE using the nRF52840.
# include <avr/wdt.h>

volatile byte led;
int k;

ISR(WDT_vect) {
  Serial.println("Asynchronous stuff in ISR() function");
  digitalWrite(LED_BUILTIN,led);
  led=!led;
}

void setup() {
  pinMode(LED_BUILTIN,OUTPUT);
  led=0;

  Serial.begin(9600);
  while(!Serial) {}
  Serial.println("== R E B O O T ==");

  WDTCSR = ( 1 << WDE ) | ( 1 << WDCE );
  WDTCSR = ( 1 << WDP2 ) | ( 1 << WDP0 ) | ( 1 << WDIE ) ; // Interruption and timeout  1/2 s
}

void loop() {
  Serial.print("Loop #");
  Serial.println(k);
  if (k++%2) {
    Serial.println("Some stuff (even branch)");
    delay(1200);
  }
  else {
    Serial.println("Some stuff (odd branch)");
    delay(4800);
  }
}

Thks.

A little searching gave this link and that code seems to have worked: https://devzone.nordicsemi.com/f/nordic-q-a/53904/nrf52840-watchdog-for-arduino-nano-33-ble-sense

Yes but your link provides the same information as I pointed out. It's only about the set of watchdog with simple reboot, not the set of ISR() mechanism at the end of the counting of the watchdog timer.

I've just added in a simple code example, working with a uno. Looking for equivalent code for the nano BLE.

You did see they used other defines than you? NRF_WDT->CONFIG = 0x01; and so on. I don't see that in your code. Your code in setup directly writes to MCU registers that do not exist on the nano 33 BLE. To configure it, you must take over those parts. If and how the watchdog interrupt can be intercepted on the nRF processor is another question. Typically the watchdog interrupt just does reset - normally it is intended not to happen within your firmware. If your idea is to time the execution of some code you might use a timer interrupt for this - not the watchdog.

In fact, for the RF52940, I'm not sure that the watchdog can provide the needed interruption mechanism despite it exists the INTENSET bit for interruption according to the chipset doc https://content.arduino.cc/assets/Nano_BLE_MCU-nRF52840_PS_v1.1.pdf). But the good way is for sure the use of timers (and one can use more than just one, quite good).
For a similar behaviour as the code given for the UNO before, here is the code one can write for the Nano BLE using a timer interrupt (see https://github.com/khoih-prog/NRF52_MBED_TimerInterrupt for full and usefull doc).
#include "NRF52_MBED_TimerInterrupt.h"

volatile byte led;
volatile uint32_t count=0;
NRF52_MBED_Timer myTimer(NRF_TIMER_1);
unsigned k=0;

void myHandler() {
  digitalWrite(LED_BUILTIN,led);
  led=!led;
  count++;
}

void setup() {
  pinMode(LED_BUILTIN,OUTPUT);
  led=0;

  Serial.begin(9600);
  while(!Serial) {}
  Serial.println("== R E B O O T ==");

  if (myTimer.attachInterruptInterval(500*1000, myHandler)) // each 1/2 second
    Serial.println("myTimer launched");
  else
    Serial.println("Can not set the timer");
}

void loop() {
  Serial.print("Loop #");
  Serial.print(k);
  Serial.print(" and nb times in Handler : ");
  Serial.println(count);
  if (k++%2) {
    Serial.println("Some stuff (even branch)");
    delay(1200);
  }
  else {
    Serial.println("Some stuff (odd branch)");
    delay(4800);
  }
}

Re: "I'm not sure that the watchdog can provide the needed interruption mechanism despite it exists the INTENSET bit for interruption according to the chipset doc"  To clarify: once the NRF52 watchdog ISR has fired you are on a one-way trip to a RESET in little more than about 60uS. It may not do what the OP needs. So if that's what you meant, yup, it's limited compared to what the AVR counterpart lets you do. For anyone that only needs 60uS before the impending reset, INTENSET usage should meet their requirements.

You do not want to update your watchdog in an ISR. It is possible to get stuck but the ISR is continually triggered. I have seen this happen many times especially when a bad transient hits it. I normally use an external one so it will force a reset on the whole package. I do this by power cycling everything. Not all watchdog timers in processors will do an external reset.

I gave above an example working with UNO and I would like equivalent with the nano ble.

It works fine with UNO, Nano, and many others. I am not have a ble to try it.


text:
Converting more strings from serial monitor to int arrays
I want to transfer 8 lists from a python script, via Serial Monitor to the Arduino. I can get the strings to Arduino and Arduino saves them as String array, but I can't change it to integer (it shows as 0.00 - I then convert it to float, because I need to divide it by 10 to get back real numbers)
I changed the lat and long in the api link because of privacy. Change it to an actual value (example latitude=42.234, longitude=20.000).
Python code:
import requests
from datetime import datetime
import serial
import numpy as np
import time

url = "https://api.open-meteo.com/v1/forecast?latitude=xx.xxx&longitude=yy.yyy&hourly=temperature_2m&hourly=windspeed_10m&hourly=windspeed_80m&hourly=windspeed_120m&hourly=windspeed_180m&hourly=winddirection_10m&hourly=winddirection_80m&hourly=winddirection_120m&hourly=winddirection_180m"
now = datetime.now()

stavek_veter = "Vetrne karakteristike"

ser = serial.Serial("COM3", 115200)

tr_cas = int(now.strftime("%H"))-1

response = requests.get(url).json()
vremenski_podatki = response["hourly"]

temp2m = vremenski_podatki["temperature_2m"]
cas = vremenski_podatki["time"]

paket = str(ser.readline())

hitr_vetra_10m = vremenski_podatki["windspeed_10m"]
hitr_vetra_80m = vremenski_podatki["windspeed_80m"]
hitr_vetra_120m = vremenski_podatki["windspeed_120m"]
hitr_vetra_180m = vremenski_podatki["windspeed_180m"]
smer_vetra_10m = vremenski_podatki["winddirection_10m"]
smer_vetra_80m = vremenski_podatki["winddirection_80m"]
smer_vetra_120m = vremenski_podatki["winddirection_120m"]
smer_vetra_180m = vremenski_podatki["winddirection_180m"]

hitr_vetra_10m_zmn = list(np.array(hitr_vetra_10m)*10)
hitr_vetra_80m_zmn = list(np.array(hitr_vetra_80m)*10)
hitr_vetra_120m_zmn = list(np.array(hitr_vetra_120m)*10)
hitr_vetra_180m_zmn = list(np.array(hitr_vetra_180m)*10)

hitr_vetra_10m_zmn = list(map(int, hitr_vetra_10m_zmn))
hitr_vetra_80m_zmn = list(map(int, hitr_vetra_80m_zmn))
hitr_vetra_120m_zmn = list(map(int, hitr_vetra_120m_zmn))
hitr_vetra_180m_zmn = list(map(int, hitr_vetra_180m_zmn))

if stavek_veter in paket:
    time.sleep(1.7)
    ser.write((str(hitr_vetra_10m_zmn[tr_cas: (tr_cas+6)]) + "\n").encode("utf-8"))
    time.sleep(0.5)
    ser.write((str(hitr_vetra_80m_zmn[tr_cas: (tr_cas+6)])+ "\n").encode("utf-8"))
    time.sleep(0.5)
    ser.write((str(hitr_vetra_120m_zmn[tr_cas: (tr_cas+6)])+ "\n").encode("utf-8"))
    time.sleep(0.5)
    ser.write((str(hitr_vetra_180m_zmn[tr_cas: (tr_cas+6)])+ "\n").encode("utf-8"))
    time.sleep(0.5)
    ser.write((str(smer_vetra_10m[tr_cas: (tr_cas+6)])+ "\n").encode("utf-8"))
    time.sleep(0.5)
    ser.write((str(smer_vetra_80m[tr_cas: (tr_cas+6)])+ "\n").encode("utf-8"))
    time.sleep(0.5)
    ser.write((str(smer_vetra_120m[tr_cas: (tr_cas+6)])+ "\n").encode("utf-8"))
    time.sleep(0.5)
    ser.write((str(smer_vetra_180m[tr_cas: (tr_cas+6)])+ "\n").encode("utf-8"))
    time.sleep(0.5)

print("Cas ob rezultatih: \n")
print(str(cas[tr_cas: (tr_cas+6)])+ "\n")
print("Hitrost vetra 10m \n")
print(str(hitr_vetra_10m[tr_cas: (tr_cas+6)])+ "\n")
print("Hitrost vetra 80m \n")
print(str(hitr_vetra_80m[tr_cas: (tr_cas+6)])+ "\n")
print("Hitrost vetra 120m \n")
print(str(hitr_vetra_120m[tr_cas: (tr_cas+6)])+ "\n")
print("Hitrost vetra 180m \n")
print(str(hitr_vetra_180m[tr_cas: (tr_cas+6)])+ "\n")
print("Smer vetra 10m \n")
print(str(smer_vetra_10m[tr_cas: (tr_cas+6)])+ "\n")
print("Smer vetra 80m \n")
print(str(smer_vetra_80m[tr_cas: (tr_cas+6)])+ "\n")
print("Smer vetra 120m \n")
print(str(smer_vetra_120m[tr_cas: (tr_cas+6)])+ "\n")
print("Smer vetra 180m \n")
print(str(smer_vetra_180m[tr_cas: (tr_cas+6)])+ "\n")

while True:
    paket = str(ser.readline())
    print(paket.encode("utf"))

Arduino code:
#include <Wire.h>
//#include <WireIMXRT.h>
//#include <WireKinetis.h>

int hitr_vetra_10m[6], hitr_vetra_120m[6], hitr_vetra_80m[6], hitr_vetra_180m[6];
int smer_vetra_10m[6], smer_vetra_80m[6],smer_vetra_120m[6], smer_vetra_180m[6];
float hitr_vetra_10m_ko[6], hitr_vetra_120m_ko[6], hitr_vetra_80m_ko[6], hitr_vetra_180m_ko[6];

int n, k;

String ser_string[8];

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Wire.begin();
  delay(6000);

  Serial.println("Vetrne karakteristike");
  delay(2000);

  for(n = 0; n<=8; n++){
    if(Serial.available()>=14){
      ser_string[n] = Serial.readStringUntil("\n");
      Serial.flush();
      Serial.println(ser_string[n]);

      if(n==0){
        while(ser_string[n].indexOf(",")!=-1){
          hitr_vetra_10m[k] = ser_string[n].substring(0,ser_string[n].indexOf(",")).toInt();
          k++;
        }
        hitr_vetra_10m[k]=ser_string[n].toInt();
      }

      k=0;
      if(n==1){
        while(ser_string[n].indexOf(",")!=-1){
          hitr_vetra_80m[k] = ser_string[n].substring(0,ser_string[n].indexOf(",")).toInt();
          k++;
        }
        hitr_vetra_80m[k]=ser_string[n].toInt();
      }
      k=0;

      if(n==2){
        while(ser_string[n].indexOf(",")!=-1){
          hitr_vetra_120m[k] = ser_string[n].substring(0,ser_string[n].indexOf(",")).toInt();
          k++;
        }
        hitr_vetra_120m[k]=ser_string[n].toInt();
      }
      k=0;

      if(n==3){
        while(ser_string[n].indexOf(",")!=-1){
          hitr_vetra_180m[k] = ser_string[n].substring(0,ser_string[n].indexOf(",")).toInt();
          k++;
        }
        hitr_vetra_180m[k]=ser_string[n].toInt();
      }
      k=0;

      if(n==4){
        while(ser_string[n].indexOf(",")!=-1){
          smer_vetra_10m[k] = ser_string[n].substring(0,ser_string[n].indexOf(",")).toInt();
          k++;
        }
        smer_vetra_10m[k]=ser_string[n].toInt();
      }
      k=0;

      if(n==5){
        while(ser_string[n].indexOf(",")!=-1){
          smer_vetra_80m[k] = ser_string[n].substring(0,ser_string[n].indexOf(",")).toInt();
          k++;
        }
        smer_vetra_80m[k]=ser_string[n].toInt();
      }
      k=0;

      if(n==6){
        while(ser_string[n].indexOf(",")!=-1){
          smer_vetra_120m[k] = ser_string[n].substring(0,ser_string[n].indexOf(",")).toInt();
          k++;
        }
        smer_vetra_120m[k]=ser_string[n].toInt();
      }
      k=0;

      if(n==7){
        while(ser_string[n].indexOf(",")!=-1){
          smer_vetra_180m[k] = ser_string[n].substring(0,ser_string[n].indexOf(",")).toInt();
          k++;
        }
        smer_vetra_180m[k]=ser_string[n].toInt();
      }
      k=0;

      delay(500);
    }

  }
  n=0;

  for(int b = 0; b<=5;b++){
    hitr_vetra_10m_ko[b]=hitr_vetra_10m[b]/10.0;
    hitr_vetra_80m_ko[b]=hitr_vetra_80m[b]/10.0;
    hitr_vetra_120m_ko[b]=hitr_vetra_120m[b]/10.0;
    hitr_vetra_180m_ko[b]=hitr_vetra_180m[b]/10.0;
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  for(int j = 0; j<=5; j++){
    Serial.println(hitr_vetra_10m_ko[j]);
  }
  delay(5000);

}

Why does it only write out 0.0 for every place in the array (example: [0.0,0.0,0.0,0.0,0.0,0.0]?
Thanks in advance for all help.
EDIT:
I've changed the last part of python code to this

while True:
    paket = str(ser.readline().decode("utf"))
    print(paket.encode("ASCII"))

and I get the following result when I print what is coming from Serial monitor (whatever data I print in python and the show it in VScode terminal.)
Cas ob rezultatih:

['2023-02-13T18:00', '2023-02-13T19:00', '2023-02-13T20:00', '2023-02-13T21:00', '2023-02-13T22:00', '2023-02-13T23:00']

Hitrost vetra 10m

[2.1, 3.1, 1.3, 1.9, 2.3, 2.6]

Hitrost vetra 80m

[0.4, 1.1, 2.5, 0.5, 1.8, 1.8]

Hitrost vetra 120m

[0.7, 0.7, 3.3, 1.1, 1.0, 1.8]

Hitrost vetra 180m

[1.3, 1.0, 4.0, 2.5, 0.8, 0.4]

Smer vetra 10m

[211, 249, 146, 248, 219, 214]

Smer vetra 80m

[360, 252, 98, 225, 217, 217]

Smer vetra 120m

[360, 180, 84, 90, 225, 217]

Smer vetra 180m

[34, 135, 85, 90, 63, 180]

b'[21,31,13,19,23,26]\n'
b'[4,11,25,5,18,18]\n'
b'[7,7,33,11,10,18]\n'
b'[13,10,40,25,8,4]\n'
b'[211,249,146,248,219,214]\n'
b'[360,252,98,225,217,217]\n'
b'[360,180,84,90,225,217]\n'
b'[34,135,85,90,63,180]\n'
b'\r\n'
b'[21,31,13,19,23,26]\n'
b'[4,11,25,5,18,18]\n'
b'[7,7,33,11,10,18]\n'
b'[13,10,40,25,8,4]\n'
b'[211,249,146,248,219,214]\n'
b'[360,252,98,225,217,217]\n'
b'[360,180,84,90,225,217]\n'
b'[34,135,85,90,63,180]\n'
b'\r\n'
b'\r\n'
b'\r\n'
b'\r\n'
b'\r\n'
b'\r\n'
b'\r\n'
b'\r\n'
b'[21,31,13,19,23,26]\n'
b'[4,11,25,5,18,18]\n'
b'[7,7,33,11,10,18]\n'
b'[13,10,40,25,8,4]\n'
b'[211,249,146,248,219,214]\n'
b'[360,252,98,225,217,217]\n'
b'[360,180,84,90,225,217]\n'
b'[34,135,85,90,63,180]\n'
b'\r\n'
b'\r\n'
b'\r\n'
b'\r\n'
b'\r\n'
b'\r\n'
b'\r\n'
b'\r\n'

please add a clear, answerable question to your post

For debugging, first change your python encoding to encode('ASCII') instead of encode('utf8') (BTW, your paket.encode("utf") doesn't seems to be correct. If you need other to help you, an example of what the data been sent by phthon code, and what you have received by the Arduino would be helpful to understand what exactly the problem you are facing.

@hcheung I've edited the post and added soma data.

Okay, if your Hitrost vetra 10m is a String representative of  floating point as [2.1, 3.1, 1.3, 1.9, 2.3, 2.6], you need to parse it with hitr_vetra_80m[k]=ser_string[n].toFloat(); instead of using toInt() method. See more about [toFloat()] method at toFloat().

@hcheung I've multiplied the numbers by 10 and will then divide it by 10 in the Arduino, so I don't read floats from Serial monitor because I've read it's very difficult to read floats.

source: Stack Exchange

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

sort: votes


text:
Why is this buffer not being sent to the server?
I'm loading a buffer with different data recorded by sensors and sending them to a server. But I also wanted to log when the data was sent on the client side, so I formatted the time of my RTC clock and tried to include it in the buffer, but this caused a problem. The data returned by the sensors are floating point numbers, but the timestamps are integers. When trying to send the buffer including both the datatypes, it is not received by the server. Under is the code which puts the data into the buffer:
char buffer[256] = {};

sprintf(buffer, "path?myfile.txt,%02d/%02d/%02d %02d:%02d:%02d,Temp=%lf,Humidity=%lf,Pressure=%lf,Light=%lf",rtc.getDay(),rtc.getMonth(),rtc.getYear(),rtc.getHours(),rtc.getMinutes(),rtc.getSeconds(),temperature,humidity,pressure,illuminance);

I am pretty sure the mixing of the data types or the formatting is the problem. I know it's not the buffer size because I have tested it with multiple sizes. The weird thing is that I can print the buffer out in the serial monitor without any problem. It is also formated the right way in the serial monitor:

"path?myfile.txt,10/02/23 17:05:16, Temp=26.863487,Humidity=24.886541,Pressure=99.868286,Light=8.387096

I have never experienced a situation where one buffer is sent successfully and another one is not.
If I for example send this buffer instead:
sprintf(buffer, "/cgi-bin/tof.cgi?zuluz.txt,Temp=%lf,Humidity=%lf,Pressure=%lf,Ligth=%lf",temperature,humidity,pressure,illuminance);

Everything works as it should. What do you think the problem is? And is there a good workaround for this? If this problem comes from the server itself, I can not do anything about it since I have no access to its backend code.
My board is the MKR NB 1500 using a MKR ENV shield to log the data.
Edit:
Here is the full function which actually writes to the server:
void write_server()
{
    Serial.println("Sending the buffer");
    char buffer[256] = {};

    client.print("GET ");
    sprintf(buffer, "path?myfile.txt,%02d/%02d/%02d %02d:%02d:%02d,Temp=%lf,Humidity=%lf,Pressure=%lf,Light=%lf",rtc.getDay(),rtc.getMonth(),rtc.getYear(),rtc.getHours(),rtc.getMinutes(),rtc.getSeconds(),temperature,humidity,pressure,illuminance);
    Serial.println(buffer);
    client.print(buffer);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(server);
    client.println("Connection: close");
    client.println();
    Serial.println("Buffer sent");
}

The only diffrence from the actual code is the path on the server and the file name in which the data is stored.

the space in the timestamp is the problem. replace it with %20 (correctly escaped for printf pattern). (and path should begin with /, but I guess it is missing just because of the obfuscation for the post)

In addition to what Juraj said, a proper HTTP query string should be in the format as  /test/demo_form.php?name1=value1&name2=value2, so you are missing a key for you datetime string, and , is not a valid delimiter and should be replaced by &.  Try path?<filename>=myfile.txt&<datetime>=10/02/23%2017:05:16&Temp=26.863487&Humidity=24.886541&Pressure=99.868286&Light=8.387096, replace  and  with whatever your server is expecting.

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


text:
an lcd with I2C is not recognized by esp32
I have a NodeMCU esp32-s board and I'm trying to connect My 16x2 lcd with PCF8574T I2C bus to the esp32 , the problem is that the lcd doesn't show anything and the WireScan sketch can't recognize the lcd too,but when I use arduion uno ,it's recognized and work perfectly ,I hope somebody can help me,the schematic for the connection is :

the schematic for the connection of the lcd with the bus is below with the bus module part number :

please add a clear, answerable question to your post

What things need to be cleared?

you need to make it clear how the LCD is connected and, most importantly, which LCD you are using ... right now, all we know which pins are connected at the ESP32 ... we know nothing else ... also, you have not asked a question about the problem

well,if you return back to my question you see I have mentioned the type and part number and this is exactly the problem, I can't provide more.

the PCF8574T is an IC that is part of the LCD ... it is an I2C bus expander ... which component is used in the display module has no bearing on the connector pinout of the LCD module

ok , thanks , I have just edited the question , please let me know if it is clear now or not.

Can you verify 5 VDC and ground are present at the I2C, LCD backpack? How are you powering the ESP32?

yes they exist and they are named as VDD and VSS , also the two parts are soldered together and the lcd is lighting when using esp32.

Do the ESP32 GIOPs operate at 3.3 VDC? You may need a logic level converter of some type on the I2C lines. For example: https://www.aliexpress.com/item/1005003157047080.html?spm=a2g0o.productlist.main.1.74f168cfuMUXE9&algo_pvid=581ce205-0f3f-42bc-8d30-a719047333f2&algo_exp_id=581ce205-0f3f-42bc-8d30-a719047333f2-0&pdp_ext_f=%7B%22sku_id%22%3A%2212000024404763535%22%7D&pdp_npi=3%40dis%21CAD%212.39%212.16%21%21%21%21%21%40211bc2a016760709924762576d06d7%2112000024404763535%21sea%21CA%21915735244&curPageLogUid=y2eJwfSkV6yg

I'm using the 5v pin to power the I2C module , but SDA and SCL pins are powered with GPIO pins which I think they are providing 3.3v.

You can run the PCF8574 on 5V and the EXP on 3V3 just be sure the I2C is pulled up to the 3V3 and NOT the 5V. I do this a lot and have never had a problem. The reason it works is the bus is driven by open collector/drain drivers which do not source any voltage.


text:
delayMIcroseconds and micros execution time not explainable
i just experimented with the timing accuracy of my Arduino Uno R3 using this code:
unsigned long beginTime;
unsigned long endTime;

void setup() {
  Serial.begin(9600); // open a serial port
}

void loop() {
  beginTime = micros();
  delayMicroseconds(200);
  endTime = micros();
  delay(500);
  Serial.println(endTime-beginTime);
  delay(500);
}

The results I got are (just an excerpt):
200
204
200
200
204
204
204
200
212
208
212
204
204

I tried to understand this behavior, read this link Can I make delayMicroseconds more accurate?.
Due to the timing of micros (4 µs) I would understand values between 200 and 208. But why do I get occasional values of 212 microseconds? I'm kinda curious, since I bought the Arduino because of bare-metal programming and bounded execution times.

Maybe you good some interrupts running during your measurement occasionally. That would make the actual execution time longer.

try to add Serial.flush() to wait until Serial finishes

@Juraj: Thanks for the suggestion. I tried it (i.e. added a Serial.flush(); after the println, but it did not work.

@chrisl: Thanks, I added noInterrupts(); before the first micros(); and interrupts(); after endTime = micros();. I got consistend values, either 200 or 204 microseconds, which was expected :).
Do you know, which interrupts might be triggered  while running such a simple program?  I thought, Serial.flush(); might stop any possible interrupt, but that was not the case..

The Arduino core uses a timer interrupt for timekeeping.

The Arduino core uses hardware Timer0 with its ISR (Interrupt Service Routine) for timekeeping. While delayMicroseconds() directly uses the value of the hardware timer, delay() and millis() are handled by the ISR. It will be called regularly.
If the ISR is getting executed during your measurement, then the execution time of the ISR will add to the execution time of your measured code. Thus you get a higher count occasionally.
To prevent this you can either deactivate all interrupts (via noInterrupts()) or deactivate this specific interrupt, either by stopping Timer0:
TCCR0B &= ~( (1 << CS02) | (1 << CS01) | (1 << CS00) );

or by letting the timer run, but deactivating its interrupts:
TIMSK0 = 0;

For details about this have a look at the datasheet of the Atmega328p, which is the microcontroller on the Arduino Uno.


text:
Why is the watchdog biting to quickly?
currently trying to implement a watchdog into my project. I am using the WDTZero library for controlling the watchdog on my MKR NB 1500. The program is trying to measure data, send it to a server, go to sleep, wake up, and repeat the process. Sometimes the code can hang if it can't connect to the NTP server or the server on which the data is being stored, I want the watchdog to reset the program in cases in which this happens.
A sketch of the program is below. The reason why the NB network is often after different connections is that the NB 1500 is not able to connect to another server if the GPRS connection is already open, so I always reset it before trying another connection.
void setup()
{
    setup_watchdog(); //Sets up the watchdog timer
    delay(1000);
    connect_GPRS_NB(); //Connects to the NB network and opens a GPRS connection
    request_NTP(); //Requests epoch1970 from the NTP server and then closes the connection
    timezone_adjustment(); //Adjusts the epoch time to my timezone (in Norway)
    set_RTC(); //Activates the SAMD21 RTC with this timezone adjusted time
    disconnect_NB(); //Disconnects from the NB network
    delay(2000);
    MyWatchDoggy.clear(); //Resets the watchdog timer
    }

void loop()
{
    connect_GPRS_NB(); //Connects to the NB network and opens a GPRS connection
    get_ENV_data(); //Takes measurements using the MKR NB ENV shield
    connect_to_server(); //Connects to the server in which the data will be stored
    write_to_server(); //Writes the data on the server
    disconnect_from_server(); //Disconnects from the server
    disconnect_NB(); //Disconnects from the NB network

    LowPower.deepSleep(300000); //Goes to deep sleep for 5 minutes
    delay(3000);
    MyWatchDoggy.clear(); //Resets the watchdog timer
}

All the functions above are written in other .cpp files and imported thru header files into the main file. Here is the code for activating and configuring the watchdog:
#include "watchdog.hpp"
#include "GPRS_NB_connection.hpp"

WDTZero MyWatchDoggy;

void setup_watchdog()
{
    MyWatchDoggy.attachShutdown(NVIC_SystemReset); //calls reset function
    MyWatchDoggy.setup(WDT_SOFTCYCLE8M); //8 minute watchdog timer
}

The program works fine in the way described at the top of the post when the watchdog is not included. But when including the watchdog, it bites after 30 seconds when the dog only should have bit after 8 minutes. I see this because data is being sent about every 25-30 seconds to the server.
At first, I thought I had not activated the watchdog in the right way, so I wrote another program to test it:
#include <Arduino.h>
#include <WDTZero.h>
#include <RTCZero.h>

WDTZero MyWatchDoggy;
RTCZero rtc;

void set_RTC()
{
    rtc.begin();
    rtc.setYear(0);
    rtc.setMonth(0);
    rtc.setDay(0);
    rtc.setHours(0);
    rtc.setMinutes(0);
    rtc.setSeconds(0);
}

void shutdown()
{
    Serial.println("Shutting down");

}

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

    }
    Serial.println("Starting up Arduino");
    MyWatchDoggy.attachShutdown(shutdown);
    MyWatchDoggy.setup(WDT_SOFTCYCLE8M);
    set_RTC();

}

void loop()
{
    Serial.print(rtc.getMinutes());
    Serial.print("/");
    Serial.print(rtc.getSeconds());
    Serial.println("");
    delay(1000);
}

But in this program the watchdog bites after about 8 minutes as it should.
I have not included the code for the functions described in the first code since I know they work without the watchdog and the code itself is very long. But if you think the problem could be caused by these functions for some reason, I will edit the post and include all the function codes.

In the WDTZero library the long watchdog times are achieved by restarting the watchdog timer in watchdog interrupt until the required time is reached.
This doesn't work if the MCU sleeps.

What would be a workaround to this? Is there a way to completely disable the WDT before going into sleep mode and then reenabling it at the start of the loop?

@5TableLegs wdt.setup(WDT_OFF);

Ok, thank you. I can't find any WDT_ON on the resource page on GitHub. So I am guessing the watchdog will automatically be enabled when doing MyWatchDoggy.setup(cycleOfChoice)?


text:
Cannot compile MFRC522 minimal I2C example
On ESP32 I'm trying to build the Minimal I2C example of the MFRC522 library:
But I get errors on the first declarations:
TwoWire i2cBus = TwoWire(0);
MFRC522_I2C dev = MFRC522_I2C(RST_PIN, 0x28, i2cBus);
MFRC522 mfrc522 = MFRC522(dev); // <--- error

Here the build output:
src/rfid.cpp:6:30: error: no matching function for call to 'MFRC522::MFRC522(MFRC522_I2C&)'
 MFRC522 mfrc522 = MFRC522(dev);
                              ^
In file included from include/rfid.h:5,
                 from src/rfid.cpp:1:
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:348:2: note: candidate: 'MFRC522::MFRC522(byte, byte)'
  MFRC522(byte chipSelectPin, byte resetPowerDownPin);
  ^~~~~~~
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:348:2: note:   candidate expects 2 arguments, 1 provided
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:347:2: note: candidate: 'MFRC522::MFRC522(byte)'
  MFRC522(byte resetPowerDownPin);
  ^~~~~~~
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:347:2: note:   no known conversion for argument 1 from 'MFRC522_I2C' to 'byte' {aka 'unsigned char'}
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:346:2: note: candidate: 'MFRC522::MFRC522()'
  MFRC522() DEPRECATED_MSG("use MFRC522(MFRC522_BUS_DEVICE bus_device)");
  ^~~~~~~
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:346:2: note:   candidate expects 0 arguments, 1 provided
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:343:2: note: candidate: 'MFRC522::MFRC522(MFRC522_BUS_DEVICE*)'
  MFRC522(MFRC522_BUS_DEVICE * dev);
  ^~~~~~~
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:343:2: note:   no known conversion for argument 1 from 'MFRC522_I2C' to 'MFRC522_BUS_DEVICE*'
In file included from include/rfid.h:5,
                 from src/rfid.cpp:1:
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:152:7: note: candidate: 'constexpr MFRC522::MFRC522(const MFRC522&)'
 class MFRC522 {
       ^~~~~~~
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:152:7: note:   no known conversion for argument 1 from 'MFRC522_I2C' to 'const MFRC522&'
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:152:7: note: candidate: 'constexpr MFRC522::MFRC522(MFRC522&&)'
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:152:7: note:   no known conversion for argument 1 from 'MFRC522_I2C' to 'MFRC522&&'

Unfortunately there is no way to open an issue on the repository.
Why the official example does not work?
UPDATE
Here the compatibility declaration for ESP32:

@VE7JRO they declare the compatibility for ESP32, see the picture in the question updated

@VE7JRO It returns: error: cannot convert 'MFRC522_I2C' to 'MFRC522_I2C*' in initialization

Guys, why the downvote? Without an explanation how can I improve my question? I did my homework: minimal and reproducible example, show effort to solve the issue by myself, complete output message. What else do you want?

you use a fork a of fork. the library is poorly maintained. use MFRC522 mfrc522 = MFRC522(&dev);

if you look, it says, "Candidate expects 2 inputs, one provided."
so in the arduino IDE hover over the function and see what it expects.
(What your putting in MFRC522(byte resetPowerDownPin); what it expects: MFRC522(byte resetPowerDownPin, Something else);)

What it expects is in the declaration of the constructor: https://github.com/MakerSpaceLeiden/rfid/blob/master/src/MFRC522.cpp#L10. And is MFRC522_BUS_DEVICE * dev

I'm not putting any byte


text:
Can't Send Text Messages Using TinyGSM Module, but it works if I do it manually using the ESP-IDF Environment - Sim7600
I am using the following device: https://www.aliexpress.com/item/1005003152097545.html?spm=a2g0o.order_list.order_list_main.119.222218028PapM6
I am trying to make an IoT sound-measurer which will send an SMS, once a sound above a certain threshold has been registered for a certain amount of time. Furthermore, it should send a "pulse" SMS every Nth hour, to ensure, that the module is still alive.
To achieve the SMS-part of this project I am using the TinyGSM module. It worked for a long time, and then suddenly it wouldn't work anymore. The only related event I can think of that happened before this, is that I tried to use the modem on the ESP-IDF, and I tried to use the GPS capabilities of the modem, once again on the ESP-IDF.
I believe this might have had something to do with the settings I had sat on the ESP-IDF, which are defined through the following AT-commands:
"AT+CFUN=0\r", "AT+CPIN="1234"\r", "AT+COPS=0,0,"Telenor DK Telenor DK",7\r", "AT+CMGF=0\r".
But after running "AT+CRESET" and "AT+CPOF" and rerunning the Arduino script, I am still stuck with the original error.
The error occurs, when I try to run the sendText method, and the message (With my phone number redacted) is:
AT+CMGF=1
AT+CMGF=1

ERROR
AT+CSCS="GSM"
AT+CSCS="GSM"

ERROR
AT+CMGS="+REDACTED"
AT+CMGS="+REDACTED"

ERROR

The full Arduino code (Where I've once again written REDACTED instead of my actual IRL phone number):
//SIMKORT indstillinger

// Pincode for simkortet
#define GSM_PIN "\"1234\""

// GRPRS credentials for simkortet
const char apn[]  = "Telenor Internet";     //SET TO YOUR APN
const char gprsUser[] = "";
const char gprsPass[] = "";

// Nummer til SMS samt besked
#define SMS_TARGET_NOISY  "+REDACTED"
#define SMS_TARGET_PULSE "+REDACTED"
#define SMS_MESSAGE_NOISY "B"
#define SMS_MESSAGE_PULSE "L"

//Netværks indstillinger fra Debugging 1 koden
#define NETWORK_MODE 2
#define PREFFERED_NETWORK_MODE 2

//Modem indstillinger
#define TINY_GSM_MODEM_SIM7600 //Om du bruger SIM7000 eller SIM7600 (TTGO'en er 7600)
#define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb
#define SerialAT Serial1

//Libraries
#define DUMP_AT_COMMANDS  //Bruges til debugging

#include <TinyGsmClient.h>
#include <SPI.h>
#include <SD.h>
#include <Ticker.h>

#ifdef DUMP_AT_COMMANDS  // if enabled it requires the streamDebugger lib
  #include <StreamDebugger.h>
  StreamDebugger debugger(SerialAT, Serial);
  TinyGsm modem(debugger);
#else
  TinyGsm modem(SerialAT);
#endif

//ESP32-Modem Forbindelser Indstillinger
#define uS_TO_S_FACTOR 1000000ULL  // Conversion factor for micro seconds to seconds

#define UART_BAUD   115200
#define PIN_DTR     25
#define PIN_TX      27
#define PIN_RX      26
#define PWR_PIN     4

//SD Kort forbindelser
#define SD_MISO     2
#define SD_MOSI     15
#define SD_SCLK     14
#define SD_CS       13
#define LED_PIN     12

int counter, lastIndex, numberOfPieces = 24;
String pieces[24], input;

//Indstillinger for dBAMåleren
#define VREF 3.3 //Voltagen som din MCU bruger, Arduino = 5
#define soundSensorPin 25 //Den pin på MCU'en, der er forbundet til outputtet på dBA måleren
#define analogMaxRange 4096 //Analog max range for din MCU, esp32: 4096, Arduino: 1023

//Funktionelle indstillinger
#define dBAMax 3.0 //Hvornår der skal sendes en SMS
#define errorMeasurement 0.0 //Fejlmarginen
#define waitBeforeSendingtext (10*1000) //Målt i millisekunder, tid før vi sender noisySMS
#define waitBeforeGoingIdle (100*1000) //Hvor lang tid dBAMeasurement må være under vores dBAMax, før vi går tilbage til idle stadiet
#define waitIntervalBetweenPulseText (1000*1000) //Antal millisekunder i mellem, at vi sender en pulse SMS

//Variable vedrørende FSMD'en - MÅ IKKE ÆNDRES
//States:
//Idle 0, dBA above Max 1, dBA momentarily below max 2, send noisy text 3, send pulse text 4
int state = 0; //Initialiserer stadiet ved 0
float dbAMeasurement;
unsigned long timeSinceLastIdle; //Bruges til at triggere loudSMS
unsigned long timeSinceLastPulse = 0; //Bruges til at pulseSMS
unsigned long timeSincedBAMax; //Tid der er gået siden, vi optog vores første dBAMax i denne omgang

//Funktioner

void sendText(String SMSTarget,String message,TinyGsm modem){
    modem.sendSMS(SMSTarget, message);
}

float getdBAMeasurement(){
  float dbAMeasurement = ((analogRead(soundSensorPin) / 4096.0 * VREF)*50.0); //Slipper for at bruge clock cycluser på at definere variable
  delay(125); //Sampling cyclus delay for stabilitet
  return dbAMeasurement;
}

bool isAbovedBAThreshold(){
  float dbAMeasurement = getdBAMeasurement();
  if(dbAMeasurement>(dBAMax - errorMeasurement)){
    return true;
  }else{
    return false;
  }
}

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

  //Opstart af Modem
  // Set LED OFF
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);

  pinMode(PWR_PIN, OUTPUT);
  digitalWrite(PWR_PIN, HIGH);
  delay(300);
  digitalWrite(PWR_PIN, LOW);

  //Tjekker for SD kort
  SPI.begin(SD_SCLK, SD_MISO, SD_MOSI, SD_CS);
  if (!SD.begin(SD_CS)) {
    Serial.println("SDCard MOUNT FAIL");
  } else {
    uint32_t cardSize = SD.cardSize() / (1024 * 1024);
    String str = "SDCard Size: " + String(cardSize) + "MB";
    Serial.println(str);
  }

  Serial.println("\nWait...");

  delay(1000);

  SerialAT.begin(UART_BAUD, SERIAL_8N1, PIN_RX, PIN_TX);

  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  Serial.println("Initializing modem...");
  if (!modem.restart()) {
    Serial.println("Failed to restart modem, attempting to continue without restarting");
  }

  // Unlock your SIM card with a PIN if needed
  if ( GSM_PIN && modem.getSimStatus() != 3 ) {
      modem.simUnlock(GSM_PIN);
  }
  modem.sendAT("+CFUN=0 ");
  if (modem.waitResponse(10000L) != 1) {
    DBG(" +CFUN=0  false ");
  }
  delay(200);

  /*
    2 Automatic
    13 GSM only
    38 LTE only
    51 GSM and LTE only
  * * * */
  String res;
  // CHANGE NETWORK MODE, IF NEEDED
  res = modem.setNetworkMode(NETWORK_MODE);
  if (res != "1") {
    DBG("setNetworkMode  false ");
    return ;
  }
  delay(200);

  /*
    1 CAT-M
    2 NB-Iot
    3 CAT-M and NB-IoT
  * * */
  // CHANGE PREFERRED MODE, IF NEEDED
  res = modem.setNetworkMode(PREFFERED_NETWORK_MODE);
  if (res != "1") {
    DBG("setPreferredMode  false ");
    return ;
  }
  delay(200);

  /*AT+CBANDCFG=<mode>,<band>[,<band>…]
   * <mode> "CAT-M"   "NB-IOT"
   * <band>  The value of <band> must is in the band list of getting from  AT+CBANDCFG=?
   * For example, my SIM card carrier "NB-iot" supports B8.  I will configure +CBANDCFG= "Nb-iot ",8
   */
  /* modem.sendAT("+CBANDCFG=\"NB-IOT\",8 ");*/

  /* if (modem.waitResponse(10000L) != 1) {
       DBG(" +CBANDCFG=\"NB-IOT\" ");
   }*/
   delay(200);

  modem.sendAT("+CFUN=1 ");
  if (modem.waitResponse(10000L) != 1) {
    DBG(" +CFUN=1  false ");
  }
  delay(200);

  SerialAT.println("AT+CGDCONT?");
  delay(500);
  if (SerialAT.available()) {
    input = SerialAT.readString();
    for (int i = 0; i < input.length(); i++) {
      if (input.substring(i, i + 1) == "\n") {
        pieces[counter] = input.substring(lastIndex, i);
        lastIndex = i + 1;
        counter++;
       }
        if (i == input.length() - 1) {
          pieces[counter] = input.substring(lastIndex, i);
        }
      }
      // Reset for reuse
      input = "";
      counter = 0;
      lastIndex = 0;

      for ( int y = 0; y < numberOfPieces; y++) {
        for ( int x = 0; x < pieces[y].length(); x++) {
          char c = pieces[y][x];  //gets one byte from buffer
          if (c == ',') {
            if (input.indexOf(": ") >= 0) {
              String data = input.substring((input.indexOf(": ") + 1));
              if ( data.toInt() > 0 && data.toInt() < 25) {
                modem.sendAT("+CGDCONT=" + String(data.toInt()) + ",\"IP\",\"" + String(apn) + "\",\"0.0.0.0\",0,0,0,0");
              }
              input = "";
              break;
            }
          // Reset for reuse
          input = "";
         } else {
          input += c;
         }
      }
    }
  } else {
    Serial.println("Failed to get PDP!");
  }

  Serial.println("\n\n\nWaiting for network...");
  if (!modem.waitForNetwork()) {
    delay(10000);
    return;
  }

  if (modem.isNetworkConnected()) {
    Serial.println("Network connected");
  }

}

void loop() {

  switch(state){
    case 0:  // Idle: Venter på at dbAMeasurement går over dbAMax - Error
      Serial.println("Back in state 0");
      dbAMeasurement = getdBAMeasurement();
      timeSinceLastIdle = millis(); //Millisekunder siden start
      Serial.println(dbAMeasurement);
      Serial.println(timeSinceLastIdle);
      Serial.println(timeSinceLastPulse);

      if((timeSinceLastIdle - timeSinceLastPulse) > waitIntervalBetweenPulseText){ //Vi vil hellere sende pulse SMS'en, før vi advarer
        state = 4;
      }
      if ((dbAMeasurement>(dBAMax - errorMeasurement))&(state != 4)){ //If we go above the allowed dBAMeasurement, we start counting until we send noisySMS
        state = 1;
      }

      break;
    case 1:  // We're counting up to sending the loudSMS
      Serial.println("Back in state 1");

      dbAMeasurement = getdBAMeasurement();
      Serial.println(dbAMeasurement);

      timeSincedBAMax = millis() - timeSinceLastIdle;
      Serial.println(timeSincedBAMax);
      if(timeSincedBAMax>waitBeforeSendingtext){
        state = 3; //SendnoisySMS
      }
      if(dbAMeasurement<(dBAMax - errorMeasurement)){
        state = 2; //Momentært under dBAMax
      }

      break;
    case 2:  // Hvis vi momentært går under dBAMax
      Serial.println("Back in state 2");
      dbAMeasurement = getdBAMeasurement();

      if((millis() - timeSincedBAMax)> waitBeforeGoingIdle){ //Når der er gået lang nok tid, hvor vi ikke måler en høj nok lyd, så genstarter vi timeren for at sende noisySMS
        state = 0;
      }

      if(dbAMeasurement>(dBAMax - errorMeasurement)){ //Vi går igen over vores threshold og går tilbage til tælle op til at sende noisySMS uden at genstarte timeren
        state = 1;
      }

      break;
    case 3:  // Send noisySMS
      sendText(SMS_TARGET_NOISY,SMS_MESSAGE_NOISY,modem);
      Serial.println("Back in state 3");
      state = 0;
      break;

    case 4:
      Serial.println("Back in state 4");
      timeSinceLastPulse = millis();
      sendText(SMS_TARGET_PULSE,SMS_MESSAGE_PULSE,modem);
      state = 0; //Go back to idle
      break;
  }
}

The odd thing here however, is that if I manually send the AT commands over UART using the ESP-IDF, I can make it send text messages without a hick.

TinyGSM has the capability of turning on DUMP_AT_COMMANDS for debugging , have you done that?

modem.setNetworkMode() return a bool true or false, not a char or string as you are checking in if (res != "1").

@hcheung I do not believe that is the issue. I believe it is boxed into a boolean.

Well, you can believe whatever you want, did you read the source code?  You had #define DUMP_AT_COMMANDS turn on, what does the log on the Serial Monitor shown?


text:
TFT display shows black stripes
I'm new to the field: I'm trying to drive a TFT ST7735S display (this is the model I'm currently using: https://www.amazon.it/dp/B078JBBPXK/ref=pe_24968671_487022601_TE_SCE_dp_1) with an Arduino Mega following this video (https://www.youtube.com/watch?v=iPeukOK6stk&ab_channel=Artigiano2.0-AlessioRomanelli). Once the hardware is set up and the code is written, when I run the example script "graphictest" of the Adafruit library for st7735 and st7789, the display shows stripes on the background as shown in the picture below:

(Note that the strange effect is not camera's fault)
Reading online I thought that the problem could be the fact that the display is powered with 5V instead of 3.3V, but I've also tried powering it with 3.3V (Arduino Mega 3.3V) with little to no changes. I've changed the tft.initR(INITR_BLACKTAB); to tft.initR(INITR_GREENTAB); too, as suggested by a user i this thread (https://forum.arduino.cc/t/bugged-1-8-inch-tft-diplay/1012166/5) and i've also tried powering the display with 5V but using 4.7k resistors in series to reduce the voltage as suggested in the same post, but it still doesn't work.
Moreover the strange effect that the image shows does only appear, if I use a 5V supply, just when the program executes the void setup() function, then becomes sharp (this does not happen if I power the display using the Arduino Mega 3.3V output supply: in fact in this case the stripes are still present even when entering the void loop() function)
As I said before, the program and the hardware setup arethe same as the video I was talking about.
One thing I noticed is that, when I press the reset button on the Arduino Mega, an instant before the program is reloaded, the stripes disappear leaving the image as sharp as it should have been, without any strange background effect. Does anyone have any idea on how to solve this issue?
Thank you in advance for any eventual answer!
EDIT:
This is the picture of the modified verison of the connections, running the graphictest program with the suggested code:
#else
  // For the breakout board, you can use any 2 or 3 pins.
  // These pins will also work for the 1.8" TFT shield.
  #define TFT_CS        10
  //#define TFT_RST        9 // Or set to -1 and connect to Arduino RESET pin
  #define TFT_RST        8 // Or set to -1 and connect to Arduino RESET pin
  #define TFT_DC         9
#endif

// OPTION 2 lets you interface the display using ANY TWO or THREE PINS,
// tradeoff being that performance is not as fast as hardware SPI above.
#define TFT_MOSI 11  // Data out
#define TFT_SCLK 13  // Clock out

// For ST7735-based displays, we will use this call
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

Hopefully every connection is visible

why are you trying to power the LCD with 3.3 V supply? ... the diagrams on the Amazon page clearly show a 5 V supply connection

In fact, I did power it with 5V supply, but after reading online it seemed (mainly from the thread I pointed in the question) that 5V could damage the display. Nevertheless I tried it all and even if powering it with 5V the problem remains.

you said that you connected some series resistors ... that's not powering it with a 5 V supply

after the problem showed when supplying 5V directly I both tried powering it using 3.3V and 5V reduced to 3.3V using resistors. But the problem showed by powering it with 5V in the first place

did it ever work correctly?

Just when I tried to restet the Arduino Mega: by pressing the built in button, an instant before the program is restarted the image appear as sharp as it should be, without any kind of problem in the background

Adafruit made that graphictest program for screens that they sell. The screen that you have is not sold by Adafruit and there is no reason why they should support that screen.
Still, you can get it to work, if it is not bricked. After you see enough variants, you get an idea about what you need to get them to work. So, I suggest the following.....
Go here https://www.arthurwiz.com/software-development/177-inch-tft-lcd-display-with-st7735s-on-arduino-mega-2560 and hook up the screen to your mega just exactly as in their table. You will make 8 connections. Download and execute their 'Hello World' program from the tutorial. If that runs ok, then you know that the connections are correct. Note that the constructor is:
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
Also, don't worry if the screen is not rotated correctly - you can add one line in setup() to fix that:
  tft.initR(INITR_BLACKTAB);
  tft.setRotation(1); // <---added
  tft.fillScreen(ST7735_BLACK);

Now on to graphictest. Find these lines and change them to how I have them. I left one line commented out to illustrate. You do this to identify which GPIO go with which function. Yes, I could have started here, but going through the first tutorial successfully means you have not bricked the screen and you have the connections correct.
#else
  // For the breakout board, you can use any 2 or 3 pins.
  // These pins will also work for the 1.8" TFT shield.
  #define TFT_CS        10
  //#define TFT_RST        9 // Or set to -1 and connect to Arduino RESET pin
  #define TFT_RST        8 // Or set to -1 and connect to Arduino RESET pin
  #define TFT_DC         9
#endif

You will use Option 2 and the constructor as stated previously - so
// OPTION 2 lets you interface the display using ANY TWO or THREE PINS,
// tradeoff being that performance is not as fast as hardware SPI above.
#define TFT_MOSI 11  // Data out
#define TFT_SCLK 13  // Clock out

// For ST7735-based displays, we will use this call
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

// Use this initializer if using a 1.8" TFT screen:
  tft.initR(INITR_BLACKTAB);      // Init ST7735S chip, black tab

Note that even though my screen still has a green tab, if I use the green tab initializer, I will have offset problems.
Make sure you haven't left any other configuration lines uncommented. I have the same screen and just hooked it up and tested all of this and everything works fine.

Let us know how it goes.
Edited to add:
You do not need to add ANY external resistors. Your Mega has connections for both 3V and 5V and you need to use both voltages.
Your initial pic (see below) shows that both pin 2 and pin 8 are connected to the same +V on the rail of the breadboard. This is incorrect. As shown in the table I linked, Pin 2 on the LCD goes to 5V on the Mega and pin 8 on the LCD goes to 3.3V on the Mega.

Thank you very much: I will try and let you know how it goes as soon as possible. In the mean time I have tried something myself: I read online that the screen, even if supplied with 5V requires 3.3V logic, thus I included 1k resistors in series with the SPI pins and the problem seems to be fixed even though the screen has become unstabile (flashy and often decays to a white screen before the end of the executiom of the setup function). I can't tell if this happens because of the fragility of breadboard connections or for any other kind of reason)

I've tried to hooke the LCD up like you suggested, but there are two main problems: the background still isn't fixed and the speed at which the lcd refreshes has significantly decreased. In other words the background that should be black starts as white and slowly becomes grey but never black

@Luke__ assuming you have proper connections and are not using any added resistors and no breadboard / lead problems, I wonder if your screen is not the problem. A nice clear pic of the screen and the mega connections might help. Did the "hello world" program run ok?

@Luke__  Please make sure you are correctly connecting SEPARATELY +5V AND +3.3V from the Mega to the correct connections on the screen - see my edit in the initial answer.

The "hello world" showed the same problems. I've edited the question with the requested picture showing the graphictest program in execution. I think I connected all correctly, tell me if I'm I'm wrong

@Luke__ I painstakingly checked all your connections and NOW I think you have them right. It is possible that you damaged the screen getting to this point because you did not have these connections initially and tried a lot of things - call that tuition for learning. One thing though, that white space on the left is an offset issue and I think you are using the green tab initializer - change it to tft.initR(INITR_BLACKTAB);      // Init ST7735S chip, black tab and see if that doesn't go away. It looks better than at first and me be as good as it gets.

yeah, I did use INITR_GREENTAB, but I've laso tried using BLACKTAB: nothing better. At this point if the screen is damaged, have you some better suggestions about some low budget ST7735 displays that are easy to use and 1.8'' (at this point I think it is easier to just use a 1.8'' display rather than a 1.77'' one), maybe that is also 5V, as it is easier to use with Arduino pin outputs ?

@Luke__ Sorry we don't really recommend products here, but I think you have something that is working and a much better idea about how careful you have to be with these connections. Keep plugging away :)

I understand. Thanks a lot for your effort and time in answering me, I really owe you a favour! XD

I had the exact same issue, and tested the things here but it did not help.
Then I pressed the reset button on my UNO with the same result as Luke__ had (the screen looked nice as long as I pressed the reset). After doing that a few times the display started to work as it should.
Strange, but resolved my issue.


text:
How can i separate values from the full string, incoming string always changes its positions?
String str = {"timestamp": "2023-02-08 16-37-31" ,"cpcb_device": [{"Station" : "832","Para": [{"tag_name": "COD","tag_value": "35.5","tag_unit": "mg/l"},{"tag_name": "BOD","tag_value": "13.7","tag_unit": "mg/l"},{"tag_name": "TSS","tag_value": "24.8","tag_unit": "mg/l"},{"tag_name": "pH","tag_value": "6.5","tag_unit": "pH"}]}]}

it looks like JSON format. try the ArduinoJson library

Using json, it shows derealization error., because string is changed every time from its position

what is " changed every time from its position"?

Input string is changed as POST / HTTP/1.1
Host: 192.168.0.197
User-Agent: libcurl-agent/1.0
Accept: /
Content-Length: 144
Content-Type: application/x-www-form-urlencoded
{"timestamp": "2023-02-08 16-37-33" ,"cpcb_device": [{"Station" : "833","Para": [{"tag_name": "Flow","tag_value": "2.0","tag_unit": "m3/hr"}]}]}

use the HTTPClient library for the POST request

Please some one tell me, how to deserialize this json data, i want only values, so how to separate values from this incoming string

the HTTPClient library will do it

String str = {"timestamp": "2023-02-08 16-37-31" }; returns error: expected ',' or ';' before ':' token please fix.

You can use substring() and indexOf() to get parts of the string at certain positions. for example:
String test = "timestamp: 123 value: test";

int val = test.indexOf("timestamp:"); //gives you the index for the beginning of "timestamp:"
int start = test.indexOf(" ", val)+1; //get index of the space starting at our 'val' index
int end = test.indexOf(" ", start); //get index of the next space, we added 1 to the previous value so it doesn't pick up the first space
timestamp = test.substring(start, end); //get the characters between these two index values

Try it out and see how it works for you, obviously getting the index of separating characters that make more sense, such as a comma or colon rather than a space.
Also you could do it like this:
String search = "timestamp:";
int start = test.indexOf(search)+search.length();
//etc...


text:
How can I connect 2 Arduinos using ESP8266 transiver: ESP01
I have: 2 arduinos UNO, 2 ESP01 transivers. But if that's not enough, I'm ready to buy something else
I need to use one of Arduinos as a wifi hot spot, and the second as a modem. They should just be connected to each other :)
P.S. This is for my school project! Subsequently, I will put some obstacles between the Arduinos to see how much the signal strength degrades.

what research have you done for your school project?

Have you googled for how to use these with an Uno? Have you searched for libraries, that make it easier? Have you tried writing a program for the Uno? Have you searched for tutorials on how to setup an access point and how to connect to an access point?

Thank you very much for corrective questions. I'm from Russia, so I wanted to find content that could help me in the most accessible way - in Russian. But, on the Russian-speaking Internet, there are very small amount of people who are really interested in this topic. Most of the tutorials rested on controlling the Arduino with a phone via wifi, but this is not exactly what I needed :)

Here is the ESP8266 WiFi library:
https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WiFi
In there You'll find an example for a WiFi access point:
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/WiFiAccessPoint/WiFiAccessPoint.ino
And an example for WiFi client:
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino
That should provide enough information for you to build your project.
To get the signal strength without connecting, you can use WiFiScan:
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/WiFiScan/WiFiScan.ino

Thanks a lot a lot a lot!!! Do you have any information about how to correctly connect modules with arduinos?

https://www.google.com/search?q=esp8266+arduino+wiring


text:
RTC problems after longer time periods
I'm using the MKR NB 1500 for server sending, an ENV shield for measuring the environment, and an external lithium battery to power the circuit. The internal RTC and WDT on the NB 1500 are used.
The program is trying to measure data, send it to a server, go to sleep, wake up, and repeat the process. Under is a scetch of how the program is set up in main.cpp:
void setup()
{
    setup_watchdog(); //Sets up the watchdog timer with a 32 s bite time
    delay(1000);
    connect_GPRS_NB(); //Connects to the NB network and opens a GPRS connection
    request_NTP(); //Requests epoch1970 from the NTP server and then closes the connection
    timezone_adjustment(); //Adjusts the epoch time to my timezone (in Norway)
    set_RTC(); //Activates the SAMD21 RTC with this timezone adjusted time
    disconnect_NB(); //Disconnects from the NB network
    delay(2000);
    disable_watchdog(); //Disables the WDT in its entirety

void loop()
{
    setup_watchdog(); //Sets up the watchdog timer with a 32 s bite-time
    connect_GPRS_NB(); //Connects to the NB network and opens a GPRS connection
    get_ENV_data(); //Takes measurements using the MKR NB ENV shield
    connect_to_server(); //Connects to the server in which the data will be stored
    write_to_server(); //Writes the data on the server
    disconnect_from_server(); //Disconnects from the server
    disconnect_NB(); //Disconnects from the NB network
    watchdog_reset(); //Resets the watchdog timer

    disable_watchdog(); //Disables the WDT in its entirety
    LowPower.deepSleep(300000); //Goes to deep sleep for 5 minutes
    delay(2000);
}

All the functions above are written in other .cpp files and imported thru header files into the main file. The reason I'm using the RTC is because I want to log the time at which the data was sent to the server on the client side.
I set the circuit outside yesterday night and it actually sent data to the server the entire night. But the RTC did not function as I had hoped. Under is a clip-out of the data which was written on the server yesterday night:
nyktertest1.txt,11-02-23I23:39:40,Temp=22.593750,Fuktighet=31.063698,Trykk=1014.553223,Lys=9.677420
nyktertest1.txt,11-02-23I23:54:40,Temp=26.049343,Fuktighet=27.074978,Trykk=1014.549561,Lys=10.322580
nyktertest1.txt,11-02-23I23:56:34,Temp=24.909540,Fuktighet=29.182085,Trykk=1014.637695,Lys=9.032258
nyktertest1.txt,01-01-00I00:05:14,Temp=24.873356,Fuktighet=29.023129,Trykk=1012.826172,Lys=5.161290
nyktertest1.txt,01-01-00I00:10:29,Temp=22.231909,Fuktighet=34.242844,Trykk=1013.905762,Lys=5.161290
nyktertest1.txt,01-01-00I00:15:43,Temp=15.881580,Fuktighet=38.981991,Trykk=1014.769043,Lys=5.161290
nyktertest1.txt,12-02-23I00:18:39,Temp=19.047699,Fuktighet=38.823032,Trykk=1014.885742,Lys=10.967742
nyktertest1.txt,01-01-00I00:05:15,Temp=18.975330,Fuktighet=34.083885,Trykk=1015.005371,Lys=9.677420
nyktertest1.txt,01-01-00I00:10:30,Temp=20.350330,Fuktighet=33.440662,Trykk=1016.046631,Lys=3.225806
nyktertest1.txt,01-01-00I00:15:45,Temp=21.291119,Fuktighet=36.523697,Trykk=1014.721191,Lys=3.225806
nyktertest1.txt,01-01-00I00:20:59,Temp=15.338817,Fuktighet=43.358864,Trykk=1014.953369,Lys=3.225806
nyktertest1.txt,01-01-00I00:26:15,Temp=10.689146,Fuktighet=47.306919,Trykk=1015.068359,Lys=3.870968
nyktertest1.txt,01-01-00I00:31:30,Temp=8.011514,Fuktighet=48.974121,Trykk=1015.034424,Lys=3.870968
nyktertest1.txt,01-01-00I00:36:44,Temp=6.600330,Fuktighet=49.428818,Trykk=1015.172363,Lys=3.870968
nyktertest1.txt,01-01-00I00:41:59,Temp=5.731909,Fuktighet=49.321609,Trykk=1015.128174,Lys=3.870968
nyktertest1.txt,01-01-00I00:47:14,Temp=5.207238,Fuktighet=48.792984,Trykk=1015.133057,Lys=3.870968
nyktertest1.txt,01-01-00I00:52:28,Temp=4.791119,Fuktighet=48.171944,Trykk=1015.092529,Lys=3.870968
nyktertest1.txt,01-01-00I00:57:46,Temp=4.375002,Fuktighet=47.377159,Trykk=1015.114258,Lys=4.516129
nyktertest1.txt,01-01-00I01:03:01,Temp=4.157896,Fuktighet=46.929855,Trykk=1015.123535,Lys=4.516129
nyktertest1.txt,01-01-00I01:08:15,Temp=4.013159,Fuktighet=46.194218,Trykk=1015.161133,Lys=3.870968
nyktertest1.txt,01-01-00I01:13:29,Temp=3.832237,Fuktighet=45.754311,Trykk=1015.314209,Lys=3.870968
nyktertest1.txt,01-01-00I01:18:43,Temp=3.705593,Fuktighet=45.044548,Trykk=1015.297852,Lys=3.870968
nyktertest1.txt,01-01-00I01:23:57,Temp=3.560856,Fuktighet=44.948437,Trykk=1015.371582,Lys=3.870968
nyktertest1.txt,01-01-00I01:29:11,Temp=3.416119,Fuktighet=44.164742,Trykk=1015.308350,Lys=3.870968
nyktertest1.txt,01-01-00I01:34:25,Temp=3.307568,Fuktighet=43.883793,Trykk=1015.287842,Lys=3.870968
nyktertest1.txt,01-01-00I01:39:39,Temp=3.307568,Fuktighet=43.458672,Trykk=1015.299072,Lys=3.870968
nyktertest1.txt,01-01-00I01:45:10,Temp=3.162830,Fuktighet=42.959621,Trykk=1015.257324,Lys=3.225806
nyktertest1.txt,12-02-23I02:08:19,Temp=3.217106,Fuktighet=42.833935,Trykk=1015.262695,Lys=3.870968
nyktertest1.txt,12-02-23I02:13:33,Temp=3.180922,Fuktighet=42.416210,Trykk=1015.253418,Lys=3.870968
nyktertest1.txt,12-02-23I02:18:49,Temp=3.144737,Fuktighet=42.331184,Trykk=1015.185059,Lys=3.225806
nyktertest1.txt,12-02-23I02:24:03,Temp=2.945724,Fuktighet=42.268341,Trykk=1015.238281,Lys=3.870968
nyktertest1.txt,12-02-23I02:29:18,Temp=2.855265,Fuktighet=41.983696,Trykk=1015.152832,Lys=3.870968
nyktertest1.txt,12-02-23I02:34:32,Temp=2.782896,Fuktighet=42.016968,Trykk=1015.135742,Lys=3.870968

The list goes on until the morning. I was not able to only copy the time column of the datasheet, but you can see the time column on the right side of "nyktertest1.txt" which was the file I was writing the data to at the server. The three numbers on the left represent the date, so 11-02-23 is the 11 of February 2023. And the time is right next to the date, a | was used the separate the time and the date. So the data in the first row was logged at 23:39:40, which would be 11:39:40 PM.
But if you look further down the time column, only the minutes and seconds were logged correctly for a good while. It seems like the RTC values where just zeroed out. But after a while, the time was corrected again.
Here is the function for doing the NTP request:
void request_NTP()
{
    Serial.println("Starting connection to 'no.pool.ntp.org'");

    Udp.begin(localPort);
    sendNTPpacket(); // send an NTP packet to a time server
    // wait to see if a reply is available
    delay(1000);

    if ( Udp.parsePacket() )
    {
    Serial.println("Packet received");
    // We've received a packet, read the data from it
    Udp.read(packetBuffer, NTP_PACKET_SIZE); // read the packet into the buffer

    //the timestamp starts at byte 40 of the received packet and is four bytes,
    // or two words, long. First, esxtract the two words:
    unsigned long highWord = word(packetBuffer[40], packetBuffer[41]);
    unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]);

    // combine the four bytes (two words) into a long integer
    // this is NTP time (seconds since Jan 1 1900):
    unsigned long secsSince1900 = highWord << 16 | lowWord;

    // Unix time starts on Jan 1 1970. In seconds, that's 2208988800
    const unsigned long seventyYears = 2208988800UL;
    // subtract seventy years:
    UNIX_1970 = secsSince1900 - seventyYears;
    Udp.stop();
    Serial.println("UDP Closed");
    }

    else
    {
        Serial.println("No packets where recieved");
        ///Av en eller annen grunn vil programmet stoppe her dersom en kun lukker UDP tilkoblingen
        Udp.stop();
        Serial.println("UDP Closed");
        Serial.println("Trying again..");
        delay(2000);
        request_NTP();
    }
}

This is the sendNTPpacket() function which was used in the request_NTP() function above:
void sendNTPpacket()
{
    //Serial.println("1");
    // set all bytes in the buffer to 0
    memset(packetBuffer, 0, NTP_PACKET_SIZE);
    // Initialize values needed to form NTP request
    // (see URL above for details on the packets)
    //Serial.println("2");
    packetBuffer[0] = 0b11100011;   // LI, Version, Mode
    packetBuffer[1] = 0;     // Stratum, or type of clock
    packetBuffer[2] = 6;     // Polling Interval
    packetBuffer[3] = 0xEC;  // Peer Clock Precision
    // 8 bytes of zero for Root Delay & Root Dispersion
    packetBuffer[12]  = 49;
    packetBuffer[13]  = 0x4E;
    packetBuffer[14]  = 49;
    packetBuffer[15]  = 52;

    // all NTP fields have been given values, now
    // you can send a packet requesting a timestamp:
    Udp.beginPacket(NTP_server, NTP_port); //NTP requests are to port 123

    Udp.write(packetBuffer, NTP_PACKET_SIZE);
    Udp.endPacket();
    delay(1000);
}

This is the function for adjusting the UNIX time to my own timezone:
void timezone_adjustment()
{
    TimeChangeRule NoCET = {"CET", Fourth, Sun, Oct, 3, +60};
    TimeChangeRule NoCEST = {"CEST", Fourth, Sun, Mar, 2, +120};
    Timezone Norway(NoCET, NoCEST);
    UNIX_adjusted_No = Norway.toLocal(UNIX_1970);
}

This is the function for setting up the RTC:
void set_RTC()
{
    const int RTC_second = second(UNIX_adjusted_No);
    const int RTC_minute = minute(UNIX_adjusted_No);
    const int RTC_hour = hour(UNIX_adjusted_No);
    const int RTC_day = day(UNIX_adjusted_No);
    const int RTC_month = month(UNIX_adjusted_No);
    const int RTC_year = year(UNIX_adjusted_No)%100;

    /// Starter RTC klokken
    rtc.begin();
    //rtc.setTime(RTC_hour, RTC_minute, RTC_second);
    //rtc.setDate(RTC_day, RTC_month, RTC_year);
    rtc.setYear(RTC_year);
    rtc.setMonth(RTC_month);
    rtc.setDay(RTC_day);
    rtc.setHours(RTC_hour);
    rtc.setMinutes(RTC_minute);
    rtc.setSeconds(RTC_second);
}

And this is the buffer being sent to the server:
sprintf(buffer,"/cgi-bin/tof.cgi?nyktertest1.txt,%02d-%02d-%02dI%02d:%02d:%02d,VannTemp=%lf,LuftTemp=%lf,Fuktighet=%lf,Trykk=%lf,Lys=%lf",rtc.getDay(),rtc.getMonth(),rtc.getYear(),rtc.getHours(),rtc.getMinutes(),rtc.getSeconds(),water_temp,air_temp,humidity,pressure,illuminance);

I don't think the RTC is just half its values. I think the watchdog might have bit on the third loop, meaning the program had to do an NTP request at startup to initialize the RTC. But the UNIX time was not successfully received from the server, so the RTC was initialized with all clock values being 0. The program continued to log for a couple of cycles as you can see on the datasheet. But then the watchdog bit again and the circuit was reset. But the NTP request was done successfully this time, and therefore the time was logged correctly until the morning when I picked it up.
This is only my theory though and I am not sure of it. What to you think is happening? And what would be a fix?
Another problem that I noticed in the morning was that the RTC seemed to be lagging over 5 minutes behind the real-time. Is this a normal issue with the SAMD21 RTC? Because im planning to eventually have this Arduino log data for weeks or months without me touching it. Having the clock fall behind after longer time periods would then be a huge problem.
Edit:
Under is the write_to_server() function:
void write_to_NTNU_server()
{
    Serial.println("Sending the buffer");
    char buffer[256] = {};
    client.print("GET ");
    sprintf(buffer,"/cgi-bin/tof.cgi?nyktertest1.txt,%02d-%02d-%02dI%02d:%02d:%02d,VannTemp=%lf,LuftTemp=%lf,Fuktighet=%lf,Trykk=%lf,Lys=%lf",rtc.getDay(),rtc.getMonth(),rtc.getYear(),rtc.getHours(),rtc.getMinutes(),rtc.getSeconds(),water_temp,air_temp,humidity,pressure,illuminance);
    Serial.println(buffer);
    client.print(buffer);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(NTNU_server);

    client.println("Connection: close");
    client.println();
    Serial.println("Buffer sent");
}

Here is the code for creating the client object from the NBClient class:
NBClient client;

always format all printout as code

please reduce your program to the simplest code that exhibits to problem

Thank you for the tips. I thought all of the code I pasted could give information about the source of the problem. But I will try to reduce it.

that is how code debugging works ... remove parts of the code that may not be causing the problem and test

It looks like Udp.parsePacket() returns the packet size. An incorrect size could give incorrect results. Can you please check that the correct packet size arrives?

Can you post the code for write_to_server which appears to be the code that actually writes the incorrect data?

comment out all of the code in loop() that deals with the database server ... use serial monitor to determine program flow ... add a lot of debugging code to print to serial

I added the write_to_server() code @nick Gammon

what board name shows the Arduino IDE when the MKR is in bootloader mode (after double reset)? If the board got for some reason a Nano IoT bootloader it would be configured as crystalless and not use the external crystal. the RTC on Nano IoT drifts as you describe because it doesn't have the external crystal.

As long as Udp.parsepacket() retrieves a packet the condition will be true (since the packet must have a size) and the code should function as normal, no matter the size of the packet. But if the packet is not retrieved the statement will return 0. And request_NTP() will be called again. So it cant be the specific size of the packet which is the problem (I think so at least).

The board type in the tools section stays as MKR NB 1500 when resetting the board Juraj. But I don't know if that's what you were talking about.


text:
Arduino IDE for ESP32: Compilation Error: Exist status 255
Problem:
I have a ESP32 and I've been trying to flash it with the Arduino IDE, however it's been giving me Python error messages :/ when I'm trying C/C++ code to flash the Arduino.
Question:
How can I setup the board below so I can flashi it with C/C++ from the Arduino IDE?
Error Message:
  [6909] Error loading Python lib '/var/folders/wm/_tds7_0s6_j9587rbm54nfv00000gn/T/_MEIli4AzL/libpython3.8.dylib': dlopen: dlopen(/var/folders/wm/_tds7_0s6_j9587rbm54nfv00000gn/T/_MEIli4AzL/libpython3.8.dylib, 10): Symbol not found: ____chkstk_darwin
  Referenced from: /var/folders/wm/_tds7_0s6_j9587rbm54nfv00000gn/T/_MEIli4AzL/libintl.8.dylib (which was built for Mac OS X 11.0)
  Expected in: /usr/lib/libSystem.B.dylib
  in /var/folders/wm/_tds7_0s6_j9587rbm54nfv00000gn/T/_MEIli4AzL/libintl.8.dylib

  exit status 255

  Compilation error: exit status 255

ESP32:

References Used/Due Diligence:

Installing the ESP32 Board in Arduino IDE (Windows, Mac OS X, Linux)
Getting Started with the ESP32 Development Board
ESP32 Bluetooth Classic with Arduino IDE – Getting Started

Version Numbers:

MAC OS Version: macOS High Sierra Version 10.13.6

Arduino Version: Version 2.0.4-nightly-20230119 CLI Version: 0.29.0

The error message says "...Mac OS X 11.0...". Is that the version of OS X you are using? Can you tell us what version of the IDE you are using?

Appended into the Question: macOS High Sierra Version 10.13.6; Arduino Version: Version 2.0.4-nightly-20230119 and CLI Version: 0.29.0

@VE7JRO I've updated the question with the version numbers.

And what do you conclude? The library was built for 11.0 but you have 10.13... Did you try to use a version of the Arduino IDE for your OS?

You might want to re-read the referenced tutorials. Disclaimer: I don't have a Mac and no ESP32 at hand, but know a bit about general computer science and used the Arduino IDE for different targets.

I don't have Mac but I am working on Linux and I also had issues with Arduino IDE v2 (in the past). Because of this I'm still using IDE v1 with no issues and that's my suggestion: try older version of the IDE on your mac, you can still download it. If it won't work you can turn to PlatformIO or VSCode IDEs.


text:
adc arduino using reference voltage to read stable/constant lithium battery voltage

I want to read my lithium battery voltage.

I WANT TO CREATE A FUNCTION TO READ MY 3.7~4.2V,1200mAH BATTERY VOLTAGE THROUGH A MICROCONTROLLER (ARDUINO OR ATTINY44).

THEN I WANT TO CALL THE CREATED BATTERY FUNCTION IN THE FORMULA TO READ PRECISE SENSOR VALUE
 int voltage = ((CALLING BATTERY FUNCTION) * (READ SENSOR VALUE)) / 1023;

I AM USING INTERNAL REFERENCE VOLTAGE 1.1V.
NOTE: I want the whole system to run on lithium battery ( I am just creating a prototype on Arduino, if it works, ill be editing the code for my attiny44 using 8mhz external crystal).
 void setup(){
   Serial.begin (115200);
 }

 void loop() {
   //REFS1 AND REFS0 to 1 1 -> internal 1.1V refference
   ADMUX |= B11000000;
   //We read A1 (MUX0)
   ADMUX |= B00000001;
   // Start AD conversion
   ADCSRA |= B11000000;
   // Detect end-of-conversion
   while (bit_is_set(ADCSRA,ADSC));
   float val = ADCL | (ADCH << 8);
   val = val * 5.7; //Multiply by the inverse of the divider
   Serial.println(val);
 }

This code is working but it is reading from analog Pin. Is there any possibility to do it without using AnalogPin because I dont have any spare pin on my attiny.

@jsotola Done, Thanks

The answer is probably no. You cannot do anything without using pins. You need a pin to interact through. You cannot interact through thin air. So you need to get a bigger Attiny

okay so you mean that it is impossible to get constant battery output using AREF pin we need analog pin to do that. is that what you mean

You wrote, that you don't have any spare pins. That would mean no AREF pin either. 2. Yes, you need a pin, that can be connected to the ADC, so any pin that is marked that way in the pinout of the Attiny44. If you have AREF free, than you maybe can change the pin connections. Though you didn't specify how the attiny is connected. In your question you show only an Arduino Uno, which seems to be irrelevant for your question.

If your attiny is powered by that same battery, you can just measure internal 1.1V reference against Vcc as ref and compute actual Vcc

@chrisl I meant no spare ADC pin i just have AREF pin free that's it

@KIIV Yes, the system is powered by the same battery. Is it possible to get constant/stable/unchanged voltage by using this method.

or is there a way to use reset pin as GPIO/ADC pin?

You can use reset pin on Attiny84 as digital IO, but not as an analog pin. And you won't be able to reprogram it without bootloader or without high voltage ISP programmer (in that case you'll have to take in account there will be 12V pulses on that pin during programming).

I want the whole system to run on lithium battery

If you power the Arduino from the battery, then you can indirectly read the battery voltage by reading the internal voltage reference. This requires no pins - just connect the battery across the Arduino ground and the 5V pin. Here is more explanation on why this works...
https://wp.josh.com/2014/11/06/battery-fuel-guage-with-zero-parts-and-zero-pins-on-avr/
Note: Do not connect more than 5 volts or less than 0 volts to the 5V Arduino pin. This pin is connected directly to the AVR without any overvoltage or reverse polarity protection. Your  3.7~4.2V battery should be fine.

Hi, thank you for your response. I need to read constant voltage not the current battery voltage and i believe that in the link the author wants to measure battery voltage. Is there a way to measure stable/constant/ unchanged battery voltage irrespective of the current battery level.

You want to (1) power your circuit using a lithium battery, and (2) you want to be able to measure the voltage of that lithium battery that is powering the circuit, correct? If so, then the above approach will do that. If not, then can you clarify what you are trying to do?

hi, please check https://arduino.stackexchange.com/questions/92329/reading-constant-battery-voltage-and-using-the-obtained-value-in-sensor-formula


text:
Communication between two hc 05 Bluetooth modules not working
I Have a problem with the connection between two hc 05 modules. The bluetooth modules are paired using AT commands. But when I run the code I cant get any data from the reciever. The bluetooth modules blink together but no data is displayed in the reciever. This is for a RC car that is controlled by a remote controller.
This is the code for the remote
void setup() {

  Serial.begin(38400);
}

void loop() {
  Serial.write("Hello!");
  delay(1000);
}

I have made sure all the baudrates are 38400 and when I just type the numbers in the serial monitor of the reciver it works fine. I have switched the bluetooth modules but It didn't work either. Boath remote and car has TX - RX and RX - TX wiring.
This is the code of the reciever
int data = 0;

void setup() {

  Serial.begin(38400);
}

void loop() {
  if(Serial.available() > 0){
    data = Serial.read();

    Serial.print(data);
  }
}

I used softwere serial as well but It gave me the same result. The reciever is an arduino mega and the transmitter is an arduino nano
Pls help.
Thank you.

reduce your code to sending and receiving one fixed byte

I tryied that but It didn't work, it didn't receive the data on the reciever. Thanks for the reply!

ok I changed it


text:
How to use reset pin as I/O pin with ATtiny44
I am using the Arduino IDE as an ISP programmer to program my ATtiny44 IC. Unfortunately, I ran out of pins, so I want to use the reset pin as I/O. I read several articles online that says it is possible and even the datasheet says so.

I have a high voltage programmer as well. I wrote the code in the Arduino IDE and then used its hex file to program it using the high voltage programmer (TNM PROGRAMMER).

After I program, the IC stops working.
////////////////////////////////////EDIT/////////////////////////////////////
const int led = 0;
const int reset_led = 11; //physical pin 4 on attiny

// the setup function runs once when you press reset or power the board
void setup() {
    // initialize digital pin LED_BUILTIN as an output.
    pinMode(led, OUTPUT);
    pinMode(reset_led, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
    digitalWrite(reset_led, HIGH);  // turn the LED on (HIGH is the voltage level)
    digitalWrite (led, HIGH);
    delay(1000);                    // wait for a second
    digitalWrite(reset_led, LOW);   // turn the LED off by making the voltage LOW
    digitalWrite(led, LOW);         // turn the LED off by making the voltage LOW
    delay(1000);                    // wait for a second
}

New fuse bit setup:

////////////////////////EDIT 2 /////////////////////////////////////////

Now, the led on reset has turned off completely while the another still blinks.
Powering my attiny44 with 5v.Code is same as before
////////////////////////////////EDIT 3////////////////////////////////////
#include <avr/io.h>
const int led = 0;
#define ledd PB3
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(led, OUTPUT);

DDRB |= (uint8_t)(1<<PB3);
pinMode (ledd, OUTPUT);

}

// the loop function runs over and over again forever
void loop() {

PORTB |= (uint8_t)(1<< PB3);

 digitalWrite (led, HIGH);
  digitalWrite (ledd, HIGH);

 delay(1000);                       // wait for a second

PORTB &= ~((uint8_t)(1 << PB3)); // set PB3 to "low"

 digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
 delay(1000);                       // wait for a second
}

This code worked miraculously for me, Thanks to @thebusybee.
/////////////////////////////EDIT 3/////////////////////////////////////////
The PB3 pin is pin11 in arduino.

It sounds like you found the answer to what you're actually asking. "After i program ( the ic stops working)." The chip executes code irrespective of whether or not the reset function is enabled. So, your problem is elsewhere. I would look at whether or not I was staying out of the brownout detection and pay attention to what I was actually using as indication to determine that it "stops working" and maybe that will lead to a different question.

What do you mean by "stops working"?

If you are powering it by 3.6V (4.2V fully charged) battery, then with 4.3V BOD level it'll be held in reset state all the time (it might work a little if the battery is fully charged and you are lucky to have threshold deviation closer to 4V)

You could enable CKOUT fuse to have PB2 indicate that the clock is going. You appear to be forcing the watchdog timer to run and we're not seeing your code, which leads back to the question of how you're determining "stops working."

@timemage The reset pin is PB3. I have connected one led to the reset pin in order to indicate if it is working

@KIIV Yes, you are right, i did some research on it as well and changed my power to constant 5V but the led on the reset pin did not blink

@thebusybee It means that the led connected to reset pin goes off fully

@timemage As you can read my code above, there are two led on the board, the led on the reset stays on but looks like the voltage or current is extremely low due to which the led brightness is difficult to be seen (this led should be blinking as per the code). I connected the reset pin to potentiometer but the moment i change the value of pot the led connected to pin0 turns OFF or hangs.

Please take the [tour] to learn how this site works. It is not a forum. Please add clarification to your question by [edit]ing it. Down here in the comments it gets lost. -- If the LED on pin 0 stops blinking when you turn the pot's wiper towards GND, I'd say that the pin 11 is still /RESET. That would also explain the "glowing" of the LED at that pin too, because the pin is an input. Are you sure that your fuses are correct?

I am not 100% sure about the fusebits, Please check i have added new picture to the post above under edit @thebusybee The led at reset is also on (without blinking) but the brightness is extremely low

If you are not sure about the fusebits, and the result seems to indicate that RSTDSBL is not set correctly, how can we be sure and help you? ;-) Did you read the device's and the programmer's documentation at least three times to make sure you set the fuses correctly?

@thebusybee If you check above i have added screenshot of latest fuse bit setting. I have been using this HV programmer and attiny for long so I've idea the only new thing is that i have never before used RESET as GPIO. Just to confirm, RESET (PB3) is program pin 11.

As the data sheet () says: "Pullup is activated and output driver and digital input are deactivated when the pin is used as the RESET pin." What you see confirms that RSTDSBL is not programmed.

In my HV programmer there is option Disable Reset Pin (RSTDSBL) and we have two options to select (Yes or No). ofc if we have to disable it we must select "YES" and program it. Right?

Did you try the other option?

Let us continue this discussion in chat.

I believe you meant trying "NO" option. Yes, i did, it didnt workout

"The reset pin is PB3." I have no idea why you said that to me. Did your question get resolved or not?

The data sheet gives insights:
Chapter 1.1.4 states:

The reset pin can also be used as a (weak) I/O pin.

"Weak" means here, that the output function cannot deliver as much current as the other outputs, according to figures 21-24 to 21-27 beginning at page 198 roughly 2 to 3 mA. This is commonly not enough for LEDs, except you use a high-efficiency LED.
And on page 66 is this relevant table (I cut the irrelevant column for PB2):

Table 10-8. Overriding Signals for Alternate Functions in PB[3:2]

Signal Name
PB3/RESET/dW/PCINT11

PUOE
RSTDISBL(1) + DEBUGWIRE_ENABLE(2)

PUOV
1

DDOE
RSTDISBL(1) + DEBUGWIRE_ENABLE(2)

DDOV
DEBUGWIRE_ENABLE(2) • debugWire Transmit

PVOE
RSTDISBL(1) + DEBUGWIRE_ENABLE(2)

PVOV
0

PTOE
0

DIEOE
RSTDISBL(1) + DEBUGWIRE_ENABLE(2) + PCINT11 • PCIE1

DIEOV
DEBUGWIRE_ENABLE(2) + (RSTDISBL(1) • PCINT11 • PCIE1)

DI
dW/PCINT11 Input

AIO

Note:

RSTDISBL is 1 when the Fuse is “0” (Programmed).
DebugWIRE is enabled when DWEN Fuse is programmed and Lock bits are unprogrammed.

Since you have DebugWIRE enabled, this seems to be the cause. The alternate function RESET is still active.
Please be aware that according to note 1 below table 19-4 on page 160:

After programming the RSTDISBL fuse, high-voltage serial programming must be used to change fuses and allow further programming.

This means that your circuit at PB3 needs to withstand the high voltage, and that the voltage source needs to provide enough current, which the circuit additionally draws at the high voltage.

Now to your code.
You use the pin number "0" and hope to have PB3. Well, according to this shamelessly linked pinout this is not correct:

Pin "0" is PA0.
PB3 has no number assigned.
Your next step could be to look up the sources of the Arduino library and check, if PB3 has a number assigned at all. I'm afraid this is not the case. If you're lucky and it has, use it. You will want to tell us about your finding then.
You can directly access the data direction control register and the port register. Grab your data sheet and other documentation, read, and implement.
This is untested:
// in setup():
    DDRB |= (uint8_t)(1U << 3);

// in loop():
    PORTB |= (uint8_t)(1U << 3);    // set PB3 to "high"
    PORTB &= ~((uint8_t)(1U << 3)); // set PB3 to "low"

Yes, i read it and is disabled it but it still did not work for me. After i make debugWire disable the reset led goes full off.

Well, that's a good sign, because now the pin became an output and went "low" (erm, how did you connect the LED?) or at least switched off the pull-up. Does the other LED still blink? -- BTW, your title says 44A but the prose 44. What exactly is it? (Correct your question.)

Oh that's a relief to know! Okay, so i have connected +ive of led directly to reset pin and -ive directly goes to GND of IC. Yes, with the new setup the other led still blinks.

Please add what you tried now to your question, and post the current fuses. If you changed the sketch, please add it, too.

Done, edit 2. The code is same as before reset programmable pin11

Would you mind to clarify which device it is, 44A or 44?

The device is attiny44 not attiny44A. I mentioned in edit2 above

OK, so your title misled me. I have corrected it. Now I need to fetch the other data sheet and to check out the differences. :-( This will need some time, I have some other work to do.

ok.no prob, i checked they are almost the same just some memory size difference is there.

Right. I edited my answer concerning page numbers and such. However, since I don't have an ATtiny44 I cannot check in real. Currently it should work as your fuses are set, I'd say.

ok, i have 44A , i tried with that it still does not work. Please recheck my fusebits the spien, boden or maybe my pin declaration has some issues

See my edit, your code is wrong. I assumed you checked that already. Just a hint: don't program "by random", development is more science than art.

OMG, it is working with your code. Thank you so much, but why do we need to write high and low in that manner, it should work with simple coding as well because in the future i have to declare this pin as one of my antenna pins, how do i do that?  (#define CSN 0)
This command i have to write for PB3. i have to declare CSN PIN of antenna to pb3

Let us continue this discussion in chat.

I have just posted my code above.

If the pin has no number assigned by the Arduino library, you cannot use the common functions. That's what I wrote in my answer. "If you have no legs, you cannot walk." However, you're free to implement your own work-around. -- Please consider to mark the answer as "accepted".

I have accepted. Arduino library has assigned it as pin 11 (PB3 is pin 11) but if we code it, it does not work. I think it is because of the digitalWrite function i will try changing that function and update u tommorow

Not every Arduino model has pin number 11 assigned to PB3, I found multiple different assignments. Make sure you look at the correct model!

I rechecked PB3 is pin 11 for arduino UNO board. I have attached picture above

Sure, the Uno has this. But you use a ATtiny44, the Uno has the ATmega328P.

ATtiny44 also declared reset pin as pin11 but if you code it that way it is always rejected. (#define CSN 2 ) this is my antenna pin which i want to shift to the reset pin. i can use avr language to it but how do i declare it.

No, according to the pinout, "RESET" has no pin number assigned for the ATtiny44. Where did you find that? -- Since the programming issue is another beast, feel free to post a new question. You might want to add a link to that in your question.

Ok i will create new link

https://arduino.stackexchange.com/questions/92300/how-to-declare-pb3-reset-pin-or-attiny44-in-program-using-arduino-ide-platform


text:
Nano RP2040 Connect with Wired Ethernet. Do I lose IoT functionality and OTA updates? Any suggestions?
So, we have a project that is developing nicely on the RP2040, and currently uses WiFi. However, a new use-case is emerging where it may need to be in a noisy industrial environment. As such it makes sense for it to be physically connected (ethernet) rather than wifi (industrial environments can be very noisy, and not every factory has a full high quality wifi).
I know there are SPI modules such as a board based on the W5500 chipset, but they beg questions:

will I lose the IoT and OTA update capability this way?
Can I get PoE via a module as well, so my customers have an easier installation?
The RP2040 is an ideal unit for us - IoT and OTA updates, with huge flash as well, so I'm not sure there's a sensible alternative (unless anyone can suggest one!). Everything else we need is in the arduino libraries as well, so that is also a great fit for us.

lose IoT functionality ... what does this mean?


text:
UART SERCOM on Pins 11-13 Arduino M0 (SAMD21)
I am a newb at coding. Does anyone have any code laying around or some time to write some to send data over UART SERCOM on pins 11/12/13 on a SAMD21 board like the Arduino M0? I am trying to send a double from my LightAPRS W-2 board but can't use I2C and this is my only option.

why is your time more valuable than anyone else's time? ... what is preventing you from doing reasearch and trying to write your own code? ... there are many examples and tutorials available about Arduino serial communication ... please make an attempt to write the code and post the result of your effort ... describe any problems you are seeing and copy/paste errors here

See https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports/creating-a-new-serial


text:
Button Matrix / Wiring Schematics
I am just beginning my journey into the Arduino world - plenty of development experience, but basically nothing with electronics outside of building computers.
The question I have involves wiring schematics - specifically for a button matrix, but it does apply more broadly. Using this diagram and Fritzing mapping, I see numerous buttons connected to each other - presumably via soldering:

My question is, can you use wire nuts (or, more specifically multi-slot lever connectors) such as these to simplify the connection process?

I apologize in advance if this seems obvious, but I get lost trying to understand how to connect this stuff because I'm so new to it all.
Thanks in advance!

that keypad can only detect one button press at a time ... if you press two buttons at once, then up to four button presses can be detected ... a diode at each switch can be used to prevent "ghost" button presses

Woah - good to know @jstola! I'm going to start looking into diodes now. So much to learn, but luckily this first project is mainly for a button/busy box for my 18-month old kid, so he's going to smash all the buttons and not care as much on whether they do everything individually or not. Definitely an excellent tip though!

if you are expecting to press only one button at a time, then you can use a resistor array ... the input to the arduino would be a single wire connected to an analog input pin

Yet another thing I didn't know existed! This would make wiring SO much easier by not having to deal with so many individual resistors. If I could give you points on here, I totally would. Thank you!!

Assuming that "multi-slot lever connectors" is shorting the inserted wires together I see no reason why you could not use them.
If you are adverse to soldering consider using switches and cables commonly found in arcade machines instead.
Previously crimped cables ...

And arcade style micro switches ...

Can be combined / connected to form the switch matrix your designed above.

Fantastic - I didn't even know these existed. Thank you!