text:
Is it possible to use assembly with arduino?
I want to learn assembly, but would like to learn by doing, is it possible to learn and make something useful with arduino hardware? I dont know where or how to start something like this.

yes it is very possible ... you can write same kind of code as the C++ compiler generates

Which Arduino? The assembly language/instruction set is dependent on the microcontroller family.
At least some of the C++ compilers used in Arduino toolchains allow you to include inline assembly code.

What do you want to reach in the end? Assembly is hardware-dependent, so if you know learn how to program an Arduino uno using assembly, that will help you only to a very small degree if you later want to program Intel CPUs in assembly.

I suggest the ARV libC project as a starting point to HOW to get assmbler code running. And the AVR Instruction Set Manual to get hold of the actual assembler mnemonics.
Maybe also my own AVR Assembly Project might be a helpful starting point with its code available on GitHub.


text:
Using Software Serial on Arduino Mega
So Im using this sensor:
https://wiki.dfrobot.com/Serial_6_Axis_Accelerometer_SKU_SEN0386 with this library https://github.com/DFRobotdl/DFRobot_WT61PC
Im using 2 sensors but got poor frequency on Arduino Uno and decicded to switch to Mega since it supports multiple communications at once.
This code works perfectly fine on Uno, but doesnt on Mega. Of course I tried using this method: https://docs.arduino.cc/built-in-examples/communication/MultiSerialMega and I know I shouldnt be using Software Serial on Mega but this library has been written using Software Serial and I cant use a different method (or at least thats how I understand it).
Here is the reason.
SoftwareSerial mySerial(10, 11);
DFRobot_WT61PC sensor(&mySerial);

So I tried multiple variations of pins (ones supporting UART, pcint, TX/RX) https://docs.arduino.cc/learn/built-in-libraries/software-serial and nothing seems to we working. Also tried removing the SD card reader, tried the original example code. I also tried Hardware Serial as it should be but again, it doesnt support this sensor and ends up resulting in errors(or vice versa). Nothing.
Here is the working Uno code:
#include <DFRobot_WT61PC.h>
#include <SoftwareSerial.h>
#include <SPI.h>
#include <SD.h>

#define FILE_BASE_NAME "Pomiar"
#define VCC2 7

const uint8_t CS_PIN = 4;

SoftwareSerial mySerial(2, 3);
SoftwareSerial mySerial2(5, 6);
DFRobot_WT61PC sensor(&mySerial);
DFRobot_WT61PC sensor2(&mySerial2);

File myFile;
File file;

const uint8_t BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1;
char fileName[] = FILE_BASE_NAME "00.txt";

void setup()
{

  pinMode(VCC2,OUTPUT);
  digitalWrite(VCC2,HIGH);

  //Use Serial as debugging serial port
  Serial.begin(9600);
  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");

  while (SD.exists(fileName)) {
    if (fileName[BASE_NAME_SIZE + 1] != '9') {
      fileName[BASE_NAME_SIZE + 1]++;
    } else if (fileName[BASE_NAME_SIZE] != '9') {
      fileName[BASE_NAME_SIZE + 1] = '0';
      fileName[BASE_NAME_SIZE]++;
    } else {
      Serial.println(F("Can't create file name"));
      return;
    }
  }

  //Use software serial port mySerial as communication seiral port
  mySerial.begin(9600);
  mySerial2.begin(9600);
  //Revise the data output frequncy of sensor FREQUENCY_0_1HZ for 0.1Hz, FREQUENCY_0_5HZ for 0.5Hz, FREQUENCY_1HZ for 1Hz, FREQUENCY_2HZ for 2Hz,
  //                        FREQUENCY_5HZ for 5Hz, FREQUENCY_10HZ for 10Hz, FREQUENCY_20HZ for 20Hz, FREQUENCY_50HZ for 50Hz,
  //                        FREQUENCY_100HZ for 100Hz, FREQUENCY_125HZ for 125Hz, FREQUENCY_200HZ for 200Hz.
  sensor.modifyFrequency(FREQUENCY_10HZ);
  sensor2.modifyFrequency(FREQUENCY_10HZ);
}

void loop()
{

  long timestamp = millis();

  float acc1;
  float acc2 ;
  float acc3 ;
  float gyro1 ;
  float gyro2 ;
  float gyro3;
  float angle1;
  float angle2;
  float angle3;

  float acc12 ;
  float acc22 ;
  float acc32 ;
  float gyro12;
  float gyro22 ;
  float gyro32 ;
  float angle12 ;
  float angle22;
  float angle32;

  mySerial.listen();
  if (sensor.available()) {

    acc1 = sensor.Acc.X;
    acc2 = sensor.Acc.Y;
    acc3 = sensor.Acc.Z;
    gyro1 = sensor.Gyro.X;
    gyro2 = sensor.Gyro.Y;
    gyro3 = sensor.Gyro.Z;
    angle1 = sensor.Angle.X;
    angle2 = sensor.Angle.Y;
    angle3 = sensor.Angle.Z;

  }

  mySerial2.listen();
  if (sensor2.available()) {

    acc12 = sensor2.Acc.X;
    acc22 = sensor2.Acc.Y;
    acc32 = sensor2.Acc.Z;
    gyro12 = sensor2.Gyro.X;
    gyro22 = sensor2.Gyro.Y;
    gyro32 = sensor2.Gyro.Z;
    angle12 = sensor2.Angle.X;
    angle22 = sensor2.Angle.Y;
    angle32 = sensor2.Angle.Z;

  }

  myFile = SD.open(fileName, FILE_WRITE);

  if (myFile) {
    myFile.print(timestamp);
    myFile.print("|");
    myFile.print(acc1);
    myFile.print("|");
    myFile.print(acc2);
    myFile.print("|");
    myFile.print(acc3);
    myFile.print("|");
    myFile.print(gyro1);
    myFile.print("|");
    myFile.print(gyro2);
    myFile.print("|");
    myFile.print(gyro3);
    myFile.print("|");
    myFile.print(angle1);
    myFile.print("|");
    myFile.print(angle2);
    myFile.print("|");
    myFile.print(angle3);
    myFile.println("");

    myFile.print(timestamp);
    myFile.print("|");
    myFile.print(acc12);
    myFile.print("|");
    myFile.print(acc22);
    myFile.print("|");
    myFile.print(acc32);
    myFile.print("|");
    myFile.print(gyro12);
    myFile.print("|");
    myFile.print(gyro22);
    myFile.print("|");
    myFile.print(gyro32);
    myFile.print("|");
    myFile.print(angle12);
    myFile.print("|");
    myFile.print(angle22);
    myFile.print("|");
    myFile.print(angle32);
    myFile.println("");

    myFile.close();
  } else {
    Serial.println("error opening test.txt");
  }
}

I also found this question: Arduino Mega 2560 SoftwareSerial Not Working.
The guy has exact problem as I do but nooone found a solution to it.
I also want to note that the manufacturer states that this library and sensor works fine on Mega. Really need your help.
cheers
@edit
So I did some tests and the only code that actually shows something in monitor is:
#include <DFRobot_WT61PC.h>

DFRobot_WT61PC sensor(&Serial);

void setup()
{
  //Use Serial as debugging serial port

  //Use software serial port mySerial as communication seiral port
  Serial.begin(9600);
  sensor.modifyFrequency(FREQUENCY_10HZ);
}

void loop()
{
  if (sensor.available()) {
    Serial.print("Acc\t"); Serial.print(sensor.Acc.X); Serial.print("\t"); Serial.print(sensor.Acc.Y); Serial.print("\t"); Serial.println(sensor.Acc.Z); //acceleration information of X,Y,Z
    Serial.print("Gyro\t"); Serial.print(sensor.Gyro.X); Serial.print("\t"); Serial.print(sensor.Gyro.Y); Serial.print("\t"); Serial.println(sensor.Gyro.Z); //angular velocity information of X,Y,Z
    Serial.print("Angle\t"); Serial.print(sensor.Angle.X); Serial.print("\t"); Serial.print(sensor.Angle.Y); Serial.print("\t"); Serial.println(sensor.Angle.Z); //angle information of X, Y, Z
    Serial.println(" ");
  }
}

But as you see the output is corrupted.

When you can provide a serial instance to the library to use, then it is not written for SoftwareSerial only. Please show how you tried with HardwareSerial and the resulting errors

Quoted from SoftwareSerial Library, "Not all pins on the Mega and Mega 2560 boards support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69)", your code not using those pins.

@hcheung I tried them, the code I provided working code for uno so there is proof I didnt make a mistake anywhere

Also I took a look at the library you mentioned, there is no reason why HardwareSerial not work, if it is causing errors, it is something else, probably not instantiates the Serial1 or Serail2 correctly.

If you have problem in Mega, shows the code that doesn't work in Mega, not the code that work in Uno.

@hcheung How can I initialize serial when I first need to initialize my sensor? And providing Hardware serial to the DFRobot_WT61PC sensor(&mySerial); function causes errors

Show the code that doesn't work, not the code that works. How will that help?

Well the code that isn't working is exactly the same @NickGammon

How is the sensor connected to the Mega?

As hcheung said SoftwareSerial on the Mega does not support pins 2, 3, 5, 6 so I don't see how you can expect it to work.

Which pins should I use then to make it work?

Avoid SoftwareSerial whenever you can. It is very fragile: there are so many ways it can break your code... It can be useful on the Uno only because on this board you have little choice. The Mega, however, has four hardware serial ports. SoftwareSerial on the Mega makes no sense at all.

@EdgarBonet how can I use this library then?

@Aivion2000: Use Serial1, Serial2 or Serial3 instead of mySerial.

It's quick and dirty but you can make it Mega compatible by deleting the line #include <SoftwareSerial.h>, and replacing the lines
SoftwareSerial mySerial(2, 3);
SoftwareSerial mySerial2(5, 6);

with
#define mySerial Serial1
#define mySerial Serial2

replacing Serial1 and Serial2 with whichever of the Mega's serial ports you wish to use for mySerial and mySerial2, and connecting your DFRobot sensor signals to the correct pins for your chosen hardware serial ports.

Thx king it worked, also we connected tx to rx and rx to tx. We don't know why it's working, but it is.

There are three fairly major issues in your code:

The Mega does not support SoftwareSerial on pins 2, 3, 5, 6 because those pins do not support change interrupts. Thus it simply can't work on those pins. This itself is a show-stopper.

Your code to read data is flawed. You test if a single byte is available (sensor.available()) and then proceed to read 9 bytes. There is no guarantee that 8 of them are actually there.

I'm confused about what you are doing in your second block of code. You are telling the sensor library to get its data from Serial, which is where you type stuff. All that would do is echo what you type, bearing in mind my point directly above.

I used an example from this library, I changed nothing in the code, just the way I initialize the sensor. I don't know how to use the sensor.available differently.

there are always 9 bytes comming out of the sensor, we tested it on Uno and it worked perfectly, why would the sensor work differently on Mega?

The bytes don't come out instantly. They take time. If you check for 1 byte then you can't guarantee that 9 bytes have arrived. Try changing to if (sensor.available() >= 9).

why would the sensor work differently on Mega - because it doesn't support those pins. How many times do we need to make this point?

You are ignoring the most likely explanation for your problem.

But I tried every possible pin combination, not only 2,3 or 5,6.

You said "Well the code that isn't working is exactly the same" - not exactly, if you tried different pin combinations, eh? Show code that uses supported pins.

source: Stack Exchange

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

sort: votes


text:
Why doesn't serial communication work on Arduino Uno r3 and ESP8266 WiFi module?
I have a simple problem here. I use an ESP8266 WiFi module and an Arduino Uno r3.
What I want is to receive a serial message from the ESP8266 on the Arduino Uno.
Note: I set the upload speed of the ESP8266 to 9600.
void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.write("hello friend");
  delay(2000);
}

Arduino Uno:
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); //rx, tx

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
}

String message = "";
boolean check = false;

void loop() {
  Serial.println(mySerial.available());
  mySerial.println("hindi nagagana");
  while (mySerial.available() > 0) {
    Serial.println(mySerial.readString());
    check = true;
  }

  if (check == true) {
    Serial.println(message);
  }

  delay(200);
}

Or any idea on how to control the Arduino Uno via the internet, such as a simple LED blink?
I used Firebase for databases an I plan to use ReactJs for webApp/Native App (nodeJs).

you print the empty String message forever once something is received on mySerial

Are you sure you have tx connected to rx and vice versa?  You could use the serial monitor to test each half in isolation.

i think you should change Serial.write() to Serial.print() because Serial.write() is for send data as bytes or series of bytes and Serial.print() send as human-readable text.
Reference:
Serial.write()
https://www.arduino.cc/reference/en/language/functions/communication/serial/write/
Serial.print()
https://www.arduino.cc/reference/en/language/functions/communication/serial/print/
esp 8266 code:
void setup()
{
 Serial.begin(9600);
}
void loop(){
    Serial.print("hello friend");
    delay(2000);

 }

Hi thank you for answering my question it really help but the thing is , its not working T_T is there any library or board installation do i need to install?? Im ran out of google stuff on the internet

write and print are same for string

Can you add your wiring diagram into question?

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


text:
LED blink patterns with multiple LEDs with millis() not using Delay()
I want to make LED blink patterns with multiple LEDs with the millis() function. I researched about it but did not find a perfect solution.
I found one blog, but it is using a LED pin number array; I need a solution without an array. Any help will be appreciated.
This is my code which I have written:
const int Button_code_1 = 2;
const int Button_code_2 = 3;
const int Button_code_stop = 4;

const int LED_one = 6;
const int LED_two = 8;
const int LED_three = 10;
const int LED_four = 12;

int buttonState_code_1 = 0;
int buttonState_code_2 = 0;
int buttonState_code_stop = 0;

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

  Serial.begin(9600);

  pinMode(Button_code_1,INPUT);
  pinMode(Button_code_2,INPUT);
  pinMode(Button_code_stop,INPUT);

  pinMode(LED_Button_one,INPUT);
  pinMode(LED_Button_two,INPUT);
  pinMode(LED_Button_three,INPUT);
  pinMode(LED_Button_four,INPUT);

  pinMode(LED_one, OUTPUT);
  pinMode(LED_two, OUTPUT);
  pinMode(LED_three, OUTPUT);
  pinMode(LED_four, OUTPUT);
}

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

  buttonState_code_1 = digitalRead(Button_code_1);
  Serial.println(buttonState_code_1);
  buttonState_code_2 = digitalRead(Button_code_2);
  Serial.println(buttonState_code_2);
  delay(1000);
  buttonState_code_stop = digitalRead(Button_code_stop);

  if(buttonState_code_1==1)
  {
    pattern_one();
  }
  if(buttonState_code_2==1)
  {
    pattern_two();
  }

}

void pattern_one()
{
  digitalWrite(LED_one, LOW);
  digitalWrite(LED_two, HIGH);
  digitalWrite(LED_three, LOW);
  digitalWrite(LED_four, LOW);
  delay(3000);
  digitalWrite(LED_one, LOW);
  digitalWrite(LED_two, LOW);
  digitalWrite(LED_three, LOW);
  digitalWrite(LED_four, HIGH);
  delay(3000);
  digitalWrite(LED_one, HIGH);
  digitalWrite(LED_two, LOW);
  digitalWrite(LED_three, LOW);
  digitalWrite(LED_four, LOW);
  delay(3000);
  digitalWrite(LED_one, LOW);
  digitalWrite(LED_two, LOW);
  digitalWrite(LED_three, HIGH);
  digitalWrite(LED_four, LOW);
  delay(3000);
}

void pattern_two()
{
  digitalWrite(LED_one, HIGH);
  digitalWrite(LED_two, LOW);
  digitalWrite(LED_three, LOW);
  digitalWrite(LED_four, LOW);
  delay(3000);
  digitalWrite(LED_one, LOW);
  digitalWrite(LED_two, LOW);
  digitalWrite(LED_three, HIGH);
  digitalWrite(LED_four, LOW);
  delay(3000);
  digitalWrite(LED_one, LOW);
  digitalWrite(LED_two, HIGH);
  digitalWrite(LED_three, LOW);
  digitalWrite(LED_four, LOW);
  delay(3000);
  digitalWrite(LED_one, LOW);
  digitalWrite(LED_two, LOW);
  digitalWrite(LED_three, LOW);
  digitalWrite(LED_four, HIGH);
  delay(3000);
}

This is my sample code with four LEDs. I have written this code with delay(), so when I want to change the pattern I can't because delay() is blocking the code.
I researched this and found the millis() function as the solution. How can I implement this code using the millis() function?

Why without an array? Thats a weird requirement. Is it for a school exercise? 2. You didn't give us enough information to help you. What exactly is your goal and what is your problem in inplementing it

I have 9 LEDs and i need to blink one after another with delay of 3s and i have 2 different blink patterns and two buttons to select the pattern and one button to stop the program. so for using different patterns i want that it should not be array otherwise if i will get more patterns then i should take more array one for each pattern.Hope it clears the query

So your pattern are just which LED lights up next and the durations are always the same? Then what is so bad with one array for each pattern, or better one array of arrays (2 dimensional array)? Still seems to be an easy approach. With the 2 dimensional array you can write it in a way that adding a pattern is just adding another pattern to the array.

Please put all the information into the question by editing it. Also please describe in detail where exactly you are stuck. What is the actual problem? What exactly is it that you don't understand. Then we can write a good answer fitting your question

I have edited my question.

This is one of the effects for 3 (sets) of LEDs from my light alarm clock sketch:
void cycleEffect() {

  static unsigned long previousMillis;
  static uint8_t cycleCounter;

  if (millis() - previousMillis > 100) {
    previousMillis = millis();
    digitalWrite(LEDS_CENTRAL_PIN, cycleCounter == 0);
    digitalWrite(LEDS_LEFT_PIN, cycleCounter == 1);
    digitalWrite(LEDS_RIGHT_PIN, cycleCounter == 2);
    cycleCounter++;
    if (cycleCounter == 3) {
      cycleCounter = 0;
    }
  }
}

@Juray: you can replace the last three lines by a more common way to do this: cycleCounter = (cycleCounter + 1) % 3 (although I just realize this might be when performance is more important)


text:
HTTP POST maximum speed at command SIMCom A7672
I'm trying to build a device for my startup IoT-related, using an A7672S.
Here is the code:
mySerial.println("AT+HTTPINIT";
checkresponse("OK\r\n");

mySerial.println("AT+HTTPPARA=\"URL\",\"http://" + host + resources + "\"");
checkresponse("OK\r\n");

mySerial.println("AT+HTTPPARA=\"CONTENT\",\"application/json\"");
checkresponse("OK\r\n");

String st = "AT+HTTPDATA=";
int pdl = postdata.length();
st += String(pdl);
st += ",15000";
mySerial.println(st);
checkresponse("DOWNLOAD");

mySerial.println(postdata);
checkresponse("OK\r\n");

mySerial.println("AT+HTTPACTION=1");
checkresponse("+HTTPACTION: 1,200");

if (BuildINString2.indexOf("+HTTPACTION: 1,200") != -1) {
  Serial.println("POST DONE");
} else
  Serial.print("ERROR POST: ");
  Serial.println(BuildINString2);
}

mySerial.println("AT+HTTPTERM");
checkresponse("OK\r\n");

// In the check function, we pass the check variable to check different possible responses of sim like ok, error, etc

void checkresponse(String check) {
  int start = millis();
  BuildINString2="";
  while (true) {
    if (mySerial.available() > 0) {
      inData =mySerial.read();
      BuildINString2 = BuildINString2 + char(inData);
    }

    if (BuildINString2.indexOf(check)! = -1) {
      delay(100);
      return;
    }

    if (millis()-start > 3000) {
      delay(100);
      Serial.println("SIM TIMEOUT");
      return;
    }
  }
}

How can we speed up the POST time? Because in my last module (SIM7600), I used CHTTPACTION which was POSTing in less than 500 ms, but on the A7672s, it's taking more than 1 s.
Can someone confirm possible issues or any other method for the fast posting of data?
Also, in this HTTP method, is HTTPTERM required for every POST or change in URL point or when it's required?

your code does not compile

It's unclear whether the part that you're asking about is the collection of statements (takes over a second to go over that loop) or whether a specific AT command you send takes over a second (from the MySerial.println to checkmyresponse return). You need to provide some more information for us to be able to help.

takes over a second to go over that loop ( i wrote Data was posting in 1 second in old simmodule, as old sim module - Sim7600 support Chttp action that simA7672 doesn't support so had to use normal HTTP command but not CHTTP so wondering ways to make posting faster if possible)


text:
Arduino IDE EEPROM put() then read() returns different data on ESP32
I'm trying to understand how to read/write a UID struct from miguelbalboa to EEPROM to persist a card ID across system restarts on my ESP32-S3 through the Arduino IDE. I expected Put/Get/Read to be symmetrical but can't seem to prove that. Here's my test program:
/**
 * This is a simple script to experiment with reading and writing MFRC522::Uid
 * structures to eeprom.
 */

#include <MFRC522.h>
#include <EEPROM.h>

#define UID_EEPROM_LOCATION 0
#define EEPROM_SIZE 256

void setup() {

  Serial.begin(115200);   // Initialize serial communications with the PC
  Serial.println("Serial started.");
  EEPROM.begin(EEPROM_SIZE);
  Serial.print("EEPROM started ");
  Serial.println(EEPROM_SIZE);
  printBytesFromEeprom();
  MFRC522::Uid uidToWrite = {
    0x04,
    {B00000000, B10000000, B11100000, B01100000},
    0
  };
  Serial.print("UID Before Write: ");
  printUid(&(uidToWrite));
  storeUidInEeprom(&(uidToWrite));
  printBytesFromEeprom();
  Serial.println("UID was put.");
  MFRC522::Uid uidFromRead;
  readUidFromEeprom(&(uidFromRead));
  printBytesFromEeprom();
  Serial.print("UID from Read: ");
  printUid(&(uidFromRead));
}

void loop() {
}

void printUid(MFRC522::Uid *uid) {
  Serial.print(uid->size, HEX);
  Serial.print(F(" byte card UID:"));
  for (byte i = 0; i < uid->size; i++) {
    if(uid->uidByte[i] < 0x10)
      Serial.print(F(" 0"));
    else
      Serial.print(F(" "));
    Serial.print(uid->uidByte[i], HEX);
  }
  Serial.println();
}

void readUidFromEeprom(MFRC522::Uid* result) {
  EEPROM.get(UID_EEPROM_LOCATION, result);
  delay(1000);
}

void storeUidInEeprom(MFRC522::Uid *uid) {
  EEPROM.put(UID_EEPROM_LOCATION, uid);
  EEPROM.commit();
  delay(1000);
}

void printBytesFromEeprom() {
  Serial.print("256 bytes from EEPROM: ");
  for (int i = 0; i < 256; i++) {
    byte myByte = EEPROM.read(UID_EEPROM_LOCATION + i);
    if(myByte < 0x10)
      Serial.print(F(" 0"));
    else
      Serial.print(F(" "));
    Serial.print(myByte, HEX);
  }
  Serial.println();
}

I'm an experienced Java developer, but new to C++. I could have made any number of basic errors.
When I run the above on my ESP32-S3-DevKitC-1, I get the following output:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd0108,len:0x43c
load:0x403b6000,len:0xbd0
load:0x403ba000,len:0x29c8
entry 0x403b61d8
Serial started.
EEPROM started 256
256 bytes from EEPROM:  E4 2C CE 3F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
UID Before Write: 4 byte card UID: 00 80 E0 60
256 bytes from EEPROM:  94 2D CE 3F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
UID was put.
256 bytes from EEPROM:  94 2D CE 3F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
UID from Read: C0 byte card UID: 79 CD 3F 00 00 00 00 00 00 00 00 0C FA 3B C7 00 00 00 00 04 00 00 00 4C 2F CE 3F 01 00 00 80 00 00 00 00 F0 2D CE 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2E CE 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

There are two unexpected things from this output:

The output of readUidFromEeprom() is different than the input to storeUidInEeprom()

Any help would be welcome!

readUidFromEeprom(MFRC522::Uid& result)

You wrote:
void readUidFromEeprom(MFRC522::Uid* result) {
  EEPROM.get(UID_EEPROM_LOCATION, result);
  delay(1000);
}

The EEPROM.get() method expects a reference to the variable you are
setting. Here, you are providing a pointer instead. The outcome is
that this call is updating the result local variable (the pointer),
rather than the memory region pointed by it.
You may try this:
void readUidFromEeprom(MFRC522::Uid* result) {
  EEPROM.get(UID_EEPROM_LOCATION, *result);  // notice the `*' operator
  delay(1000);
}

Same thing for EEPROM.put().
Edit: As suggested by Juraj in a comment, it can make more sense to
have readUidFromEeprom() accept a reference rather than a pointer:
void readUidFromEeprom(MFRC522::Uid &result) {
  EEPROM.get(UID_EEPROM_LOCATION, result);
  delay(1000);
}

But then you have to also change the caller:
readUidFromEeprom(uidFromRead);

Well...
I still don't know why the above wasn't working. But if I switch to my own byte encoding in EEPROM (the obvious one that I assumed put() used, then I get the right behavior:
/**
 * This is a simple script to experiment with reading and writing MFRC522::Uid
 * structures to eeprom.
 */

#include <MFRC522.h>
#include <EEPROM.h>

#define UID_EEPROM_LOCATION 0
#define EEPROM_SIZE 256

void setup() {

  Serial.begin(115200);   // Initialize serial communications with the PC
  Serial.println("Serial started.");
  EEPROM.begin(EEPROM_SIZE);
  Serial.print("EEPROM started ");
  Serial.println(EEPROM_SIZE);
  printBytesFromEeprom();
  MFRC522::Uid uidToWrite = {
    0x04,
    {B00000000, B10000000, B11100000, B01100000},
    0
  };
  Serial.print("UID Before Write: ");
  printUid(&(uidToWrite));
  storeUidInEeprom(&(uidToWrite));
  printBytesFromEeprom();
  Serial.println("UID was put.");
  MFRC522::Uid uidFromRead;
  readUidFromEeprom(&(uidFromRead));
  printBytesFromEeprom();
  Serial.print("UID from Read: ");
  printUid(&(uidFromRead));
}

void loop() {
}

void printUid(MFRC522::Uid *uid) {
  Serial.print(uid->size, HEX);
  Serial.print(F(" byte card UID:"));
  for (byte i = 0; i < uid->size; i++) {
    if(uid->uidByte[i] < 0x10)
      Serial.print(F(" 0"));
    else
      Serial.print(F(" "));
    Serial.print(uid->uidByte[i], HEX);
  }
  Serial.println();
}

void readUidFromEeprom(MFRC522::Uid* result) {
  byte uidSize = EEPROM.read(UID_EEPROM_LOCATION);
  for (byte i = 0; i < uidSize; i++) {
    result->uidByte[i] = EEPROM.read(UID_EEPROM_LOCATION + 1 + i);
  }
  byte uidSak = EEPROM.read(UID_EEPROM_LOCATION + 2 + uidSize);
  result->size = uidSize;
  result->sak = uidSak;
}

void storeUidInEeprom(MFRC522::Uid *uid) {
  EEPROM.write(UID_EEPROM_LOCATION, uid->size);
  for (byte i = 0; i < uid->size; i++) {
    EEPROM.write(UID_EEPROM_LOCATION + 1 + i, uid->uidByte[i]);
  }
  EEPROM.write(UID_EEPROM_LOCATION + 2 + uid->size, uid->sak);
  EEPROM.commit();
}

void printBytesFromEeprom() {
  Serial.print("256 bytes from EEPROM: ");
  for (int i = 0; i < 256; i++) {
    byte myByte = EEPROM.read(UID_EEPROM_LOCATION + i);
    if(myByte < 0x10)
      Serial.print(F(" 0"));
    else
      Serial.print(F(" "));
    Serial.print(myByte, HEX);
  }
  Serial.println();
}

And output as expected is:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd0108,len:0x43c
load:0x403b6000,len:0xbd0
load:0x403ba000,len:0x29c8
entry 0x403b61d8
Serial started.
EEPROM started 256
256 bytes from EEPROM:  04 00 80 E0 60 FF 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
UID Before Write: 4 byte card UID: 00 80 E0 60
256 bytes from EEPROM:  04 00 80 E0 60 FF 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
UID was put.
256 bytes from EEPROM:  04 00 80 E0 60 FF 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
UID from Read: 4 byte card UID: 00 80 E0 60

On the ESP23 platform, consider using the Preferences library. EEPROM in arduino-esp32 is emulated using the Preferences library. Might mess up the calls to MFRC522 lib though.
Preferences docs include the API and tutorial.


text:
Using pyFirmata with a 360° servo; how do I stop it?
I am testing out pyFirmata. I have a 360° servo, and know how to change its direction, but I dont't know how to stop it.
What command, like servo.write(), would work to make it stop moving until prompted to move again?

loop through all possible values

The "angle" is the speed, so set it to the angle that means 'don't move' - i.e., the middle.

You'll need to check datasheets for your servos but a PWM value of 1500 microseconds would generally be near neutral / no rotation. Decreasing values less than this should generate increasing speed clockwise. Increasing values greater than neutral should generate increasing speed counter clockwise.
See https://arduino.stackexchange.com/a/88650/71575


text:
How does erasing the EEPROM work?
The datasheet for the ATmega328P contains this table, which describes bits 4 and 5 of EECR:

EEPM1
EEPM0
Programming Time
Operation

0
0
3.4ms
Erase and write in one operation (atomic operation)

0
1
1.8ms
Erase only

1
0
1.8ms
Write only

I'm currently working on some non-blocking EEPROM-handling code and I'm wondering when and how I should erase the EEPROM.

What does erasing do? Does it set one byte to 0x0, or the entire EEPROM?
Should I erase it first whenever I want to write a byte?

If not, why is there an option to erase and write separately?

How do I initiate an erase?

Either the datasheet is rather lacking concerning the EEPROM, or I'm just not finding what I'm looking for. I tried using a search engine, but all results are either about the Arduino EEPROM library or <avr/eeprom.h>, both of which use polling instead of interrupts (and are therefore blocking).

"the datasheet is rather lacking concerning" Hmm, maybe link to the datasheet you're using, because I remember that these things are answered in it, unless you maybe you've wound up with a "summary" and not "complete" datasheet. There are also appnotes about using AVR EEPROM.

I tried using a search engine, but all results are either about the Arduino EEPROM ... don't be searching for arduino eeprom ... don't search for either of those

Your questions are answered in the AVR ATMega328 datasheet.
The procedure for erasing and writing the internal EEPROM is outlined in chapter 7.6 (Register Description).

The Erase operation erases 1 byte (erasing an EEPROM cell sets it to all 1s, i.e. 0xff).
The EEPROM address to be erased/programmed is pointed to by the EEARL and EEARH registers. The value to be programmed into that address is set by the EEDR. Reading a value from EEPROM returns the value in the same EEDR register.
Before writing a new value to the EEPROM, the old value must first be erased. You can do that as two separate actions or one single action. You could also leave the cell deprogrammed (erased) by only erasing it and not programming it again.
You initiate an erase of the EEPROM address pointed to by EEARH/EEARL, by setting EEPM1 to 1, EEPM0 to 0 and setting EEPE to 1 to start the erase operation. Setting EEPM1 and EEPM0 both to 0 will erase and program a new byte in a single operation.

As for making EEPROM writes non-blocking, you could set a (non-blocking) timer for the duration of the write, erase or erase/write operation. According to the datasheet these operations respectively take 1.8, 1.8 and 3.4 ms. Just make sure your code does not access the EEPROM while these operations are taking place.
You could also (non-blocking) periodically poll the EEPE bit until it is cleared, signalling the operation is finished.
The most elegant way, i.m.o. is to make use of the EERIE flag by setting it to 1, which will enable the ATmega to generate an interrupt when the EEPROM operation is finished.

If the new value sets bits to 0 that are 1 in the old value, no erase is necessary. For example, you can write 0x55 into a cell that contains 0xD7 without the need to erase the cell before.

@thebusybee, true, you can generally change an unprogrammed ("1") EEPROM bit to a programmed ("0") bit without erasing the cell. Changing bits from 0 to 1 again does require erasing the cell. This is not unique to the ATmega328 but works for many/most EEPROMs.

I switched to FRAM, 32K x 8 can be gotten for just a few $$$, generally less the imported Arduinos. It is as fast as the Arduino can access it, both read and write. You can use I2C or SPI depending on which unit you buy. There are some very nice libraries for it making it easy to use. It is non volatile, ie does not lost information when power fails. It will support in the range of a trillion memory cycles with no delay when writing or reading it so no blocking. Just a few extra processor cycles because of the SPI or I2C overhead. If you have code already written for the External EEPROM it should work as is but it will have an unneeded delay in it.

Interesting though your answer is, it is a bit like answering someone who is having problems with their Ford, telling them that a Cadillac works better.


text:
How can I use a LCD I2C and a RTC3231 on a Arduino Pro Mini?
On a small project, I have a DS3231 RTC module and a LCD I2C module that I'm trying to connect on a Arduino Pro Mini board. However, both the RTC and LCD require connecting the SDA and SCL to the pins A4 and A5 respectively.
The libraries do not seem to allow changing the connected pins. Why is that? I have other pins available, like A6 and A7, can those be used?

Wow! First question and already downvotes without comments or answer. This is a real nice community! I feel welcome!

I guess, the downvotes are, because you didn't research your problem. you would find that I2C is a bus

SDA and SCL are the lines of the I2C bus. It being a bus means that you can connect multiple devices to it. Each device on an I2C bus has an address. You cann connect both devices on these pins and talk to each device one after another

@Juraj well, I'm asking because I'm researching. Seriously. It's like an employer asking for 5 years experience; someone has to give a guy a chance.

Welcome, I understand where you are coming from, without a background you do not know what to ask. Were were all where you are at one time. I hope this helps.  You need to do some studying on the I2C bus, online tutorials will make it easy. You you will find you can connect over 100 devices to it at one time The SCL and SDA lines go from module to module. Note each module has its own address, sometimes they are selectable. Some modules have pull up resistors, others do not. To keep it interesting the pull up resistors are mostly 10K but that is not a constant.
There are loading rules etc to be careful of if you have long wires or maybe more than three units. You need to add pull ups to each of the two lines (example: 4.7K from SCL to +5) or use something in the 3K range for a 3V3 system. The reason is because the bus has both dominant and recessive states where the recessive is high which the resistor provides. The SCL and SDA output/input on the parts have open collector/open drain outputs so they cannot source anything.
Once you have it hooked up you need to run a program called I2C scan or something like that. If you have wired it correctly it will give you the address of the module, you will probably get two or three as there is the RTC, Memory device and possible a temperature sensor.
The #1 rule is the Arduino A Power Supply it is NOT! A small module or two connected to the 5V out is fine but never connect a motor directly to any arduino you will probably fry the Arduino.
I use Vin and supply it with about 8 volts by using either a Buck or Sepic converter from a 12V 2A or larger supply. I do it this way because I get a more stable voltage on the Arduino because of the extra filtering etc built into the analog regulator section. Real nice when using the A/D, keeps things stable. Were here to help, ask questions any time and do not worry is some over eager person decides to vote you down. Read the guidelines etc and  you will do great.
You can search online for "Arduino RTC" and find a lot of programs with software.

Thank you for this very helpful explanation! I had noticed a drop-down in voltage when connecting a 4 channel multi-function relay module, I already figured to connect it's power source directly to the power source, and NOT on the Arduino! I was not aware of the I2C protocol. I find a lot of the tutorial confusing since there are so many different modules and boards! It'll get clearer with time. Thanks!

Just for fun answer your question in two weeks, you will be surprised at how much you learned. Have fun!


text:
Garbage in serial monitor
I'm revisiting my Arduino stuff (I want to revive Teleinfo shield to monitor closely my power consumption). I just cannot get the thing to work (Teleinfo Shield + Uno Wifi).
When trying to check what's happening this is the kind of Serial Monitor screens that I get.
Any hints on how to solve? It happens with other Uno as well and different versions of IDE.
Thank for any help, the answers I found in different places didn't lead me to a solution.
I tried several baud settings, (same for port and monitor, each time) and sometimes nothing was written, sometimes complete garbage, sometimes as illustrated
The code is the following Teleinfo_Arduino_V0_3E.ino (just added some lines writing to serial to follow progress; and modified Serial.begin accordingly and "shortened" to stay within size limits but it's sending wrong characters ate beginning))
/*
              Datalogger Téléinfo 2 compteurs sur Arduino

              Compteur 1: consommation
              Compteur 2: production solaire en tarif BASE

              Juin 2011:
              v0.2  * passage automatique à l'heure d'été
                      correctif erreur abo BBR
                      modification ecriture sur SD (utilisation de teleinfoFile.print à la place s'une variable STRING
                      qui plante l'Arduino avec les abonnements BBR
              v0.2a * ajout mode sans puissance apparente pour ancien compteur et calcul de celle-ci pour les logiciels d'analyse
              v0.2b * pour Arduino 1.0 (mise à jour de la RTC et utilisation de la librairie SD livrée avec la 1.0)
              v0.2c * modif type de variable pour éviter d'avoir 2 enregistrements à la même minute (surtout sur des proc + rapide)
              v0.3  * détection automatique du type d'abonnement sur le compteur 1
              v0.3a * Fonction de mise à l'heure par l'usb (interface série) en 1200 bauds 7 bits parité pair
                      Procédure:
                      1- carte débranchée, enlevez la pile de son support (pour réinitialiser l'horloge)
                      2- enlevez le cavalier du shield téléinfo
                      3- configurer votre logiciel émulateur de terminal (termite,Hyperterminale...) en 1200 bauds 7 bits parité pair
                      4- mettre sous tension la carte.
                      -- Le programme détectera le reset de l'horloge et vous demandera de rentrer l'heure et la date. --

              v0.3b * Correction bug calcul PAP compteur 2, enregistrement journalier compteur 2
              v0.3c * Triphasé sur compteur 2
              v0.3d * correction bug retour ligne sur compteur 2 (entête fichier)
              v0.3e * Correction bug si pas de compteur 2
*/

#include <SD.h>
#include <SPI.h>
#include <Wire.h>
#include <RTClib.h>

const char version_logiciel[6] = "V0.3e";

// #define echo_USB            //envoie toutes les trames téléinfo sur l'USB
#define message_systeme_USB  //envoie des messages sur l'USB (init SD, heure au demarrage, et echo des erreures)

//*****************************************************************************************
byte inByte = 0;  // caractère entrant téléinfo
char buffteleinfo[21] = "";
byte bufflen = 0;
byte mem_sauv_minute = 1;
byte mem_sauv_journee = 1;
byte num_abo = 0;
byte type_mono_tri[2] = { 0, 0 };
uint8_t presence_teleinfo = 0;  // si signal teleinfo présent
byte presence_PAP = 0;          // si PAP présent
boolean cpt2_present = true;    // mémorisation de la présence du compteur 2
boolean compteursluOK = false;  // pour autoriser l'écriture de valeur sur la SD
boolean mem_affichage_cpt2_present = true;

int ReceptionOctet = 0;            // variable de stockage des octets reçus par port série
unsigned int ReceptionNombre = 0;  // variable de calcul du nombre reçu par port série
byte reg_horloge = 1;
boolean mem_reg_horloge = false;
const uint8_t val_max[6] = { 24, 59, 59, 31, 12, 99 };

// declarations Teleinfo
unsigned int papp = 0;  // Puissance apparente, VA

uint8_t IINST[2][3] = { { 0, 0, 0 }, { 0, 0, 0 } };  // Intensité Instantanée Phase 1, A  (intensité efficace instantanée) ou 1 phase en monophasé

unsigned long INDEX1 = 0;  // Index option Tempo - Heures Creuses Jours Bleus, Wh
unsigned long INDEX2 = 0;  // Index option Tempo - Heures Pleines Jours Bleus, Wh
unsigned long INDEX3 = 0;  // Index option Tempo - Heures Creuses Jours Blancs, Wh
unsigned long INDEX4 = 0;  // Index option Tempo - Heures Pleines Jours Blancs, Wh
unsigned long INDEX5 = 0;  // Index option Tempo - Heures Creuses Jours Rouges, Wh
unsigned long INDEX6 = 0;  // Index option Tempo - Heures Pleines Jours Rouges, Wh

// compteur 2 (solaire configuré en tarif BASE par ERDF)
unsigned long cpt2index = 0;     // Index option Base compteur production solaire, Wh
unsigned int cpt2puissance = 0;  // Puissance apparente compteur production solaire, VA

#define debtrame 0x02
#define debligne 0x0A
#define finligne 0x0D

// *************** déclaration carte micro SD ******************
const byte chipSelect = 4;

// *************** déclaration activation compteur 1 ou 2 ******
#define LEC_CPT1 5  // lecture compteur 1
#define LEC_CPT2 6  // lecture compteur 2
//
byte verif_cpt_lu = 0;
//

byte compteur_actif = 1;           // numero du compteur en cours de lecture
byte donnee_ok_cpt[2] = { 0, 0 };  // pour vérifier que les donnees sont bien en memoire avant ecriture dans fichier
byte donnee_ok_cpt_ph[2] = { 0, 0 };

// *************** variables RTC ************************************
byte minute, heure, seconde, jour, mois, jour_semaine;
unsigned int annee;
char date_heure[18];
char mois_jour[7];
byte mem_chg_heure = 0;  //pour pas passer perpetuellement de 3h à 2h du matin le dernier dimanche d'octobre
RTC_DS1307 RTC;

// ************** initialisation *******************************
void setup() {
  // initialisation du port 0-1 lecture Téléinfo
  Serial.begin(1200);
  // parité paire E
  // 7 bits data
  UCSR0C = B00100100;
#ifdef message_systeme_USB
  Serial.print(F("-- Teleinfo USB Arduino "));
  Serial.print(version_logiciel);
  Serial.println(F(" --"));
#endif
  // initialisation des sorties selection compteur
  pinMode(LEC_CPT1, OUTPUT);
  pinMode(LEC_CPT2, OUTPUT);
  digitalWrite(LEC_CPT1, HIGH);
  digitalWrite(LEC_CPT2, LOW);

  // verification de la présence de la microSD et si elle est initialisée:
#ifdef message_systeme_USB
  if (!SD.begin(chipSelect)) {
    Serial.println(F("> Erreur carte, ou carte absente !"));
    return;
  }
  Serial.println(F("> microSD initialisee !"));
#endif

  // initialisation RTC16

  Wire.begin();
  RTC.begin();

  if (!RTC.isrunning()) {
#ifdef message_systeme_USB
    Serial.println(F("RTC non configure !"));
#endif
  }

  DateTime now = RTC.now();  // lecture de l'horloge
  annee = now.year();
  mois = now.month();
  jour = now.day();
  heure = now.hour();
  minute = now.minute();
  jour_semaine = now.dayOfTheWeek();

  format_date_heure();
#ifdef message_systeme_USB
  Serial.println(date_heure);
#endif
}

// ************** boucle principale *******************************

void loop()  // Programme en boucle
{

  if (!(RTC.isrunning()) && (reg_horloge < 7)) {  // si l'horloge n'est pas configurée
    digitalWrite(LEC_CPT1, LOW);

    if (!mem_reg_horloge) {
      switch (reg_horloge) {  // debut de la structure
        case 1:
          Serial.print(F("Entrer Heure: "));
          break;
        case 2:
          Serial.print(F("Entrer Minute: "));
          break;
        case 3:
          Serial.print(F("Entrer Seconde: "));
          break;
        case 4:
          Serial.print(F("Entrer Jour: "));
          break;
        case 5:
          Serial.print(F("Entrer Mois: "));
          break;
        case 6:
          Serial.print(F("Entrer Annee 20xx: "));
          break;
      }
      mem_reg_horloge = true;
    }
    if (Serial.available() > 0) {  // si caractère dans la file d'attente

      Serial.print(F("un nombre a ete recu")); //---- lecture du nombre reçu
      while (Serial.available() > 0) {
        // tant que buffer pas vide pour lire d'une traite tous les caractères reçus
        inByte = Serial.read();         // renvoie le 1er octet présent dans la file attente série (-1 si aucun)
        Serial.println(inByte);
        if (((inByte > 47) && (inByte < 58)) || (inByte == 13)) {
          ReceptionOctet = inByte - 48;  // transforme valeur ASCII en valeur décimale
          if ((ReceptionOctet >= 0) && (ReceptionOctet <= 9)) ReceptionNombre = (ReceptionNombre * 10) + ReceptionOctet;
          // si valeur reçue correspond à un chiffre on calcule nombre
          Serial.print(ReceptionNombre);
          Serial.print(reg_horloge);
        } else
          presence_teleinfo = -1;
      }  // fin while
      if (inByte == 13) {
        if ((ReceptionNombre > val_max[reg_horloge - 1]) || (ReceptionNombre == -1)) {
          Serial.println(F("Erreur horaire"));
          ReceptionNombre = 0;
          mem_reg_horloge = true;
        } else {
          Serial.print("cela bugge");
          switch (reg_horloge) {  // debut de la structure
            case 1:
              heure = ReceptionNombre;
              Serial.print("heure:");
              Serial.println(heure);
            case 2:
              minute = ReceptionNombre;
              break;
            case 3:
              seconde = ReceptionNombre;
              break;
            case 4:
              jour = ReceptionNombre;
              break;
            case 5:
              mois = ReceptionNombre;
              break;
            case 6:
              annee = 2000 + ReceptionNombre;
              break;
          }

          mem_reg_horloge = false;
          ReceptionNombre = 0;
          ++reg_horloge;

          if (reg_horloge > 6) {
            RTCsetTime();
            Serial.println(F("Reglage heure OK - installer le cavalier pour la teleinfo"));
            digitalWrite(LEC_CPT1, HIGH);
          }
        }
      }
    }
  }

  else {

    DateTime now = RTC.now();  // lecture de l'horloge
    minute = now.minute();
    heure = now.hour();
    seconde = now.second();

    if ((heure == 0) && (minute == 0) && (seconde == 0)) {
      annee = now.year();
      mois = now.month();
      jour = now.day();
      jour_semaine = now.dayOfTheWeek();
    }

    // passage à l'heure d'été +1 heure
    // la lib RTC a une fonction: dayOfWeek qui donne le jour de la semaine (la DS1307 se charge de tout !)
    // réponse: 0 -> dimanche, 1 -> lundi etc...
    //
    if ((heure == 2) && (minute == 0) && (seconde == 0) && (jour_semaine == 0) && (mois == 3) && (jour > 24)) {
      heure = 3;
      RTCsetTime();
    }

    // passage à l'heure d'hiver -1 heure
    if ((heure == 3) && (minute == 0) && (seconde == 0) && (jour_semaine == 0) && (mois == 10) && (jour > 24) && (mem_chg_heure == 0)) {
      heure = 2;
      RTCsetTime();
      mem_chg_heure = 1;
    }

    if ((heure == 23) && (minute == 59) && (seconde == 10))  // pour être sur de pas tomber pendant l'enregistrement toutes les minutes
    {
      if ((mem_sauv_journee == 0) && (compteursluOK))  // un seul enregistrement par jour !
      {
        fichier_annee();
        mem_sauv_journee = 1;
        mem_chg_heure = 0;
      }
    } else
      mem_sauv_journee = 0;

    if (seconde == 1) {
      if ((mem_sauv_minute == 0) && (compteursluOK))  // un seul enregistrement par minute !
      {
        enregistre();
        mem_sauv_minute = 1;
      }
    } else
      mem_sauv_minute = 0;

#ifdef message_systeme_USB
    if ((donnee_ok_cpt[1] == B00000111) && (mem_affichage_cpt2_present)) {
      if (mem_affichage_cpt2_present) Serial.println(F("- Compteur 2 detecte"));
      mem_affichage_cpt2_present = false;
    } else if ((!cpt2_present) && (mem_affichage_cpt2_present)) {
      if (mem_affichage_cpt2_present) Serial.println(F("- Compteur 2 non present !"));
      mem_affichage_cpt2_present = false;
    }
#endif

    if ((donnee_ok_cpt[0] == verif_cpt_lu) and (cpt2_present)) {
      if ((type_mono_tri[0] == 1) && (donnee_ok_cpt_ph[0] == B10000001)) bascule_compteur();
      else if ((type_mono_tri[0] == 3) && (donnee_ok_cpt_ph[0] == B10000111))
        bascule_compteur();
    } else if ((donnee_ok_cpt[1] == B00000001) or ((compteur_actif == 2) and (!cpt2_present))) {
      if ((type_mono_tri[1] == 1) && (donnee_ok_cpt_ph[1] == B10000001)) bascule_compteur();
      else if ((type_mono_tri[1] == 3) && (donnee_ok_cpt_ph[1] == B10000111))
        bascule_compteur();
      compteursluOK = true;
    }

    if (compteur_actif == 2) {
      if (presence_teleinfo > 200) {
        cpt2_present = false;
        compteursluOK = true;
        bascule_compteur();
      } else
        cpt2_present = true;
    }

    read_teleinfo();
  }
}

///////////////////////////////////////////////////////////////////
// Calcul Checksum teleinfo
///////////////////////////////////////////////////////////////////
char chksum(char *buff, uint8_t len) {
  int i;
  char sum = 0;
  for (i = 1; i < (len - 2); i++) sum = sum + buff[i];
  sum = (sum & 0x3F) + 0x20;
  return (sum);
}

///////////////////////////////////////////////////////////////////
// mise en forme Date & heure pour affichage ou enregistrement
///////////////////////////////////////////////////////////////////
void format_mois_jour() {
  sprintf(mois_jour, "%02d,%02d,", mois, jour);
}

// Convert normal decimal numbers to binary coded decimal
static uint8_t bin2bcd(uint8_t val) {
  return val + 6 * (val / 10);
}

///////////////////////////////////////////////////////////////////
// mise à l'heure de la RTC (DS1307)
///////////////////////////////////////////////////////////////////
void RTCsetTime(void) {
  Wire.beginTransmission(104);  // 104 is DS1307 device address (0x68)
  Wire.write(bin2bcd(0));       // start at register 0

  Wire.write(bin2bcd(seconde));       //Send seconds as BCD
  Wire.write(bin2bcd(minute));        //Send minutes as BCD
  Wire.write(bin2bcd(heure));         //Send hours as BCD
  Wire.write(bin2bcd(jour_semaine));  // dow
  Wire.write(bin2bcd(jour));          //Send day as BCD
  Wire.write(bin2bcd(mois));          //Send month as BCD
  Wire.write(bin2bcd(annee % 1000));  //Send year as BCD

  Wire.endTransmission();
}

MacBookPro 2018 runnning Monterey

Do you have the correct baudrate set in the serial monitor? Can you please show your Arduino code?

See also https://stackoverflow.com/questions/17893792/arduino-garbled-serial-output

Are you referring to this thing. If so, what are you doing with the jumpers?

Yes. I do as advised with jumpers for the setup phase (jumper removed, battery removed and put back for zeroing the clock)but the monitor displays as illustrated and the process stops after entering a value for the hour

Parity mismatch
The essence of the seems to be this:
Serial.begin(1200);
// parité paire E
// 7 bits data
UCSR0C = B00100100;

The code changes the USART to operate with EVEN parity and 1 stop bits, or 7E1 for short. The Arduino serial monitor uses the more common NO parity 1 stop bit configuration (8N1). I did a small hello world type test to confirm that the kind of output you're getting on the Serial Monitor is about like expected for this mismatch.
Resolving
So, you need them to match. You can:

Either remove/comment out UCSR0C = B00100100; to go with the normal 8N1 configuration.

Or use a serial terminal emulator or other software capable of configuring for the port for even parity and 1 stop bits (7E1).

Incidentally, if you have good cause to use 7E1, the conventional way to do it is Serial.begin(1200, SERIAL_7E1); I don't know why they manually manipulated the hardware registers, perhaps the code predates support for this form of begin().
Serial Monitor Support
The IDE's Serial Monitor is reportedly capable of being configured for something other than 8N1 via preferences.txt. I did not get it working, but I also didn't spend that long trying. Perhaps I will again and update this. I think I didn't close all instances of the IDE. I've now verified that the Serial Monitor can be operated in 7E1 making the following changes to the arduino15 directory's preferences.txt file:

Old line reading
New line reading

serial.databits=8
serial.databits=7

serial.parity=N
serial.parity=E

That said, it is probably a mistake to have a change like that hidden away where it will cause lots of confusion later when 8N1 is needed. So, a terminal emulator is still probably a better choice if you actually want or need even parity and 1 stop bits. I in fact I'm going to change mine back now, just so this doesn't catch me. I'd use a regular software terminal emulator instead of messing with these, but it's to know that you can use Serial Monitor if you're forced to do that for whatever reason.

Good catch! Re “use a serial terminal emulator”: Indeed, both the comments on the code and the manual of the shield recommend setting up a terminal emulator at 1200/7E1. Re “perhaps the code predates support for this form of begin()”: It would seem so. The code is dated in the comments “June 2011”. This form of begin() was introduced on August 2012 and released on November 2012.

Oh cool. Thanks for looking it up. I probably should have, but in all the mental juggling with wording things I think I just let the thought drop. If I edit again I'll call out that you'd done research that ended up confirming it. I notice they don't appear to be using the pre-2.0 IDE in the screenshot, so... I may feel compelled to soon anyway to maybe expand on the serial monitor bit.

I'll be looking for all of this and revert back, but time is a constraint for me. Many thanks for helping me in this.

Removing UCSR0C = B00100100; gets the garbage out...I'll look further into this. Thanks


text:
Will many nrf24L01 radio modules running at the same time cause interference?
I am working on a battle bot type of project where their will be 4 transmitters communicating with 4 receivers attached to the robots in the 4 foot x 4 foot playing field. Are their any complications that will arise when trying to run many radio modules at the same time? Like relating to interference or noise? If so, what solutions or work-arounds exist for this problem?

their means belonging to them ... i think that you wanted to use there

my battle strategy would involve trying to jam the enemy's RF, blinding it with IR LEDs, and tasering it in case they didn't shield.

According to HowToMechatronics, the NRF24L01 module can use 125 different channels which gives a possibility to have a network of 125 independently working modems in one place. Each channel can have up to 6 addresses.
I believe that as long as you agree a channel allocation amongst competitors there shouldn’t be problems.
For more information on channel setting see NRF24l01 Channel switching

Welcome Rishikesh, there is a great possibility they will have problems. Because I do not know the environment or what the hardware is configured I cannot properly answer your question without a lot more information. I can suggest Look here for some information: https://forum.arduino.cc/t/nrf24l01-transmission-problem/526158/3 Here is another link that will help: https://devzone.nordicsemi.com/f/nordic-q-a/38005/nrf24l01-communication-is-interfered-by-wifi I hope this helps.

Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.


text:
ESP32-C3 - undefined reference to `esp_ble_gap_start_advertising'
I have a Bluetooth project for an ESP32 devkit and want to compile it for an ESP32-C3. I use the newest ESP32 Arduino core as a component with esp-idf and the following configuration for PlatformIO:
[platformio]
src_dir = src
default_envs = debug

# Common build environment that is used for each of the tasks
[env]
platform = espressif32
framework = espidf

board = esp32-c3-devkitm-1

# 4 MB module version
board_upload.flash_size = 4MB
board_upload.maximum_size = 4194304
board_build.partitions = partitions.csv

# Settings for serial upload
upload_speed = 921600
upload_port = COM2

# Settings for serial console
monitor_speed = 115200
monitor_port = COM2
monitor_filters = esp32_exception_decoder

# Additional packages
platform_packages =

# Aditional build scripts for all environments to run before (`pre`) and after (`post`) the main build script
extra_scripts =

# Common build flags for all environments
build_flags =

lib_deps =
    bblanchon/ArduinoJson@^6.18.0

[env:debug]
build_type = debug

build_flags =
    ${env.build_flags}
    -D DEBUG
    -D APP_VERSION_POST='debug'

lib_deps =
    ${env.lib_deps}

extra_scripts =
    ${env.extra_scripts}

[env:release]
build_type = debug

build_flags =
    ${env.build_flags}
    -D RELEASE

lib_deps =
    ${env.lib_deps}

extra_scripts =
    ${env.extra_scripts}

I use the following toolchain:
 - framework-espidf @ 3.40401.0 (4.4.1)
 - tool-cmake @ 3.16.4
 - tool-esptoolpy @ 1.30300.0 (3.3.0)
 - tool-idf @ 1.0.1
 - tool-mconf @ 1.4060000.20190628 (406.0.0)
 - tool-ninja @ 1.9.0
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch3

But I got the following error during the linking:
.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: .pio\build\debug\esp-idf\arduino-esp32\libarduino-esp32.a(BLEAdvertising.o): in function `BLEAdvertising::start()':
components/arduino-esp32/libraries/BLE/src/BLEAdvertising.cpp:247: undefined reference to `esp_ble_gap_start_advertising'
.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: components/arduino-esp32/libraries/BLE/src/BLEAdvertising.cpp:214: undefined reference to `esp_ble_gap_config_adv_data'
.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: components/arduino-esp32/libraries/BLE/src/BLEAdvertising.cpp:225: undefined reference to `esp_ble_gap_config_adv_data'

Update 1
A verbose build outputs the following command before the error appears:
riscv32-esp-elf-g++ -o .pio\build\debug\firmware.elf -T memory.ld -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u pthread_include_pthread_rwlock_impl -u include_esp_phy_override -u start_app -T sections.ld
-u __ubsan_include -T esp32c3.rom.ld -T esp32c3.rom.api.ld -T esp32c3.rom.libgcc.ld -T esp32c3.rom.newlib.ld -T esp32c3.rom.version.ld -T esp32c3.rom.newlib-time.ld -T esp32c3.rom.eco3.ld -u __assert_func -u vfs_include_syscalls_impl -T esp32c3.peripherals.ld -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u newlib_include_assert_impl -u __cxa_guard_dummy -u __cxx_fatal_exception --specs=nosys.specs -Wl,--Map=C:/Projects/firmware-loader/.pio/build/debug/Firmware-Loader.map -Wl,--cref -Wl,--gc-sections -Wl,--undefined=uxTopUsedPriority -Wl,--wrap=_Unwind_Backtrace -Wl,--wrap=_Unwind_DeleteException -Wl,--wrap=_Unwind_FindEnclosingFunction -Wl,--wrap=_Unwind_Find_FDE
-Wl,--wrap=_Unwind_ForcedUnwind -Wl,--wrap=_Unwind_GetCFA -Wl,--wrap=_Unwind_GetDataRelBase -Wl,--wrap=_Unwind_GetGR -Wl,--wrap=_Unwind_GetIP -Wl,--wrap=_Unwind_GetIPInfo -Wl,--wrap=_Unwind_GetLanguageSpecificData -Wl,--wrap=_Unwind_GetRegionStart -Wl,--wrap=_Unwind_GetTextRelBase -Wl,--wrap=_Unwind_RaiseException -Wl,--wrap=_Unwind_Resume -Wl,--wrap=_Unwind_Resume_or_Rethrow -Wl,--wrap=_Unwind_SetEnableExceptionFdeSorting -Wl,--wrap=_Unwind_SetGR -Wl,--wrap=_Unwind_SetIP -Wl,--wrap=__cxa_call_unexpected -Wl,--wrap=__deregister_frame_info -Wl,--wrap=__deregister_frame_info_bases -Wl,--wrap=__gxx_personality_v0 -Wl,--wrap=__register_frame -Wl,--wrap=__register_frame_info -Wl,--wrap=__register_frame_info_bases -Wl,--wrap=__register_frame_info_table -Wl,--wrap=__register_frame_info_table_bases -Wl,--wrap=__register_frame_table -fno-lto -fno-rtti -march=rv32imc -nostartfiles -Og -g2 -ggdb2 .pio\build\debug\src\Devices\JERRY\jerry.o .pio\build\debug\src\Devices\Memory\memory.o .pio\build\debug\src\Devices\TOM\I2CM.o .pio\build\debug\src\Devices\TOM\tom.o .pio\build\debug\src\Loader\loader.o .pio\build\debug\src\Version\version.o .pio\build\debug\src\main.o -L.pio\build\debug -LC:\.platformio\packages\framework-espidf\components\bt\controller\lib_esp32c3_family\esp32c3 -LC:\.platformio\packages\framework-espidf\components\esp_wifi\lib\esp32c3 -LC:\.platformio\packages\framework-espidf\components\esp_phy\lib\esp32c3 -L.pio\build\debug\esp-idf\esp_system\ld -LC:\.platformio\packages\framework-espidf\components\esp_rom\esp32c3\ld -LC:\.platformio\packages\framework-espidf\components\esp_wifi\lib\esp32c3 -LC:\.platformio\packages\framework-espidf\components\soc\esp32c3\ld -Wl,--start-group .pio\build\debug\esp-idf\esp_ringbuf\libesp_ringbuf.a .pio\build\debug\esp-idf\asio\libasio.a .pio\build\debug\esp-idf\protobuf-c\libprotobuf-c.a .pio\build\debug\esp-idf\esp_lcd\libesp_lcd.a .pio\build\debug\esp-idf\mdns\libmdns.a .pio\build\debug\esp-idf\protocomm\libprotocomm.a .pio\build\debug\esp-idf\cbor\libcbor.a .pio\build\debug\esp-idf\cmock\libcmock.a .pio\build\debug\esp-idf\unity\libunity.a .pio\build\debug\esp-idf\bt\libbt.a .pio\build\debug\esp-idf\coap\libcoap.a .pio\build\debug\esp-idf\esp_adc_cal\libesp_adc_cal.a .pio\build\debug\esp-idf\esp_hid\libesp_hid.a .pio\build\debug\esp-idf\wear_levelling\libwear_levelling.a .pio\build\debug\esp-idf\esp_local_ctrl\libesp_local_ctrl.a .pio\build\debug\esp-idf\esp_websocket_client\libesp_websocket_client.a .pio\build\debug\esp-idf\expat\libexpat.a .pio\build\debug\esp-idf\fatfs\libfatfs.a .pio\build\debug\esp-idf\freemodbus\libfreemodbus.a .pio\build\debug\esp-idf\spiffs\libspiffs.a .pio\build\debug\esp-idf\openssl\libopenssl.a .pio\build\debug\esp-idf\libsodium\liblibsodium.a .pio\build\debug\esp-idf\jsmn\libjsmn.a .pio\build\debug\esp-idf\mqtt\libmqtt.a .pio\build\debug\esp-idf\json\libjson.a .pio\build\debug\esp-idf\wifi_provisioning\libwifi_provisioning.a .pio\build\debug\esp-idf\arduino-esp32\libarduino-esp32.a .pio\build\debug\esp-idf\RAK3172\libRAK3172.a .pio\build\debug\esp-idf\app_trace\libapp_trace.a .pio\build\debug\esp-idf\app_update\libapp_update.a .pio\build\debug\esp-idf\bootloader_support\libbootloader_support.a .pio\build\debug\esp-idf\console\libconsole.a .pio\build\debug\esp-idf\cxx\libcxx.a .pio\build\debug\esp-idf\driver\libdriver.a .pio\build\debug\esp-idf\efuse\libefuse.a .pio\build\debug\esp-idf\esp-tls\libesp-tls.a .pio\build\debug\esp-idf\esp_common\libesp_common.a .pio\build\debug\esp-idf\esp_event\libesp_event.a .pio\build\debug\esp-idf\esp_gdbstub\libesp_gdbstub.a .pio\build\debug\esp-idf\esp_http_client\libesp_http_client.a .pio\build\debug\esp-idf\esp_http_server\libesp_http_server.a .pio\build\debug\esp-idf\esp_https_ota\libesp_https_ota.a .pio\build\debug\esp-idf\esp_hw_support\libesp_hw_support.a .pio\build\debug\esp-idf\esp_ipc\libesp_ipc.a .pio\build\debug\esp-idf\esp_netif\libesp_netif.a .pio\build\debug\esp-idf\esp_phy\libesp_phy.a .pio\build\debug\esp-idf\esp_pm\libesp_pm.a .pio\build\debug\esp-idf\esp_rom\libesp_rom.a .pio\build\debug\esp-idf\esp_serial_slave_link\libesp_serial_slave_link.a .pio\build\debug\esp-idf\esp_system\libesp_system.a .pio\build\debug\esp-idf\esp_timer\libesp_timer.a .pio\build\debug\esp-idf\esp_wifi\libesp_wifi.a .pio\build\debug\esp-idf\espcoredump\libespcoredump.a .pio\build\debug\esp-idf\freertos\libfreertos.a .pio\build\debug\esp-idf\hal\libhal.a .pio\build\debug\esp-idf\heap\libheap.a .pio\build\debug\esp-idf\log\liblog.a .pio\build\debug\esp-idf\lwip\liblwip.a .pio\build\debug\esp-idf\mbedtls\libmbedtls.a .pio\build\debug\esp-idf\newlib\libnewlib.a .pio\build\debug\esp-idf\nghttp\libnghttp.a .pio\build\debug\esp-idf\nvs_flash\libnvs_flash.a .pio\build\debug\esp-idf\pthread\libpthread.a .pio\build\debug\esp-idf\riscv\libriscv.a .pio\build\debug\esp-idf\sdmmc\libsdmmc.a .pio\build\debug\esp-idf\soc\libsoc.a .pio\build\debug\esp-idf\spi_flash\libspi_flash.a .pio\build\debug\esp-idf\tcp_transport\libtcp_transport.a .pio\build\debug\esp-idf\tcpip_adapter\libtcpip_adapter.a .pio\build\debug\esp-idf\vfs\libvfs.a .pio\build\debug\esp-idf\wpa_supplicant\libwpa_supplicant.a .pio\build\debug\esp-idf\mbedtls\mbedtls\library\libmbedcrypto.a .pio\build\debug\esp-idf\mbedtls\mbedtls\library\libmbedtls.a .pio\build\debug\esp-idf\mbedtls\mbedtls\library\libmbedx509.a -lbtdm_app -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lbtbb -lgcov -lc -lm -lstdc++ -lgcc -Wl,--end-group

Update 2
It looks like libbt.a isn´t linked. May this cause this issue? How can I fix it or where do I find the required part in the build system of pio?

Is there a way to see which components have been linked or tried to be linked in PlatformIO?

@NickS. please take a look at my updated question. I have inserted the last command output in verbose build.

CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y

I have had a very similar issue just now. In short, the solution was to rename library file from .c to .cpp
Extended explanation. My platformio.ini:
[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino

I am using third-party library which I build from source. This library is provided by two  "lib_name.c" and "lib_name.h" files, which I have put into a lib/lib_name/ directory according to Platformio README file.
It was failing during linkage until I renamed "lib_name.c" to "lib_name.cpp", header file remained untouched.


text:
Problem with push button
I am making a project where if the push button is pressed, the LCD screen will show a message. But with many trial and errors, it doesn't give the right result.
Here is the circuit:

Here is the code:
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#define BUTTON 7
void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  pinMode(BUTTON, INPUT);
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 0);
  // print the number of seconds since reset:
  lcd.print("Press Button");
  lcd.setCursor(0,1);
  lcd.print("to make COFFEE");
  if (digitalRead(BUTTON) == HIGH) {
    lcd.clear();
    lcd.print("SENT TO MACHINE");
  }
}

It looks like you have several issues.

The positive and negative supply "rails" on your prototyping board are not connected together internally. You should add a positive jumper wire.

You are trying to detect when the button provides a HIGH logic level, but there is no possibility of doing so with the current "wiring".

One more thing that could help to determine this, or another possible issue, is a picture of your setup from a different angle so we can see exactly how that button, capacitor, and resistor are connected.
This is the area which would be nice to see from a different angle.

I haven't analyzed (yet anyway) their circuit as you have, but message on the LCD indicates that lcd.print("SENT TO MACHINE");  was executed at some point (because of the trailing INE on first line), which seems to cast doubt on "no possibility of doing so". So, you may want to acknowledge it in the answer, if only to dismiss it, assuming it doesn't inform you that something different is going on in their circuit.

@timemage -  You mis-quoted me. It's "You are trying to detect when the button provides a HIGH logic level, but there is no possibility of doing so with the current "wiring".", which is an accurate statement. I also suspect, just like you,  the OP's declaration pinMode(BUTTON, INPUT); has turned the input into a radio antenna, and it just happens to trigger the message "SENT TO MACHINE". HINT: The best part of SE is the fact that multiple people can answer the same question.

The quote seems accurate. Your reply indicates that you've misunderstood what I'm saying. What you're doing right here in this comment is what I meant by acknowledging what is happening on the LCD, if only to dismiss it. Only, not doing it in the answer. What you're saying about the behavior of it without the pullup is inline with what thinking I have done on it. So, no need, to my make own answer. However, your answer can be improved by saying both of these things, in the answer itself.

@timemage - LOL, every answer on every SE stack can be improved. Instead of complaining about my answer, try posting a better one. I suggest one of those "book report" answers. Use all the tools in the "compose answer tool box", like bold text, italic, H1, H2, etc. Make sure it is the maximum number of chars you can enter (30K or is it 60K now?), because that's exactly what  a new user is looking for, right?

It's an honest attempt to be helpful. I'm not sure what is going to convince you of that.

The point of having comments under answers is so that answers, which may be quite good, can be tweaked further to make them better. Or, to point out inaccuracies.

I appreciate your help! Everything is working (and sorry for the bad angle :/ )

you should implement debouncing because when you press the button with your hand it will bounce and make the signal instable so no High/Low, here's the doc from Arduino:
https://www.arduino.cc/en/Tutorial/BuiltInExamples/Debounce


text:
POST request (HTTPClient) with ESP8266 not working on localhost (http code = -1)
I've been looking around for a solution, but couldn't manage to find one. I'm looking to send a post request from an ESP8266 on a local API.
Here is my code :
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>

String ssid = "HUAWEI P30 lite";
String password = "testazerty";
String serverName = "http://192.168.56.1:3030/drink/voltron";

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  Serial.println("Connecting");
  while(WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to WiFi network with IP Address: ");
  Serial.println(WiFi.localIP());
}

void loop() {

    if(WiFi.status()== WL_CONNECTED){
      WiFiClient client;
      HTTPClient http;

      http.begin(client, serverName);

      http.addHeader("Content-Type", "application/json");
      int httpResponseCode = http.POST("{\"city\":\"toronto\"}");

      Serial.print("HTTP Response code: ");
      Serial.println(httpResponseCode);

      http.end();
  }
}

Both my computer and ESP8266 are connected to my phone network (HUAWEI).
192.168.56.1 is the IP of my computer.
API is running, and I can successfully make the request from postman (see image below).

It always return -1 as http code. I activated debug level HTTP_CLIENT, here is what I have on the serial monitor :
11:07:41.645 -> SDK:2.2.2-dev(38a443e)/Core:3.0.2=30002000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:6105635
11:07:41.645 -> fpm close 1
11:07:41.645 -> mode : sta(30:83:98:b1:da:62)
11:07:41.645 -> add if0
11:07:41.645 -> Connecting
11:07:42.160 -> .....scandone
11:07:45.348 -> state: 0 -> 2 (b0)
11:07:45.348 -> .state: 2 -> 3 (0)
11:07:45.441 -> state: 3 -> 5 (10)
11:07:45.441 -> add 0
11:07:45.441 -> aid 6
11:07:45.441 -> cnt
11:07:45.441 ->
11:07:45.441 -> connected with HUAWEI P30 lite, channel 6
11:07:45.441 -> dhcp client start...
11:07:45.864 -> ....ip:192.168.43.88,mask:255.255.255.0,gw:192.168.43.1
11:07:47.870 -> .
11:07:47.870 -> Connected to WiFi network with IP Address: 192.168.43.88
11:07:47.870 -> [HTTP-Client][begin] url: http://192.168.56.1:3030/drink/voltron
11:07:47.870 -> [HTTP-Client][begin] host: 192.168.56.1 port: 3030 url: /drink/voltron
11:07:47.870 -> [HTTP-Client][sendRequest] type: 'POST' redirCount: 0
11:07:53.021 -> [HTTP-Client] failed connect to 192.168.56.1:3030
11:07:53.021 -> [HTTP-Client][returnError] error(-1): connection failed
11:07:53.021 -> HTTP Response code: -1
11:07:53.021 -> [HTTP-Client][end] tcp is closed

firewall on PC?

I completely turned off Windows Defender, but still have the same output

Can your PC ping the ESP32?

I tried to do it connecting to my home router, and it worked perfectly !
The problem comes from sharing internet with my mobile, but at least it can work with router. I looked it up, and seems that it might be because of the protocol used (IPv4/IPv6). Here is what I found.

localhost is the device itself ... synonymous with 127.0.0.1 ... did you mean to say local host instead?

try to Disable your windows firewall or add exption to allow access

You are on different subnets. Your API is 192.168.56.1 and your device is 192.168.43.88, but your subnet mask is 255.255.255.0. That puts these devices on separate subnets within the network. Try changing your subnet mask to 255.255.0.0. Reference: http://www.steves-internet-guide.com/subnetting-subnet-masks-explained/

TLDR:
This is a networking problem, not a programming problem. Try changing your subnet mask to 255.255.0.0 on your router/network configuration, or make sure they're actually connected to the same router. If different routers, try to change one to a "Wireless Access Point" configuration. If you can't get them on the same network, you will have to expose your API to the Internet.
Long version:
You are on different subnets. Your API IP address is 192.168.56.1 and your device IP address is 192.168.43.88, but your subnet mask is 255.255.255.0. That puts these devices on separate subnets within the network.
There are a lot of complicated explanations of subnets and subnet masks on the internet. I linked one of the better ones below. Technically, you are not just on different subnets but on different networks entirely. You have a 192.x.x.x IP address, making it a Class C network. That makes your address pattern one of "network.network.network.node". Depending on your router configuration or other network hardware, you can upgrade it to a Class B network by customizing your subnet mask as 255.255.0.0 ("network.network.node.node"). Class B addresses might require a lot of customization on your end depending on your specific circumstances. By using a subnet mask of 255.255.0.0 on a Class B address, you classify the IP address parts .56.1 and .43.88 as being on the same network AND subnet. If you change it to Class B addressing without changing the subnet, the .56 will be one subnet and .43 will be a different subnet.
Sometimes this addressing is done automatically based on the installed hardware. This is especially problematic in home networks containing multiple wireless routers but connected to the same modem. Many home routers have a "Wireless Access Point" setting that removes a lot of the more complex router configuration. This might convince your router(s) to put you onto the same subnet. If that works, you now have your devices able to connect locally! Additional router configuration might be required to expose ports for your API to incoming requests across subnets.
If your network class is being determined by your ISP and you can't get your devices onto the same network, you have to expose your API to the Wild Wild Web :D There are many services which allow for Dynamic DNS, but I'd suggest reading through https://www.ionos.com/digitalguide/server/tools/free-dynamic-dns-providers-an-overview/ and selecting one that meets your needs. This WILL require advanced router configuration to expose ports to the internet. Please select a Dynamic DNS services that provides DDOS protection. Once it is exposed, your ESP8266 can hit your API as it would any public API. Please put authentication on your API.
References:

Subnet explanation -
http://www.steves-internet-guide.com/subnetting-subnet-masks-explained/
Dynamic DNS providers -
https://www.ionos.com/digitalguide/server/tools/free-dynamic-dns-providers-an-overview/


text:
Noise in RF 434 transmitter and receiver
I'm working on RF transmitter and receiver modules using two Arduino UNOs. I'm getting an additional noise on the receiver side in serial.println.
To be more clear about the question. Hre is my transmitter code
// Include RadioHead Amplitude Shift Keying Library
#include <RH_ASK.h>
// Include dependant SPI Library
#include <SPI.h>

// Create Amplitude Shift Keying Object
RH_ASK rf_driver;

void setup()
{
    // Initialize ASK Object
    rf_driver.init();
    Serial.begin(9600);
}

void loop()
{

    const char *msg = "Hello World";
    rf_driver.send((uint8_t *)msg, strlen(msg));
    rf_driver.waitPacketSent();
    Serial.println((char *)msg);
    delay(1000);
}

Here is my receiver code
// Include RadioHead Amplitude Shift Keying Library
#include <RH_ASK.h>
// Include dependant SPI Library
#include <SPI.h>

// Create Amplitude Shift Keying Object
RH_ASK rf_driver;

void setup()
{
    // Initialize ASK Object
    rf_driver.init();
    // Setup Serial Monitor
    Serial.begin(9600);
}

void loop()
{
    // Set buffer to size of expected message
    uint8_t buf[11];
    uint8_t buflen = sizeof(buf);
    // Check if received packet is correct size
    if (rf_driver.recv(buf, &buflen))
    {

      // Message received with valid checksum
      Serial.print("Message Received: ");
      Serial.println((char*)buf);
    }
}

And here is my Serial monitor in receiver side

So, can somebody help me to sort out this issue

You're treating a raw buffer as a string.
In C a string is an array of characters (11 in your case) terminated by a NULL character.  You receive 11 bytes into an 11 byte array and then try and print it - without any terminating character - so the output "overruns" into the memory following your array.
You need a buffer of 12 bytes not 11, and you have to make sure that the 12th byte (byte number 11) is zero.
Or use Serial.write(buf, buflen); function to write exactly 11 bytes to the serial.


text:
How to configure 16x2 character LCD to work with 8bit?
I have the LiquidCrystal library installed but all the examples are for 4bit connection, I want to drive the LCD with 8bit.
In LiquidCrystal.cpp file it says;

When the display powers up, it is configured as follows:
DL = 1;  8-bit interface data

But what's is the function, should it be like this: LiquidCrystal DL(1);? where and how should I call DL = 1;?

You don't "do" anything to enable 8 bit. As it says when the device powers up the DL bit in the configuration is already set, enabling 8 bit.
You just need to wire it for 8 bit and specify all 8 bits of wiring in the constructor.
The manual entry for the constructor shows you what parameters you can specify:

https://www.arduino.cc/reference/en/libraries/liquidcrystal/liquidcrystal/


text:
Using Arduino to read and write data to RS232 device
I have a micro turbojet engine (JetCat P100-RX) which is operated through an Electronic Control Unit (ECU).
The ECU has a lot of information about the engine. I want to access that information and also send commands to the ECU to control the engine.
The ECU connects to a Mini I/O device. This connection is shown in the following image:

The details of both the ECU serial connection and the Mini I/O Board are given in this manual page 4. (What I understand here is that the data stream from the Mini Board follows a RS232 protocol.) It looks as shown:

I would like to collect the information from the Tx, Rx and GND pins using the Arduino Uno.
How can I do this? The Arduino is connected to my PC through the USB port.
EDIT1: What I tried doing:
I connected the Tx, Rx and GND of the Mini Board to pins 10 and 11 of the Arduino and configured 10 and 11 as serial pins and GND to Arduino GND (Rx anf Tx respectively) using SerialSoftware as follows:
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600); // Set to 9600 as the manual says (link above)
}

void loop() {
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
}

My circuit diagram:

But I don't get any output on the Serial Monitor.
While reading online I found out that I need some converter. Following these posts, I have bought a MAX3232. Do I need to use that? How do I use that and what changes do I make in my code?

not a question about arduino specifically ... you would have the same question if you used any other microcontroller ... first thing to do is to determine the signalling voltage levels on the RxD and TxD pins

The manual for the device shows that TX and RX are 3.3V signals.

@jsotola Yes Indeed, the pins are 3.3V. Now where shall I move from here? I am not an electronics guy ;)

@Wendall You are right, the manual does say that. Now how shall I connect?

Since you are not using the JetCat RS232 adapter (which converts the 3.3V signals into RS-232 levels (which would require the MAX 3232) you should be able to connect directly to the UART of your Arduino. Once you have it working with your hardware THEN try to get it going using a software driven serial port. In my experience, software ports work OK, but not well and almost not at all if I am using interrupts for my own purposes. Since it is a 3.3V signal you MAY have to convert them to 5V. Google around a bit, there are lots of ways to do it. There are 3V Arduinos too, then it will work at 3V.

Since the USB interface uses the same Arduino UART, either be careful not to send anything from your PC to the Arduino, or indeed use a software port. As mentioned it can work fine.

That is relatively easy to do.  If you have a Mega or another Arduino that has more than one serial port, great. If not, then softwareserial is what you need. For this to work all grounds must be connected.
Softwareserial can only receive on one channel at a time. On the hardware level you should use a high-impedance receiver to monitor both the RX and TX signals. I use a 74HC14 (74C914 is rated at +- 25 V on its input) or similar device. Place a 50 kΩ resistor from the RX to an input on the IC, do the same with the TX to another input on the IC. The input protection diodes of the 74HC will limit the current, at 50 kΩ 50 V gives 1 mA.
Connect the outputs of the IC to inputs of the Arduino. Each input needs to be configured to receive ASYNC input at the correct baud and other parameters. I have done this many times and it works great. I always did it with UARTs, not software. Note the 74HC device inverts the signal as is normal with RS232. There are various modules available for the Arduino that have a USART, UART or similar serial device on them.

Thanks for your reply. Para1: Softwareserial-check. What do you mean "all" grounds? I see only 1 GnD pin on the Mini Board. Para2: I don't understand what you are talking about, the voltages on the Mini Board are 3.3V, where is 50V coming from? Para3: How to configure to receive ASYNC input at correct baud rate? Can you show some code as example?

What does the Mini board connect to. RS232 is a three wires, one for Tx, one for Rx, and one for Ground. The grounds of each unit need to be connected. That is to simply show the input to the gate is rugged. At 50V you will have 1 mA of current into the HC protection, and not destroy the chip. Sorry on the code, there is a lot of it posted for the Arduino. At best I could only guess as you do not even have the design finished. Be sure you get the number of bits correct, parity correct, number of stop bits correct and of course the baude. Typically is 9600,n,1 (9600 baud, no parity and 1 stop.


text:
Connect an MPX10DP Pressure Sensor to an Arduino Mega 2560
I'm literally new to using Arduino, i am trying to build a Pitot Tube to measure airspeed using an MPX10DP differential pressure sensor and i am working with an Arduino Mega 2560.
Honestly, i have studied some tutorials of people building a Pitot Tube but the pressure sensors they use are not available in my region, the only pressure that i could afford is the MPX10DP but i am not sure of how to connect it to my arduino and make it get values.
Can someone help me or guide me a bit?

start by determining what type of output the sensor provides ... when you know that, then ask how to measure it using an Arduino ... as it stands, your question is not about arduino

That part was originally introduced by Motorola many years ago. It is a silicon strain gauge in a bridge configuration. You need an external amplifier as it only has maybe 50 mVdc output depending on your circuit. It is a relative output voltage depending on how you excite it. The one you have is a differential unit, they also made absolute and gauge units as well.  There were many application notes published on the MPX family of pressure transducers. You may have to look in the Motorola archives to find them. The voltage will be either + or - from your reference point depending on what the differential pressure is. They are not temperature compensated so you need to design that into your circuit as well.

Thanks for the answer Gil, do you know what kind of amplifier do i need? and also how do I know what resistance band I need?

Simply look for "application note MPX10DP" there are many, AN840 comes to mind but it has been a lot of years probably in the mid 1990s.


text:
USB serial port no longer detected after successful upload
I successfully uploaded a sketch to my Arduino Micro using the USB serial port but if I try to change the sketch that port is not available. The sketch I uploaded on the Micro runs fine when I plug in the USB cable. The ports shown are /dev/cu.Bluetooth-Incoming-Port and /dev/cu.wlan-debug. If I plug in a different chip the port is there. What would cause it to disappear for the Micro?

You are probably encountering a very common problem which is already answered on here. Does your non-working Arduino appear in your USB hardware list briefly after reset?

You are simply running a sketch that doesn't create and expose a serial port to the computer.

I'm not sure what that means but more importantly, what can I do to be able to upload new sketches (and avoid this issue in the future)?

Problem fixed by following suggestion from namakada81 "Open an empty arduino sketch, select the pro micro and no port, click upload and as soon as the ide says "uploading" reset the arduino

Who is namakada81?

All I know is that someone with this username posted this solution on reddit 3 years ago https://www.reddit.com/r/arduino/comments/cliro2/how_to_reset_arduino_pro_micro_bootloader/


text:
Why am I reading only zeroes from PORTB?
I am using a custom Arduino Nano compatible board with an Atmel 328P.  I am externally changing the values applied to several pins on PORTB.  I expect to be able to read the values of these pins (low or high) but I always read zeroes.  However, the pin change interrupt is called.  What do I need to do to read values from PORTB?
Supply voltage is 5 volts.  Pin applied high voltage is 3.3 volts.
With the below code, when I change the voltage applied to a pin, LED1 flashes but LED2 does not.
#include <avr/interrupt.h>

#define LED1_PORT                           (PORTD)
#define LED1_PIN_bm                         (_BV(4))         //D1, white

#define LED2_PORT                           (PORTD)
#define LED2_PIN_bm                         (_BV(3))         //D2, red

volatile bool g_bValueChanged = 0;

void setup()
{
  DDRB = 0;                     //set all as inputs
  PCMSK0 = 0xfb;                //exclude 1 pin because of noise
  PCICR |= (1 << PCIE0);        //enable pin change interrupt 0 (for pins PB0..7)

  sei();
}

uint8_t g_valuePrevious = 0;

void loop()
{
  if (g_bValueChanged)
  {
    g_bValueChanged = false;

    LED1_PORT |= LED1_PIN_bm;
    delay(40);
    LED1_PORT &= ~LED1_PIN_bm;
    delay(40);
  }

  uint8_t value = PORTB;
  if (value != g_valuePrevious)
  {
    g_valuePrevious = value;

    LED2_PORT |= LED2_PIN_bm;
    delay(40);
    LED2_PORT &= ~LED2_PIN_bm;
    delay(40);
  }
}

ISR(PCINT0_vect)
{
    g_bValueChanged = true;
}

The PORTB register is initialized by the hardware to zero. You never
write to this register, so it always stays zero.
Maybe you are mixing up PORTB and PINB:

PORTB is the port output register, controlled by you
PINB is the port input register, for which the bits
corresponding to input pins are controlled by whatever drives those
pins from the outside.

I am applying a signal to those pins externally.  I have been programming XMega which uses the same PORTB for input and output.  Now I see PINB in the datasheet, you are probably correct, I will try it.

@Joe: Yes, that is what I understood from reading your question.

Thank you, that was the answer, I was not aware that the processor I am using had different registers for input and output.

Different registers, indeed. And there is even a free goodie: if you attempt to write to the port input registers, you get toggle functionality: for every bit you write to one, the corresponding output pin is toggled.