text:
Read SD card on ATMEGA328 from ESP826
I have a ATMEGA328 with ESP826 (like this http://arduinolearning.com/hardware/atmega328-esp8266-arduino-board.php) and can successfully send information from the ATMEGA328 to the ESP826 via serial.
I can also record information from the ATMEGA328 to SD card.
What I would like to do is read data from the SD card with the ESP826 so I can upload it to a server..
When I try to connect directly:
#include <ESP8266WiFi.h>
#include <SPI.h>
#include <SD.h>

File myFile;

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

  Serial.print("Initializing SD card...");

  if (!SD.begin(10)) {
    Serial.println("initialization failed!");
    return;
  }

  myFile = SD.open("/");

  printDirectory(myFile, 0);

  Serial.println("done!");

}

void loop(){
}

void printDirectory(File dir, int numTabs) {
  while (true) {

    File entry =  dir.openNextFile();
    if (! entry) {
      // no more files
      break;
    }
    for (uint8_t i = 0; i < numTabs; i++) {
      Serial.print('\t');
    }
    Serial.print(entry.name());
    if (entry.isDirectory()) {
      Serial.println("/");
      printDirectory(entry, numTabs + 1);
    } else {
      // files have sizes, directories do not
      Serial.print("\t\t");
      Serial.println(entry.size(), DEC);
    }
    entry.close();
  }
}

It doesn't find the card. This is regardless of whether I have pins 1&2 ON or not.
Is there any way to write to the SD card using the ATMEGA328 and read that from the ESP826 (to send the files to the cloud)?

you can't. SPI pins of the esp8266 are not accessible on Uno+WiFi. you can't wire an SD card to the esp8266.

You can't. There's no connection between the ESP8266 and the SD card.
However you can program the ATMega328 to read the SD card then send that data to the ESP8266 for forwarding to the internet.

Thanks! What's the best way to send data from the ATMega to the ESP8266? The file on the SD card will be a sound file.

Have you consider something like nodeMCU?
Is there a reason why you using such a complicated board?
This would enable you to connect your SD card reader directly to nodeMCU, which can read the data  from same inputs as atmega328 (watch for voltage differences) including the sensors which has the capability of uploading data to the cloud without the need of additional MCU, while making debugging far easier.
I know that I am going to get dislikes here, but it looks to me like one of those cases when you connect two things that would work better of alone, making something does doesn't do either ones job very well.
Maybe you can get a refund...
If not contact your card issuer for "Cardholder not present" claim that bot VISA and Master card have.
Is there any reason why wouldn't standard nodeMCU be enough for your project? (probably superior)
If its not enough:
If you connect node-mcu (5-15 Eur/Pounds/Dolars) and a nano (About half of the price) on a breadboard and connect them together via (software) serial pin, (using jumper cables and resistive divider), you can program them without messing with pointless dip switches  and learn something usefull for future projects. latter you can replace nano for 3V3 pro miny to remove even the divider.
There is this absurd idea from Arduino core team developers of using superiour Esp32 MCU as a secondary tool to inferiour ATMEGA328, while logically you should do the opposite.
This is amplified by the fact that I would personaly consider Esp8266 core arduino libraries superior to those made for atmel...
You might even find that the 2-3MB FS you can create on ModeMCU might be enough without the need of SD card.
I had a quick look through the site and a combination defaulting to http and nonstandard hardware, combined with low standard of explanation, But what I find really imoral is harvesting excessive number of domain names on a similar subject which could have been used for other projects makes me think if these tutorials are designed to increase the sales of badly designed boards... I would recommend you to change the tutorial source...

point taken , comment deleted

Can you tell me what this statement has to do with the question: "BUT EVEN WORSE STEALING EXCESSIVE NUMBER OF DOMAIN NAMES"? Using all capital letters, with a bold and italic font, is NOT going to send the message you think it will to the community.

I think pointing out the immoral action of the website designers, is relevant in pointing as additional reasons to point asker towards better tutorial, or source for board. I have rephrased, the sentence (not sure how did caps happened)

So now, you change the irrelevant text to this "But what I find really imoral is harvesting excessive number of domain names on a similar subject domain names" with a bold font.Can you tell me how that statement applies to the OP's question?

I am unable to explain you mine reasoning any better then in mine previous comment. maybe once I think how to rephrase explanation for mine reasoning. Otherwise we may have to differ in opinion and I will get mine expected down-vote. I accept that you are better at programming then me, just disagree with you on this point. Good night


text:
I cannot communicate using RS232 between Arduino and Lakeshore Fluxmeter. How do I get data back from the fluxmeter?
I am using an Arduino Leonardo and the DFrobot RS232 shield to try and communicate with a flux meter. I am trying to write "UNITS?", which would have the fluxmeter send back a single byte that would translate to which units it is using.
The problem is, I can see from the Arduino side it is writing those 6 bytes, but at the if (Serial1.available()), there is nothing there. I have the switch on the shield to on, and I did the tutorial on the DFrobot wiki to make sure my shield works.
I think it has to do with how the Serial1.write() is done. I don't think it is receiving the command correctly, so it does not respond.
Shown below is my code:
#include <Keyboard.h>

// Define pins, so you only need to change them in one spot
#define BUTTON 7

bool runner = 0;

void setup() {
  // Begin Serial communication at 9600 baud rate
  Serial1.begin(9600);
  pinMode(BUTTON, INPUT);
  // create an interrupt that will call send_command() whenever the button pin has a rising edge
  attachInterrupt(digitalPinToInterrupt(BUTTON), send_command, RISING);
  // start the Keyboard process
  Keyboard.begin();
}

// called when button is clicked
// will use Serial.write() to send commands
// then will write the data with the keyboard
void send_command() {
  runner = 1;
  return;
}

void loop() {
  if (runner) {
    char pkneg, pkpos;
    // This next section writes the commands to the 480,
    // then reads the data and prints it to the Serial Monitor
    int sent = Serial1.write("UNITS?");
    Keyboard.println(sent);
    if (sent <= 0) {
      Keyboard.print("Fort Myers we got a problem\n");
    }
    //Keyboard.print(marker);
    delay(5000);

    if (Serial1.available()) {
      Keyboard.print("Here!\n");
      pkpos = Serial1.read();
  }
  else pkpos = 'x';
  pkneg = 'x';

  char pkneg1[10], pkpos1[10];
  // dtostrf(pkpos, 4, 3, pkpos1);
  // dtostrf(pkneg, 4, 3, pkneg1);

  Keyboard.print(pkneg);
  Keyboard.print('\t');
  Keyboard.print(pkpos);
  Keyboard.print('\n');

  // for testing

  runner =0;
  }
}

You are lacking the line terminators from your serial writing. As it says in the manual:

Terminators are fixed to CRLF.

And in the example code (the Quick Basic is probably the easiest to follow):
CMD$ = CMD$ + TERM$
PRINT #1, CMD$;

(where TERM$ is "\r\n").
So changing your Serial1.write to include the terminators should help the device to recognize that you have finished sending the command and it should respond to it:
Serial1.write("UNITS?\r\n");

By the way, testing the return value of the Serial1.write is pointless. It will always return the number of characters in the string you supplied - serial data over the UART pins is always sent even if there is nothing there to receive it.

thank you for your continued help! The terminators did not work at first, but then I tried writing like this: Serial1.write('U');   Serial1.write('N');   Serial1.write('I');   Serial1.write('T');   Serial1.write('S');   Serial1.write('?');   Serial1.write('\r');   Serial1.write('\n'); and that worked. Just trying to get READ? to work now, because what it returns is gibberish lol

source: Stack Exchange

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

sort: votes


text:
Invalid use of non-static member function
In order to explain my problem I used 3 classes: Actions, Triggers, and Combine.
Actions simulates an action function, that is defined externally.
Triggers has that function that needed to be executed.
Combine combines Actions and Triggers.
Now, void combine_funcs() is a member function of Combine class, when the match between Triggers and Actions happen -> passing a function to be executed.
Here void combine_funcs() is show with std::bind, but is was also tested straight foreward.
Error outsput is given below code.
class Actions
{
  typedef void (*cb_func)(uint8_t resaon);

private:
  cb_func exter_func;

public:
  void get_external_func(cb_func func)
  {
    exter_func = func;
  }
  void callAction(uint8_t i)
  {
    exter_func(i);
  }
};

class Triggers
{
public:
  void this_is_external_func(uint8_t i)
  {
    Serial.println(i);
  }
};

class Combine
{
public:
  Actions a;
  Triggers b;

  void combine_funcs()
  {
    a.get_external_func(std::bind(&Triggers::this_is_external_func, this,std::placeholders::_1));
  }
  void loop()
  {
    if (millis() > 10000)
    {
      a.callAction();
    }
  }
};

Combine combo;

void setup()
{
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Start!");
  combo.combine_funcs();
}

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

Compilation output:
/Users/guydvir/Dropbox/Arduino/sketch_jul26a/sketch_jul26a.ino: In member function 'void Combine::combine_funcs()':
    sketch_jul26a:36:34: error: cannot convert 'std::_Bind_helper<false, void (Triggers::*)(unsigned char), Combine*, const std::_Placeholder<1>&>::type' to 'Actions::cb_func' {aka 'void (*)(unsigned char)'}
       36 |     a.get_external_func(std::bind(&Triggers::this_is_external_func, this,std::placeholders::_1));
          |                         ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |                                  |
          |                                  std::_Bind_helper<false, void (Triggers::*)(unsigned char), Combine*, const std::_Placeholder<1>&>::type
    /Users/guydvir/Dropbox/Arduino/sketch_jul26a/sketch_jul26a.ino:9:34: note:   initializing argument 1 of 'void Actions::get_external_func(Actions::cb_func)'
        9 |   void get_external_func(cb_func func)
          |                          ~~~~~~~~^~~~
    /Users/guydvir/Dropbox/Arduino/sketch_jul26a/sketch_jul26a.ino: In member function 'void Combine::loop()':
    sketch_jul26a:42:20: error: no matching function for call to 'Actions::callAction()'
       42 |       a.callAction();
          |                    ^
    /Users/guydvir/Dropbox/Arduino/sketch_jul26a/sketch_jul26a.ino:13:8: note: candidate: 'void Actions::callAction(uint8_t)'
       13 |   void callAction(uint8_t i)
          |        ^~~~~~~~~~
    /Users/guydvir/Dropbox/Arduino/sketch_jul26a/sketch_jul26a.ino:13:8: note:   candidate expects 1 argument, 0 provided
    exit status 1
    cannot convert 'std::_Bind_helper<false, void (Triggers::*)(unsigned char), Combine*, const std::_Placeholder<1>&>::type' to 'Actions::cb_func' {aka 'void (*)(unsigned char)'}

EDIT_1 : Change Combine class to inherete other classes
class Combine : public Actions, Triggers
{
public:
  void combine_funcs()
  {
    get_external_func(this_is_external_func);
  }
  void loop()
  {
    if (millis() > 10000)
    {
      callAction(13);
    }
  }

yeilds same error:
/Users/guydvir/Dropbox/Arduino/sketch_jul26a/sketch_jul26a.ino: In member function 'void Combine::combine_funcs()':
sketch_jul26a:33:23: error: invalid use of non-static member function 'void Triggers::this_is_external_func(uint8_t)'
   33 |     get_external_func(this_is_external_func);
      |                       ^~~~~~~~~~~~~~~~~~~~~
/Users/guydvir/Dropbox/Arduino/sketch_jul26a/sketch_jul26a.ino:22:8: note: declared here
   22 |   void this_is_external_func(uint8_t i)
      |        ^~~~~~~~~~~~~~~~~~~~~
/Users/guydvir/Dropbox/Arduino/sketch_jul26a/sketch_jul26a.ino: At global scope:
sketch_jul26a:60:6: error: redefinition of 'void setup()'
   60 | void setup()
      |      ^~~~~
/Users/guydvir/Dropbox/Arduino/sketch_jul26a/sketch_jul26a.ino:46:6: note: 'void setup()' previously defined here
   46 | void setup()
      |      ^~~~~
sketch_jul26a:68:6: error: redefinition of 'void loop()'
   68 | void loop()
      |      ^~~~
/Users/guydvir/Dropbox/Arduino/sketch_jul26a/sketch_jul26a.ino:54:6: note: 'void loop()' previously defined here
   54 | void loop()
      |      ^~~~
exit status 1
invalid use of non-static member function 'void Triggers::this_is_external_func(uint8_t)'

};

Does this Q+A help? https://stackoverflow.com/a/72450270/10292145

@VE7JRO can you explain why do I need a void* ?

why not set the object as a parameter?

@Juraj i tried, with no luck

@guyd - When I try to compile your code, I get different errors. I am using a different compiler than you are, so my first error leads me here: https://stackoverflow.com/questions/14261013/bind-is-not-a-member-of-std In the Arduino world, they point me here: https://forum.arduino.cc/t/include-functional-error/397411  The only questions I have for you is, why are you writing your code this way, and what problem are you trying to solve?

Why not using class inheritance, for example, class Combine public Action {}? However, solution aside, don't create classes for the sake of creating classes, all three of your classes are not necessary or should belong to somewhere else as methods.

I'll try to explain my bigger problem:
I have 2 classes I've written and tested. One is a Button-Read states including timeouts class, and second class deals with turning ON/Off lights including PWM lights. BOTH are used and tested before. Third library combines both including have on-flash parameters and MQTT command (as some kind og a wrapper) even have multiple instances of my third class.
I want to use all my 3 classes as a legacy that works, rather that re-write it all

I meant the parameter type should by a class and you pass an object there and execute the function on that object. a member function must be invoked on an object, that is why you can use that function as a parameter. it doesn't know on what object it should be executed.

@Juraj can you explain using example ?

maybe later today

You need to call this_is_external_func() on an object, but you don't provide one in callAction(). I see two alternatives: 1) Provide an object to call the method on. 2) Make the method a class function, which does not need an object.

@hcheung took your advice for inherete (see edit 1), but same results

the return type of bind is not the same type as the type of the original function

@Juraj Can you point ?

I changed your sketch with auto f = std:bind.... and a.get_external_func(f); and the error message is a little clearer.

@Juraj - GREAT!!! that was the first lead I got what did I do wrong.

The problem is, that the return type of bind is not the same type as the type of the original function so you can't set it with void get_external_func(cb_func func).
But it looks like in X->Y problem. If you do OOP, use objects.
I take the sketch in the question as a test so I want comment on other parts and how to do them properly. I just made minimal changes to pass the object and call the method (member function) with the object.

class Triggers
{
public:
  void func(uint8_t i)
  {
    Serial.println(i);
  }
};

class Actions
{
  Triggers* trigers;

public:
  void set_triggers(Triggers* t)
  {
    trigers = t;
  }

  virtual void callAction(uint8_t i)
  {
    trigers->func(i);
  }
};

class Combine
{
public:
  Actions a;
  Triggers b;

  void combine_funcs()
  {
    a.set_triggers(&b);
  }
  void loop()
  {
    if (millis() < 10000)
    {
      a.callAction(1);
    }
  }
};

Combine combo;

void setup()
{
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Start!");
  combo.combine_funcs();
}

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

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


text:
Using ESP32 GPIO, Serial.printf(...) prints weird characters when input is larger than 12 characters
Learning C with the Freenove WSP32-WROVER starter kit and there's an issue I cannot find an answer to. Using the provided code to input some data with UART, it would seem to have a strange behavior whenever I input string that is larger than 12 characters. Under 12, everything is fine.
/**********************************************************************
  Filename    : SerialRW
  Description : Use UART read and write data between ESP32 and PC.
  Auther      : www.freenove.com
  Modification: 2020/07/11
**********************************************************************/
String inputString = "";      //a String to hold incoming data
bool stringComplete = false;  // whether the string is complete

void setup() {
  Serial.begin(9600);
  Serial.println(String("\nESP32 initialization completed!\n")
                + String("Please input some characters,\n")
                + String("select \"Newline\" below and click send button. \n"));
}

void loop() {
  if (Serial.available()) {         // judge whether data has been received
    char inChar = Serial.read();         // read one character
    inputString += inChar;
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
  if (stringComplete) {
    Serial.printf("inputString: %s \n", inputString);
    inputString = "";
    stringComplete = false;
  }
}

The output of any larger than 12 characters string is sometimes a little bit different, but always seems to follow a similar pattern. For any 13 characters long string, I get :

⸮⸮?

The ouput changes if I add characters, for example 20 characters is this :

D⸮⸮?

I assume the unprintable character is a new line.
The baud rate is set at the same value both in the code and in the serial monitor and I get the same results if I change the baud rate.
Any explanation regarding this behaviour and how to avoid it would be most welcomed.

Change:
Serial.printf("inputString: %s \n", inputString);

to:
Serial.printf("inputString: %s \n", inputString.c_str());

%s expects a const char * which is not what inputString yields.
What you're seeing in the difference between strings larger and smaller than 12 characters is down to whether or not small string optimization is in use and how structures are passed in the ESP32's calling convention.

Thanks a lot, this did solve the issue <3

As a rule, it is better to use char array thhen string. While string might be smaller then your maximum size of array, its variable nature makes it very hard for memory allocation to guess a right size.
While it is not a problem in a simple program like this when you get to larger projects where your functions are used within libraries, variable nature of string makes memory alocation within gaps in memory fragmentation too unreliable. (I have solved many crashes simply by changing strings to char arrays)Its well worth getting into a habit of char arrays rather then strings

I have tried to remove "in  fragmentation" unfortunately 5 minute edit rule for comment is too low for dissgraphic person"


text:
Arduino/ESP8266 How to give users updated compiled code without using Arduino IDE
I have an Arduino project using an ESP8266 dev board.
I want to be able to give users updates to my software in the future and I don't want them to have to download the code and the Arduino IDE to do so.
Is there a way to take the compiled code from the Arduino IDE and use some other software to upload the compiled code to the ESP8266 dev board?

There's a detailed console option (can't remember what it's called) that when enabled will show you how the board is being programmed. You can then run those commands outside of Arduino IDE to have the same effect.

I figured it out! After getting some comments, I have decided to got with Option B.
Firstly for both options, you will need to:

Using the Arduino IDE
Under the "Sketch" tab; click "Export compiled Binary", then click "Show Sketch Folder" (This is where your .bin file is)

Option A - Using an application

Download the ESPEasyFlasher code from below.
You will probably have to open this with Visual Studio and compile it yourself.
Make sure your .bin file and esptool.exe are included in your bin/release folder or  wherever you want to have the "FlashESP8266.exe" program permanently.
Run the "FlashESP8266.exe" program; select your com port, select your bin file, select the upload rate, then click flash.

So you just have to make sure that your user has;

Python installed
Provide them a copy of the "FlashESP8266.exe"
Provide them a copy of the "esptool.exe"

I don't know if this will work the exact same for an ESP32 as I believe they have two .bin files...
Resources:
https://nerdiy.de/en/howto-esp8266-mit-dem-esptool-bin-dateien-unter-windows-flashen/
https://github.com/BattloXX/ESPEasyFlasher
Option B - Using OTA Update
3.You will need to first implement OTA Updates as @StarCat has pointed out
in the comments.
4.Navigate to the URL you implemented.
5.Choose the File System, select your .bin file.
6.Click Update FileSytem
7.Should take a couple seconds or so and should be updated!
I can confirm this works when your ESP8266 is set to host a Soft Access Point.
Koudos to @StarCat.
Resources:
https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html#web-browser

You could also use the ESP8266HTTPUpdateServer in your code to allow the user to update the dev module using a web browser and the .bin file you provide them.

i would use the OTA to avoid any need of software. there's a few examples built-in tpo the lib, i can't recall which one is best. i would use the one where the user browses to an html page served by the esp instead of relying on an internet connected push server, which can be prone to field problems that a dead-simple upload this file to this page option is.


text:
How to control 1 servo with 2 potentiometer?
I have been building a RC plane completely from scratch using an arduino but I am fairly new to this.
Essentially I have been able to make my two arduinos communicate with each other so that when one joystick is moved, the brushless motor is activated, and when the other joystick is moved up or down, 2 servos are activated to push my plane flaps up or down.
The problem I am running into is I am not sure how to control the same servo motors when I move the joystick left and right. Ideally when moved left, one servo would push a flap up and the other down, and vice versa.
The closest thing I have come across on the internet is using a push button to switch between the two control methods but I would ideally like everything to work more smoothly together w/o the push button if that makes sense.
If anyone has any ideas what to write in my code please let me know or if I need to clarify anything else.
Thank you so much for the help in advance.

joystick up-down and joystick left-right are two separate, independent controls

try reading on the finite state mashine. In simple programs like this it would help yyou manage different states.
https://create.arduino.cc/projecthub/tolentinocotesta/let-s-learn-how-to-use-finite-state-machine-with-arduino-c524ac?ref=part&ref_id=8233&offset=13

you are probably trying to do read joystick1, move servo1 ... read joystick2, move servo1 somehow ..... instead use variables ...  read joystick1, set variable value ... read joystick2, adjust variable value ... use final variable value to move servo1

Flaps or Ailerons? https://www.youtube.com/watch?v=XxrdhJanotw

First you should make sure that your inputs and outputs are separated in code. This means that the inputs (like the joystick potis) only change variables in your code. Then below the input code block you output these variables to the servos and motors. This makes the code in your situation easier, since the inputs don't trigger actions, but only set the variables for the actions, which then get executed by another code block.
Your up-down joystick sets the position for the flaps (as you have already coded). The left-right joystick then only creates a deflection from that position. You can code this like the following (in pseudo code):
Read up-down joystick
Map value from analog value to range 0 to 180 and save in variable "flap_pos"
Read left-right joystick
Map value from analog value to range -90 to 90 and save in variable "flap_deflection"
Write servo1 value as "flap_pos+deflection"
Write servo2 value as `flap_pos-flap_deflection"

Note that flap_deflection can be negative or positive (depending on joystick direction) and can thus deflect in both directions. And the different signs in the servo commands make sure that the deflection will behave inverted between the servos (one side moving down when the other is moving up). You will need to adjust the value mapping depending on your flap hardware. And you might want to restrain the values to a specific range (also depending on your hardware).
As you can see there is no if statement or similar in the pseudo code above. All the magic is in the mapping of the read analog values and the addition and subtraction.

Like the idea of pseudo code. The only reason why I am not marking up is becuase the question does not contain enough question to have a correct answer

There is no real magic, it is just simple math. :-D In "the good ol' days" analog mixers did what you describe digitally. Anyway, good answer, even if it reveals that (young) developers lost a lot of knowledge today.


text:
How to connect a 4 channel relay switch directly to a 5V power source?
When connecting a 4 channel relay to a Arduino Pro mini, there is a noticeable power drain from the board when relays are active. This is clearly visible as the 16x2 LCD dims. I remember reading that this could damage the Arduino, is this true?
In any case, since the entire project will be powered by a rechargeable 12V battery, I bought some buck converters to lower the voltage from 12V to 4.66V (this is what I identified the output to be from the Arduino, I even tried increasing it to 4.8V), so I can power the relay switch directly instead of going through the Arduino.
However, the relay does not power on and I have no idea why.
Can someone help me understand? I'm new to this.

Parts

eBoot Mini MP1584EN DC-DC Buck Converter
4 Channel 5V Relay Shield Module
Mini Nano V3.0 ATmega328P Microcontroller Board

Edit
I found this answer but I do not know if it applies and, if it does, what changes I would need to make with my current connections.

Maybe you never connected the grounds? Please show your wiring.

The 5V is from the buck converter to the relay, then the GRND goes back to the battery through the buck converter again.

What about to the Arduino?

@Majenko sorry for the crude drawing, but this is the connections I have.

That's far less crude than many people post...  Those connections look fine to me.

Then I am dumbfounded and I have no idea why it does not power on :/

Those connections will will work if the converter passes the ground through, not all do. Also without a link to technical information on the particular parts All I can do is guess. Another possibility is the relay module is not properly jumpered or it does not have 5V relays as pictured. Specs help eliminate these questions. I assume you have the 12V to the pro mini on the Vin terminal not 5V.

Yes, the Arduino is powered through the Vin connector. I thought of sending the ground back to the Arduino, but was not sure if this would be good since the source did not come from it.

@Majenko I added more details to the question, and an answer, but I'm a programmer, not an electrician; a lot from that answer is not clear to me.

Just a few question: 1) First you say "there is a noticeable power drain from the board when relays are active".  Later you say "the relay does not power on".  This is confusing.  Do the relays activate or not? 2) If using a power supply what is its Amperage rating. If a battery, its mAh rating? 3) According to your diagram, it may be that jumper JD-VCC is necessary.  Is jumper JD-VCC installed?

@st2000 1) when I connect the relay's VCC to the Arduino's 5V output, everything works, but there is a power drain on the LCD screen module (connected to a different 5V output) when activating relays, so I'm going for total isolation instead and it does not work, 2) the battery is rated at 12V and 10Ah 120Wh, 3) the JD-VCC jumper is installed (as I understand, removing the jumper expects the relays to be powered on 3.3V, right?)

That battery sounds more than enough.  It's charged correct? Just checking, your power wires are not long (perhaps less than 15 meters) and of sufficient thickness. For example, 16 gauge could carry 5 Amps.  Which is likely 10 times you needs. You can not go total isolation. If you use 2 different power sources, their grounds need to be connected together.  Regardless, your diagram appears to be fine. I could ask how your LCD is powered and what is it's model number.  Or you could add it to your question.

OK,

You should not ever use inductive load from voltage regulator shared with MCU.
Relays are massive eaters, and the 4.6 volts were actually caused by arduinos NTC kicking in to protect arduinos supply, the relays on your picture are designed for power around 5DC so you should design your circuit in that regards. I am impressed by the fact that little regulator on pro miny even survived it, meaning its likely to be reasonably made board.
The Pro miny voltage regulator is nowhere near as powerful as thatone on Nano or UNO and only barely manages to run anything more then the MCU itself.
Watch your current. I am not sure whats the max current of your buck converter. Amazon specifications usually do not concern themselves with petty things like reality. SO it might not be strong enough to run all 4 relays. Though Colour is matching more often then wrong
Again relays are massive power eaters and the lower voltage, the higher current so you can often lower your consumption by using relays made for higher voltage.
Next batteries don't store that much power, get influenced by external influences and their capacity further decreases as the life goes. you can save a lot of power by using transistors/mosfets where possible.

It takes considerable additional design steps to make project run on a battery and replacing relays for bigger transformers or mosfets is often part of it.
Set any of the relays on, in arduino code and measure its voltage against ground.
If its 5V then arduino is sending signal fine.
If it is not, then check the resistance between its and arduinos ground. if its just few ohms look for issues on the arduino.
if resistance between grounds is big or even unmeasurable, then connect the arduino ground with relay board ground.
If you can measure 3-5V (Dependant on a pro mini version) between arduinos output and the ground then you don't have enough power on the relay modules supply.
Extra note:Make sure the arduino is not powered from buck converter as volage regulator has minimum voltage diference it can drop and could not be powered via regulator from a supply of less then 6.something Volts
As stated in Jroberts answer once everithing is working, you might want to disconnect the suplly to arduino from 12 volt source to Vin; and connect your arduino to your buck converter set at 5V (4.95ish-5.05ish) to 5V pin adding 10uF capacitor between the 5V and GND on arduino.
The buck converters are more efficient in dropping voltage, then voltage regulators, so that would extend your battery life. (this isnt majourisue as compared to the arduinos consuption is tiny compared t the consumption of the relays

It feels weired when Edgar Bonet stopped edited all mine answers.  I was newer meant to stop him, it was just an observation...

I don't see relay coils powered from the Mini in the question

@juraj: That is reference to the original setup where asker describes to power it via arduino and that the voltage output reduced and LCD dimmed, this according to the asker made asker believe that the voltage he measured was a correct voltage to output from buck converter, supplying too low voltage in his second (new) setup

I'm not a double-E but I'll take a stab at it.
Arduinos' on-board voltage regulators are not particularly efficient; they sink to ground whatever the board doesn't draw, dissipating it as heat. And they usually are not provided with heat sinks, meaning the regulator is heat-limited. You're powering the Arduino with 12v, so whatever current the Arduino does draw, that same current times 7 volts (the voltage drop from 12v to 5v) is waste heat. Driving four relay coils draws (using the specs on the Amazon page) adds 80mA (times 7v) to that heat dissipation.
It looks like at least some Pro Minis (yours?) use a Micrel 2095 voltage regulator which has internal current limiting which may include thermal protection(?) -- shutting off your Arduino when the regulator gets too hot.
Despite that some of the above is speculative on my part, it does suggest an experiment. You've got a regulated 5v source - instead of powering the Arduino at Vin from the 12v source, try powering it's +5v pin with +5, which would significantly reduce the regulator's power dissipation (and therefore, its temperature).

I don't see relay coils powered from the Mini in the question

The product description I referred to in my answer says: "5V 4-Channel Relay interface board, and each one needs 15-20mA Driver Current. " [emphasis mine]

but the coils are powered from the 5 V pin of the relay board and that is not connected to Micro

I think this is not an answer, but rather an extension to one of the points in mine answer or one of the points in askers questions. It would be better as just a coment. I wont downwote as its interesting addition, but neither upwote, as it does not contain the actual answer in additional info.


text:
ESP32 cam and MB code uploaded but nothing in Serial Monitor

The code works successfully but nothing happens in the serial monitor, what do I do as I've tried almost everything.

Your serial monitor's baud rate isn't set to 115200

No longer an issue.
Any fully released version of the 2.X IDE including the original 2.0.0 release should work. If you're having a problem these days it is probably because you've selected the wrong board causing problems as explained below.
At the time the original answer was given the 2.0-rc9.1 release candidate was current. IDE version 2.0-rc9.3 bundled arduino-cli version 0.27.0-rc.1 which contains code to make the relevant settings work. So every version form the official 2.0.0 release to current (version 2.1.1 as of this update).
Original Answer
In short, use the 1.X series IDE instead of the 2.X series IDE. As of writing, this would be IDE version 1.8.19.

In version 1.8.4 support for a board properties called .serial.disableDTR and .serial.disableRTS were added.
Certain boards, like the ESP32-CAM combined with the ESP32-CAM-MB require this feature in order for the Serial Monitor to see traffic (actually it's worse than that, which I'll explain below). The current 2.X series IDE (2.0-rc9.1 as of writing), which has a completely different code base, appears not to have re-implemented this feature. Presumably they will eventually.
When you install the 1.X series IDE, make sure you test the Serial Monitor with the ESP32-CAM selected. It may be counterintuitive that testing an Arduino UNO as your selected board wouldn't just work, given that you're only using the Serial Monitor and not actually compiling or uploading. But it will, no kidding, fail to work as this board's definition does not specify these .serial.disableDTR and .serial.disableRTS properties that the ESP32-CAM board description does.
In case you're wondering, ESP32 upload tool controls DTR and RTS itself irrespective of these board definition properties that affect the Serial Monitor and Serial Plotter. That's why your uploading works but your Serial Monitor fails under the current IDE 2.0 release candidate.
Without going into detail on what DTR and RTS are supposed to do, and what they can be made to do, etc, typical operating configurations for a serial port are such that when the port is open these signals are going to go active. The ESP32-CAM-MB board design is such that having both active DTR and RTS both active is effectively pushing down both the GPIO0 and rather crucially the EN/RESET buttons. In other words, without this additional fiddling that the 1.X series IDEs (with correct board selected) and esptool do, opening the serial port has the effect of holding your ESP32-CAM in reset (or NOT-enabling it if you like). So not only are you not getting any serial traffic, the board is simply not executing any code at all.

You have other options also, but each kind of requires an explanation in its own right. But, I can give you hints as to what they are:
It is possible to continue using the 2.0 IDE to do your development and upload but use something else instead of the 2.0 IDE's Serial Monitor. But it will introduce complexity, confusion, and annoyance into your setup. Whatever that "something else" is must allow for the disabling for DTR and RTS. Note that disabling DTR and RTS is not merely turning off flow control; that will not manipulate them and it will ignore their counterpart signals, but it will also leave them in the wrong state.  One candidate is IDE 1.x's Serial Monitor.  Another is RealTerm, which will allow you to clear DTR and RTS (in that order) to then work as a serial monitor. In any case you will need to close the serial connection yourself prior to each upload as the 2.0 IDE will be unable to do that on your behalf as it would normally do its own internal monitor.
You can also interrupt the DTR an RTS signals in hardware before the get to the ESP32-CAM board. Having done that, it no longer matters whether any software controls DTR and RTS, but you then need to manually operate GPIO0 and EN/RESET yourself to enter the bootloader. To accomplish that you'll either need to use a mess of jumpers and the ESP32-CAM-MB (or any other 3.3V serial transceiver) not mounted to the ESP32-CAM and construct push button circuits for GPIO0 and EN/RESET.  Alternately you can physically modify the ESP32-CAM-MB in a way that interrupts DTR and RTS from the transceiver but keeps operational buttons. This can be done by desoldering a pair of diodes or cutting the traces on the way to the buttons and headers.
It may also only take a few well placed lines in one of the 2.0 IDE's javascript/typescript to crudely hack in a disabling of DTR and RTS, if you don't care what else it breaks. If I get bored maybe I'll look into that. Doing it properly in response to the correct board properties is a more involved project though.

If you use the command line, you can use this command to open a serial console to the esp32:
arduino-cli monitor -p /dev/ttyUSB0 --discovery-timeout 60s --config 'rts=off' --config 'dtr=off' --config 'baudrate=115200'

If you use the IDE, see the answer of timemage.

My answer was out of date so I've added that this should be a non-issue in non-release candidate 2.X version IDEs.  With respect to ardunio-cli, if you're using 0.27.0-rc.1 onward, you should be able to specify esp32:esp32:esp32cam : whatever in --fqbn and that would make it so you didn't need the --config 'rts=off' --config 'dtr=off' options. But what you have should be good for dealing with old arduino-cli versions in any case.

I needed these parameters with the arduino-cli version 0.33. I have not tested 0.33.1 yet.

Odd. I've just tested with the 0.27.1 out of the 2.0.0 IDE package and it behaves in line with how I'd thought: arduino-cli monitor --port /dev/ttyUSB0 pulls RTS/RST low. Adding --fqbn esp32:esp32:esp32cam causes it not to do that per disableRTS. As does the --config options you've suggested without the --fqbn specified.  -cli version 0.32.3 out of the latest IDE 2.1.1 behaves the same way. I don't have your exact version. I'll keep it in mind though. Maybe I've missed something.

I'm using platformIO and had the same issue. Disabling the RTS and DTR solved my problem too!
monitor_dtr = 0
monitor_rts = 0

I've barely touched PlatformIO. I'm just guessing these go a project config file. It would be better if this were filled out a bit so that someone running across it had that guidance.


text:
I want a Rotary Encoder to make 10 steps at once, but my code isn't working. What am I doing wrong?
I'm using a rotary encoder on my Arduino Micro, that is supposed to do single steps or ten steps at once, depending on which position a switch is in.
The Rotary: https://www.reichelt.de/drehimpulsegeber-15-impulse-30-rastungen-vertikal-ec11mvbfx-p315144.html?&nbc=1 (on this site are pictures and datasheets as well.)
The Switch:
https://www.reichelt.de/miniatur-kippschalter-ein-aus-ein-3-a-250-v-goobay-10023-p285990.html?&nbc=1
Wiring: (image following later)

        1--------Pin16 |  Pin A3----Switch
Rotary  2--------GND   |  GND-------|
        3--------PIN17 |

The rotary encoder gives no output, neither the Serial.print nor the gamecontroller. Also there is no output in either switch position.
EDIT:
After using arrays and loops like @jsotola teached me, it works nearly the way its supposed to, but sometimes, although the switch is off, it clicks ten times.
The code looks like this shortened now
#include <Arduino.h>
#include <Joystick.h>
#include <BasicEncoder.h>
#include <TimerOne.h>

int EncoderPins[] = {
  4, 5, 6, 7, 8, 9, 10, 11
};
int EncoderCount = 8;

BasicEncoder encoder4(EncoderPins[6], EncoderPins[7], HIGH, 2);

void timer_service() {
  encoder4.service();
}

#define joyButton16 EncoderPins[6]  // Rotary4
#define joyButton17 EncoderPins[7]  // Rotary4
#define joyButton18 21              // HDG_SWITCH := Switch to select between single and 10 steps

//Joystick(Joystick HID ID, Joystick Type, Button Count, Hat Switch Count, Include X, Include Y, Include Z, Include Rx, Include Ry, Include Rz, Include Rudder, Include Throttle, Include Accelerator, Include Brake, Include Steering)
Joystick_ Joystick(0x15, JOYSTICK_TYPE_JOYSTICK, 19, 0,
                   true /*X*/, false/*Y*/, false/*X*/,
                   false/*Rx*/, false/*Ry*/, false/*Rz*/,
                   false/*Rudder*/, false/*Throttle*/, false/*Acc*/,
                   false/*Brake*/, false/*Steer*/);

const bool initAutoSendState = true; // code is sends continuously and doesnt wait for polling

int EncoderState[] = {
  0, 0, 0, 0
};

void setup() {
  for (int q  = 0; q < EncoderCount; q++)
  {
    pinMode(EncoderPins[q], INPUT_PULLUP);
  }

  Serial.begin(9600);
  Joystick.begin();

  Timer1.initialize(100);
  Timer1.attachInterrupt(timer_service);
}

void loop() {
  GET_CHANGE();

  int CurrentButton18State = !digitalRead(joyButton18);
  switch(CurrentButton18State){
    case 0:
      switch(EncoderState[3]){
        case  1: clickButton(15); Serial.println(EncoderState[3]); break;
        case -1: clickButton(16); Serial.println(EncoderState[3]); break;
        } break;
    case 1:
      switch(EncoderState[3]){
        case  1: clickTen(15); break;
        case -1: clickTen(16); break;
        } break;
  }
}

void clickButton(int pin) {
  Joystick.setButton(pin, 1);
  delay(2);
  Joystick.setButton(pin, 0);
}

void clickTen(int pin) {
  for (int ii = 0; ii < 10; ii++)
  {
    clickButton(pin);
    Serial.println("step: "); Serial.println(ii);
    delay(10);
  }
}
void GET_CHANGE()
{
  for(int E = 0; E<4; E++)
  switch(E) {
    case 3: EncoderState[E] = encoder4.get_change(); break;
  }
}

Please reduce the code to the minimum that produces the behaviour you describe. Is this code meant for the Arduino Uno? If so, Arduino pin A3 (your switch pin) is physically the same as pin 17 (one of your encoder pins). Pins 0 and 1 are the Serial RX/TX pins, which you can't use for other things if you need input/output on the Serial port.

@StarCat, it says Arduino Micro

@StarCat since "A3" is the marker on the board itself, i thought it would be easier to understand, ofcourse every analog pin can be used as an digital (in the code i do so). I postet the complete sketch, because i dont know, if the problem maybe is in an other part then the two switches.
The Buttons on pins 0/1 may get wired with a voltage distributor on an other pin

why are you talking about selecting between 10 steps and 1 step when you cannot get the encoder to work? ... please focus your question to the problem

No output, neither in on nor in the off position of the switch

Which rotary encoder and switch are you referring to? When I google those words, it seems there are millions of choices. Is the switch built in to the rotary encoder? I am having trouble seeing your rotary encoder from my computer. How about sharing a link to the manufacturer, or datasheet, or a picture of it?

I postet the complete sketch, because i dont know, if the problem maybe is in an other part then the two switches. - if you reduced the code to the encoder part only you would find that out, wouldn't you?

@jsotola the Rotarys above, which have no switch connected, are working.

@VE7JRO added them

Again, please reduce your source to the minimum that still reveals your problem.

I second the other commenters: you are posting too much code. Please, see How to create a Minimal, Reproducible Example. 2. May be unrelated to your problem but, your code assumes BasicEncoder::get_change() always returns −1, 0 or 1. This may not always be the case, especially considering that you have quite a few delay() in your code.

@EdgarBonet I read the link you posted and will reduce the code this afternoon (with help of Jsotola). get_change() should either give 1 or - 1 if rotary is used and 0 if it stands still, doesn't it?

Re the value returned by get_change(): as stated in the documentation, get_change() returns “the number of counts since the last call to the method”. If the loop executes very quickly, this will almost always be within ±1. The documentation suggests “Try adding a delay in loop() to see larger changes being reported.” You already have quite a few delays.

@EdgarBonet so you think i should compare if its higher or lower than 1 v -1?

And this I could put in a loop, so it pushes the button that often i rotated the switch, couldn't I?

i want to excuse for shorten the code that late, but now it is, had no time before and forgot when i wrote the question

This is not an answer to the question, but a tip about simplifying your code.
This is a snippet of your code.

void loop() {

// some more code here

  int encoder1State = encoder1.get_change();
  switch (encoder1State) {
    case 1:
      Joystick.setButton(8, 1);
      delay(25);
      Joystick.setButton(8, 0);
      //Serial.println(encoder1State);
      break;
    case -1:
      Joystick.setButton(9, 1);
      delay(25);
      Joystick.setButton(9, 0);
      //Serial.println(encoder1State);
      break;
    case 0:
      break;
  }
  int encoder2State = encoder2.get_change();
  switch (encoder2State) {
    case 1:
      Joystick.setButton(10, 1);
      delay(25);
      Joystick.setButton(10, 0);
      //Serial.println(encoder1State);
      break;
    case -1:
      Joystick.setButton(11, 1);
      delay(25);
      Joystick.setButton(11, 0);
      //Serial.println(encoder1State);
      break;
    case 0:
      break;
  }
  int encoder3State = encoder3.get_change();
  switch (encoder3State) {
    case 1:
      Joystick.setButton(12, 1);
      delay(25);
      Joystick.setButton(12, 0);
      //Serial.println(encoder1State);
      break;
    case -1:
      Joystick.setButton(13, 1);
      delay(25);
      Joystick.setButton(13, 0);
      //Serial.println(encoder1State);
      break;
    case 0:
      break;
  }
  int currentButton20State = !digitalRead(joyButton20);
  int encoder4State = encoder4.get_change();
  switch (currentButton20State) {
    case 0:
      switch (encoder4State) {
        case 1:
          Joystick.setButton(14, 1);
          delay(25);
          Joystick.setButton(14, 0);
          Serial.println(encoder4State);
          break;
        case -1:
          Joystick.setButton(15, 1);
          delay(25);
          Joystick.setButton(15, 0);
          Serial.println(encoder4State);
          break;
        case 0:
          break;
      } break;
    case 1:
      switch (encoder4State) {

        case 1:
          TenRotaryStepsUP();
          break;
        case -1:
          TenRotaryStepsDOWN();
          break;
        case 0:
          break;
      } break;
  }

  //GetParamFromFS2020();
  //ShowFlightParam();

  delay(10);

}

void TenRotaryStepsUP()
{
  for (int i = 0; i < 10; i++)
  {
    Joystick.setButton(14, 1);
    delay(25);  //for testing set on higher number e.g. 500
    Joystick.setButton(14, 0);
    Serial.println("step: "); Serial.println(i);
    delay(10);
  }
}

void TenRotaryStepsDOWN()
{
  for (int i = 0; i < 10; i++)
  {
    Joystick.setButton(15, 1);
    delay(25);
    Joystick.setButton(15, 0);
    Serial.println("step: "); Serial.println(i);
    delay(10);
  }
}

It can be simplified by putting repeated code into functions.

void loop() {

// some more code here

  int encoder1State = encoder1.get_change();
//Serial.println(encoder1State);
  switch (encoder1State) {
    case 1:
      clickButton(8);
      break;
    case -1:
      clickButton(9);
      break;
    case 0:
      break;
  }

  int encoder2State = encoder2.get_change();
  switch (encoder2State) {
    case 1:
      clickButton(10);
      break;
    case -1:
      clickButton(11);
      break;
    case 0:
      break;
  }

  int encoder3State = encoder3.get_change();
  switch (encoder3State) {
    case 1:
      clickButton(12);
      break;
    case -1:
      clickButton(13);
      break;
    case 0:
      break;
  }

  int currentButton20State = !digitalRead(joyButton20);

  int encoder4State = encoder4.get_change();
  switch (currentButton20State) {

    case 0:
      switch (encoder4State) {
        case 1:
          clickButton(14);
          break;
        case -1:
          clickButton(15);
          break;
        case 0:
          break;
      } break;

    case 1:
      switch (encoder4State) {
        case 1:
          clickTen(14);
          break;
        case -1:
          clickTen(15);
          break;
        case 0:
          break;
      } break;
  }

  //GetParamFromFS2020();
  //ShowFlightParam();

  delay(10);

}

void clickButton(int pin) {
  Joystick.setButton(pin, 1);
  delay(25);
  Joystick.setButton(pin, 0);
}

void clickTen(int pin) {
  for (int i = 0; i < 10; i++)
  {
    clickButton(pin);
    Serial.println("step: "); Serial.println(i);
    delay(10);
  }
}

You can even format your code like this.
switch (encoder3State) {
  case  1:      clickButton(12);      break;
  case -1:      clickButton(13);      break;
  case  0:                            break;
}

EDIT
Also refer to the following about the use of arrays as variables, to specify pins, instead of individual variable names
https://www.arduino.cc/en/Tutorial/BuiltInExamples/Arrays
eg. use lastButtonState[1] instead of lastButton1State and joyButton[1] instead of joyButton1
that will allow the use of for loops to repeat the same action for multiple pins
int currentButton2State = !digitalRead(joyButton2);
if (currentButton2State != lastButton2State) {
  Joystick.setButton(1, currentButton2State);
  if (currentButton2State == 1) {
    delay(1);
    Joystick.setButton(1, 0);
  }
  lastButton2State = currentButton2State;
}

becomes
int currentButtonState[pin] = !digitalRead(joyButton[pin]);
if (currentButtonState[pin] != lastButtonState[pin]) {
  Joystick.setButton(pin-1, currentButtonState[pin]);
  if (currentButtonState[pin] == 1) {
    delay(1);
    Joystick.setButton(pin-1, 0);
  }
  lastButtonState[pin] = currentButtonState[pin];
}

Thanks @jsotola, will try this when I'm back at home!

added more info

Thanks, I will try this this afternoon (also I will reduce the code in the question)

You can also handle multiple encoder steps with something like if(encoder3State>0) while(encoder3State--) clickButton(12); if(encoder3State<0) while(encoder3State++) clickButton(13);.


text:
The RF 433MHz receiver code is working only when I reset the Arduino
I'm working on RF modules using Arduino but I observed the if statement is only running once and I need to reset the receiver every time to make it work with real-time changes in the transmitter.
I connected the 16X2 LCD display for displaying the data.
If I start the transmitter and started sending data as "1", it's showing "Bye" but when I change the transmitter data to "0", then also it is showing "Bye" only.
I changed a code a little bit but I felt it is the problem with the previous data stored in buf variable.
I'm expecting the LCD should display "Hi" when I changed the transmitting data to "0" from "1" which is not happening only "Bye" is displaying every time.
Here is the Arduino receiver code:
#include <RH_ASK.h>
#include <SPI.h>
#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
RH_ASK rf_driver;
char message[2];

void setup()
{
    rf_driver.init();
    Serial.begin(9600);
    lcd.begin(16,2);
}

void loop()
{
    uint8_t buf[2];
    uint8_t buflen = sizeof(buf);

    buf[1] = '\0';

    if (!rf_driver.recv(buf, &buflen))
    {
        if (strcmp((char*)buf, "0") == 0) {
            Serial.println("Hi");
            if (strcmp(message[0], (char*)buf[0]) != 0) {
                lcd.print("Hi");
            }

            lcd.display();
        }
        else if (strcmp((char*)buf, "1") == 0) {
            Serial.println("Bye");
            if (strcmp(message[0], (char*)buf[0]) != 0) {
                lcd.print("Bye");
                lcd.display();
            }
        }
    }
    message[0] = (char*)buf[0];
}

Here is the transmitter code:
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK rf_driver;

void setup()
{
    rf_driver.init();
    Serial.begin(9600);
}

void loop()
{
    const char *msg = "1";
    rf_driver.send((uint8_t *)msg, strlen(msg));
    rf_driver.waitPacketSent();
    delay(1000);
}

The Serial monitor output is as follows:

Does the serial monitor output "Hi" if you change the transmitted value to "0"? (You might want to extend your transmitter code a bit for easier debugging.) -- Why do you initialize the LCD each time, is this necessary? -- Please indent your source properly, it is hard to read. I've edited it once, but you have overwritten it, so I repeat the edit.

No, it's not outputting "Hi" when i change the transmitted value to "1". It is continuously showing "bye" only.

Huh? With "1" you want to output "Bye". Why do you expect "Hi"?

sorry,  it's not outputting "Hi" when i change the transmitted value to "0". It is continuously showing "bye" only. Only i click on reset button on Arduino, it is working

What is shown in the serial monitor if you output the received message?

char message[2];  ... if (strcmp(message[0],  You should be getting a warning for this. If not, turn your warning level up in the preferences.

It is just continuously showing "bye" irrespective of the changes in transmitted message

go back to the beginning ... reduce your code ... forget about decoding the received data ... print the received data and the length of the received data ... do you receive what you expect to receive?

I pointed this out in a comment thinking the question would probably get closed when this was understood to be a typo, but I guess it's not a typo.

char message[2]; ... if (strcmp(message[0], You should be getting
a warning for this. If not, turn your warning level up in the
preferences.

If you increase the warning level you should see something that at least hints at some of what I'm saying below.
Cutting your code down to a part relevant to the description of the problem:
char message[2];
// ...
uint8_t buf[2];
// ...
if (strcmp(message[0], (char*)buf[0]) != 0) {

strcmp() expects a pointer to a character for both its first and second arguments. However, message[0] is of type char and buf[2] is of type uint8_t (ultimately an unsigned char). The individual characters being used are being interpreted as pointer values (as in memory addresses) which strcmp() expects to refer to the first characters of strings.  In other words, it's going to some pair of memory addresses between 0 and 255 and trying to interpret whatever it finds at those locations as strings and compare them. The combination of what you're doing being undefined and not having a strong expectation of what to find at these memory addresses, it's not really surprising (to me anyway) how your comparisons are evaluating.
A minimal change that should bring the strcmp closer to making sense is:
if (strcmp(message, (char*)buf) != 0) {

message and buf here will end up evaluating to the actual locations of their strings.
You were already doing half of this line correctly in your other use of buf in if (strcmp((char*)buf, "0") == 0); note no [0] usage there.

In the above I'm addressing this directly and taking it for granted that you have some reason to want to use string that have one (non-null) character in them, that you intended to expand this code to longer messages somehow. Otherwise it makes more sense to just dispense with strings altogether and have rh_driver.recv read directly into a single character type and then use the equality comparison == rather than strcmp().
The sections of code would look more like:
char message; // now individual char
// ...
uint8_t buf;  // now individual char
// ...
if (!rf_driver.recv(&buf, sizeof buf)) { //sizeof buf is 1
    if (buf == '0') { // now simple application of ==
        Serial.println("Hi");
        if (message != buf) {  // now simple application of !=
            lcd.print("Hi");
        }
// ...
message = buf; // no longer using [0] because no longer an array


text:
How to wire an ESP32-S2 Dev KitM-1 for power?
I'm putting an Espressif ESP32-S2 Dev KitM-1 into a project box. The box will have 12VDC power and a 5V buck converter for the Dev Kit.
Do I need to use the USB port to power the Dev Kit or can I directly wire 5VDC to the 5V pin (and ground, of course) to power it?

The official documentation has

Power Supply Options
There are three mutually exclusive ways to provide power to the board:

Micro-USB Port, default power supply
5V and GND pin headers
3V3 and GND pin headers


text:
Duplicate Arduino SD Library
I need to have two independent arduino sd libraries so that I can modify one and have the other one intact. I struggle to do so.
Does anyone know if this is even possible?
What should be the path to properly do so?
I tried a lot of things but I always end up in a spot where I dont know what code is working and what is not. Last try I duplicated all the files and renambed all the functions to whatever"2" but couldn't make it work

What is the background of your project? Do you want to use both libraries in the same sketch? If so, why? What requirements do you have? Please [edit] your question and add these informations, don't use comments.

Do you need to use both of them insifde the same project?

If not then just create the library folder and copy it within the project where you are editing it Then include it as #include "Sd.h" rather then #include "Sd.h"

Yes I need to use them both inside the same project

If your objective is to use 2 SD card readers (pseudo) simultaneously in a project then this may help: https://forum.arduino.cc/t/two-sd-cards-on-the-same-project/1012605

that wont work, I need two independent sd libraries on the same sketch

You urgently need to add your goal to the question by [edit]ing it. Don't let us and future viewers pick up all the details like bread crumbs from your comments. -- Do you want the two different libraries access the same SD card or two different SD cards? -- Does you project build the libraries from source, or does it use ready-built libraries?

@the-busybee Quote from post "I need to have two independent arduino sd libraries so that I can modify one and have the other one intact." Quote from title "Duplicate Arduino SD Library"

Well, I'm giving up. Good luck!

If you want to use two SD card than instead of copying the whole library just create another instance of the class like
SDClass SD2;

Now you can call SD2.begin(CS_PIN_2) or any other function of the sd library.

That wont work because you are using the same library just changing the name where you call it. I need two independent libraries

Why do you need two independent libraries? Are you aware that the variables of both objects of SDClass are already independent?

@Espada86 Why you want two libraries? Because you want to use two SD cards ?

@the-busybee the requierement is to have two independent libraries because I want to modify one and have the other one unchanged but being able to call any of them on the same sketch.

@Espada86 Can you give a hint what you want to change in the library ?

@Espada86, use one modified library. modify it that way so it can be used the unmodified way too


text:
Strange characters on display st7920
My Display is showing texts with strange characters in Chinese. how can i fix this

        #include <Arduino.h>
        #include <U8g2lib.h>

        #ifdef U8X8_HAVE_HW_SPI
        #include <SPI.h>
        #endif
        #ifdef U8X8_HAVE_HW_I2C
        #include <Wire.h>
        #endif

          U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18, /* data=*/ 23, /* CS=*/ 5, /* reset=*/ 22); // ESP32

        void setup(void) {
          u8g2.begin();
        }

        void loop(void) {
          u8g2.clearBuffer();                   // clear the internal memory
          u8g2.setFont(u8g2_font_ncenB08_tr);   // choose a suitable font
          u8g2.drawStr(0,10,"Hello World!");    // write something to the internal memory
          u8g2.sendBuffer();                    // transfer internal memory to the display
          delay(1000);
        }

run simple "hello world" code first

Your source is far too big to be examined. Please step back and write the most simple test program that still reveals the issue.

Looks like you're trying to print uft8

I put a simple code like hello world and still the same error

Have you double-checked your wiring, and that the display uses SPI? Do you have an oscilloscope to watch the transmitted signals, at least the initializing ones?


text:
ESP8266 SDCard initialization bug
I have an ESP8266 wich is connected to an SDCard module, an SHT21 sensor and an BMP280. The idea is that I want to log data from the sensors to the SD Card, but if I initialize the SD Card with SD.begin(chipSelect), all the data from sensors become NaN or random values. If I initialize it, it is logging only NaN on the sd card, so the card is working, and if I dont initialize it, I get good and normal values into the serial monitor.
The Card Module is connected to D5,D6,D7,D8, and the two sensors are connected to D1 and D2, and all powered from 3v.
Any idea?
This is the code:
#include <Wire.h>
#include <SPI.h>
#include <Sodaq_SHT2x.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp;
#include <SD.h>
File myFile;
float pressure;
float temperature;
float altimeter;
float humidity;
float dewPoint;
float temperature2;
float humidity2;
float dewPoint2;
int chipSelect = 5;
float QNH = 1015;
const int BMP_address = 0x76;

int ledB = D4;
int ledG = D3;
int ledR = D0;

void setup()
{

  Serial.println("initialization done.");
  Wire.begin();
  Serial.begin(9600);
  bmp.begin(BMP_address);
  Serial.println("PTHBox Logger");
    //Checking if SDCard is alive
    if (SD.begin(5)){
    Serial.println("SD card is alive");
  }else{
    Serial.println("SD card is ded");
    while(1); //halt program
  }

//Checking the logfiles from the SDCard and deleting them
  if (SD.exists("/csv.txt"))
  {
    Serial.println("Removing csv.txt");
    SD.remove("/csv.txt");
    Serial.println("csv.txt is fresh and ready to log");
  }

//  Writing headers to csv.txt
   myFile = SD.open("/csv.txt", FILE_WRITE);
   if (myFile) // it opened OK
    {
    Serial.println("Writing headers to csv.txt");
    myFile.println("Altitude,Pressure,Temperature,Humidity,DewPoint");
    myFile.close();
    Serial.println("Headers written");
    }else {
    Serial.println("Error opening csv.txt");
  }
//  Setting pinModes for the LED
  pinMode(D0, OUTPUT);
  pinMode(D3, OUTPUT);
  pinMode(D4, OUTPUT);
  //Set PWM frequency 500, default is 1000
  //Set range 0~100, default is 0~1023
  analogWriteFreq(500);
  analogWriteRange(100);

}

void loop()
{
  // Testing the led
  analogWrite(ledR, 100);
  analogWrite(ledG, 0);
  analogWrite(ledB, 60);

  Serial.print("Humidity(%RH): ");
  Serial.print(SHT2x.GetHumidity());
  Serial.print("     Temperature(C): ");
  Serial.print(SHT2x.GetTemperature());
  Serial.print("     Dewpoint(C): ");
  Serial.print(SHT2x.GetDewPoint());
  pressure = bmp.readPressure()/100;  //and conv Pa to hPa
  Serial.print("     BMP PRESSURE");
  Serial.print(pressure);
  Serial.print("     BMP ALT");
  Serial.println(bmp.readAltitude (QNH));
  Serial.print("     BMP TEMP");
  Serial.print(bmp.readTemperature());

//  Assigning values to variables

 pressure = bmp.readPressure()/100;  //and conv Pa to hPa
 temperature = (bmp.readTemperature()); //temperature from bmp
 altimeter = bmp.readAltitude (QNH); //QNH is local sea lev pressure
 humidity = (SHT2x.GetHumidity());
 dewPoint = (SHT2x.GetDewPoint());
 temperature2 = (SHT2x.GetTemperature());

//  Writing the values to SDCARD
myFile = SD.open("/csv.txt", FILE_WRITE);
    // if the file opened okay, write to it:
    if (myFile)
    {
      Serial.println("Writing to csv.txt");
      myFile.print(altimeter);
      myFile.print(pressure);
      myFile.print(temperature);
      myFile.print(humidity);
      myFile.println(dewPoint);
      myFile.close();
    }
    else
    {
      Serial.println("error opening csv.txt");
    }
  delay(1000);
}

is it a Wenos D1 mini or a NodeMcu? don't mix numbers and D labels for pins in one sketch.  https://arduino.stackexchange.com/questions/75704/what-are-the-best-gpio-pins-to-use-for-my-project/75706#75706

It is a NodeMcu

io 5 is D1. it is a good choice for the CS pin, but then you have to wire the SD card's CS pin there, not elsewhere. but D1 and D2 are default pins for I2C (Wire) so I guess you have a sensor wired to D1/D2.

You're calling
if (SD.begin(5)){

GPIO5 is not necessarily D5. Use the D5 constant; it will evaluate to whatever GPIO number D5 actually is. So,
if (SD.begin(D5)){

Although you don't appear to be using the variable, you also have:
int chipSelect = 5;

which should be
int chipSelect = D5;

The difference between GPIO numbers and pin labels leads to problems for a lot of people. GPIOx is specific to the ESP8266 - it corresponds to a pin number and function on the actual chip; Dx is specific to the particular breakout board and is not always the same GPIO number (or the same between breakout boards).

It is doing the exact same thing. Like I said, the file is getting written onto the SD Card, but if the sd card is getting initialized, the sensors stop working.

Are you sure you selected the correct board?

GPIO5 is SCL on the ESP8266, so using GPIO5 for chip select would definitely break I2C communications. Try adding Serial.print("D5 is "); Serial.println(D5); to find out what D5 is defined as.

if it is a Wenos D1 or a NodeMcu it doesn't make sense to use D5 as CS, because D5 is SPI CLK pin.

I did that, it says dhat D5 is 14. (BTW It is a NodeMcu)

Nevermind, I figured it out. I used D8 instead of 5, and now it is working. I got tricked because the SD Card was working and D5 too, and I thought that wasn't the problem. Thank you, guys! Cheers!

Glad you got it working!

@Mereics, io 15 (D8) has to be LOW at boot. the use as CS pins can interfere


text:
Can the USB interface IC be identified via code alone?
I know that the master controller can be found in verbose upload output in IDE, but I have a few boards from different manufacturers and my smartphone camera is apparently insufficient to take a legible picture. Is there something I can do from the PC, either via official IDE or otherwise, that will return usb controller chipset?

did you look into driver details in Windows Device Manager?

Which property do I need?, meaninng, there is a dropdown under Property, Which option contains the chip?
c
ETA:N/M It's Driver Description. If you write an answer I will accept.

If the Device Manager does not give a sufficient answer directly, it tells you the VID:PID combination that identifies each USB device. Use this numbers to ask your favorite web search engine.


text:
Arduino MQTT Library sending disconnect packets even though it is not called
I am trying to connect to AWS IoT through the Arduino Portenta H7 and I am following this blog (https://create.arduino.cc/projecthub/Arduino_Genuino/securely-connecting-an-arduino-mkr-wifi-1010-to-aws-iot-core-a9f365).
When I run the code, it shows that there was an error connecting to the MQTT broker (Error code: -2)...but when I check the Cloudwatch logs, it shows a successful connection and a client initiated disconnection. I am not sure why it disconnects as my code does not initiate disconnection.
Here is the code:
void connectMQTT() {
  Serial.print("Attempting to MQTT broker: ");
  Serial.print(broker);
  Serial.println(" ");

  while (!mqttClient.connect(broker, 8443)) {
    // failed, retry
    Serial.print(mqttClient.connectError());
    Serial.print("\t");
    delay(5000);
  }
  Serial.println();

  Serial.println("You're connected to the MQTT broker");
  Serial.println();

  // subscribe to a topic
  mqttClient.subscribe("arduino/incoming");
}

Did you correctly set up the certificate?

Yes...because the Cloudwatch logs show that the device connected and even subscribed


text:
Code explanation when pH sensor is connected to Arduino
I have to measure the pH value for some experiment. I have checked various codes and all include the average of pH values.
#define SensorPin 0          // the pH meter Analog output is connected with the Arduino’s Analog
unsigned long int avgValue;  //Store the average value of the sensor feedback
float b;
int buf[10],temp;

void setup()
{
  Serial.begin(9600);
  Serial.println("Ready");    //Test the serial monitor
}
void loop()
{
  for(int i=0;i<10;i++)       //Get 10 sample value from the sensor for smooth the value
  {
    buf[i]=analogRead(SensorPin);
    delay(10);
  }
  for(int i=0;i<9;i++)        //sort the analog from small to large
  {
    for(int j=i+1;j<10;j++)
    {
      if(buf[i]>buf[j])
      {
        temp=buf[i];
        buf[i]=buf[j];
        buf[j]=temp;
      }
    }
  }
  avgValue=0;
  for(int i=2;i<8;i++)                      //take the average value of 6 center sample
  avgValue+=buf[i];
  float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt
  phValue=3.5*phValue;                      //convert the millivolt into pH value
  Serial.print("pH:");
  Serial.println(phValue,2);
  delay(5000);
}

Kindly explain the meaning of these two lines. Why take constant values as in bold (5/1024/6) and (3.5*pH)? Can I use some other value instead of these?
float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt
  phValue=3.5*phValue;                      //convert the millivolt into pH value

This is a fine example why magic numbers are bad. Always use symbolic constants.
Concerning the first line:

The "5.0" is the reference voltage of the ADC, apparently 5.0 volts.

The "1024" is the width of the range of values returned by the ADC.

The "6" is the number of samples summed up in the two lines before.

The ADC returns values in the range from 0 to 1023, giving you 1024 different values. If it measures 0% of its references voltage, it returns 0. If it measures 100% of its references voltage, it returns 1023. Actually the value "1024" should be "1023", but considering the accuracy it does not really matter.
By dividing the measured value by 1024, a single ADC value ranges from 0.0 (0%) to 0.999 (nearly 100%).
Multiplication by "5.0" gives the voltage, if we suppose that the reference voltage is 5.0 volts.
As 6 samples are summed up, another division by 6 is necessary to obtain the average.
In contrary to the comment the result of the first line is the measured and averaged voltage in volts, not in millivolts.
If the author had used smybolic constants, no comment would have been necessary and thus could not become erroneous.
Concerning the second line:
Apparently this is the factor of the sensor between voltage and pH value. A voltage of 0 volts means a pH value of 0, and a voltage of 4 volts means a pH value of 14. Note: pH can only range from 0 to 14.
Since you did not post a link to the data sheet of the used sensor, we cannot check this. But you can.
A first approach with symbolic constants:
static const int FIRST_INDEX_FOR_AVERAGE = 2;
static const int NUMBER_OF_VALUES_TO_AVERAGE = 6;

static const float FULL_SCALE_IN_VOLTS = 5.0;
static const int ADC_MAXIMUM = 1023; // was 1024

static const float PH_PER_VOLT = 3.5; // or even better 14.0 / 4.0

// ...

avgValue = 0;
for (int i = FIRST_INDEX_FOR_AVERAGE;
     i < FIRST_INDEX_FOR_AVERAGE + NUMBER_OF_VALUES_TO_AVERAGE;
     i++)
{
    avgValue += buf[i];
}

float phValue = avgValue * FULL_SCALE_IN_VOLTS / ADC_MAXIMUM / NUMBER_OF_VALUES_TO_AVERAGE;

phValue = phValue * PH_PER_VOLT;

There is no need to cast avgValue to float since FULL_SCALE_IN_VOLTS is float and so the calculations are done in floating point.

PH values follows a linear equation, y = mx + b, the 3.5 is the slope of the linear line. Typically a PH probe need to be calibrated with two buffer solutions, for example, at PH4 and another at PH9 or PH7, the line can then be draw and the slope can be determined.

A voltage of 0 volts means a pH value of 0, and a voltage of 4 volts means a pH value of 14. Not exactly, the measurement of PH value usually required to be amplified via an OP AMP, and since PH value can't be a negative value, the OP AMP is usually "raise" the reference voltage, say, to 2.5V, and then calibrate the probe for the OP Amp to output 0 voltage when PH is at 7.0 (Center of the PH range), so the PH value swing between +/-2.5V.

As I wrote, we have no information what sensor and external circuitry the OP uses. Therefore, I simply explained the factor. Anyway, your comments are welcome, as an potential edition of my answer. Just keep the meaning, please.

Re “the value ‘1024’ should be ‘1023’”: In theory, it should be 1024. This is clearly stated in the datasheet of the microcontroller: the value 1023 “represents the selected reference voltage minus one LSB”. In practice, you have to calibrate the ADC if you need this level of accuracy. I have measured a slope of ≈1026 on three Arduinos.

@EdgarBonet Thanks for this valuable insight!


text:
Define a custom baudrate in Serial Monitor
Is there a way to define a different baud rate from the ones we are shown in the dropdown menu of the Serial Monitor? I want to define a custom value.

There is no easy way to do so. The list of available baud rates is
hard-coded in the Java source of the Arduino IDE. To add a custom
rate, you would have to modify the source code and rebuild the
IDE.
I suggest you consider using a terminal emulator instead of the
serial monitor. On Linux, I like picocom: not a real terminal
emulator, but a minimal program that “connects” the terminal emulator
you are already using (gnome-terminal, rxvt...) to the serial port. It
supports custom baud rates, which it rounds to the nearest
rate the hardware can provide. Picocom works on Mac too.
For Windows, Adafruit recommends Putty or X-CTU. Sparkfun
recommends quite a few options for Windows, Mac and Linux.

If you are growing out of the Arduino IDE consider swaping to PlatformIO, baud-rate is just one of the many extra things you will get a chance to tweek.
If you are on X64 architecture, you can although use eclipse, but I find platformIO bit better for Arduino.
Arduino IDE is an OK starter, but to grow you will need to move further.
To add to Edgar Bonets answer, there are many other serial terminals including but not limited to: pyserial (multiplatform),screen (UNIXes), even good old Putty (runs on nearly everything that can blink I believe even on comodore)...


text:
Trying to understand stepper behavior, and I have some specific questions
I'm using a repurposed MKS Gen L V1.0 board (arduino MEGA + RAMPS, basically) to control a pair of IR sensors and a NEMA 23 stepper with TB6600 driver.
The application is simple: raise and lower the end of a roller. Wait for a signal from the sensors, wait for a time to see if the issue fixes itself and if it doesn't, turn 300 revolutions CW to raise, CCW to lower; wait; if we still have an issue, turn 150; issue fixed, return to zero.
It all works the way I want it to, except for the speed and direction of the stepper. NOTE: this is with the motor not attached to anything. NO LOAD.
To test, I've loaded a very simple script:
// speed tests
for (int a = 650; a <= 1200; a += 50) {
    Serial.println(a)
    // do the thing a few times (for this test, once)
    for (int y = 0; y <= 1; y++) {
        // turn one revolution
        for (int x = 0; x <= 200; x++) {
            digitalWrite(stepPin, HIGH);
            delayMicroseconds(a);
            digitalWrite(stepPin, LOW);
            delayMicroseconds(a);
        }
    }
    delay(1000);
}

exit(0);

Any delayMicroseconds value below 650 or above 1200, the motor jitters or vibrates but doesn't turn. When it does spin, the motor changes direction between spins, and as we get near the top of bottom of the range, it'll even change direction mid-spin.
The driver is set to 200p/rev and 1.5a. (I played with microstepping and higher amperage, but it didn't make an appreciable difference.)
Before you enthusiastically recommend a library, I've worked with both AccelStepper and Stepper (the default Arduino library?), and neither were as reliable or predictable as the code above.
I would like to be able to use AccelStepper, but the ac/de-celeration ramps have the same symptoms as my simpler code: between 650 and 1150μs, everything's fine, anywhere outside that range is not.
What don't I know? What am I missing to be able to turn slower and/or faster than that narrow range? Why does it change direction mid-spin or between spins?

Is the motor axle attached to something mechanically? If yes, have you tried it with no load attached to the motor?

This is without load. Once it is loaded, it'll be turning a screw, so very little load on it.

Please provide an image of how you wired everything up. Sudden direction change might indicate a floating dir pin

Done: image as requested.

Did you connect ground of the RAMPS to the negative terminals of the TB6600?

Everything is connected as shown in the image. If the board itself has a ground, I'm not aware of it. (MKS GEN L V1.0 - repurposed 3d printer board)

Mhh, normally you wouldn't change the length of the pulses for controlling the speed of the motor, just their frequency. Please try having the first delay fixed to 50us and vary the second delay. My TB6600 driver works correctly with this

At 50us, the motor whines without moving. If I stray very far from 800us in either direction, the motor just chatters. The driver is set ON-ON-OFF, OFF-OFF-OFF (200 steps, 3.5a). It's a NEMA23 if that makes a difference.


text:
Not enough memory error using OneSheeld.h
I'm a dairy farmer and I'm new to playing around with Arduino's. I created a code to send me SMS's when my equipment stops working as it should, but I run into a "Not enough memory" error. Here's my code:
#include <OneSheeld.h>
int IPFeed = 13;
int IPScraper = 12;
int IPPump = 11;
int XVal = 0;
int TFeedCharge = 0;
int TFeedRun = 0;
int TScraper = 0;
int TPump = 0;
int TLFeedCharge = 60;
int TLFeedRun = 60;
int TLManure = 2;
int TInc = 60000;

void setup() {
  pinMode(IPFeed, INPUT);
  pinMode(IPScraper, INPUT);
  pinMode(IPPump, INPUT);
  OneSheeld.begin();
}

void loop() {
  XVal = digitalRead(IPFeed);
  if (XVal == HIGH) {
    TFeedRun = 0;
    TFeedCharge = TFeedCharge +1;
    if (TFeedCharge == TLFeedCharge) {
      delay(150);
      SMS.send("613xxxxxx6","ProFeed 2020 is stoped at the charging station.");
      delay(150);
      SMS.send("613xxxxxx9","ProFeed 2020 is stoped at the charging station.");
      TFeedCharge = 0;
    }
  }
  else {
    TFeedCharge = 0;
    TFeedRun = TFeedRun +1;
    if (TFeedRun == TLFeedRun) {
      delay(150);
      SMS.send("613xxxxxx6","ProFeed 2020 is stopped away from the charging station.");
      delay(150);
      SMS.send("613xxxxxx9","ProFeed 2020 is stopped away from the charging station.");
      TFeedRun = 0;
    }
  }

  XVal = digitalRead(IPScraper);
  if (XVal == HIGH) {
    TScraper = TScraper +1;
    if (TScraper == TLManure) {
      delay(150);
      SMS.send("613xxxxxx6","The manure scraper has stopped working.");
      delay(150);
      SMS.send("613xxxxxx9","The manure scraper has stopped working.");
      TScraper = 0;
    }
  }

  XVal = digitalRead(IPPump);
  if (XVal == HIGH) {
    TPump = TPump +1;
    if (TPump == TLManure) {
      delay(150);
      SMS.send("613xxxxxx6","The manure pump has stopped working.");
      delay(150);
      SMS.send("613xxxxxx9","The manure pump has stopped working.");
      TPump = 0;
    }
  }

  delay(TInc);
}

Here is the error message:
Arduino: 1.8.19 (Windows 10), Board: "Arduino Nano, ATmega328P"

Sketch uses 24812 bytes (80%) of program storage space. Maximum is 30720 bytes.

Global variables use 2087 bytes (101%) of dynamic memory, leaving -39 bytes for local variables. Maximum is 2048 bytes.

Not enough memory; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing your footprint.

data section exceeds available space in board

Error compiling for board Arduino Nano.

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

Any ideas on how to fix this issue?

Comments are not for extended discussion; this conversation has been moved to chat.

Including the whole library, which is what you are doing, does not work on small boards like yours. Instead you have to only use the parts of the library that you need.
Fortunately the OneSheeld library provides a simple way of doing that, through the use of a couple of #define directives before you include the library.
Since you are only using the SMS functionality you only need to turn on that functionality - so start your sketch with:
#define CUSTOM_SETTINGS
#define INCLUDE_SMS_SHIELD

before the #include <OneSheeld.h> line and it will compile.

Your problem is caused by using too much RAM, not program memory, as the error message says:
Global variables use 2087 bytes (101%) of dynamic memory, leaving -39 bytes for local variables. Maximum is 2048 bytes.
The library you are using is likely occupying a large amount of RAM. However, currently your alert messages are stored in RAM as well, causing the limit to be exceeded.
To make the compiler store the strings in program memory (flash) instead of RAM, you can wrap each string in an F() macro. For example,
SMS.send("613xxxxxx6","ProFeed 2020 is stopped away from the charging station.");
becomes
SMS.send("613xxxxxx6",F("ProFeed 2020 is stopped away from the charging station."));
(You can also wrap the phone number to save even more RAM, but as the limit has only been exceeded by 39 bytes/characters it is unnecessary.)
Majenko's answer might potentially work too as the excluded parts of the library might happen to save just enough RAM, but the F() technique is still handy.

sms.send function doesn't accept a flash string. so it uses the version with String and creates a temporary String

Interesting. That makes removing includes the only solution.


text:
Esp8266-01 and Arduino
I recently bought an ESP8266 (ESP-01s). When I first connected it to Arduino,AT commands showed. Then when I uploaded other code,the commands stopped showing. I flashed it using many flashing tools and firmwares and the flashing was successful but AT commands still not showing. ESP is not responding to any code I execute in Arduino.

"Please help" How exactly? You need to give something to work with. Code, wiring, etc.

When you put code on the esp you remove the AT code. If your way AT commands you have to put on the AT code

ESP-01 by default shipped with AT Command firmware, when you upload an Arduino sketch, it override the firmware and replaced with Arduino boot loader and sketch (i.e. ESP-01 became an Arduino). If you want to get back the AT Command firmware, see my answer here on how to do that.

This is a common problem with newcommers to the ESP8266. It ships with AT commands working and as soon as you try putting your own code on it the AT commands stop working.
Well, of course they do.
The AT commands aren't something the ESP8266 does. It's something the software installed on the ESP8266 does, and you just deleted that software and put your own software on.
You can either have AT commands (by installing the correct AT firmware for your board) or run your own software on it - not both (unless, of course, you write your software in such a way that it responds to AT commands, but that's a completely separate thing...)


text:
Mouse.move: how do I move the mouse to the center of a screen?
I have a program operating in full screen mode. I would like to move the mouse to the center of the screen. Is this something I can do with the functionality of Mouse.h?
https://www.arduino.cc/reference/en/language/functions/usb/mouse/
Mouse.move moves fixed increments. maybe I should change the mouse start location in the computer program.
my issue, is that the "circuit playground" is the primary interface, using the accelerator for position. Once the computer is running the software, the Arduino has to be centered to work properly.
alternatively, is there a command I can send that could center the mouse?

There are two ways of working with HID mice - absolute and relative. The Arduino Mouse library only works in relative mode, but you want absolute.
There's another library https://github.com/NicoHood/HID which does do considerably more than the normal Arduino HID libraries - including "Absolute Mouse".

hey cool, samd21 support!
Thanks @Majenko


text:
Arduino + ESP8266 to send MQTT messages
I'm wondering if an Arduino Uno (or any other 328 family) that connects via Serial to an ESP8266 can send MQTT messages, rather than AT commands.

I didn't use MQTT yet so I didn't try any of the following options. I only know they exist.

AT firmware version 2 has a set of AT commands for MQTT. But development of AT 2 for esp8266 was ended with version 2.2. It requires an esp8266 with a 4 MB flash.

a very old esp8266 firmware called ESPLink has support to register to a MQTT topic and then use it in Arduino with the EL-link library. (The main goal of the ESPLink firmware was OTA update for Uno)

PubSubClient library is a very popular Arduino library for MQTT. It works over any standard Arduino networking library. For esp8266 there are multiple options for a firmware+library combination. I can only recommend my WiFiEspAT library (all others have too many problems). WiFiEspAT works with AT firmware in esp8266. Best is to use AT 1.7.5 or the 'fake' AT firmware ESP_ATMod, which is an Arduino sketch.

The third option will take much more flash and RAM than the first two, but it is a standard and portable way. You can port it to other networking library or other MCU type.
EDIT: Another option is to write a sketch with MQTT for the esp8266 directly and communicate the data with Uno or not use the Uno at all.


text:
Nokia 5110 LCD display doesn't work
Here is my circuit (all resistors are 10 kΩ, to lower the voltage, although I did try it without them with the same result):

The pinout on my display is (pin 1-8): RST, CE, DC, DIN, CLK, VCC, LIGHT, GND.
And here is my code:
#include <Nokia_5110.h>
#define RST 6
#define CE 5
#define DC 4
#define DIN 3
#define CLK 2
Nokia_5110 lcd = Nokia_5110(RST, CE, DC, DIN, CLK);

void setup() {
  pinMode(2, OUTPUT); //CLK
  pinMode(3, OUTPUT); //DIN
  pinMode(4, OUTPUT); //DC
  pinMode(5, OUTPUT); //CE
  pinMode(6, OUTPUT); //RST
  lcd.setContrast(60);
  lcd.setCursor(5, 2);
  lcd.print("Test");
}

void loop(){}

Problem is: nothing happens. I can only control the backlight via the potentiometer, but there is no text on the display. Now, this is my first attempt on this display so I might have just done something wrong; if you find it please tell me.
I'm using Nokia_5110.h library (https://github.com/baghayi/Nokia_5110)

Maybe show your actual display with its pinout. You have RST identified as Arduino pin 6 going to header pin 1 on the display.  RST is in the middle of the header on the one display I have that is like this. So, either your wiring is very wrong, or possibly more likely there's just no way to know because your display doesn't have the same pinout as mine.

@timemage the pinout on my display is (pin 1-8): RST, CE, DC, DIN, CLK, VCC, LIGHT, GND

Turns out I have a second one that's closer to that pinout, at least if old old pictures are to be believed. I don't see where you called lcd.begin().

@timemage I was reverse engineering one of the example sketches (specifically, this one: https://github.com/baghayi/Nokia_5110/blob/master/examples/Basic/Basic.ino) from the guy who made the library that I am using and there was nothing like that. I also tried different other examples from the internet with other libraries and they had the same results

LOL. Alright, edit your question to show which library you're using, since you're not using the common one.

@timemage I'm using Nokia_5110.h library (https://github.com/baghayi/Nokia_5110)

As said, [edit] your answer. This is not a forum, please don't put important information in a comment. -- Why did you insert serial resistors?

Welcome! A labeled schematic even hand drawn would be much better than the frizzy picture you are displaying. It would show all the connections and pin numbers along with power and ground connections. 20 seconds with that will convey much more information then the frizzy thing will in 5 minutes.


text:
Why does keyboard.h add 136 to each key?
I want to create a custom keyboard mapping in the official arduino keyboard library
Why do the key definitions add 136 to each number?
See Keyboard_es_ES.h on github
#define KEY_MASCULINE_ORDINAL    (136+0x35)
#define KEY_INVERTED_EXCLAMATION (136+0x2e)
#define KEY_GRAVE                (136+0x2f)
#define KEY_N_TILDE              (136+0x33)
#define KEY_ACUTE                (136+0x34)
#define KEY_C_CEDILLA            (136+0x31)

Looking at the ascii table, I see nothing special about value 136

It could be argued that this is an implementation detail of the library,
that does not need to be documented. ;-) Anyway, here is the reason...
The keyboard library uses a custom encoding scheme for representing
both characters and keys. The public methods press(), release(),
write(), print() and println() interpret the user-provided data
according to this scheme. With this encoding, the interpretation of a
byte depends on which of these three ranges it belongs to:

Bytes in the range [0, 127] are understood to be ASCII
characters. This is what enables you to write things like
Keyboard.println("Hello!");. The library uses a keyboard layout
array to map those characters to key scan codes¹, possibly modified by
Shift or AltGr. You provide a pointer to this array as an argument to
begin().

Bytes in the range [128, 135] are interpreted as modifier keys,
such as KEY_LEFT_CTRL, KEY_RIGHT_SHIFT, etc. Note that these keys
do not have proper scan codes, as their state is transmitted to the
host as a bit map (one byte for the eight keys) rather than as codes
added to a list.

Bytes in the range [136, 255] are interpreted as raw scan codes
in the range [0, 119], shifted by 136. This is what lets you
actuate arbitrary keys such as KEY_PRINT_SCREEN or KEY_LEFT_ARROW.
All scan codes of a standard full-size PC keyboard (ANSI 104 or
ISO 105) lie in the range [4, 101]: you can access all of
them, and even some more like KEY_F24.

Regarding the file Keyboard_es_ES.h: the codes in there are for keys
that match ASCII characters in the US layout but not in the Spanish
layout. The purpose is to ensure that every key of a ISO 105
keyboard can be actuated using either an ASCII character (like
Keyboard.press('a');) or a KEY_* macro.
¹ The USB standard calls them “usage codes”, but the old term “scan
codes” seems more prevalent.

Just an idea for self-documenting source, but I'm quite sure you are aware of this. ;-) You could use symbolic constants instead of magic numbers.


text:
One LED in 4x4 matrix does not turn on
I'm an art student and absolute beginner to electronics/code  -  my broader goal is to learn how to control individual LEDs when there are many of them (like 64 or more even, so am learning about shift registers, multiplexing etc. also).
I have been working with a 4x4 matrix example by Jon Fox. I have breadboarded it as below and checked it multiple times.

For the most part it's successful; the code runs and I get the LED animations in his code. I am also able to anticipate which parts of the code refer to which LEDs when I test by commenting out parts of the code - for example r1c1() refers to the top row, right-most LED.

However, the top row, second from the left LED does not turn on.
I have tested the individual LEDs before starting, tested the connections of the wires in case they don't make good connection in the breadboard, and tried adding 330 Ω resistors to the rows (instead of the orange connection wire in the image), and tried with 1 kΩ resistors instead of 220 Ω. The reason I tried those values was that I have been successful when I've used another set up I have, image below.

The blue and the white LEDs draw similar voltage so as far as I understand this wouldn't affect anything. The code runs great on this also.
I understand I could still be making some human error, especially as I've been going crazy with this. However, because I really want to understand the factors involved in controlling LEDs, I'd love to know if at all there are other variables at play.
For one, I was looking into 'floating inputs' hence tried adding the other set of resistors, and tried colour LEDs (more bulbs were either off or dim) as well as 3 mm white LEDs (same result as 5mm). The most difficult thing in this process is wondering what I don't know, so if anyone can direct me towards things I should consider for my purpose, or help me solve my current problem, I'd be really grateful.

It is very difficult to be certain.  You state that the second from the left LED in to top row is not turning on as expected.  In the bread-board diagram this LED is plugged into holes D7 and D8.  However, in the image it appears this LED is plugged into holes D8 and E8.
The exact letter/number may not matter if you are not following your bread-board diagram precisely.  However all pins in a row (i.e. A8, B8, C8, ... , E8) are shorted together.  So plugging in an LED into holes D8 and E8 would prevent it from lighting up.
Also, you have added resistors to your matrix which are not in the bread-board diagram.  The column resistors appear correct but the row resistors are questionable.  In practice, if you are going to light only 1 LED in a column at a time, then you might get by with only column resistors.  For such a configuration (only column resistors) you may see the LEDs dim if you light more than 1 per column.  If you do want to light more then one LED per column, the trick is to let the software switch LEDs on and off such that there is only one lit per column at a time. But fast enough so that a human eye can not see it.  So a bit faster than 100ms.

Thanks for your reply. Just to confirm, the LED second from the left in the top row is plugged into D7 (cathode -) and D8 (anode +).

Then check if it is reversed bias (put in backwards).  LEDs are diodes that happen to give off light.  And diodes can only be inserted forward biased (in the correct direction).

Let me know if the "only use column or row resistors but consider not using both & use software to mitigate dimming from lighting too many LEDs at once" is not clear.  Even in your second "free-standing" display I imagine the more LEDs you light in a given column  or a given row the dimmer the individual LEDs will become.  If you don't want to mess with the software (i.e. you just want to be able to light any combination of LED w/o dimming problems) then you will need to add a resistor to each and every individual LED.

It is put in the correct direction. I can remove the row resistors, I tried them in the breadboard since they worked in the free standing version, and I wondered about needing a pull-up(down?) resistor because of this idea of the floating input? Maybe that's totally irrelevant. At the moment I'm not experiencing dimming, in either version. There is no current or voltage on this LED and I just wonder why.

I just figured out my mistake - misconnected one of the cathode wires -  the 2nd LED is on. But your feedback was useful and much appreciated.