text:
Error for compiling for board Arduino Uno
I am new to Arduino and just got this error after writing this code:The error message is pasted after the code. I am kindly requesting for assistance so that someone can help me understand why it isn't compiling. I even changed the board to mega at the tools section but still get the same error

    #include <Tone.h>

int ledred1 = 2;
int ledgreen1 = 3;
int ledorange1 = 4;
int ledred2 = 5;
int ledgreen2 = 6;
int ledorange2 = 7;
int ledred3 = 8;
int ledgreen3 = 9;
int ledorange3 = 10;

int sound = 250;

int trigPin1 = 11;
int echoPin1 = 12;

int trigPin2 = 13;
int echoPin2 = 14;

int trigPin3 = 15;
int echoPin3 = 16;

#define buzzer1 17
#define buzzer2 18
#define buzzer3 19

Tone tone1;
Tone tone2;
Tone tone3;

long distance1=0;
long distance2=0;
long distance3=0;

long t1=-10000;
long t2=-10000;
long t3=-10000;

void checkDistance(long distance, Tone toneobj, int frequency, long *timer);

long measure(int trigger, int echo);

void setup() {
  Serial.begin (9600);
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);

  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);

  pinMode(trigPin3, OUTPUT);
  pinMode(echoPin3, INPUT);

  tone1.begin(buzzer1);
  tone2.begin(buzzer2);
  tone3.begin(buzzer3);

  pinMode(ledred1, OUTPUT);
  pinMode(ledred2, OUTPUT);
  pinMode(ledgreen1, OUTPUT);
  pinMode(ledgreen2, OUTPUT);
  pinMode(ledred3, OUTPUT);
  pinMode(ledgreen3, OUTPUT);
}
void firstsensor(){ // This function is for first sensor.
  int duration1, distance1;
  digitalWrite (trigPin1, HIGH);
  delayMicroseconds (10);
  digitalWrite (trigPin1, LOW);
  duration1 = pulseIn (echoPin1, HIGH);
  distance1 = (duration1/2) / 29.1;

      Serial.print("1st Sensor: ");
      Serial.print(distance1);
      Serial.print("cm    ");

  if (distance1 <=200&& distance1>=100) {  // Change the number for long or short distances.
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,HIGH);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);

    sound=250;

  } else {
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);
     }

  if (distance1 <100&& distance1>=50) {  // Change the number for long or short distances.
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,HIGH);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);

    sound=275;

  } else {
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);
      }
        if (distance1 <50&& distance1>=0) {  // Change the number for long or short distances.
    digitalWrite (ledred1, HIGH);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);

    sound=300;

  } else {
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);
      }
      if(distance1>200 || distance1<0){
    Serial.println("Out of Range");
    noTone(buzzer1);
  }
  else{
    Serial.print(distance1);
    Serial.println("cm");
    tone(buzzer1,sound);

  }
}
void secondsensor(){ // This function is for second sensor.
    int duration2, distance2;
    digitalWrite (trigPin2, HIGH);
    delayMicroseconds (10);
    digitalWrite (trigPin2, LOW);
    duration2 = pulseIn (echoPin2, HIGH);
    distance2 = (duration2/2) / 29.1;

      Serial.print("2nd Sensor: ");
      Serial.print(distance2);
      Serial.print("cm    ");

     if (distance2 <=200&& distance2>=100) {  // Change the number for long or short distances.
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, HIGH);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);

    sound=250;

  } else {
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);
     }

  if (distance2 <100&& distance2>=50) {  // Change the number for long or short distances.
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,HIGH);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);

    sound=275;

  } else {
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);
      }
        if (distance2 <50&& distance2>=0) {  // Change the number for long or short distances.
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, HIGH);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);

    sound=300;

  } else {
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);
      }
      if(distance2>200 || distance2<0){
    Serial.println("Out of Range");
    noTone(buzzer2);
  }
  else{
    Serial.print(distance2);
    Serial.println("cm");
    tone(buzzer2,sound);

  }
}
void thirdsensor(){ // This function is for third sensor.
    int duration3, distance3;
    digitalWrite (trigPin3, HIGH);
    delayMicroseconds (10);
    digitalWrite (trigPin3, LOW);
    duration3 = pulseIn (echoPin3, HIGH);
    distance3 = (duration3/2) / 29.1;

      Serial.print("3rd Sensor: ");
      Serial.print(distance3);
      Serial.print("cm");

     if (distance3 <=200&& distance3>=100) {  // Change the number for long or short distances.
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, HIGH);

    sound=250;

  } else {
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);
     }

  if (distance3 <100&& distance3>=50) {  // Change the number for long or short distances.
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,HIGH);
    digitalWrite (ledgreen3, LOW);

    sound=275;

  } else {
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);
      }
        if (distance1 <50&& distance1>=0) {  // Change the number for long or short distances.
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);

    sound=300;

  } else {
    digitalWrite (ledred1, LOW);
    digitalWrite (ledgreen1,LOW);
    digitalWrite (ledorange1,LOW);
    digitalWrite (ledred2, LOW);
    digitalWrite (ledorange2,LOW);
    digitalWrite (ledgreen2, LOW);
    digitalWrite (ledred3, LOW);
    digitalWrite (ledorange3,LOW);
    digitalWrite (ledgreen3, LOW);
      }
      if(distance3>200 || distance3<0){
    Serial.println("Out of Range");
    noTone(buzzer3);
  }
  else{
    Serial.print(distance3);
    Serial.println("cm");
    tone(buzzer3,sound);

  }
}

void loop() {
Serial.println("\n");
firstsensor();
secondsensor();
thirdsensor();
delay(100);
}

This is the error message:
Arduino: 1.8.13 (Linux), Board: "Arduino Uno"
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer0_pin_port'
libraries/Tone-1.0.0/Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer0_pin_mask'
libraries/Tone-1.0.0/Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer1_pin_port'
libraries/Tone-1.0.0/Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer1_pin_mask'
libraries/Tone-1.0.0/Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer2_pin_port'
libraries/Tone-1.0.0/Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer2_pin_mask'
libraries/Tone-1.0.0/Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer0_toggle_count'
libraries/Tone-1.0.0/Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer1_toggle_count'
libraries/Tone-1.0.0/Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer2_toggle_count'
libraries/Tone-1.0.0/Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `__vector_7'
libraries/Tone-1.0.0/Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

You include the Tone library and you use the tone() function from core. They are in conflict.
Use tone1.tone() or remove the Tone library and use the tone() function.

Thank you. I removed the tone library and used the tone () function by itself and it worked


text:
How do I make a motor spin every 10 minutes?
I am new to Arduino, please don't be harsh. I want to make a motor spin at every x amount of time (Lets say 10 minutes). Once the program is started, I want it to start the motor (stop after 10 seconds), and every 10 minutes, it continues the process. Is it possible to make it?,

Yes, possible and a good start for a beginner. Look into the BlinkWithoutDelay example. Try some tutorials about millis(). That will give you the understanding about how you can do timed things with an Arduino. If you have any specific problems with that, you can always come back here and ask about it :)

The simplest option is to use delay() to implement the waits:
void loop() {
    turn_motor_on();
    delay(10000);  // 10 seconds
    turn_motor_off();
    delay(600000);  // 10 minutes
}

Since these long numbers may be difficult to read, you can make them
more readable by defining some units:
const unsigned long second = 1000;
const unsigned long minute = 60000;

Then you can for example delay(10 * minute);
Beware there is a trap if you try to do arithmetics with integer
literals. The following:
delay(10 * 60 * 1000);  // BUG!

will not work on most Arduinos, as the multiplications will be
performed on the int data type, which can only hold numbers up to
32,767. It is safer to use either explicitly typed constants (unsigned long is the appropriate type for delays) or integer literals typed with
the suffix UL (which stands for “unsigned long”).
Note that the Arduino will do no useful work while delaying. If you want
to do any kind of work during the delay, see the “Blink Without Delay”
Arduino example.

Dude! Teaching a newbie to use delay? That path leads quickly to madness! (To the OP: It's fine until you want to check for a button press, read a sensor, or do anything else during that delay. The Arduino comes to a screeching halt in a delay.)

I would advise learning to use millis() to accomplish the same thing, right away. If you use delay() you will only end up having to rewrite your code later.

@DuncanC: Yes, when a beginner is at level 0, I think starting with the simplest possible approach is better. And delay() is simpler than millis(): that's why Blink is in section 1 of the Arduino examples while BlinkWithoutDelay is in section 2. Also “having to rewrite your code later” is actually a good thing for a beginner. That's how you learn! But note that I warned the OP that he may have to use the BlinkWithoutDelay approach at some point.

Yes, of course it's possible.  The loop() function might look something like:
loop(){
    turn_motor_on();
    wait_seconds(10);
    turn_motor_off();
    wait_minutes(10);
}

Now all you have to do is write your turn_motor_on() and off functions and also wait_seconds() and wait_minutes().  I'll leave the motor controls to you since you have not provided any detail on how the motor is hooked up.
You could use the Arduino delay() function:
void wait_seconds(int num_seconds){
    for(int i=0; i<num_seconds; i++){
        delay(1000);
    }
}

void wait_minutes(int num_minutes){
    for(int i=0; i<num_minutes; i++){
        delay_seconds(60);
    }
}

Of course there are many other ways to do this but this method is simple and easy to understand and will get you started easily.

source: Stack Exchange

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

sort: votes


text:
Issues converting an uint32_t into a char*
I'm using a capacitive touch sensor that as 12 touch points and stores it's state data as a binary number.

I want to take that state, add a bit of data onto the front, and then send it up to a server via websockets. I'm using the Arduino Websockets library for my websocket client.
The library has a sendBinary method that allows you to provide a character pointer for the data.

So, I wrote a function that makes a new 32 bit unsigned integer, adds my metadata, then the touch state, and then attempts to take the address of the payload integer and cast it to a character pointer:
void sendTouchStateToServer()
{
    Serial.println("sending state to server");

    uint32_t payload = touchControllerMessageType << 12;
    Serial.println(payload);
    payload |= currentTouchState;

    Serial.print("Payload contents: ");
    Serial.println(payload);
    Serial.print("Payload contents cast as character pointer: ");
    Serial.println((char *)&payload);
    Serial.print("Payload size: ");
    Serial.println(sizeof(payload));

    client.sendBinary((char *)&payload, sizeof(payload));
}

The issue is that while the integer version of the payload looks fine, when I try to cast it into a character pointer the contents is wrong.

I've also tried creating a payloadPointer and directly set the address of the integer as the pointer address, but this also fails.

(I should take this moment to say I'm still pretty green to arduino cpp concepts like this).
What's the right way of doing this? I'm reading up on pointers and trying to understand how to properly do it, but I can't quite figure it out. Could someone explain the correct way of doing it and why? I want this to work, but more than that I want to understand the "why and how" of the proper way.
Thanks! :bows:

Are you trying to send the {metadata, payload} as a string of characters? Converting the payload by casting it doesn't do what you want it to. If so, you need build the string in a buffer (char[]), convert or copy the metadata into that buffer,  convert (not cast) the data from integer to its string representation, append that string to the buffer, and finally, pass the address of the buffer (that's the (char *) you need) to the function expecting chars. Casting an int to a (char *) doesn't change it; it tells the compiler to consider this to be a pointer to characters - which it isn't!

When sending binary data, use Serial.write(), not Serial.print(). The latter is only for ASCII encoded data

Related: How can i convert a uint32_t to a char* type.

Your code with sendBinary is probably fine, as long as on the other side you also use a function that expects to receive exactly 32 bits of binary data (in little-endian format).
Trying to print (char*)&some_32bit_int on the other hand will not do anything useful.
The short version is this:

if you want to send (or receive) binary data, use functions made for binary data - they will usually take a pointer to char (or uint8_t or something like that) and a length.
if you want to send (or receive) strings, use functions meant for strings. They'll sometimes take String, or std::string or, unfortunately perhaps, char * for C strings.

Never mix both.
Functions that expect a (C) string expect it to actually be a C string, i.e. a sequence of chars ending with a null byte (0x00). The chars are expected to be mostly ASCII printable characters. If you give them just plain raw data like the memory address of an int, you won't get what you want.
Trying to print raw data using a function that expects a C string will result in garbage (or nothing at all, or a lot more garbage than you expected!). (Details in the second part.)
If you want to format your data into a string for sending (using a string/text protocol), then use functions like sprintf to do the conversion. (Or use a library that does JSON if your receiver is a web thing - that's pretty handy.)
e.g.
char buffer[32];
sprintf(buffer, "{data:%d}", payload);

Then send buffer via a function that expects a C string.

Consider this:
uint32_t payload = 0x00323130;

The first line initializes a 32 bit int to a specific value, 0x00323130 in hex. Now let's assume that payload was stored in memory at address 0x0100. The memory after that assignment would look like this:
Addr.  Val
0x0100 0x30  // our same number 0x00323130 stored in little-endian format
0x0101 0x31
0x0102 0x32
0x0103 0x00

When you do:
client.sendBinary(&payload, 4);

Those four bytes get send over the wire (or the air) exactly as they are. Nothing more, nothing less. If that's what the receiver expects you're golden.
Now if you do:
Serial.println((char *) &payload);

Serial.println is an overloaded function. When you give it a char *, it expects a C-string, which is a series of characters terminated by a "null byte", i.e. a byte value of zero. Serial.println will then look at the first byte pointed to by the argument. If it's zero, it stops. Otherwise it outputs that char to the serial line, and moves on to the next character. Repeat until a zero byte is found.
In the specially crafted case here with that specific value of payload, Serial.println would receive address 0x0100 and:

Look at the value at 0x0100, get 0x30, check that it's not zero, and pass it on to the serial line. Serial monitor would receive 0x30 and display that. By lucky coincidence this is the ASCII character code for the digit "0".
Look at the value at 0x0101, get 0x31, check that it's not zero, and pass it on to the serial line. Serial monitor would receive 0x31 and display that. By lucky coincidence this is the ASCII character code for the digit "1".
Look at the value at 0x0102, get 0x32, ... serial monitor displays "2".
Loot at the value at 0x0103, get 0x00. That is a null byte, so it stops there, and sends a newline sequence to the serial.

So in this fabricated scenario the output on the serial monitor would be "123".
Try it with payload = 0x00616263; - serial monitor will display "cba".
In short, Serial.println will output exactly the bytes it finds in memory to the serial, until it encounters a zero byte. The serial monitor will try to display those bytes. But, unless you've crafted those values very carefully, all you'll get out of it is garbage - relatively few 8bit values map to printable characters, and even when they do they won't "look" anything like the raw data you had.
If your number happens to start with a zero byte in its binary little-endian representation, Serial.println won't print anything - like if you had given it an empty string.
If your number doesn't contain a zero byte, it will keep on reading memory past the storage allocated for payload until it finds one - possibly outputing much more "junk" than a 32bit variable could ever contain.

Excellent, thorough answer. (Voted)

Good answer. I also voted.

Wow, this answer was fantastic! Thanks for taking the time to write this out. This makes a lot of sense. I'm going to do some c++ exploration outside of my arduino so i can do some memory inspection (I don't have the tools to do JTAG debugging). Thanks again for the answer!

The sending with client.sendBinary((char *)&payload, sizeof(payload)); is OK.
Your attempts to print binary data are wrong.
A print() of the 4 bytes of uint32_t as char array will print 4 characters which ASCII codes are in those 4 bytes and then continue print characters from memory after the variable, until a byte with 0 is read. Some of the characters can be a not printable terminal control characters.
A Serial.write((char *)&payload, sizeof(payload)); will print 4 characters which ASCII codes are in those 4 bytes.
The simplest way to visualize your binary payload is Serial.println(payload, BIN);. This will print the uint32_t value in binary.

Awesome. Thanks for the answer. It's good to know about the binary formatting :clap:

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


text:
Movement and storage of servo positions via bluetooth
I am trying to program a 4DOF robotic arm (using 4 servo motors). I would like to move the servos using an Android app, by means of bluetooth (HC-05).
I developed the app, in whose interface there are 7 buttons (Up, Down, Left, Rght, Forward, Backward, Save) and a field in which you can type using the keyboard (I attached an app interface screenshot).
So far, I tried to manage only Up button (which senses 'U' via bluetooth to Arduino) and Down (which sens 'D'), which would move the servo intended for vertical arm movements. That code works quite well, although the app crashes sometimes, but I still can't figure the reason out. Using the println() function I can see that Arduino reads in the bluetooth input the character '⸮ ' , what does it mean? I use a baud rate of 9600.
Then, what I would like to do is: once I have moved the servo and reached a particular position, I'd like to save the position of the motor into an array. In order to allow multiple positions saving, after Save button is pressed, I want Arduino to wait for another input from the bluetooth (so that, it would wait for another button to be clicked from the app or for something typed into the dedicated bar from keyboard) that defines the position within the array, in which I save the servo position (eg: I type '2' into the dedicated app bar and Arduino, which is waiting for an input, receiving it, saves the last servo position into the array servo01pos[2]). I wrote the "case ('S')" code that is quite long and inefficient but, at least, it works.
Thanks in advance to anyone who will help me.
Giammarco

#include <SoftwareSerial.h>
SoftwareSerial bluetooth(10, 11); //BlueTooth RX ,TX
#include <Servo.h> // servo library

unsigned long timestampSend = 0; // BT Write wait period
String readString;
Servo servo01; // servo name
byte pos01 = 90;
#define ANGLE_STEP 10 // 10 degree steps
int servo01pos\[50\];
char data;
char button;
int x = 1;

void setup() {
  Serial.begin(9600);
  bluetooth.begin(9600);
  delay(1000);
  Serial.println("Ready ...");
  Serial.println ("\n");
  servo01.attach(12);
  servo01.write(pos01);
}

void loop() {
  do {
    if (bluetooth.available() > 0) {
      Serial.println(data);
      do {
        delay(500);
        data = bluetooth.read();
        Serial.println(data);
      } while (bluetooth.available() > 0);
      if (data == 'U' || data == 'D' || data == 'L' || data == 'R' || data == 'F' || data == 'B' || data == 'S' || data == 'X') {
        Serial.print("Received value: ");
        Serial.println(data);
        switch (data) {
          case ('S'): //SAVE
            Serial.println("Enter the button you desire to set...");
            do {
              data = 254;
              bluetooth.listen();
              button = bluetooth.read();
              if (button == '0' || button == '1' || button == '2') {
                data = 'S';
              }
            } while (data != 'S');
            Serial.println("SAVING POSITIONS ...");
            if (button == '0') {
              servo01pos\[0\] = pos01;
            } else if (button == '1') {
              servo01pos\[1\] = pos01;
            } else if (button == '2') {
              servo01pos\[2\] = pos01;
            }
            servo01.write(pos01);
            Serial.println(button);
            Serial.println(pos01);
            Serial.println(servo01pos\[1\]);
            Serial.println(servo01pos\[2\]);
            Serial.println(servo01pos\[0\]);
            //}
            break;

          case ('U'):
            Serial.println("UP");
            if (pos01 <= 180 - ANGLE_STEP) {
              pos01 = pos01 + ANGLE_STEP;
              servo01.write(pos01);
              Serial.println(pos01);
              delay(20);
              Serial.println(data);
            }
            break;

          case ('X'):
            Serial.println("EXIT");
            x = 0;
            break;
        }
      }
    }
  } while (x != 0) ;
}

When your app crashes, it might send garbage data via serial, which then gets interpreted as a reversed auestion mark. You should look into the logs of your app to check, why it crashes. What is your question about the rest of the project? You didn't formulate one there

Thank you for your answer. I tried with the catlog but no problems seems to occour (I'll try again just to be sure). My main question is just about the reversed question mark. The second part is just to know if there are others easier way to do what I would like to do in the case 'S'.
Many thanks.
Giammarco

I just tried using a random app downloaded from PlayStore (and using the same Arduino code) and I still have that problem. In that case I think I can say that it is not a my app problem, is it?

I think I solved the problem using a power supply. It seems that the reversed question mark occurred when there was a power outage. Now it seems to work properly. Thank you very much again for your help!
Giammarco

Please write that solution into a proper answer and accept it as correct. That helps us keeping track, which questions are already answered.

The character '⸮ ' was given everytime there was a power outage. So, it is enough to use an external power supply to power bluetooth and servos (Arduino cannot power all those modules simultaniously).

As chrisl mentioned, you should mark your answer as accepted.


text:
What’s the most common (and low cost) microprocessor with at least two threads?
I want to make a next version of my current project. I’m hoping to use an Arduino compatible processor that also supports at least 2 processes simultaneously without using pro threading or any other software workaround. The more commonly used the processor is, the better the user support will be if something goes wrong.

What do you by "supports at least 2 processes simultaneously without using pro threading". What's "pro threading" in this context? Is that a specific library/framework?

ESP32.  Dual core 240MHz, plus an extra XLP state machine.  Cheap and easily available on eBay/Amazon/Ali Express etc.  And with full Arduino support.

You may also be interested in the Teensy 4.0. It is single-threaded (one CPU core), but it executes two instructions at a time if possible and runs at 600 MHz.
Beyond that, I only know of the ESP32 as well, for genuinely having two threads. Beware, if you want to design a product using that there might be extra hurdles with the FCC/whatever your country has since it is a radio emitter. Using an ESP32 module might simplify things, but I have very little idea how the legalities work.
It also seems a little wasteful to use a processor with Bluetooth and WiFi capabilities just because you need two threads, but it may be the only option.


text:
Ultrasonic Sensor(HC-SR04) recording random distance
I am am trying to make a code which automatically controls relay on basis of ultrasonic sensor measurements. I am using a nodeMCU as a microcontroller rather than an arduino. The relay and the ultrasonic sensor is being powered from a 5V source and nodemcu from a 3.3V Source. I don't think none of the sensors are interfering with each other as all the sensors are kept at a distance. Due to the random values my relay is being latched without any reason.
Can someone please help me out with the problem. I don't want these values(above 3000) being shown in the serial monitor.
#define TRIGGER 5
#define ECHO    4
#define RELAY   0

void setup() {
  Serial.begin(9600);
  pinMode(TRIGGER, OUTPUT);
  pinMode(ECHO, INPUT);
  pinMode(BUILTIN_LED, OUTPUT);
  pinMode(RELAY, OUTPUT);
}
void loop() {
  long duration, distance;
  digitalWrite(TRIGGER, LOW);
  delayMicroseconds(10);

  digitalWrite(TRIGGER, HIGH);
  delayMicroseconds(10);

  digitalWrite(TRIGGER, LOW);
  duration = pulseIn(ECHO, HIGH);
  distance = (duration / 2) / 29.1;

  if (distance < 30 ){
    digitalWrite(RELAY, HIGH);
  }else{
    digitalWrite(RELAY, LOW);
  }

  Serial.print("Centimeters: ");
  Serial.println(distance);

}

Please no text as image. You can copy and paste the text from the serial monitor and format it as code.

First thing: disconnect the relay, and try to just measure the distance. If it's still as bad, then either your target is not providing a strong enough echo, or some other object is giving too strong an echo.

These random values could be nothing but noise as your receiver may be sensing other source of ultra sound. In your case, the circuit is especially sensitive as the output powers a relay and any noise in the input side will cause the relay to "chatter". There are many approaches to filtering and smoothing out the signal. One method would be to implement a basic averaging algorithm where you take several readings and then average out the result. Compare this result with the threshold and the output should be smoother.
EDIT
Here is a rudimentry example, where I take multiple readings (nb_measurements measurements) and then take the average over it:
long getDuration() {
  digitalWrite(TRIGGER, LOW);
  delayMicroseconds(10);

  digitalWrite(TRIGGER, HIGH);
  delayMicroseconds(10);

  digitalWrite(TRIGGER, LOW);
  return pulseIn(ECHO, HIGH);
}

void loop() {
  float duration = 0, distance = 0;
  int nb_measurements = 10;
  for (int i = 0; i < nb_measurements; i++) {
    duration += getDuration();
  }
  duration = duration/nb_measurements;
  distance = (duration / 2) / 29.1;

  if (distance < 30 ){
    digitalWrite(RELAY, HIGH);
  } else{
    digitalWrite(RELAY, LOW);
  }

  Serial.print("Centimeters: ");
  Serial.println(distance);

}

Due to the extra processing, this will be in theory slower than your previous code but in practice, you wouldn't perceive it as long as you keep nb_measurements at a reasonable value. There are more complex digital signal filtering algorithms, search around and you can find good documentation and libraries online.

Could you help me with that please

@ShubhamBajaj, Sure have a look at the edited answer

Look at the OP's data: averaging won't help. The bad values are about 50 times larger than the good ones. A single bad value within your 10 samples will put the average completely off. And these bad values are about 50% of the samples.

Is there a way to decrease noise in hardware level instead of software level?

@YaMin Some high frequency noise can be eleminated using a small value decoupling capacitor


text:
Maximizing SPI-speed between Arduino DUE and RA8875 display driver
For a project I would like to be able to control my RA8875 display driver as quick as possible using an Arduino due.
I started from the Adafruit library and replaces all  "digitalWrites" with direct port manipulation.
Apart from that I wanted to also use that maximum possible SPIspeed.
In the adafruit datasheet I didn't find any specification of the maximum SPIspeed of the controller. In an older datasheet I only found the max speed in relation to the system clock. But I have no idea what that is. .
After googling, the max spi speed of the RA8875 seems to be 12Mhz (source).
So I decided to just try different SPIspeeds. Though I do found the library's Adafruit_RA8875.cpp file a bit confusing since it defines uint32_t spi_speed multiple times based on the architecture.

Once starting at line 48
Once starting at line 134
Once starting at line 164

And the chosen speeds for each architecture are not consistent between those 3 assignments.
I decided to replace line 66:

SPI.beginTransaction(SPISettings(spi_speed, MSBFIRST, SPI_MODE0));

with:

SPI.beginTransaction(SPISettings(12000000, MSBFIRST, SPI_MODE0));

and tried other speeds. But it always resulted in a black screen on my display.

To speed up the RA8875, you should start with small clock frequency to initialize the RA8875 including the pll configuration and then you can make the clock frequency faster. It works with me.


text:
esp2866 powered externally not working
I got a beginner level problem.
I got two esp2866 nodeMCU, they both work with the usb cable and I can get the blink program to run though it.
Running them with external power doesn't seem to work though. I expect the blink program to run when I plug them in but I get no led light signal at all. My power source looks identical to this. I got jumpers set on 5V. I don't have a voltage meter but I've tested against my Arduino Uno and it runs as expected when connected to the same wires.

Shouldn't I get the blink signal or any other led signal if the nodeMCU got power?
Any clue to how I could fail to provide power?

thank you!
edit: picture and jack barrel power input: 5V 3A

Consider editing your question to include decent images of your wiring.

If you're using the barrel jack into that regulator board, the voltage being provided to the barrel jack may also be important to know.

@timemage- done

It seems like the specification of the NodeMCU VIN as working with 5V is very misleading. I have a board that has the same issue as you, and my 5V supply does turn the NodeMCU on, but I can't get the WiFi to broadcast!

Read the answer by @timemage. The voltage going into the board is not 5V but some lower voltage, caused by the voltage drop in the breadboard power supply. Add to that the fact that all NodeMCU's are not created equal, especially when connecting things to their power bus.

Linear Regulator Dropouts
The linear voltage regulators found on that board are going to expect more than 5V at the barrel jack, because they require a minimum "drop out" voltage.  The AMS1117 that is on that board, so far as I can tell, has a drop out voltage up to 1.3V.  So you would want at least 6.3V (perhaps better 7V) at the barrel jack in order to get 5V out of it.
So the NodeMCU board may be seeing 5 - 1.3 or 3.7V at the input to its 3.3V regulator, which also requires its own drop out.  The output of that 3.3V regulator may then be significantly below what the esp8266 specified operating voltage range.
UPDATE
So I did the tests mentioned in the comments, just to illustrate the problem.  And the results are about as expected.
I altered the stock blink sketch that comes with IDE version 1.8.13 to use LED_BUILTIN (as opposed to 9) in the pinMode and digitalWrite calls.
I changed the LOW period, which is LED ON for my board, to 10000ms so that my voltmeter would have time to settle on a voltage test across the LED.
And I uploaded to the board, a NodeMCU 1.0 clone by Hitletgo.
When powered on its USB micro b jack, 3.3V labeled pin of the broad measuring 3.30 V.  The LED color is blue, it is bright and it is dropping 2.66V.
Then I switched to powering the NodeMCU board by via of VIN pins from the YwRobot regulator board.  I provided 5.05V to the barrel jack.  To not great surprise, it does not blink.
The voltage out of regulator board was 3.26V.  To be clear, I have this jumper for 5V.  As a sanity check, I jumpered it for 3.3V and got about 2.5V out of it.  Again, this is unsurprising because it also needs a dropout voltage.
I then measured the "3.3V" header line on the NodeMCU itself to be 2.14 V.  Without sufficient voltage into the 3.3V regulator, it is not providing 3.3V out.  And what it is producing is below that LED forward voltage when lit.  So it is not surprising that it is not lit.
The ESP8266 technical specifications suggest that it can run down to 1.8V.  So just for the hell of it I connected the board back to USB and updated the blink sketch to "blink" D8 (or GPIO15) 4 seconds on, 4 seconds off.  I did not attach anything to this pin except the voltmeter.
I then reconnected the board to the test rig and found with a meter that it is "blinking" D8 just fine with a logic level consistent with the voltage the ESP8266 is actually receiving.
So in summary, the arrangement here is running the ESP8266 but there is not enough available voltage for it to light the LED.  And it is very likely the exact same thing is happening for you.

Thank you, that sounds reasonable. I assume then my Arduino Uno was just flexible enough so it could run on 3.7V.

@bhenriksson, Possibly.  The ESP8266 module may also go lower than the NodeMCU board as whole can.  To take a simple example, if your LED is blue, it's possible your esp8266 is still functioning but unable to get enough forward voltage to turn on the LED.  You're going to want a meter sooner or later.  Sooner probably is best.

@bhenriksson, tell you what: I will try to locate my NodeMCU clone here and the regulator board that I have of that design.  If I'm able to do that, I may update the question with my measurements, as an example. Though it's difficult to say for certain how well this will translate to your exact conditions.  In the meantime maybe try to locate a 7V to 9V adapter and try that.

@bhenriksson, I probably should have mentioned that there's a diode on the on the breadboard voltage regulator board between the barrel jack and the 5V regular that drops additional voltage, very roughly half a volt, which probably explains why the 5V line is lower than the expected minimum of 3.7V.  I did not measure it, though.  I may update it to include that later.

Think of Vin like a car, not enough gas and you will not get there. Over fill it and you could burn it up.

I can confirm the 'burn up' theory.


text:
Do the I/O pins on Arduino read current or voltage?

So I've recently started Arduino and I just had a question about the digitalRead() function.
Does the IO Pins read Voltage or Current?
The reason I'm asking is because of the attached circuit.
So IO pin 7 is HIGH when the button is not pressed because the resistor is connected to 5V through the resistor. When the button is pressed the button is shorted to ground and is LOW. Why does it read LOW? Surely it would still read 5v because it is still connected to 5V through the resistor?

you do not need a pullup resistor on the switch ... just enable the internal pullups

Surely it would still read 5v because it is still connected to 5V through the resistor? Equally you might argue it will read 0v because it is connected to Gnd via a direct short. The short will take precedence over the resistor.

They read voltage.  When you close the pushbutton switch the input should have a 0V or digital "0" on it.  When you open the pushbutton the resistor should pull the input to 5V or digital "1".
Yes, it is still connected to +5V via the resistor but the nearly 0 Ohm switch pulls the line all the way (or very close) to 0V.

For digital pins, it's more of a voltage comparison. They only measure if the voltage is above of below a certain threshold. So they only check whether it's HIGH of LOW. For the ATMega328p on the UNO, any voltage below 1.5V will return a LOW / 0, and anything above 3.5V will return a HIGH / 1. (Any voltage in between don't have a guaranteed outcome).

@Gerben If we're aiming to be absolutely accurate here, then the actual specification for Vil(max) is 0.3 * Vcc and Vih (min) is 0.5 * (0.6 * Vcc).  So if you are running at Vcc = 5.0V that comes out to be 1.5V and 3.5V.  If your Vcc is different from 5.0V, then these values also vary. See the Atmel/Microchip ATMega328P datasheet on page 258.  https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf


text:
How to identify pinout of ATmega 2560 derivative board?
My 3d printer, Creality Ender 4, has an ATmega 2560 chip based card, and I need to identify the number associated with a particular Pin.
I read, on the official Arduino website, a simple tutorial in which through a small led connected to two pins of the card, you wrote a code (sketch) that made it turn on, but you had to know the Pin number.
I would like to do this on my board, I unplug all cables (power supply, motors, etc.) and connect it to the PC via USB and from Arduino IDE, I execute the code, connecting the LED on the ground and on the signal (see image).
To identify the Pin number I thought I would go to exclusion, because I know all the PIN numers of the chip, until the LED lights up.
So I ask, is that correct? is there a chance of damaging the card? or is there a better method?
Thanks in advance

not correct because the microcontoller pins are not directly connected to peripheral plugs on the board ... yes, the board could be damaged ... it is better to obtain a schematic diagram or at least a table of pin functions

The 3dpinter/board manufacturer don't want give me the schematics, or just the number I need. On the internet there is very little info about the board...

I'd suggest using a multimeter in continuity mode, on the unpowered board. Then check which MCU pin is connected to the pin you're looking at.

Disconnect everything but the switch.
Run this:
for each pin,
  set the pin to INPUT_PULLUP mode;
  do,
    read and print the pin number and pin state;
  until operator touches a key;
  read and discard the serial input;
end;

You do:

Each time a new pin number prints on the terminal,
toggle the switch a few times to confirm whether you are seeing the result of your actions.
If not, touch the spacebar to try the next pin #
else, you found it.


text:
RadioHead library change the state when a new message is received
I would like to control a toy car from the server. I use RadioHead library for communication and it works fine.
The application running on the server side is as follows.
#include <RHReliableDatagram.h>
#include <RH_ASK.h>
#include <SPI.h>

#define SERVER_ADDRESS 1
#define ROBOT_ADDRESS 2
#define GO_RIGHT "Go right"
#define GO_LEFT "Go left"
#define GO_FORWARD "Go forward"
#define GO_BACK "Go back"
#define STOP "Stop"
#define SERVER_DELAY 500

unsigned int transmitterPin = 10;
unsigned int receiverPin = 12;

RH_ASK transmitterServer(2000, receiverPin, transmitterPin, 0);

RHReliableDatagram radioCommunication(transmitterServer, SERVER_ADDRESS);

void setup()
{
    Serial.begin(9600);
    if (!radioCommunication.init())
        Serial.println("Radio communication failed");
}

uint8_t buffer[RH_ASK_MAX_MESSAGE_LEN];

void sendData(uint8_t * data, uint8_t length)
{
    Serial.println("I'm sending commands to the robot");

    // Send a command to the robot
    if (radioCommunication.sendtoWait(data, length, ROBOT_ADDRESS))
    {
        // Now wait for a response from robot
        uint8_t from;
        if (radioCommunication.recvfromAckTimeout(buffer, &length, 2000, &from))
        {
            Serial.print("I've got - ");
            Serial.print((char*) buffer);
            Serial.print(" - message from the robot whose addres is : ");
            Serial.print("0x");
            Serial.println(from, HEX);
        }
        else
        {
            Serial.println("No response. Does the robot works?");
        }
    }
    else
        Serial.println("Attempt to resend data failed.");
    delay(SERVER_DELAY);
}

void loop()
{
    sendData(GO_RIGHT, sizeof(GO_RIGHT));
    sendData(GO_LEFT, sizeof(GO_LEFT));
    sendData(GO_FORWARD, sizeof(GO_FORWARD));
    sendData(STOP, sizeof(STOP));
    sendData(GO_BACK, sizeof(GO_BACK));
    sendData(STOP, sizeof(STOP));
}

The application running on the robot is as follows.
#include <RHReliableDatagram.h>
#include <RH_ASK.h>
#include <SPI.h>

#define SERVER_ADDRESS 1
#define ROBOT_ADDRESS 2
#define GO_RIGHT "Go right"
#define GO_LEFT "Go left"
#define GO_FORWARD "Go forward"
#define GO_BACK "Go back"
#define STOP "Stop"
#define RIGHT_LIGHT 4
#define LEFT_LIGHT 7
#define FORWARD_LIGHT 8

unsigned int receiverPin = 2;
unsigned int transmitterPin = 12;

RH_ASK robotTransmitter(2000, receiverPin, transmitterPin, 0);
RHReliableDatagram radioCommunication(robotTransmitter, ROBOT_ADDRESS);

void setup()
{
    Serial.begin(9600);
    pinMode(RIGHT_LIGHT, OUTPUT);
    pinMode(LEFT_LIGHT, OUTPUT);
    pinMode(FORWARD_LIGHT, OUTPUT);

    if (!radioCommunication.init())
        Serial.println("Radio communication failed");
}

uint8_t buffer[RH_ASK_MAX_MESSAGE_LEN];
uint8_t command[RH_ASK_MAX_MESSAGE_LEN];

void moveRight()
{
    Serial.println("------------");
    Serial.println("I'm going right");
    Serial.println("------------");

    /*
       // Time consuming task

    for (int i = 0; i < 3; ++i)
    {
        digitalWrite(RIGHT_LIGHT, HIGH);
        delay(1000);
        digitalWrite(RIGHT_LIGHT, LOW);
        delay(1000);
    }

    */
}

void moveLeft()
{
    Serial.println("------------");
    Serial.println("I'm going left");
    Serial.println("------------");

    /*
       // Time consuming task

    for (int i = 0; i < 3; ++i)
    {
        digitalWrite(LEFT_LIGHT, HIGH);
        delay(1000);
        digitalWrite(LEFT_LIGHT, LOW);
        delay(1000);
    }

    */
}

void runCommand(char* command)
{
    if (strcmp(command, GO_RIGHT) == 0)
    {
        moveRight();
    }
    else if (strcmp(command, GO_LEFT) == 0)
    {
        moveLeft();
    }
}

void loop()
{
    uint8_t response[] = "OK";
    if (radioCommunication.available())
    {
        uint8_t length = sizeof(buffer);
        uint8_t from;
        if (radioCommunication.recvfromAck(buffer, &length, &from))
        {
            Serial.print("I got - ");
            Serial.print((char*) buffer);
            Serial.print(" - command from the server whose addres is ");
            Serial.print("0x");
            Serial.println(from, HEX);
        }
        // Send the message to the server (with retries) and wait for an ack.
        if (!radioCommunication.sendtoWait(response, sizeof(response), from))
            Serial.println("Repeated attemps to send data to server failed");
        strncpy(command, buffer, sizeof(command));
        runCommand(command);
    }
}

As it stands, the serial output of robot is as follows:

Let's increase the SERVER_DELAY variable to 2000. This way the server will send a command every two seconds.
Besides this, let's run a command that will take some time on the robot. To do this we might uncomment time consuming task lines.
So that, when the robot receives Go right command, it will try to turn on and off lights three times.
After making these changes let's look at the serial output of robot.

What happens is, after receiving the Go left command it tries to blink LEFT_LIGHT three times. But meanwhile it misses Go forward command. And again after receiving the Go right command it tries to blink RIGHT_LIGHT three times but misses Go left command.
What I would like to do is when robot receives a new command, it should stop whatever it was doing and execute the new command.
How should I do this? Any ideas. Thanks.

An easy-enough fix would be to replace your delay calls with something that regularly checks if data is available from the server.
Something like:
/* returns true if the sleep was interrupted by incoming data */
/* warning: does not wait at all if data is available */
bool interruptible_delay(unsigned long ms)
{
  unsigned long end = millis() + ms;
  while (millis() < end) {
    if (radioCommunication.available()) {
      return true;
    }
    delay(10); /* tune to taste */
  }
  return false;
}

This should work as long as the innner delay is much shorter than your communication timeouts.
You will most likely need to handle the case where the sleep was interrupted in your "action" functions if they become more complexe than a led blink. I.e. if your action is a series of complex motor moves, and a message arrives in the middle, you need to design the function so that it is in a safe or neutral state before returning to the main loop.

I was about to figure out that might be related to delay function. Your solution is brilliant. It works like a charm. Thanks.


text:
OV2640 Camera example with Arduino
I searched for ov2640 with Arduino examples but only I could get the examples of Arducam. So I'm trying this example with OV2640 camera. As ov7670 and ov2640 have similar pinouts. But I'm not getting the image(output)(But I got the output while using OV7670 camera). I don't know why I'm not getting the output. Someone please let me know where do I go wrong(Reference image attached) and please let me know any other example you may know.
Thank you,
Roshan

There's no datasheet at the link you provided. From what I've been able to find out, the OV2640 works at 1.2V while it looks like you're supplying it with 1.8V. That might be a problem. Output I/O voltages might also be too low to be recognized by the Arduino.

As I seen in other project OV2640 camera with PIC microcontroller. They used to supply 1.8V. They used MIC550 IC to regulate(1.8V) the voltage. I used here lm317.                       https://www.circuitvalley.com/2019/06/opensource-diy-usb-webcam-ov7670-ov2640-pic32-USB-UVC-Video-device-class.html


text:
How to send Serial data from an Arduino Uno into the Serial of an ESP-01?
So, i need to send sound sensor data from an Arduino Uno to the ESP8266 (ESP-01), so it can output a push notification to my phone whenever there's a loud noise. I have the sensor just powered and hooked up to the Analog 0 pin, and the ESP powered and hooked up to the Arduino Serial pins in reverse (RX to TX, TX to RX)
This is the code i have on the Arduino:
void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.write(analogRead(A0) + "\r\n");
  delay(100);
}

And this is the code i have on the ESP:
(i'm omitting the notification part for clarity, it doesn't even use Serial, so i don't think it should interfere)
void setup() {
  Serial.begin(115200);
}
void loop() {
  String val;
  val = Serial.readString();
  if( val.toInt() < 50 ){ sendNotification("Hello!"); delay(10000);}
}

I have tested the Sensor output and it seems fine, whenever i snap or clap the readings show a peak (although reversed, it stays on 1023 constantly then peaks to around 0~50), and the ESP can also send notifications normally. But the trigger on the notification never seems to fire, so i guess the ESP is not receiving the data properly.
I'm new-ish to Arduino, so i don't know if i'm doing something wrong here,
Thanks in advance!

Serial.println(analogRead(A0)); will send the value as text terminated by \r\n. at receive side use at least readStringUntil

Writing Junk From Memory
Serial.write(analogRead(A0) + "\r\n");

This is advancing a pointer to "\r\n" by whatever number is being returned by analogRead.  In other words, you are not sending the measurement but junk from memory after (or sometimes at) "\r\n"'s memory location.
Serial.println(analogRead(A0)); appears to be what you were going for here.  println's line termination for the UNO serial connection is "\r\n".
Logic Levels
When it comes to attaching the serial connections together, there should be some level conversion going on.  Because an UNO's pins are 5V logic levels and the ESP-01 expects 3.3v levels.

Thanks for the info! Just writing the analogRead(A0) wasn't working, so i supposed the ESP needed the newline and carriage to accept input, just like the AT commands.
The level conversion you said is an hardware conversion, like reducing the 5V to 3.3V with a resistor, or is it a software conversion of some kind?

For the UNO TX to ESP-01 RX a resistor voltage divider will probably work fine.  Going in the other direction you'll need some kind of buffer to reliably get to the UNO's minimum logical level high voltage.

Thanks again! I'll go buy a regulator and see if it works. Another question, i only need to send the serial from the UNO to the ESP, the ESP never sends anything back. Do i need the buffer to regulate the tension for the ESP to UNO connection anyway?

@Jao: there are things called "logic level converters" available that are built for this sort of scenario. Worth a look instead I think.

@Jao, in the direction of UNO to ESP it is likely you just need to create a divider on your UNO TX's signal and the level converter would not be strictly necessary, although one can probably be more efficient.  A divider is a simple solution.  Keep in mind that your UNO TX/D1 is the same signal ultimately goes back to the PC, so when you use it to send to the ESP-01 you are also sending stuff to the PC/Serial Monitor.

Also your ESP-01 is not a 5V device.  So you don't want to power it from 5V in case you've been doing that.  You'll also want to avoid trying to power it from the UNO's 3.3V line, which won't likely provide the current the ESP-01 will demand when doing anything on WiFi.


text:
Error uploading to esp 32 board
I had a problem when installing the esp32 core. I couldn't do it through the board manager procedure because I can't find esp32 for installation in the board manager even though I put the link correctly in the preferences section so I had to download a zip file and unzip it in hardware/espressif/esp32 folder. Now whenever I try to upload the code(a simple LED blinking code) it says error compiling for board with the following error message
exec: "C:\Users\ABDUL\Documents\Arduino\hardware\espressif\esp32/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++: file does not exist
Please help me. I don't know what to do anymore

So does the file, C:\Users\ABDUL\Documents\Arduino\hardware\espressif\esp32/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++, exist?

You know that, besides entering the link in the preferences section, you have to download and install the new board manager from the "Tools->Board XXX->Board Manager" menu, don't you?

what link is this? ... I put the link correctly in the preferences section

This link "https://dl.espressif.com/dl/package_esp32_index.json". I put it in preferences but I couldn't find the esp32 for installation in tools>boards>board manager. I searched as instructed but I couldn't find it

Sometimes it seems to help to close and reopen the IDE after editing the boards manager URLs list.

The correct link is https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

I just tried it. It's showing the same result as the previous one. It's not showing esp32 in the board manager

Have you tried reinstalling the IDE or installing an older version?


text:
Arduino keypad variables to serial port
I've been trying, for over a week now, to create a program that will store my keypad presses into variable, and with a press of an enter, it will switch to the next variable to store the presses. The program is made to load addresses (mainly IP addresses) to different devices over serial connections. Because there are different types of addresses, each time the user press enter in the keypad (made the # button to a '\r' char) the program needs to switch to the next type of address and get the key presses from the keypad and store them until the next '\r' press. My problem is that I don't know how to store those addresses in the Arduino, and switch to a different "char" (I used char because I didn't knew how to convert them to store key presses into string) every '\r' press. I've included the handler for this part of my code. This is my first post here so if anything is missing let me know. thanks ahead.
bool handlerManualEntry( void )
{
    static uint8_t stateManualEntry = statesFunc::ST_INIT;

    char keyval = ReadKey();
    switch( stateManualEntry )
    {
        case    statesFunc::ST_INIT:
            //do whatever inits you need here (screen, variables etc)

            stateManualEntry = statesFunc::ST_RUN;

        break;

        case    statesFunc::ST_RUN:
            //is there a keypress?
            if( keyval != NO_KEY )
            {
                switch( keyval )
                {

                    case    '\r':
                        //when we get a return, send it to the serial port
                        Serial.print( '\n' );
                        u8g2log.print('\f');
                        for(int i=0; i<6; i++)
                        {
                          if(i == 0)
                          {
                          Serial.print(ethernetIP);
                          }
                        else if(i == 1)
                          {
                          Serial.print(ethernetSubnet);
                          }
                        else if(i == 2)
                          {
                          Serial.print(ethernetGetway);
                          }
                        else if(i == 3)
                          {
                          Serial.print(vmeIP);
                          }
                        else if(i == 4)
                          {
                          Serial.print(vmeSubnet);
                          }
                        else if(i == 5)
                          {
                          Serial.print(eventPort);
                          }
                        else if(i == 6)
                          {
                          Serial.print(timeOut);
                          }
                        }
                        //and finish out by returning the state to INIT and returning true
                        //stateManualEntry = statesFunc::ST_INIT;
                        //return true;

                    break;
                    case 'D':
                          u8g2log.print('N');
                          Serial.print('N');
                    break;

                    case 'C':
                          u8g2log.print('Y');
                          Serial.print('Y');
                    break;

                    default:
                        //for any other key, print to the serial port and LCD
                        u8g2log.print(keyval);

                        enterAddresses();
                    break;

                }

            }

        break;

    }

    return false;

}

void enterAddresses()
{
  int x;
  if(keyval != '\r')
  {
    if(pointer == 1)
    {

      keyval = keypad.getKey();
      u8g2log.print(keyval);
      ethernetIP += keyval;
    }
    else if(pointer == 2)
    {
      keyval = keypad.getKey();
      u8g2log.print(keyval);
      ethernetSubnet += keyval;
      }
    }
    else if(pointer == 3)
    {

      keyval = keypad.getKey();
      u8g2log.print(keyval);
      ethernetGetway += keyval;

    }
    else if(pointer == 4)
    {
      keyval = keypad.getKey();
      u8g2log.print(keyval);
      vmeIP += keyval;
    }
    else if(pointer == 5)
    {
        keyval = keypad.getKey();
      u8g2log.print(keyval);
      vmeSubnet += keyval;
    }
    else if(pointer == 6)
    {
      keyval = keypad.getKey();
      u8g2log.print(keyval);
      eventPort += keyval;
    }
    else if(pointer == 7)
    {

      keyval = keypad.getKey();
      u8g2log.print(keyval);
      timeOut += keyval;

    }
    pointer++;
    u8g2log.print('\f');

}

char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'.','0','\r','D'}
};

byte rowPins[ROWS]={39,41,43,45};
byte colPins[COLS]={31,33,35,37};

//Create an object of keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
char keyval;

please format all of your code, not just parts of it ... it is unreadable the way you presented it

what is the reason for using for(int i=0; i<6; i++) to run seven Serial.print() commands in sequence?

Consider constraining the user and simplifying your code.

Simplify your code by putting rules on how the IP address is entered. When entering the IPv4 address in dot-decimal notation require that all 3 digits are always used for each of the four quad-dotted notation values.  For example, the IPv4 address 192.168.10.20 would be entered as "192168010020".

Eliminate unnecessary keypad buttons.

The only keys required for the above scheme are 0, 1, 2, ..., 9.  No other keys need to be detected or supported by additional software.

Start simple, get that working then add complexity.

Essentially, a state machine is most often used as the underlying coding pattern when interfacing with a user.  Keeping track of what the user has done, the current state the user is in and where the user may go is the job of the state machine.  To implement the above, the state machine will need to be complex enough to track the 1s, 10s & 100s position of each quad-dotted notation values as well as which quad-dotted notation value is currently being entered.  This is complex enough for a first pass.  Later, in subsequent passes, consider adding an "abort" key for when the user feels a new attempt is in order.  Still later, consider adding a "back space" key.  Finally, consider adding an "enter" key and dripping the 3 digit per quad-dotted notation value requirement.


text:
Switch case options get broken after a function call
I'm sorry for the basic question, but I have a switch case where any code placed after a certain function call simply never gets called, and I've spent half a day looking at it, so thank you so much for your help.
Running on an Arduino UNO.
Here is the loop, and every option in the switch case after the call to moist_sensor.read() simply never gets in:

void loop() {

  while (Serial.available() > 0) {
    char val = (char)Serial.read(); // read data byte by byte and store it
    Serial.println(val);
    switch(val) {

      case 'O':
            digitalWrite(13, LOW);

            break;

      case 'I':
            digitalWrite(13, HIGH);

            break;

      case 'W':
            water(2000);
            break;

      case 'E':

            int reading = moist_sensor.readd(); //THE PROBLEMATIC LINE
            //Serial.println(reading); // send the received data back to raspberry pi
            break;

//it never enters any of these cases below

      case 'M':

        //String reading2 = moist_sensor.packaged_reading();
        //Serial.println(reading2); // send the received data back to raspberry pi
        break;

      case 'W':

        water(5000);
        break;

      default:

        delay(5000);

    }
  }

I've tried changing the name of the function with fears of special keywords, swapping it with other cases (such as putting case 'W' above, where it works, and vice versa), and I always get the same behaviour. If i comment the line, everything works as expected.
I know the method isn't actually called all the time, but for sanity's sake, moist_sensor.readd() right now is just:
int readd() {
return 0;
}

It also works fine if its the last case, but this buggs me, and I want to create other cases with function calls.
Thank you so much!

You seemed to have solved it. For the reason, take a look at the compiler errors:
sketch_nov22a:31: error: jump to case label [-fpermissive]
       case 'M':
            ^
sketch_nov22a:25: error: crosses initialization of 'int reading'
             int reading = moist_sensor.readd(); //THE PROBLEMATIC LINE
                 ^
sketch_nov22a:38: error: jump to case label [-fpermissive]
       case 'W':
            ^
sketch_nov22a:25: error: crosses initialization of 'int reading'
             int reading = moist_sensor.readd(); //THE PROBLEMATIC LINE
                 ^
sketch_nov22a:43: error: jump to case label [-fpermissive]
       default:
       ^
sketch_nov22a:25: error: crosses initialization of 'int reading'
             int reading = moist_sensor.readd(); //THE PROBLEMATIC LINE
                 ^
exit status 1

If you got it to compile your compiler must be configured a bit differently to mine. However you can see that by putting int reading = ... in the case block, the compiler tries to execute that first (to initialize reading) which causes it to jump case labels.
By moving int reading outside the case statement, the compiler no longer has to initialize the variable, and that line merely becomes a function call and assignment (not a variable initialization).

You can avoid that by putting the code into its own block, that is, instead of:
  case 'E':

        int reading = moist_sensor.readd(); //THE PROBLEMATIC LINE
        //Serial.println(reading); // send the received data back to raspberry pi
        break;

Use:
  case 'E':
        {
        int reading = moist_sensor.readd(); //THE PROBLEMATIC LINE
        //Serial.println(reading); // send the received data back to raspberry pi
        }
        break;

Yeah, I'm using the arduino-cli to compile/upload to the board from the RPI, and while I do get error messages, turns out I might be missing a ton of warnings.
Interesting to actually look into the "error: jump to case label" and how it messes the compilers logic by still considering the variable declaration valid in the next cases of the switch, but not the initialization.
Thank you for the block fix! I always thought repeated declarations in cases like this would be optimized by the compiler, does it apply to this case? I'd prefer to avoid a needlessly global variable.

The scope and lifetime of a (non-static) variable inside a block is the block itself. The compiler may well put that variable into a register and not use memory at all. So I would say, yes the compiler will optimize as much as it can.

As soon as I posted this, I looked at the variable declaration inside the case and thought I'd fix this ugly code, and turns out that is what breaks the entire thing, I had no idea...
case 'E':

            int reading = moist_sensor.readd(); //THE PROBLEMATIC LINE
            //Serial.println(reading); // send the received data back to raspberry pi
            break;

should just be
case 'E':

            reading = moist_sensor.readd(); //THE PROBLEMATIC LINE
            //Serial.println(reading); // send the received data back to raspberry pi
            break;

with the "int reading;" declaration somewhere else above.


text:
What is the advantage of a 3MP OV3660 sensor on the ESP32 M5Stack camera if it can only save upto 2MP images?
I am making a self-contained stills camera and the ESP32-based modules seem well-suited to my project due to the easy incorporation of a TFT viewfinder screen and TF card slot in one package. I am not interested in saving video or web streaming.
I have worked with the TTGO ESP32 camera that uses the OV2640 2MP sensor and can save full 2MP UXGA (1600x1200) resolution stills (albeit with mandatory JPEG compression turned on - I have only managed to get 1.3 MP images without compression).
I see now there is a version of ESP32 camera that uses the OV3660 3MP sensor (called 'M5Stack Timer Camera'). However, the specs for that camera https://docs.m5stack.com/#/en/unit/timercam say it can save upto a maximum of UXGA - i.e. 2MP images.
So what is the advantage of having a 3MP sensor chip if you can only save 2 MP images? Or is there a way of saving the full 3MP sensor resolution (i.e. 2048 x 1536) stills from this camera?
Thanks

I contacted the M5Stack people directly and they assured me that they made an error in their original web page specs and that the camera does indeed support full 3MP capture. So I bought one of these M5Stack Timer Cams and tested it. I can confirm that the device will save a 3 MP image at full QXGA resolution (2048 x 1536).
This option was not available on with the Win10 example app they provide but it was only possible with their official Arduino 'webcam' example. This is a web server WiFi example sketch and one of the options is QXGA and this does work.
So the definitive answer to my question (based on practical experience) is that the advantage of using the OV3660 is that it can provide 3MP pictures and the original specs provided by M5Stack were misleading hence the confusion expressed in my question.
It would also be interesting to hear if anyone has managed to get OV3660 working at full 3MP on other generic ESP32 boards. So far I have seen no other example published on the web.

The limit isn't the camera - it's the memory.
At 3 megapixels you have 3145728 pixels. At 3 bytes per pixel (8 bits each of red green and blue) it requires 9437184 bytes to store the image. That's more than can fit into the 8MB PSRAM.
1600x1200 will probably be one of the standard resolutions that the specific camera in use can capture, and is probably the biggest size that is below 8MB in size for a single frame.
So, what advantage of having a 3 megapixel camera? Well, none to you, other than the cost. It's probably cheaper to use a newer 3 megapixel camera than an older 2 megapixel camera.

It is perfectly possible to run at the resolutions you desire though. This resolution is known as QXGA and is supported by the OV3660 driver in the ESP32 Camera library.  There are some caveats though:

You must use JPEG compression. Not only is this to make the image small enough to fit into PSRAM but also to make it possible to write the whole frame into PSRAM fast enough that you don't miss bits of the data.
You will not be able to "do" anything with the image other than send it to somewhere else (such as an SD card or a web server). There just isn't enough room to uncompress the image.

Sure - but that assumes an uncompressed video stream at 3 bytes (24 bits) per pixel. These OmniVision sensors can output colour at 16 bits per pixel in YUYV format. So that would be uncompressed video at 6 Mb leaving 2MB for working stuff. Furthermore these OV sensors also have an inbuilt on-chip JPEG compression of the video stream before it hits the ESP32 - so the 8MB RAM should be sufficient at least for the more compressed streams. I'm guessing there must be some other reason the designers chose this 3MP chip. Possibly cost, as you say, or marketing - but I wonder if there is more to it.

@WildCat You know what you have to do to compressed images to do anything to them? You have to uncompress them. So compression is actually counterproductive, since you then have to accommodate both the compressed and uncompressed versions.

@Mejenko. Yes but you can just pump the compressed stream to TFcard without uncompressing it in RAM and you can use a low res version for viewfinder video - that is how the OV2640 in the TTGO ESP32 camera works. I can save compressed 2MP images but if I lower or switch off compression the PSRAM is insufficient. In theory they could make it work. I wonder if anyone has - and can tell us how.

@WildCat You also have to consider speed as well - writing to PSRAM is not fast, and you have to be able to write a whole frame to the PSRAM fast enough to capture it. Espressif recommend JPEG for anything larger than CIF and converting it afterwards.

QXGA is supported by the ESP-IDF so there's no reason why you couldn't do it. Just follow one of the examples and change the framesize to FRAMESIZE_QXGA

@Mejenko. Thanks for this answer. I have seen this option in the libraries but the fact that it exists does not mean necessarily that a particular hardware module can do it. I asked the question because the M5Stack manufacturer says the output resolution of the M5Stack Timer Camera is limited to 2MP. I need to know about this module in particular. Perhaps if I hook up an OV3660 sensor to a generic ESP32 board it might work but I need to know which to buy - so specifics are important. Have you actually tried with the M5Stack Timer Cam and it works?

@WildCat The M5Stack Timer Camera is just a generic ESP32 with an OV3660. There's nothing special about it. It may well be that they changed the camera module between versions and never updated that part of the website.

Your answers are reasonable in theory but practice can be different due to gaps in detailed knowledge. According to my searches a few people tried (and failed) to get OV3660 working e.g. [me-no-dev][https://github.com/espressif/esp32-camera/blob/master/sensors/ov3660.c] and some think it might be impossible [bkeevil][https://github.com/bkeevil/esp32-cam]. I have yet to see a 3MP image, from anyone, taken with an OV3660 and ESP32 - hence my question. But it may be that the folks at M5Stack have cracked this nut and missed a trick in marketing. I will do some more digging.

The m5stack timer camera X (OV3660) lacks support.
There is nothing on how to flash and use micropython in this device.
There is a cameratool you can download and take snapshots via serial port, there is the standard arduino software you can flash and that's it.
I miss some guides on how to flash micropython on it and make it work with mqtt and more complex setups. I'm not an arduino person, just want to code some python on it.
I bought 2 of those cameras and those are sitting in a shelf for 6 months with 0 use. One day when someone publish a full micropython firmware for that camera, i'll give it a try.
PS: I've tried to compile a micropython firmware with OV3660 support, but no luck on make it work.


text:
How does one upload a synthesized solution to the Arduino Vidor FPGA?
I've compiled a solution and have received a ttf file from Intel Quartus which is designed for the Vidor 4000 Arduino board. The file represents a synthesized bitstream to be sent to the FPGA. How do I upload the file to the FPGA onboard the VIDOR board? I've got a JTAG programmer if necessary.


text:
Arduino zero programming port recognized as EDBG USB port
I am using Arduino Zero with Windows 10. I tried following the procedure listed in Getting started with Arduino to set up my Arduino/environment, however, when I connect the Zero's Programming Port to my laptop's USB 3.0 port, it detects it as "Atmel Corp. EDBG USB Port" instead of "Arduino Zero Prog. Port" (or something similar) as described under the section "Installing Drivers for the Zero" in the above link. Since it is recognized as an EDBG USB Port, I am unable to burn bootloader or upload sketches using the Programming port as it cannot detect CMSIS-DAP.
when I try to upload a sketch I get the following error:
Arduino: 1.8.13 (Windows 10), Board: "Arduino Zero (Programming Port)"
Sketch uses 23496 bytes (8%) of program storage space. Maximum is 262144 bytes.
Global variables use 3536 bytes (10%) of dynamic memory, leaving 29232 bytes for local variables. Maximum is 32768 bytes.
Open On-Chip Debugger 0.10.0+dev-gf0767a31 (2018-06-11-13:36)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
debug_level: 0
none separate
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
Error: unable to open CMSIS-DAP device 0x3eb:0x2111
Error: No Valid JTAG Interface Configured.
Error: No Valid JTAG Interface Configured.

When I try to burn bootloader I get the following error:
Open On-Chip Debugger 0.10.0+dev-gf0767a31 (2018-06-11-13:36)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
debug_level: 0
none separate
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
Error: unable to open CMSIS-DAP device 0x3eb:0x2111

Error while burning bootloader.

How can I fix this?
So far, I tried

re-installing the IDE several times, and also tried uninstalling the device- but it auto installs the driver when I connect again.
Starting IDE as an admin did not help, although I think the issue is the EDBG CMSIS-DAP is not installed, and instead, the EDBG USB driver is installed

what I would try:  select EDBG programmer in Tools menu and Burn bootloader or Upload with programmerr

@Juraj, I did select EDBG programmer, chose the right board, and port when I got the error messages.

is it a genuine Arduino Zero? please add a link to a page where you bought it

I bought it a while ago and based on the confirmation email, I bought it from Arduino LLC and the email was from  "Arduino Store USA store-usa@arduino.cc"

ok. are you sure the USB cable good?

Yes, I tried several of them.

I don't have one of these to test with, but in looking at the driver installation instructions, I would expect it to say "EDBG Virtual COM Port" before a driver is installed and "Atmel Corp. EDBG CMSIS-DAP" after the driver is installed.
The "Arduino Zero Programming Port" is something I expect only appears in the Tools/Port menu in the IDE, despite what it says in the article.  You can see this name given in the boards.txt file.  And this makes sense to me, given that the EDBG firmware is Atmel's not Arduino's and there appears to be no indication in the driver directory, the content of the INF files, to suggest that they they're providing their own customized driver for the programming port.  So I would trust what you see in the images, suggesting it should say CMSIS-DAP without mention of "Arduino Zero" at all.  So far as I can tell, you're not doing anything incorrect driver-wise, but I'm also not seeing everything.
In any case, it appears you should have the VID (03eb) and PID (2157) in the device properties that boards.txt instructs the IDE to look for:
arduino_zero_edbg.name=Arduino/Genuino Zero (Programming Port)
  1 arduino_zero_edbg.vid.0=0x03eb
  2 arduino_zero_edbg.pid.0=0x2157

However, your error mentions PID=2111.  I looked this up in a USB VID/PID database, and it mentions the an ATMEL Xplained board, which is not a completely unrelated thing, but this VID:PID are not mentioned in the driver information or boards.txt for the Arduino Zero.
I did find this one mention that the Xplained USB PID was used on the M0 Pro which is a different beast from the Zero.
In any case, I would not worry about not seeing something like "Arduino Zero Prog. Port" in device manager itself for the programming port.
Make sure you are using Zero and not M0 Pro.  If you have the M0 pro, in which case properties in Device Manager may show PID as *2111, I'm not sure what to suggest except that maybe you should install Microchip Studio since this seems to be the only way I can find to get the Xplained EDBG drivers.  Some work may still be required after that to get it to work in the IDE.
If you have a Zero and not M0 Pro installing Microchip Studio may also install the EDBG driver for it as well, although this really shouldn't be necessary.

Thanks! that makes sense. Although I have retrieved the "board info" multiple times in the past, I just now noticed that it says
BN: Arduino M0 Pro (Programming Port)
VID: 03eb
PID: 2111
SN: FFFFFFFFFFFFFFFFFFFF

@jiggling_electrons, interesting serial number (I assume that's what SN is).  I don't know what to make of that, but yeah, it sounds like you need to use the Xplained Pro driver and who knows what from there.  It may be possible for you to alter the PID values the driver .INF and boards.txt file in order to get the IDE to work with it.

@jiggling_electrons,  Or perhaps better, don't mess with the PID in the INF file.  Instead, get the Xplained driver by installing Microchip Studio (I think),  and then modify boards.txt in order to get the IDE to recognize the board, if necessary, after that.

@jiggling_electrons, so is it a M0 Pro or a Zero? can you upload over bootloader when you select M0? what was on the invoice? the boards are very similar at first look.

@Juraj, based on the link pointed by timemage, the board is Zero Pro :(, its programming port says M0 Pro but Native USB is Zero. I am not able to upload even if I select the M0 Pro as the board. I also downloaded the Atmel Studio but I am trying to figure how to upload without an ICE or select the EDBUG. My invoice says Zero.

@jiggling_electrons, without going into detail I have found a few other things and have other questions.  But it's going to be a back and forth.  If you find me on freenode I'll try to help.  Whatever relevant and useful parts can be written up here, but I suspect there will be a bunch of rabbit holes that would otherwise make a mess of the question and answer.

post on forum https://forum.arduino.cc/index.php?topic=715160.msg4804484#msg4804484

@timemage, did you get my pings on freenode? we can also discuss instead on discord jiggling_electrons#1370 or in the arduino forum forum.arduino.cc/index.php?topic=715160.msg4804484#msg4804484, pointed as well by Juraj above.

I did.  That is where to find me, I just wasn't around at the time.


text:
Is there any way to catch the response of SIM800L after sending the at command?
I am using sim 800l with arduino. I am successfully sending AT command from arduino, not in serial monitor but I am unable to catch the response after each successful command execution if its ok or not. I want to do that because, if there is an error in a certain command the next command will not be executed unless its successful. Can you tell me is there any way to do so?

use readBytesUntil

Read Nick Gammon's How to process incoming serial data without blocking. Once you understand it, you can build your own parser.

for a polling serial read I use this method :
bool tSim8_sendCommand(uint8_t sim_cmd[])
{
    uint8_t simOK[2] = {0}, i=20;
    tSoftSerial1_write(sim_cmd);
    tSoftSerial1_write("\r\n");
    while (i--)
    {
        simOK[0] = simOK[1];
        simOK[1] = tSoftSerial1_readChar();
        if(simOK[0] == 'O' || simOK[1] =='K')
        {
            return true;
        }
    }
    return false;
}

the variable i i the while loop, is used just for retries, so the program doesn't get trapped in an infinite loop. the code is self-explanatory. the incoming characters are "pushed" into an array till the array reads "OK".
for a non-blocking one, it's a bit complicated as you have to define state-machines and concurret loops. here is a method I use for finding out if the last transmission was OK:
void tsim_phase_ok_routine(uint8_t inChar)
{
    if(tsim_aux_buff[0] == 'O' && tsim_aux_buff[1] =='K' && tsim_aux_buff[2] =='\r')
    {
        tsim_status_flag |= (1<<PHASE_OK);
        tsim_status_flag &=~(1<<PHASE_CON_ERR);
        return;
    }
    else
    {
        tsim_aux_buff[0] = tsim_aux_buff[1];
        tsim_aux_buff[1] = tsim_aux_buff[2];
        tsim_aux_buff[2] = inChar;
        err_timeout--;
    }
    if(!(tsim_status_flag & (1<<PHASE_OK)) && !err_timeout)
    {
        tsim_status_flag &=~(1<<PHASE_OK);
        tsim_status_flag |= (1<<PHASE_CON_ERR);
    }

}

I define "PHASES" to find out which phase is sim800 in. the whole function would be written in RX interrupt service routine and the input character would be fed to it.

what is tSoftSerial1_readChar?

@Juraj it was a software serial handler for reading chars

do you know the readBytesUntil functions? https://www.arduino.cc/reference/en/language/functions/communication/stream/streamreadbytesuntil/

@Juraj actually, the code I wrote is in C99 so I could use it on any platform. I the link, yes it does the same job

and why do you confuse a newbie with it?

@Juraj it's an answer anyway. that's why many question here have multiple answers. there would be people who just google the same question and may or may not be newbie or using the exact platform. and my answer is pure C so it can be used on arduino "as is" and many other platforms. we can't also deduce the OP is newbie because he wasn't aware of the method.


text:
Register writing by compound assignment and pointer in Arduino due
I'm confused with register wrting method by compound assignment and/or pointer because I don't know where are some of the values come from.
Example 1
REG_PMC_PCER1 |= PMC_PCER1_PID36;  // Enable PWM - Peripheral Identifiers 36

This works the same as REG_PMC_PCER1 = (1<<4)
REG_PMC_PCER1 is not readable, so |= operator shouldn't work.
What is PMC_PCER1_PID36 ? Is the some sort of bit mask defined in the IDE ?

Example 2
PMC->PMC_PCER0 |= PMC_PCER0_PID13;   // PWM controller power ON

This works the same as REG_PMC_PCER0 = (1<<13)
This is similar to Example 1 but there is pointer PMC. Why it's needed ? If PMC_PCER0_PID13 is a bit mask then REG_PMC_PCER0 need not indexing.

So my questions are:

Why compound assignment works on write-only registers ?
Where are those constants (PMC_PCER1_PID36,PMC,etc.) defined ?

Thanks in advance !

Why compound assignment works on write-only registers ?

Probably out of force of habit more than anything.  People are used to having to set bits in registers where the other bits can be read and they want them to stay the same, in which case |= makes sense.
I'd considered that |= might be generating a more efficient instruction, but at least with your REG_PMC_PCER1 |= PMC_PCER1_PID36 example objdump indicates that this is not the case.

Where are those constants (PMC_PCER1_PID36,PMC,etc.) defined ?

Code-wise, they're defined in the ATMEL's (now Microchip's) CMSIS files.  These are header files whose existence is somewhat standardized by ARM for these ARM Cortex processors.  Much of their content isn't however.  E.g., you may see a few things related Cortex M3 that are the same between this ATMEL device in an STM32 counterpart, but GPIO registers may be completely different.
My broadly, they're defined by ATMEL in their datasheets.

I haven't found a statement that explains flatly that a write-only register will appear to be all zero bits when attempting to be read, but that is likely the case.  If I find a simple statement to that effect I'll call it out.


text:
How to make a pairing and mode button on a remote control receiver
I'm working on a remote control project and have come across many different RF receiver/transmitter modules. Many have a pairing/mode button on the receiver that serves to pair the receiver and transmitter and to choose which mode the transmitter is in, momentary, latching, toggle, etc.

How can I replicate this feature using Arduino and those cheap RF transmitter/receiver combos on Ebay? Specific code would be nice, but just a general idea as to how it would be done in theory will work too. I've watched several tutorials that explain the use of the Radiohead library with the cheap RF combos, but none demonstrate how to set up a feature such as this. Thanks.

Remote sends a number before the command bits. The receiver checks if this number is the same with the number that corresponds with the position of the switches.
You can do the same in software. Have the first few bits be some number. The receiver can then check if the first few bits of the received "message" matches that number. If it doesn't it will just throw it out.
This is the same method used with IR-remote controls. The signal from your VCR remote will also be received by your TV. But the TV sees that the code doesn't match the one it's expecting. So it will ignore those.