text:
Arduino Nano nRF24L01+ DFPlayer Mini SPI Problem
I'm working with an Arduino Nano board clone (CH340) on wireless control of DFPlayer Mini, transceiver sending a Struct variable with MachinePrefix (just in case), sound type (I have more folders by type of machines) and number of sounds.
The transceiver works fine, but the receiver doesn't. If I upload data into the Arduino, the DFPlayer plays the first song once (row 43 - myDFPlayer.play(1)), but after nRF24 init is not working.
After nRF24 init I'm still receiving data in valid format and range. If I comment out the nRF24 part, the DFPlayer is working, but together not. I read about working two devices on one SPI bus but I don't understand what's wrong. I think the problem is the same MOSI pin. In my opinion it should work but did not.
Any suggestions?
Here is the code of receiver:

#include
#include "RF24.h"
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

RF24 myRadio (8, 9); // CE, CS
byte addresses[][6] = {"Sx001"};

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);

struct dataStruct {
  short machinePrefix;
  short soundType;
  short soundNumber;
} dataReceived;

void setup() {
  mySoftwareSerial.begin(9600);
  Serial.begin(115200);
  delay(1000);
  Serial.println(F("RF24+dfplayermini-recever"));
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while(true);
  }

  Serial.println(F("DFPlayer Mini online."));
  myDFPlayer.setTimeOut(500);
  myDFPlayer.volume(5);  //Set volume value. From 0 to 30
  myDFPlayer.play(1);  //Play the first mp3
  //----------------------------
  delay(1000);
  myRadio.begin();  // Start up the physical nRF24L01 Radio
  myRadio.setChannel(108);  // Above most Wifi Channels
  // Set the PA Level low to prevent power supply related issues since this is a
  // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
  myRadio.setPALevel(RF24_PA_MAX);
  myRadio.setDataRate(RF24_250KBPS);
  //  myRadio.setPALevel(RF24_PA_MAX);  // Uncomment for more power
  myRadio.openReadingPipe(1, addresses[0]); // Use the first entry in array 'addresses' (Only 1 right now)
  myRadio.startListening();
  Serial.println(F("RF24 online."));
}//--(end setup )---

void loop() {  /****** LOOP ******/
  if (myDFPlayer.available()) {
    printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states.
  }
  if (myRadio.available()) { // Check for incoming data from transmitter
    while (myRadio.available()) { // While there is data ready
      myRadio.read( &dataReceived, sizeof(dataReceived) ); // Get the data payload
    }
    Serial.println("loop");
    myDFPlayer.loop(3);
    if (dataReceived.machinePrefix == 11001) {
      Serial.println("same device prefix");
      int playingData = dataReceived.soundNumber;
      if (myDFPlayer.available()) {
        Serial.println("player available");
        Serial.println(myDFPlayer.readType());
        Serial.println(myDFPlayer.read());
      }
      myDFPlayer.play(2);
    }
    Serial.println(dataReceived.machinePrefix);
    Serial.println(dataReceived.soundType);
    Serial.println(dataReceived.soundNumber);
    Serial.println("-----------------------------");
  } //END Radio available
}//--(end main loop )---

/*----------*/
void printDetail(uint8_t type, int value){
  switch (type) {
    case TimeOut:
      Serial.println(F("Time Out!"));
      break;
    case WrongStack:
      Serial.println(F("Stack Wrong!"));
      break;
    case DFPlayerCardInserted:
      Serial.println(F("Card Inserted!"));
      break;
    case DFPlayerCardRemoved:
      Serial.println(F("Card Removed!"));
      break;
    case DFPlayerCardOnline:
      Serial.println(F("Card Online!"));
      break;
    case DFPlayerPlayFinished:
      Serial.print(F("Number:"));
      Serial.print(value);
      Serial.println(F(" Play Finished!"));
      break;
    case DFPlayerError:
      Serial.print(F("DFPlayerError:"));
      switch (value) {
        case Busy:
          Serial.println(F("Card not found"));
          break;
        case Sleeping:
          Serial.println(F("Sleeping"));
          break;
        case SerialWrongStack:
          Serial.println(F("Get Wrong Stack"));
          break;
        case CheckSumNotMatch:
          Serial.println(F("Check Sum Not Match"));
          break;
        case FileIndexOut:
          Serial.println(F("File Index Out of Bound"));
          break;
        case FileMismatch:
          Serial.println(F("Cannot Find File"));
          break;
        case Advertise:
          Serial.println(F("In Advertise"));
          break;
        default:
          break;
      }
      break;
    default:
      break;
  }
}

if not difficult, show the code of the transmitter. pls)

When using SPI, pin 10 should never be used as an INPUT. Otherwise the Atmega can go into SPI Slave mode. But you use pin 10 as the RX pin.
Just swap pin 9 and 10, and update your code accordingly.

Thank you so much, i hadn't thought about changing pins to other digital pins on the Arduino, because my low understanding of Softwareserials...
Now i use pins D4 and D5 for dfplayer and it worked like a charm.

Just make sure you set pin 10 as an OUTPUT.

authors: Сергей Овчинников


text:
How to wrap/scroll text with U8G2?
Does anyone know how to wrap and or text using the U8G2 Libary? I know there are other libraries that do this for you, but I'd like to use U8G2.
Thank you!
My code's here for reference. It's not clean, but it works for now.

You have to do it manually. Scrolling is a simple matter of printing substrings and padding with spaces. Wrapping is a simple matter of printing substrings on different lines.

The Arduino Uno has very limited amount of memory to implement scrolling and wrapping of text for an LCD driver in general. The sketch has to do this, e.g. calculate line breaks, sub-section of text to be displayed, update when focus changes (i.e. scroll), save text, etc. Your sketch seems to be only a limited amount of text so you should be able to do this calculations, save of state, text box projection, etc.

You can do something like this:
    void loop(void) {
        u8g2_uint_t x;

        u8g2.firstPage();
        do {

            // draw the scrolling text at current offset
            x = offset;
            u8g2.setFont(u8g2_font_inb30_mr);       // set the target font
            do {                                // repeated drawing of the scrolling text...
                u8g2.drawUTF8(x, 30, text);         // draw the scolling text
                x += width;                     // add the pixel width of the scrolling text
            } while( x < u8g2.getDisplayWidth() );      // draw again until the complete display is filled

            u8g2.setFont(u8g2_font_inb16_mr);       // draw the current pixel width
            u8g2.setCursor(0, 58);
            u8g2.print(width);                  // this value must be lesser than 128 unless U8G2_16BIT is set

        } while ( u8g2.nextPage() );

        offset-=1;                          // scroll by one pixel
        if ( (u8g2_uint_t)offset < (u8g2_uint_t)-width )
            offset = 0;                         // start over again

        delay(10);                          // do some small delay
    }

The code is taken from https://github.com.
It is an excellent library, but it is can require a big amount of memory, fit very well on ESP8266 (tried on nodeMCU) / ESP32.
Of course on ESP32 it is faster.
Used for small OLED 0.98" screen.

source: Stack Exchange

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

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

sort: votes


text:
I am not able to use ESP8266 12E with Arduino
I am doing my engineering degree. I want to make a project connecting multiple ESP8266 with a router and control multiple relay boards. I am unable to use ESP8266 12E with Arduino. I used this connection shown in the link below, but it didn't work. So please help me with the solution. I also referred to all possible posts, but it didn't help. Please help me as soon as possible.
Connection:

post: How to connect ESP8266 12e directly to Arduino Uno (without shields)

In engineering, you'll have to use valid sources and constantly validate your choices (and explore options). Why would you even use an Arduino + ESP8266, if you can use an ESP8266 dev board (with USB) instead of an Arduino (+ESP)

Have you also checked the answer on that question? You could check other sources and see if they validate that connection, or simply do it conoletely different (try to explain why thuis connection is right, and other aren't)

i already bought arduino and because of my budget i am unable to buy dev board. So is there a way by which i can integrate esp8266 12e(without wifi shield) with arduino

They're around 4$, but you could also use an Arduino (or USB<->serial chip) to program the ESP8266 directly.

But, have you checked other sources? And what firmware is installed on your ESP8266?

i dont know about the firmware and unable to check it. I am unable to make esp8266 work with arduino. Is there a schematic and code available to make this happen

How can you be sure that you can communicate with the device, if you're not sure what firmware is installed. It may not have any firmware on it as far as we know?

I agree with Paul, you shouldn't use the Arduino, you can get break out boards at £1 for 10, but that's not what your problem is...
You are using a couple of resistors to do the level shifting taking the 5V to 3.3V.  This is a bad plan, you need a proper bidirectional level shifter, particularly at higher baud rates, i.e. above 1000.
You are supplying the top VCC rail with both 3V from the batteries and 3.3V from the Arduino, not the best plan IMO.
You are not supplying the Arduino with any power, I guess this is a drawing error but just in case it isn't I though I best mention it.
You have no level shifting on the Arduino's Rx line.  Its not technically needed, but you might require it particularly when the batteries are going flat.
You are using batteries and that's not a great plan.
Have you configured the ESPs using the AT command set, since you won't program them.
Just for the record the ESP has more memory it has a faster processor (80MHz) and you can still use the Arduino IDE.  You should be able to pick up boards to mount the ESPs so you can use them more easily for less that the price of the level shifters, but its your call.

can you suggest which breakout board should i use. And what proper method i should follow to use esp8266 12 e perfectly. And guys i live in india and the things are 2 or 3 times costly, and where i live don't have varieties of this things even online i don't have much options.    I am trying to find out ideal breakout board for 12e .But in mean time i can use suggestions that how can i use 12e.   :)

Something like this item from AliExpress https://www.aliexpress.com/item/10Pcs-Set-ESP8266-WiFi-Modules-Breakout-Transfer-Board-Adapter-Plate-For-ESP-07-ESP-08-ESP/32655534675.html?spm=2114.01010208.3.37.hpB7yI&ws_ab_test=searchweb0_0,searchweb201602_3_10065_10068_10000007_10084_10083_10080_10082_10081_10060_10061_10062_10056_10055_10054_10059_10099_10078_10079_10073_10097_10100_10096_10070_10052_423_10050_10051_424,searchweb201603_6&btsid=3433ccd4-e3f2-4707-8e9f-7968b5f02360
Or something similar.  Just to make the ESP more useable.

You may be able to make you own break out boards depending on your soldering ability.
How do you use it properly?  In the Arduino IDE use the board manager to download the support for ESPs.  At the basic level it is so similar to an Arduino you will laugh.  There are loads of tutorials out there, the biggest problem is remembering that in the code digital pin 0 means GPIO 0 which may or may not be marked as zero on your board.  On my boards pin 0 is pin 6 :)

@Matt, for the pins, you may want to do a search on ”[name of your breakout/devboard] Arduino pins" and do defines such as: '#define PIN6 D0', to have a solution that has no runtime overhead and is as easy to use.

I am the author of the linked question. Just to clarify, the image you're using has the old connection, which wasn't working for me. Please refer to the updated version of that connection, embed below:

The main changes were: the GPIO15 pin needs to be grounded, and the RESET pullup is now wired to the battery's 3.3v. Also the resistors were changed from 220ohms to 10k, but since it's a voltage divider it shouldn't make much of a difference.
Hope this helps anyone out there!

There is also a library which can help you communicating with ESP2866 through Arduino called WiFiEsp.
It's like WiFi library for Arduino but instead for ESP8266.

Bruh that ain't even an esp8266 12e that is a different esp board. The esp8266 12e is basically an Arduino with an added wifi feature which increases the number of tasks you can do. If you are using an esp8266 12e then you can connect it directly to your laptop and start programming on the Arduino IDE software. It is super awesome and I have worked with it once for my plans home automation system. With a bit of research, you can find out which esp board that is if you really want to work with that circuit diagram.

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

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


text:
A class within a class - via an Initialiser Lists: NOT able to update a variable
My test are based on the blog of http://arduinoetcetera.blogspot.be/2011/01/classes-within-classes-initialiser.html.
Because I would like to use this idea, I tried with a simple idea, after the instance is created just update a value.
But for some reason, the code compiles perfectly and there seems to be no error with the update method, but it DOES NOT UPDATE the variable.
But my output on the serial monitor show that the number (volatile int) doesn't update.
Object of class First has value - Number: 6
Object of class Second has value - Number: 13
Object of class Second has value - Double: 26
Object of class Second has value - Update: [0] - 20  // <--
- -
Object of class First has value - Number: 6
Object of class Second has value - Number: 13        // <--
Object of class Second has value - Double: 26
Object of class Second has value - Update: [1] - 70
- -
Object of class First has value - Number: 6
Object of class Second has value - Number: 13

code - MAIN :  First thing(6, 13);
[edited on request of @Mark Smith]
#include "First.h"
First thing(6, 13);
...
int newValue;
...
int ledPins[] = {
  20, 70, 45, 68, 543, 321
}; // an array of pin numbers to which LEDs are attached
int pinCount = 6; // the number of pins (i.e. the length of the array)
bool plus=true;
int index=-1;
void loop() {
  Serial.print("Object of class First has value - Number: ");
  Serial.println(thing.Number());
  Serial.println();
  Serial.print("Object of class Second has value - Number: ");
  Serial.println(thing.getSecond().Number());
  Serial.print("Object of class Second has value - Double: ");
  Serial.println(thing.getSecond().Double());
  ...
  Serial.print("Object of class Second has value - Update: [");
  if ( plus && index == (pinCount-1) ) {
    plus=!plus;
  }
  if ( !plus && index == 0 ) {
    plus=!plus;
  }
  // change + <--> -
  (plus) ? index++ : index--;
  newValue=ledPins[index];
  Serial.print(index,DEC);
  Serial.print("] - ");
  Serial.println(newValue, DEC);
  thing.getSecond().Update(newValue);
  Serial.println("- - ");

code - FIRST
#include "First.h"
...
First::First(int firstNumber, int secondNumber) : widget(secondNumber) {
  itsNumber = firstNumber;
}
int First::Number() {
  return itsNumber;
}
Second First::getSecond() {
  return widget;
}

code - SECOND : void Second::Update(int newNumber)
#include "Second.h"
...
volatile int itsNumber;
Second::Second(int newNumber) {
  itsNumber = newNumber;
}
void Second::Update(int newNumber) {
  itsNumber = newNumber;
}
int Second::Number() {
  return itsNumber;
}
int Second::Double() {
  return itsNumber*2;
}

For the complete code
https://github.com/droopy4u/ARDUINO
 - https://github.com/droopy4u/ARDUINO/tree/master/ClassWithClasses -

Could you post the actual code please? The part you've posted doesn't show the problem part. It's not good to rely on external links because they might disappear, and in your case it's not obvious (enough that I can be bothered to work out) which of the two very similar sets of files in your git repo you're using. Thanks.

This isn't an Arduino specific question, its general C/C++ BUT it is quite an important problem that lots of novice programmers have so I don't think it should be moved.

Even without the real code, I think the problem is with the function First::Second().
You need to understand what happens in C++ when values are passed as parameters.  The are passed by value by default, this means a COPY of the value is passed into the function, you can modify the parameter all you like but when you return those changes are lost.
There are two exceptions to this, the first is pointers.  When you pass in a pointer you can modify what is pointed to but you still can't modify the pointer, because that is a copy.  If you want to modify the pointer then you need a pointer to a pointer int** ptr_to_ptr.
The other exception is a reference.  In this case the function can modify the parent function's variable.  This is more efficient in terms of memory.
So you have:
int AddOne(int value) {++value; return value};   // 5 == AddOne(5);
int AddOne (int value) {return value+1};         // 6 == AddOne(5); - doesn't modify the parameter.
int AddOne(int* pValue) {(*value)+1; return *value;}//6 == AddOne(5); - Pointer
int AddOne(int& value){++value; return value;}   // 6 == AddOne(5); - Referance
int AddOne(const int& value){++value; return value;} // Compiler error, modifying const value.

So why it is First::Second() causing the problem?  Well the same rules apply to return values as to parameters and you are returning a copy of the value widget so you then modify that copy and then dispose of it.  So this is what you need to fix the problem.
Second& First::getSecond()
{
    return widget;
}

EDIT : Its not clear in the preceding text but you don't need getSecond() to return a reference if you are not altering the value of widget so getDouble() will return the expected value because it is working form a copy of the original and not storing any changes.  However update() will not work as expected because the result of getSecond() goes out of scope (gets disposed of) once the call is complete.  The changes its made are not save to the original because it is working on a copy.

PART1
Thank you very much for response ... first I was thinking and tried the same thing but then in the Class with the variable, but most probably I did something wrong, because of the compiler errors.
But I created a First.cpp and a First.h file - library. - so is it then not an instance?
I try to understand it ... but find it hard to solve the problem.

PART2
Tried your suggestion
by
Second& First::getSecond() as well Second &First::getSecond()
->
prototype ... does not match any in class 'First'.
I'm a beginner, but if I call the method thing.getSecond().Double() then it returns the correct data  int Second::Double(){   return itsNumber*2; } as 26. But it seems that the update is not working well, do you maybe have an other suggestion?

... thanks for your quick response and effort Because I have not enough reputation I'm not able to vote on your answer. Even not enough privilege to edit my own comment. Thank you very much.

The position of the space doesn't matter in this case, but I prefer Second& First::getSecond() because it makes it a bit clearer that it is Second you are referencing.  The error prototype ... does not match any in class 'First' means you need to change it in the .h and the .cpp file.

Part 2 :)  without using Second& First::getSecond() thing.getSecond().Double() will return 26 because you are taking a copy of widget and returning that copy and then reading the value from that copy before disposing of it.      When you do thing.getSecond().Update(8) you are getting a copy of widget, changing the value in that copy and then disposing of the copy.  The value in widget was never changed and this is why it is not working as you think it would.    I understand it can be difficult to comprehend so in every day terms...

Imagine that you have a letter.  You take a photocopy of the letter.  On this copy you underline the address the letter was sent from.  You then throw the photocopy away.  Where has the underlined text gone on the original?
If we use a reference & to the object (or a pointer) it means that there was no photocopy you changed the original letter and you still have the underlining.  Does that make more sense?

Now it is clear ... just an other COPY of the widget.
Thank you very much ...
An other question ... were you may be know the answer to let (the two) classes communicate with each other ... what is the best way to do it.
Event handlers ... or ... what are you recommendations?

I don't really understand what you want to do, also its another question so I think you should raise it as a separate question.  I'll keep looking for it.

mean something ... delegate ... "Observer" - and method notifyObservers of "Observable" ... But gonna search on google ... thanks any way ... Happy Hollidays

@MATT,
with trying to get the address of variable via
    const long SERIAL_SPEED=38400;//baud rate of the serial communication

//global variable
    int a = 15;
    int *b=a;

void infoVar(){
    Serial.print("\n\n");
    Serial.print(" a -  ");  Serial.println(a, DEC );
    Serial.print("*b -  ");  Serial.println(*b, DEC );  // dereferencing
    Serial.print("\n");

    Serial.print("int  b - ");  Serial.println( (int) b, DEC );   // ???
    // This is the content of the pointer variable b
    Serial.print("int &b - ");  Serial.println( (int) &b, DEC );  // address of memory location where b is stored
    Serial.print("int &a - ");  Serial.println( (int) &a, DEC );  // address of memory location where a is stored
}

void setup() {
  // put your setup code here, to run once:
    Serial.begin(SERIAL_SPEED);      // open the serial port at SERIAL_SPEED bps:

    Serial.println("Started : ### reference_pointer ###\n\n");

// *** :  when uncomment next line : the value b = 123
//b=123

    *b=a;
    infoVar();

    a=235;
    *b=a;
    infoVar();

    a=1928;
    *b=a;
    infoVar();

    }

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

OUTPUT
 a -  15
*b -  15

int  b – 15
        // don't understand here that it is 15
            //thought that is would be the the address of the variable 'a'
            // it seems that it keeps the first initiated value??? ***
int &b - 676
int &a - 256

 a -  235
*b -  235

int  b - 15
int &b - 676
int &a - 256

 a -  1928
*b -  1928

int  b - 15
int &b - 676
int &a - 256


text:
GPS and Arduino
I am working on a project with an Arduino Uno. I want to know if the latitudes and longitudes can be input to the Arduino for the Arduino to move to that particular location. If it's possible then which sensors or actuators are to be used? Please also mention some references for me to read and collect the required information.

Try this: http://bfy.tw/DbBj

OK, notwithstanding Majenko's excellent suggestion in the comments above, I played around with Arduino and GPS, so I can probably offer a few pointers.

First, GPS:
All the GPS modules that I have played with give out a series of standard strings of information or "sentences". These sentences are defined by the National Marine Electronics Association (NMEA) protocol. You are going to want to spend some time learning how to use this information.
The most commonly used string in an NMEA sentence is $GPRMC. From this you can extract date, time and position. But there is a lot more useful information in an NMEA sentence, so do your research.
When you have decided which GPS module you want to use, just use Google to search for sample Arduino code specific to that module. That should be enough to get you started.

On the subject of GPS Modules:
There are many available. Just Google search for "Arduino GPS module".
They vary in price from a few GB pounds to well over a hundred GB pounds. It all depends on what you need from it, and what you can afford. Personally, I got very good results from cheap (~ £5 GB) Neo-6M modules (like the one shown here) with some mobile robots I was experimenting with.

Now, I've just typed "Neo-6m GPS Arduino" into Google, and one of the first sites was this Instructable, which has more than enough information to get you going with this combination.

Path planning
Yes, you could give a robot a GPS and a target location and have it plan a route and move to the new location.
Sounds easy doesn't it?
It isn't.
It really, really isn't!
Path planning is a complicated discipline. There is an introductory course on Computational Motion Planning available (free to audit last time I looked) on Coursera if you are interested. It's part of a Robotics "Speciality", so depending on your existing skills, you might want to work through the modules in sequence.
[If you do decide to do all the modules in the Speciality, I shared my notes for some of the modules via my Scribd account. Some of these also contain elements on motion planning. (Be warned, some of them also contain a lot of maths!)]
The best practical advice I can give is to start small.
I tested my robots in a local park, over distances measured in tens, rather than hundreds of metres. I then introduced obstacles (trees) in a different part of the park, and things got a whole lot more interesting! (Not least, of course, because GPS really doesn't like trees! So you have to use other sensors when the robot isn't receiving data from the GPS ...).
And if you think that's complicated, just wait until you introduce "moving obstacles", like people, dogs, cars, bicycles, ...!

Hopefully that will give you some pointers to get you started. When you hit problems with your code (and you're almost certainly going to hit problems with your code!), sites like this will be a godsend.
I really wish Arduino: SE had been around back when I was banging my head against the proverbial wall trying to work out why my code wasn't doing what I expected it to!

See this site, for a practical example:
http://www.instructables.com/id/Arduino-Powered-Autonomous-Vehicle/


text:
Need help to find code error to send AT command response in sms
I know that there is something wrong in my code bellow because I don't get "OK" as response in the SMS when I use Serial.print ("AT") . "AT" is an AT command.
I am using the example 2 of http://forum.arduino.cc/index.php?topic=396450.0
I tested the code bellow on the serial monitor and I am able to see the response of the AT commands on the serial monitor with Debug.println(receivedChars);. However, I am unable to receive the command's response in the SMS and would like to know what is wrong in this procedure. When I upload this code bellow, I only see "AT" in the SMS without the "OK". I think that SW_Serial.print(receivedChars); should show give OK in the SMS but I don't see it.Do you kmow why?

The full code is very long but my error can be found in the part of the code which I gave

I replaced the older code by the new one which is more complete . It includes the setup and the includes. Can you tell me why I don't get "OK" response in SMS ?

It is disrespectful to change your question to gibberish. Please don't do that.

You are making the mistake of hoping the serial response will come very quickly. You are checking for serial available, which is good, but the function PrintModemResponse gives up once no serial is available. This is quite likely to be before all of the data has arrived. Imagine you are listening to me talking, and you assume that if there is a brief pause (as I take a breath) that my sentence is over. You are better off reading until you get a definite "end marker" like a newline.
I notice you are doing something like that in recvWithEndMarker.
You may find my page about how to process incoming serial data without blocking helpful. Example code from that page:
/*
Example of processing incoming serial data without blocking.

Author:   Nick Gammon
Date:     13 November 2011.
Modified: 31 August 2013.

Released for public use.
*/

// how much serial data we expect before a newline
const unsigned int MAX_INPUT = 50;

void setup ()
  {
  Serial.begin (115200);
  } // end of setup

// here to process incoming serial data after a terminator received
void process_data (const char * data)
  {
  // for now just display it
  // (but you could compare it to some value, convert to an integer, etc.)
  Serial.println (data);
  }  // end of process_data

void processIncomingByte (const byte inByte)
  {
  static char input_line [MAX_INPUT];
  static unsigned int input_pos = 0;

  switch (inByte)
    {

    case '\n':   // end of text
      input_line [input_pos] = 0;  // terminating null byte

      // terminator reached! process input_line here ...
      process_data (input_line);

      // reset buffer for next time
      input_pos = 0;
      break;

    case '\r':   // discard carriage return
      break;

    default:
      // keep adding if not full ... allow for terminating null byte
      if (input_pos < (MAX_INPUT - 1))
        input_line [input_pos++] = inByte;
      break;

    }  // end of switch

  } // end of processIncomingByte

void loop()
  {
  // if serial data available, process it
  while (Serial.available () > 0)
    processIncomingByte (Serial.read ());

  // do other stuff here like testing digital input (button presses) ...

  }  // end of loop

do you mean like that my PrintModemResponse should be like this (answer under your post)?

Please amend your question to clarify it. Answers are for answering the question, not clarifying what other people have told you.

Please tell me if my new PrintModemResponse called PrintModemResponse2 from the new full code is ok ?  It still doesn't give me the right thing. Do you know how I could improve it ?

It's not any better because as soon as available has 0 it doesn't matter what flagend is, the while loop will still exit before you get the whole thing.

Your code in GetModemResponse does not wait for a newline. I suggest you read the link I gave above. You seem to have three or four functions, all of which rather confusingly get a response from the modem. One should be plenty.

For the function GetModemResponse, can it really affect the response that it doesn't wait for the newline and since I am calling it only once and it's in the void setup() ?. I implemented your function from the link instead of my function PrintModemResponse() as we can see in the main code which I replaced. However, I still don't get the desired reply. Does anyone know why?

Can you post some output from this program?  There are a lot of debugging prints going on in there and it might help to see what is going on.  Are you not getting the response you want in setup?  Or are you talking about a response in loop?  Is the code making it to loop at all?

Wait, you're receiving that on the cellphone?  I thought we were talking about the Arduino receiving something.  Now I'm confused.

OK, please stop and explain the big picture of what it is that we're working on and what it is supposed to do and how it is supposed to work.  All through that whole ordeal over on the Arduino board I thought you were trying to receive an OK on the Arduino.

"Does anyone know whyI don't get OK response always? "
Yes, we know that's the question.  You don't have to keep repeating it over and over.  What you need to do instead is clarify it.

I said this in the first post: However, I am unable to receive the command's response in the SMS... What does that mean to you? and in that case Why did you think that it's only on the Arduino ?

I didn't think it was only on the Arduino.  I thought the "OK" you wanted to receive on the Arduino.  Now I'm not sure what you think is sending what where.  To me it looked like you posted Arduino code.  Does that code actually run on the phone?  Or the Arduino?

And no you haven't described what this setup is.  You jumped straight into what you thought the code problem is.  I'm looking for the big picture idea.  Like, "this is a project to allow my Arduino to tell my phone to call my mom if I get lost" or whatever it is actually supposed to do.  Help me understand what you have actually set up.  Remember, nobody here can see it.


text:
No data in text file
Data can be seen in the console but the data is not being written in the text file. The file is created but there is no data in it.
Here is my code in Processing,
import processing.serial.*;
Serial myPort;  // Create object from Serial class
String val;     // Data received from the serial port
PrintWriter output;
void setup()
{

   String portName = Serial.list()[0];
   myPort = new Serial(this, portName, 9600);
   output = createWriter( "my.txt" );
}
void draw()
{
    if ( myPort.available() > 0)
     {  // If data is available,
         val = myPort.readStringUntil('\n');
       output.print( val );
     }
    println(val); //print it out in the console

 }

and in Arduino,
  int potPin = 0; // initialize analog pin 0 for LM35 temperature sensor
  void setup()
  {
     Serial.begin(9600);// set baud rate at”9600”
  }
  void loop()
  {
     int val;// define variable
     int dat;// define variable
     val=analogRead(0);
     dat=(125*val)>>8;// temperature calculation formula
     Serial.print("Tep:");//
     Serial.print(dat);// output and display value of dat
     Serial.println("C");// display “C” characters
     delay(500);// wait for 0.5 second
   }

Any answers are appreciated. Thank you!

Don't know "processing" but do you close the file at the end? Because if you open it, write and then let it open, the file size stay at 0 and you can't read data. So maybe you really write data but they stay invisible because of the fact you don't close the file.

The Arduino has simple task of sending data to your computer, and does not create any files. Check your Processing script. As mentioned by Peter, be sure you closing file after storing anything into it.

@LookAlterno my question was how to write arduino data to text file using Processing

Processing questions are off-topic.

I'm voting to close this question as off-topic because it is about Processing and not about Arduino.  While similar in heritage, writing files on the development machine with Processing is not an Arduino question.

createWriter description says:

"For the file to be made correctly, it should be flushed and must be
  closed with its flush() and close() methods"

Source: https://processing.org/reference/createWriter_.html
This question is not about Arduino, but Processing language.


text:
With the press of a button, I need to play an intro sound file, then one of 50 other sounds in order, each time a button is pressed
I need to play an intro file and one of 50 different files after it in order each time the switch is pressed, with a short delay between the intro and next file.
For example let's say the intro is called "intro.wav," and each of the 50 other sound files are just named 01.wav-50.wav.
The logic would be:
TRIGGER
PLAY intro.wav
250ms DELAY
PLAY 01.wav
END

TRIGGER
PLAY intro.wav
250ms DELAY
PLAY 02.wav
END

TRIGGER
PLAY intro.wav
250ms DELAY
PLAY 03.wav
END

and so on, until all 50 files are played, then start over.
The messages are going to be a curated group of words. I'm not sure what the intro will be yet, but it will just be something like:
intro.wav = "The word of the day is"
01.wav = "help"
02.wav = "climb"
03.wav = "think"
I'm looking for some guidance on where to start with this, if an Arduino product would be suitable, and if so, which one.  I've worked with the Adafruit Audio FX Sound Board before, and that can almost do what I need it to do, but not by itself. It looks like I'll need an Arduino of some kind to accomplish this, so I went ahead ordered an Uno.
I'm not married to the idea of having the intro and word files separate either. If I need to create all 50 files to contain the intro and the word, that would be fine, as long as each one is triggered sequentially.
In that scenario, 01.wav could be "The word of the day is ... help" and the button would basically be the "next track" command.  I don't really have a problem with doing that because I'm all about keeping things simple and I don't think I'd run out of space, but I think it would be less time consuming to just dump all the individual word files onto the card.
The important thing is that the track(s) would play once, then stop, and when the button is pressed again, the next one plays.

That's simple.  Look at any basic Arduino example for how to read your button.  Then you just need an if statement that says if the button is pressed then play a sound.  An array of file names or if they're really sequentially numbered then you can probably create the file names on the fly.  They're just char array strings.  What part of this is holding you up?  You've done a great job of describing what you want to do but not what your problem is.  This isn't a free code writing service.  If you were hoping someone would just tell you what to do next you're in the wrong place.

@delta_g Yeesh. Guess I’m just a big dummy and I should give up since this is so simple and I couldn’t figure it out instantly! ¯\(ツ)/¯  This is my first foray into the Arduino world and was kinda hoping someone else had a similar project so as not to reinvent the wheel because yes it does seem like an easy thing to do, and in my 2 hour search I didn’t find any solutions.  I’m sure I’ll figure it out once I have a device I can work with.

Try forum.arduino.cc   That more for the non-specific, just tell me how to do it kind of questions.

@AdamDallas, you are not a dummy, you are a beginner arduino programmer ... try out some of the example sketches that are included with the Arduino IDE ... break your programming task into small pieces ... start with the button ... write code that toggles an LED ... add code that increments a number ... add code that inserts the number into a text string to produce a file name such as "4.wav" ... find code on the internet that plays wav files from the SD card ... pass the file name to that code

You will find all the code and thelibrary you need on the Adafruit learn center.
For such a project I would use a DF-robot (clone) MP3 player (~4$), an Uno, a speaker and an SD card. The library for the player includes examples to get you started and the sound project you plan is possible even with low programming skills. Look at the example codes provided and start to program.

Thanks for the input!  I just saw this, but I happened to order the microSD MP3 player the day I posted the question so I'm glad I'm on the right track. I will be testing as a standalone device today, but it does look like I'll probably need some code.  I was just reading through the sample code from DFRobot and it definitely looks like this is feasible.  Just hoping I can do this with the cheaper Arduino stuff and not have to use a Pi.


text:
how to get file date and time (Timestamp) from a file on sd card with SD.h?
i want to get the date and time (Timestamp) of a specific file on sd card.
How can i do this?
I use the sd.h and can not use any other like SdFat.h

an old version of SdFat is under the hood of the SD library. the wrapper classes don't make the timestamp accessible. you would have to open the file SdFat way and then process it as in ls function in SdFile.cpp


text:
`time()` doesn't reset to 0 when calling `ESP.restart();` on ESP32?
I'm using an ESP32 and it's fine, I have no issues at all.
I was just curious that after flashing a new firmware via OTA, like this:
#include <ESPAsyncWebSrv.h>
#include <Update.h>

void http_page_flash(AsyncWebServerRequest* request) {
    if (!check_auth(request)) {
        return request->requestAuthentication();
    }

    request->send_P(200, "text/html", flash_html, http_page_flash_processor);
}

void http_api_flash(AsyncWebServerRequest* request) {
    if (!check_auth(request)) {
        return request->requestAuthentication();
    }

    ESP.restart();
}

void http_api_flash_part(AsyncWebServerRequest* request, String filename, size_t index, uint8_t* data, size_t len, bool final) {
    if (!check_auth(request)) {
        return request->requestAuthentication();
    }

    if (index == 0) {
        if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { //start with max available size
            Update.printError(Serial);
            request->redirect("/flash?status=error&message=" + String(Update.errorString()));
        }
    }

    if (len) {
        if (Update.write(data, len) != len) {
            Update.printError(Serial);
            request->redirect("/flash?status=error&message=" + String(Update.errorString()));
        }
    }

    if (final) {
        if (Update.end(true)) { //true to set the size to the current progress
            request->redirect("/flash?status=success");
        }
        else {
            Update.printError(Serial);
            request->redirect("/flash?status=error&message=" + String(Update.errorString()));
        }
    }
}

time() result doesn't seem to re-set to 0.
When accessing newly submitted entries which are time-based, they are timestamped as if the board never reset to 0, but all my entries are reset to 0 (so the memory is being reset):
void device_data::push(int co2_ppm, float rh, float temp_c, int sensor_status, unsigned long sequence_number) {
    unsigned long now = (unsigned long)time(NULL);

    current_ventilation_state_co2 = determine_current_ventilation_state(current_ventilation_state_co2, co2_ppm, global_config_data.co2_ppm_low, global_config_data.co2_ppm_medium, global_config_data.co2_ppm_high);
    current_ventilation_state_rh = determine_current_ventilation_state(current_ventilation_state_rh, rh, global_config_data.rh_low, global_config_data.rh_medium, global_config_data.rh_high);

    latest_measurement.relative_time = now;
    latest_measurement.set_co2(co2_ppm);
    latest_measurement.set_rh(rh);
    latest_measurement.set_temp(temp_c);
    latest_measurement.sensor_status = sensor_status;
    latest_measurement.sequence_number = sequence_number;
    latest_measurement.state_at_this_time = get_highest_ventilation_state(current_ventilation_state_co2, current_ventilation_state_rh);

    very_short_data.pushOverwrite(latest_measurement);
    // ...
}

The data is completely reset as the ring buffer is back to being size=0, but now is not close to 0, it's just increased as if it completely survived the ESP.restart() call.
I'm just curious, is this by design? Is this a bug?
Is time() somehow saved to flash? Or to some special restart-persistent memory?
I use the flash to store my configuration, but I never store or restore the time in any of my configuration.
If it's some special static ram which is not flash storage, can I also access this for my own purposes?

esp32 has RTC peripheral


text:
Arduino Serial Monitor displaying weird characters and changes spelling

I am recieving the following in my serial monitor. There is a mix of wierd characters then the spelling changes for words once it gets repeated. I don't know why its doing this. my esp01 chip uses 115200 baud rate and the program is 115200 baud rate as well. What is going on.
#include <SoftwareSerial.h>

#define TIMEOUT 5000 // mS
#define LED 5

SoftwareSerial mySerial(7, 6); // RX, TX

const int button = 11;
int button_state = 0;

void setup()
{
  pinMode(LED, OUTPUT);
  pinMode(button, INPUT);

  Serial.begin(115200);
  mySerial.begin(115200);

  SendCommand("AT+RST", "Ready");

  delay(5000);

  SendCommand("AT+CWMODE=3", "OK");
  SendCommand("AT+CIFSR", "OK");
  SendCommand("AT+CIPMUX=1", "OK");
  SendCommand("AT+CIPSERVER=1,80", "OK");
}

void loop() {
  button_state = digitalRead(button);
  mySerial.println(button_state);

  if (button_state == HIGH) {
    SendCommand("AT+CIPSEND=0,23", "OK");

    delay(250);

    mySerial.println("
Button was pressed!
");

    delay(250);

    SendCommand("AT+CIPCLOSE=0", "OK");
  }

  String IncomingString = "";
  boolean StringReady = false;

  while (mySerial.available()) {
    IncomingString = mySerial.readString();
    StringReady = true;
  }

  if (StringReady) {
    Serial.println("Received String: " + IncomingString);

    if (IncomingString.indexOf("LED=ON") != -1) {
      digitalWrite(LED, HIGH);
    }

    if (IncomingString.indexOf("LED=OFF") != -1) {
      digitalWrite(LED, LOW);
    }
  }
}

boolean SendCommand(String cmd, String ack) {
  mySerial.println(cmd); // Send "AT+" command to module

  if (!echoFind(ack)) // timed out waiting for ack string
    return true; // ack blank or ack found
}

boolean echoFind(String keyword) {
  byte current_char = 0;
  byte keyword_length = keyword.length();
  long deadline = millis() + TIMEOUT;

  while (millis() < deadline) {
    if (mySerial.available()) {
      char ch = mySerial.read();
      Serial.write(ch);

      if (ch == keyword[current_char])
        if (++current_char == keyword_length) {
          Serial.println();
          return true;
        }
    }
  }

  return false; // Timed out
}

SoftwareSerial doesn't work reliably at 115200 baud. use 9600 baud. do not forget to change the baud rate at AT firmware side

Try adding:
void setup()
{
  pinMode(LED, OUTPUT);
  pinMode(button, INPUT);

  Serial.begin(115200);
  while(!Serial){}       // Loop until USB is ready

  mySerial.begin(115200);

It will unblock once the USB port is ready.

Your code for the most part looks ok. Your symptoms indicate a Baud mismatch or the receiver is not getting all of the bits. Try doing without the delay's, even reducing them may help. Note when in a delay the processor is committed and cannot do anything else.  See if that helps. 115000 baud is quit hot for the Arduino and software serial. Maybe you can slow things down a little and see if that helps.


text:
is using two UARTs wiser compared to I2C and UART with Arduino + Xbee + BNO055 Sensor
Hardware

Arduino Nano
XBee Pro S1 (802.15.4) Modules
Adafruit BNO055 Absolute Orientation Sensor

Purpose
I want to send the Euler angles and Linear Acceleration angles to the a central XBee Coordinator (can be connected to a Computer or a Single Board Computer) every 100 ms
Since the BNO055 has SDA and SCL pins for I2C how will the performance of the Nano matter when sensor data is acquired from the BNO sensor and send to XBee module which will be connected to the Hardware Serial UART Port?
An interesting observation was that if one:

Shorts the PS1 pin to 3.3V for the BNO055, the SDA and SCL will function as RX and TX pins for UART.
  source

In terms of interfacing, I can think of the Xbee now connected to the Hardware Serial Port and perhaps the BNO sensor will can be connected to the Nano via SoftwareSerial port. But will that serve any better purpose in terms of performance and data acquisition i.e. using two Asynchronous Serial Ports compared to one?

All software serial solutions are much less efficient than HardwareSerial (i.e., Serial).  SoftwareSerial is particularly bad, because it disables interrupts for long periods of time.  95% of the MCU time can be spent twiddling its thumbs, waiting for each bit to come in.
Using the I2C interface for the BNO055 means that the Arduino hardware will independently and concurrently handle each byte of data from the BNO055 and from Serial (i.e., the XBee).  Your sketch can continue to do other things while each byte arrives.  This is most efficient.
Software serial port libraries handle each bit of data, sometimes to the exclusion of all other activity.

So even though I2C being a synchronous serial protocol and UART being asynchronous; results might tend to be good in status quo than 2 asynch. modes on the Arduino.

@Shan-Desai, the processor load is much less with I2C+UART.  Sync/asynch does not matter, because the peripherals (I2C controller and USART) operate independently from the CPU.  It's like hardware-accelerated graphics vs. software rendering.


text:
No Information obtained when using 2 x SoftwareSerial ports on Arduino Nano
I have a LoRa Click Module and Adafruit Ultimate GPS which both use Serial Communication.
I wish to just check the initial tests with all the components in on the Serial Console. Hence I have declared :

SoftwareSerial GPSSerial(10,11);
SoftwareSerial LoRaSerial(5,6);

Apparently when I declare them and upload the code on the board I do not obtain any information.
observations

However when I comment out the LoRaSerial declaration I obtain the GPS coordinates.
When I set the SoftwareSerial LoRaSerial(10,11) I retrieve the information.
I thought 5,6 pins won't be the right choice and hence went on the set SoftwareSerial(8,9) but I retreive no information.

inference
Nano cannot take into consideration more than 1 SoftwareSerial Component. However the Official Documentation states that all Digital pins can be used for Software Serial.
Is it too much for a Nano to have overall 3 Serial ports (including Serial itself)?
sketch
#include <SoftwareSerial.h>
#include <TheThingsNetwork.h>

SoftwareSerial GPSSerial(10, 11); //RX , TX
SoftwareSerial LoRaSerial(8,9); // RX, TX (tried with 5,6 too)
#define freqPlan TTN_FP_EU868

 TheThingsNetwork ttn(LoRaSerial, Serial, freqPlan);
void setup() {
  Serial.begin(115200);
  GPSSerial.begin(9600);
  LoRaSerial.begin(57600);
}
void loop() {
  delay(2000);
  while (GPSSerial.available()) {
    char c = GPSSerial.read();
    Serial.write(c);
  }
  delay(2000);
  while (LoRaSerial.available()) {
    ttn.showStatus();
  }
  delay(2000);
}

You cannot use two SoftwareSerial instances at the same time - or not for receiving anyway.
SoftwareSerial is a "last resort" system - only to be used if there is absolutely no other option. And then you need to be aware of certain information and rules:

Only one device can listen at any time, switchable using the SoftwareSerial::listen() method
When a byte is being received nothing else can happen - it takes over the entire CPU for the duration of reception
When a byte is being transmitted nothing else can happen - it takes over the entire CPU for the duration of transmission
There is a minimum required time between successive bytes when receiving that causes problems at higher baud rates

These limitations mean that, when using multiple devices, you have to know before hand which device will be sending you data so you can be ready to receive it. It also means that SoftwareSerial is effectively half duplex - it only really works properly when you are either only receiving, only transmitting, or using a "call-response" scenario like sending "AT" commands and looking for a response afterwards.
So the general recommendation is: use hardware UARTs whenever possible (and if you don't have enough, then consider using a different, more suitable, board with multiple UARTs), and if you must use SoftwareSerial then limit yourself to only one instance of it.
As a last resort you can always use multiple boards and connect them using a different system, such as I2C.

Sometimes, with some devices, SoftwareSerial can struggle at higher baud rates, there are quite a few posts on here about it.  Would it be possible to set the LoRaSerial to 9600 too?
Can you try just the LoRaSerial on its own?
Do you have a second device, could you wire the SoftwareSerials on you Nano to two Software Serial ports on your second device and then squirt anything it receives to the hardware serial port (and then to the console).  Then send some test messages from the Nano and see if the device picks them up?
ESP8266 have 2 and a half serial ports (Serial1 is Tx only), but unless you were going to hook the ESP to the Nano via I2C or use the ESP instead of the Nano, that's probably not going to help you in the case.


text:
Two floating point values do not get added and printed on ESP-WROOM-32
I have a Olimex ESP32-PoE board which has a ESP-WROOM-32.
I just found out a strange behaviour for printing floating point numbers on the board.
Sketch
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  float a=34567891.234;
  float b=2.3456;
  a++;
  Serial.print(a+b, 4);
  Serial.println("");
  delay(1000);
}

the sketch is extremely simple where I want to add two floating point numbers, one a big and another small to print their addition result upto 4 places.
Output
on the serial console in the Arduino IDE
34567896.0000
34567896.0000
34567896.0000
34567896.0000
34567896.0000
34567896.0000
34567896.0000
34567896.0000
34567896.0000
34567896.0000
34567896.0000
34567896.0000
34567896.0000

Everytime I increment the float a using a++ i expect it to increment by one and print the result but the output above is completely off.
Without Increment
void loop() {
  // put your main code here, to run repeatedly:
  float a=34567891.234;
  float b=2.3456;
  Serial.print(a+b, 4);
  Serial.println("");
  delay(1000);

}

output
34567896.0000
34567896.0000
34567896.0000

Same output.
Is this Board specific or is the Serial.print not supporting float?

Try doubles.  34567891.234 needs 35 bits of precision to keep the decimals, but floats only have 23.

There is a similar question, but that confuses me even more: https://stackoverflow.com/questions/8561393/is-using-increment-operator-on-floats-bad-style

As already stated in comments and Dave X's answer, floats have a limited
resolution. That resolution is given by the constant FLT_EPSILON,
which is the difference between 1 and the smallest float larger than 1.
On any system conformant to IEEE 754, FLT_EPSILON is 2−23,
or about 1.19e-7. The implication is that, within the interval
[1, 2], the real numbers that can be exactly represented by floats
are the multiples of FLT_EPSILON. The resolution, however, degrades as
you consider larger numbers. Within the interval [2, 4] it is twice
as coarse. Within [4, 8], it's four times as coarse and so on:
interval     resolution
------------------------------------------
1    – 2     2^-23 ≈ 1.19e-7 (FLT_EPSILON)
2    – 4     2^-22
...
2^23 – 2^24  1
2^24 – 2^25  2
2^25 – 2^26  4
...

Your number a is just slightly larger than 225. Within this
range, the numerical resolution (aka “ulp”: unit in the last place)
is 4 (last line in the table above). Thus floats in this range can
only represent exact multiples of 4. When you write
double a=34567891.234;

the compiler replaces this by the closest float, which happens to be
34567892. Same thing for b, but in this case the rounding error is tiny
and inconsequential (about -1.1e-7). When you write
a++;

you are replacing a with the float that is closest to a+1, which
happens to be a itself. So the instruction has no effect. When yo do
Serial.print(a+b, 4);

you are computing the float closest to 34567892+2.3456, which is
34567896.
A double instead has a resolution DBL_EPSILON which is
2−52, or about 2.22e-16. This gives you some precision
margin, but be aware that AVR-based Arduinos do not really support
doubles and treat the double keyword as a synonym for float. This
may only be an issue if you ever have to move your code to a more
traditional Arduino.

I didn't know about the AVR double-float synonym.  thanks.

Try doubles instead of floats.
Your initial value, 34567891.234 needs 35 bits of precision to keep track of the decimals, but floats only have 24 bits pf precision. So to have enough precision to keep track of the difference between 34567891.234 and 34567891.234+1, you need higher precision storage.
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  double a=34567891.234;
  double b=2.3456;
  a++;
  Serial.print(a+b, 4);
  Serial.println("");
  delay(1000);
}


text:
Connecting ESP8266 to Arduino Uno
I want to get data from ESP to my Arduino. I added firmware v2 to my ESP and it works correctly in my serial USB to TTL and shows the JSON data that I send to it.
But when I connect to my Uno serial it shows some unknown chars.
#include <SoftwareSerial.h> //Including the software serial library
#define DEBUG true
SoftwareSerial esp8266(2, 3); // This will make the Arduino pin 2 as the RX pin and Arduino pin 3 as the TX. Software UART
/* So you have to connect the TX of the esp8266 to the pin 2 of the Arduino and the TX of the esp8266 to the pin 3 of the Arduino. This means that you need to connect the TX line from the esp to the Arduino's pin 2 */

void setup() {
  Serial.begin(115200); // Setting the baudrate to 9600
  esp8266.begin(115200); // Set it according to your esp’s baudrate. Different esp’s have different baud rates.
  pinMode(11, OUTPUT); // Setting the pin 11 as the output pin.
  digitalWrite(11, LOW); // Making it low.
  pinMode(12, OUTPUT); // Setting the pin 12 as the output pin..
  digitalWrite(12, LOW); // Making pin 12 low.
  pinMode(13, OUTPUT); // Setting the pin 13 as the output pin.
  digitalWrite(13, LOW); // Making pin 13 low.
  sendData("AT+RST\r\n", 2000, DEBUG); //This command will reset module to default
  sendData("AT+CWMODE=2\r\n", 1000, DEBUG); // This will configure the mode as access point
  sendData("AT+CIFSR\r\n", 1000, DEBUG); // This will get ip address and will show it
  sendData("AT+CIPMUX=1\r\n", 1000, DEBUG); // This will configure the ESP8266 for multiple connections
  sendData("AT+CIPSERVER=1,80\r\n", 1000, DEBUG); // This will set the server on port 80
}

void loop() {
  if (esp8266.available()) {
    // Checking that whether the esp8266 is sending a message or not (Software UART Data)
    while (esp8266.available()) {
      // Checking whether ESP8266 has received the data or not
      char c = esp8266.read(); // Read the next character.
      Serial.print(c);
      // Storing the response from the ESP8266
    }
  }
}

String sendData(String command, const int timeout, boolean debug) {
  // Function to send the data to the esp8266
  String response = "";
  esp8266.print(command); // Send the command to the ESP8266
  long int time = millis();
  while ((time + timeout) > millis()) {
    // ESP8266 will wait for some time for the data to receive
    while (esp8266.available()) {
      // Checking whether ESP8266 has received the data or not
      char c = esp8266.read(); // Read the next character.
      response += c; // Storing the response from the ESP8266
    }
  }
  if (debug) {
    Serial.print(response);
   // Printing the response of the ESP8266 on the serial monitor.
  }
  return response;
}

Prints this for me:
???AR)?WS?TZ?eO?C?AJ+CIFSR
+CIFSR:APHP,"192.168.4.1"
+CIFSQ:APMAC,"62:01:94:22:96:7e"

OK
AZ??R????jC?u?H?AT+CIPSERVDR=1,80

OK
0,CONNECT

+IPD,0,385:POST / HTTP/1.1
cache-control: no-cache
Postman-Token; 45494ff7-b3e1-400f-8afc-fcda26514705
Content,Type: application/jsonUser-Agent: PostmanRunthme/6.1.6
@ccept: */*Host: 192.178.4.1
accept-encoding: gzip, defl`te
content,length: 14Connection: keep-alive
{"name":"`li"}0,CLOSED

My correct JSON is: {"name":"ali"}. But it shows incorrectly. And I set the mt serial library to #define _SS_MAX_RX_BUFF 1024.
How can I fix this?
My connection is:

i used AT+UART_DEF=9600,8,1,0,0 and it works correctly now

Software serial doesn't work reliably at 115200. You need to use a lower baud rate:

Connect the ESP8266 back to your serial USB to TTL setup.
Send the following command to reconfigure the ESP8266 to do AT communication at 9600 baud: AT+UART_DEF=9600,8,1,0,3
Change line 9 of your sketch to esp8266.begin(9600);. This will cause the Uno to communicate with the ESP8266 at 9600 baud.
Upload the revised sketch to your Uno and connect it back up to the ESP8266.

when i use this command AT+UART_DEF=9600,8,1,0,3 and i change to 9600 do not show any thing or command AT no response from esp why this happen

Try connecting arduino's TX and RX pins (0 and 1) with esp8266's RX and TX and see if it works. Upload a blank sketch. Whatever you type in serial box will be sent to esp.
Instead of using voltage divider you should use logic level converters with LM2596.


text:
Unplanned behavior with two power sources
I'm trying to control this servo, and whenever I leave the Uno connected, via USB, to the PC, most of the time the servo barely moves, and sometimes jitters.

simulate this circuit – Schematic created using CircuitLab
I connected the oscilloscope to try to understand / solve my problem, and I see that the signal I send is the same whether or not the USB is connected. I measured the voltage over the 5V/GND and it's constant at 5V and doesn't dip/spikes. I tried with a pull-down resistor on the signal pin (don't know if it's a good idea) and it doesn't change anything.
If I unplug the battery, but keep the USB connected, the servo stays immobile, but I figure that's because the Arduino can't feed a servo, hence why I wanted to use an external power for it. The second power source is a PowerBoost 1000C with a LiPo battery.
As soon as I unplug the USB port, the servo just starts moving properly, so I figured it must be interference of some kind. I saw the accepted answer to this question and it has me doubt whether I should use a battery while it's plugged in, but surely there is a way. Would I kind of need to connect the GND of my circuit to the GND wire of the USB before it actually enters the Arduino?
I didn't post the code as it's basically just the swipe demo from the website, and because it works when on battery only.
Regards

Beginner error: As stated in the diagram, I connected the external source of power to the 5V pin, while it should have been connected to the Vin pin. /ashame

If that solved your issue please mark it as accepted.

I can't for the next 2 days. Should I just delete the question, since the likeliness of it helping anyone is slim?


text:
Find vehicle movement by IMU and GPS
I'm using MPU9250 which has both accelerometer and gyroscope in a vehicle. What I want is to just know that if the vehicle is currently moving or not. I searched and find out that I can't get velocity easily so I skipped that but I was wondering how can I found movement with an IMU.
Edit:
As @Duncan said, it seems that it cannot be examined with only IMU. I also have a GPS sensor in my device and having the speed value from GPS but it is not very accurate. For example, if the vehicle is stopped for 5 minutes I get variable speeds between 0 to 10.0 kmph and on the other hand getting the location as lat/long has about 20 meters error. So I can't really rely on it. I was wondering can I combine both GPS and IMU to find out if it is really moving or not?
One solution that I came was relying on GPS speed but for spikes just check the accelerometer variations and if it is beyond a threshold, it means that it actually moved.

You can't measure velocity with an accelerometer and gyroscope.There is no way to tell if you are sitting still or traveling on a smooth road at 200kph when you start taking readings. Vibration is the only thing you can measure, and a parked car with a rough idle might show more vibration than a smoothly running car traveling at 100kph. There is really no way to tell.

@DuncanC Thanks, I've edited the question.

You noted that your goal is to determine whether or not a vehicle is in motion. Because you are trying an IMU, I assume the device that needs to know this is on-board the vehicle.
There are many complicated ways to know this, such as using the acceleration data from the IMU to perform Inertial Dead Reckoning, this has the problem of temporal drift. A GPS has the issue of needing it's speed data to be filtered a bit to get rid of high-speed spikes.
But -- if you just need to know if the vehicle is moving or not, and if the vehicle has wheels, you can use an light detector, such as an IR emitter and IR receiver pair, along with a slitted disc attached to the wheel, and simply count when the last time the receiver was activated -- if beyond some threshold of time, then you assume the wheel is not turning, and thus that the vehicle is not moving. Or perhaps just use a light sensor and paint white and dark patterns on the wheel.
Or put a magnet on the wheel and place a hall effect sensor (magnet sensor) near where the magnet will pass. Count the pulses from the hall effect sensor.
If the vehicle is not a wheel-based vehicle, then you may have to rely on GPS or some other method, however.

Unless you know for certain that the vehicle is stationary when recording begins, you don't have a frame of reference for Inertial Dead Reckoning. You can't know if the vehicle is stationary or traveling at 100kph, as I mentioned in my comment. Also, with typical low cost accelerometer and gyroscope units, measurements are not accurate enough, and drift quickly swamps actual velocity calculations.

Indeed -- which is why my answer steered away from that and toward something more concrete.

You are right but, I can't add sensors. I don't need accurate accuracy and I need to solve this problem with only IMU and GPS.


text:
ESP-12 + FTDi + platformio
I have 2 questions.

Why we have to put our functions before void loop and void setup into VScode+platformio?
I switched from arduino IDE to VScode+platformio today, when I upload the sketch with platformio into my esp-12, it doesn't work. (It works with arduino IDE)

I have this Warning: src\main.cpp:46:24: warning: large integer implicitly truncated to unsigned type [-Woverflow]
 const byte menuColor = 0XF206;
[EDIT]The problem comes from these lines:
attachInterrupt(digitalPinToInterrupt(enA), enAin, RISING);
attachInterrupt(digitalPinToInterrupt(enB), enBin, RISING);
attachInterrupt(digitalPinToInterrupt(enBtn), enBtnIn, FALLING);

read [Functions in C++](For question 1, read Function in C++ for better understanding on function declaration. For question 2, 0xF206 is 16-bit long, or 2 bytes, so you should declare your variable as use const unsigned int menuColor = 0xF206;, and read more here.

"when I upload the sketch"   .... that should say when I compile the sketch .... the upload happens after your sketch is successfully compiled .... in your case, the upload to the ESP-12 never happens

Why we have to put our functions before void loop and void setup into VScode+platformio?

Because that is how C works. The Arduino IDE hides it from you by adding function prototypes at the start of your code.

I switched from arduino IDE to VScode+platformio today, when I upload the sketch with platformio into my esp-12, it doesn't work. (It works with arduino IDE)

const byte menuColor = 0XF206;

That can never work. The value 0x06 will be assigned to menuColor since a byte is only 8 bits.  You need to learn to use data types that are suitable for the values you are trying to store in them.

Thank, you I understand my error with menuColor. Now I know what's the problem.
#include <Arduino.h>

const int enBtn = 3;

void en(){
    digitalWrite(2,1);
    delay(500);
    digitalWrite(2,0);
    delay(500);
}

void setup() {
  pinMode(2, OUTPUT);
  pinMode(enBtn, INPUT);
  attachInterrupt(digitalPinToInterrupt(enBtn), en, FALLING); //Doesn't work into platformio
}

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  // initialisation RTC16

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

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

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

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

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

void loop()  // Programme en boucle
{

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

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

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

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

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

  else {

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

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

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

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

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

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

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

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

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

    read_teleinfo();
  }
}

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

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

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

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

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

  Wire.endTransmission();
}

MacBookPro 2018 runnning Monterey

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

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

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

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

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

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

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

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

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

Old line reading
New line reading

serial.databits=8
serial.databits=7

serial.parity=N
serial.parity=E

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

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

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

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

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


text:
ESP32 cannot serial monitor
I use esp32 devkit v1 .
I code follwing this picture.

const int vavle = 1;
int d = 1;

void setup()
{
  Serial.begin(115200);
  delay(2000);
  while (!Serial);
  Serial.println();
  pinMode(vavle,OUTPUT);
  Serial.println(d);
}

void loop()
{
  Serial.print("Open Vavle");
  digitalWrite(vavle,HIGH);
  delay(3000);
  digitalWrite(vavle,LOW);
  delay(1000);
  Serial.print("Close Vavle");
}

but serial monitor has error when use serial monitor it show me square .
I confirm select true board rate.
you can solve this problem .

first thing to remember when posting here is never post a picture of text unless absolutely necessary ... please copy your code and paste into your question ... also copy and paste the entire content of the serial monitor

Side note: You probably want to open or close a valve.

The GPIO1 pin you are trying to use with  const int vavle = 1; ... pinMode(vavle, OUTPUT); is the same pin that carries serial data to the PC.
From the pinout:

Their schematic link is broken, but if you find schematic for pretty much any similar board using this module you'll see GPIO1/U0TXD connected to a serial transceiver chip which is then connected to the USB port.
You need choose some other pin. There are pin guides and official documentation containing the same details that you can use to figure out which GPIO to use.
GPIO numbers 16 through 33 inclusive are all output-capable and seem to have no special requirements, so they make sense to choose from.

Thank you ,I can solve this problem


text:
ESP32 AsyncWebServer SPIFFS problem loading page
I can load spiff docs, but I get a 404.  Wireless works, IP addressing works and I can load other examples successfully.  This simple image load ino is giving me fits!
#include <WiFi.h>
#include <AsyncTCP.h>
#include <SPIFFS.h>
#include <ESPAsyncWebServer.h>
const char *ssid = "x";
const char *password =  "123456789";
IPAddress staticIP(10,0,0,1); //ESP static ip
IPAddress gateway(0,0,0,0);   //IP Address of your WiFi Router (Gateway)
IPAddress subnet(255, 255, 255, 0);  //Subnet mask

AsyncWebServer server(80);

void setup() {
  Serial.begin(115200);
  WiFi.softAP(ssid, password);

server.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
{request->send(SPIFFS, "/index.htm", "text/html");});

server.on("/image.png", HTTP_GET, [](AsyncWebServerRequest *request)
{request->send(SPIFFS, "/image.png", "image/png");});

server.begin();

}//END setup

void loop()
{
}

<!DOCTYPE HTML>
<html>
<head>
     <meta charset='UTF-8'>
</head>
<body>
     <img src="image.png" alt=" image goes here">
</body>
</html>

I don't have an ESP32 to test with.  Though, I tried to make your code run on an ESP8266, but it's a bit of an effort to validate what is ultimately a wild guess on my part.
And that is: perhaps you have some uppercase letters in your filename such that "/image.png" does not match perfectly and furthermore maybe SPIFFS is case sensitive.  That is, your file could be named Image.png or IMAGE.png and that might matter.
UPDATE:
In my exploring this on the ESP8266, I'd forgotten to execute SPIFFS.begin().  And I see no counterpart to it in your code.
At least one example of ESPAsyncWebServer I've seen does call SPIFFS.begin()
I found that the filenames are case sensitive, again at least on the ESP8266; so that can be a source of problems.
Also checked that if the SPIFFS size is changed through menu selections, I did indeed need to reupload the SPIFFS image.
I know these are different systems; in fact the code I'm using to test doesn't compile for ESP32, but I suspect a lot of the code is shared, and so maybe the problems are as well.

This is it!  Thanks for taking the time.


text:
OLED 128x64 make text bigger
I have a sketch that prints out a value from 0 to 100.  I want it to take up the whole screen.
I can't figure out how to make the font bigger I think that the part of the code defines the size of the font is :
    oled.setFont(System5x7)

But if I alter the value 5x7 it just spits out errors messages.
This is all the code:
#include "SSD1306Ascii.h"
#include "SSD1306AsciiAvrI2c.h"
SSD1306AsciiAvrI2c oled;
#define I2C_ADDRESS 0x3C

int TankValue0;
int TankValue1;

void setup() {
  Serial.begin(9600);
  oled.begin(&Adafruit128x64, I2C_ADDRESS);
  oled.setFont(System5x7);
  oled.clear();
}

void loop() {
  int sensorTankValue0 = analogRead(A0);
  int sensorTankValue1 = analogRead(A1);
  TankValue0 = map(sensorTankValue0, 300, 785, 100, 0);
  TankValue1 = map(sensorTankValue1, 300, 785, 000, 0);
  if (TankValue0 < 0) {
    TankValue0 = 0;
  }
  if (TankValue1 < 0) {
    TankValue1 = 0;
  }
  if (TankValue0 > 100) {
    TankValue0 = 100;
  }
  if (TankValue1 > 100) {
    TankValue1 = 100;
  }
  oled.print(TankValue0);
  oled.print(" L");
  oled.println(" ");
  //oled.print("T1=");
 // oled.print(TankValue1);
 // oled.println(" ");
  oled.setCursor(0, 0);
  delay(1000);
}

You can't just choose arbitrary numbers. "System5x7" is the name of a font. You have to look in the library you're using to see what other fonts are available and choose one accordingly.

spits out errors messages ... what error messages? ...  why do you believe that error messages are useless for determining the source of the problem?

As pointed out above "System5x7" is The name of a font that is being used.  In this case the 5 and 7 do refer to how many dots are used to make up the output text, but it is just the name of the font it is drawing upon who's code is inside the library-- is this case:
"library->SSD1306Ascii->src->fonts"
In this folder are many fonts to chose from that one can substitute for "System5x7" for example "fixed_bold10x15".  I have not found one that fill the whole screen.  Presumably 64x64 would get me both digits.  I have explored the font file, but it is beyond me to create one from scratch.