0

hello guys i'm new to this field i really need your help i want to wire a GSM module (SIM808) to a ESP32 board using the TX and RX pins so the pins are labeled RX and TX no pin number like the others how can i declare them in the code. i already tested the code on an arduino uno on pins 0 and 1 (RX and TX) and it works fine here is the board i'm using : i already tried using pins 16 and 17 but didn't work i need to try using pins number 40 and 41 according to image below enter image description here

2
  • "Didn't work" is not very descriptive. Please show your code and how you have connected the module. It may be good to known that the ESP32 has a very flexible serial port configuration and serial I/O can be mapped to most of the GPIO pins.
    – StarCat
    Commented Jul 21, 2023 at 11:06
  • Tx and Rx is used by Serial port for your Serial Monitor. Unlike Arduino Uno, which only has one Serial port, ESP32 has 3. You can use the TxD2 (GPIO17) and RxD2(GPIO16) for connecting to your SIM808 module. You uses the port with Serial2.begin(115200).
    – hcheung
    Commented Jul 22, 2023 at 6:18

1 Answer 1

0

First off, thank you for all the guidance and support you've provided. As a beginner in the world of Arduino and embedded systems, it's been tremendously helpful.

The main issue I was facing had to do with not knowing how to declare the TX and RX pins in my C++ code, especially when these pins weren't labelled with their GPIO numbers like the others on my ESP32 board. After a bit of research and reading through your comments, I learned that these pins can simply be declared using their GPIO numbers, which are indicated on the schematic of the board.

For instance, to utilize RX0 and TX0, they need to be declared as 3 and 1 respectively. Here's an example:

 #define RXD 3  //RXD
    #define TXD 1  //TXD
    
    HardwareSerial SIM808(2);

void setup()
{
  //
  //
   SIM808.begin(9600, SERIAL_8N1, RXD, TXD);
}

I was able to get the SIM808 module working with this method, but I'm noticing that the system isn't always consistent. Sometimes it takes a long time to execute commands, which is something I will have to look into.

I just wanted to express my gratitude for the warm welcome and helpful guidance I've received here. This being my first post, I was worried about asking a "dumb question," but the community has been nothing but supportive.

As I continue to learn and explore more about embedded systems, I'm sure I'll be back with more questions, and hopefully, in time, some answers of my own to contribute!

4
  • this is a very bad advice. You want to use SoftwareSerial on hardware Serial pins? and this hardware Serial is already wired to the USB chip which communicates with the computer. You can use Serial2 on RX2/TX2 pins. Serail2 already exists as an object and is initialized for the pins. (as already mentioned in the comment below the Q)
    – Juraj
    Commented Jul 24, 2023 at 9:31
  • Don't use SoftwareSerial on a device that has enough hardware serial ports to do the job.
    – StarCat
    Commented Jul 24, 2023 at 10:16
  • can you provide more information about SoftwareSerial and HardwareSerial to help me better understand and also i'm running out of pins in my project is there any solution to reduce the number of pins or use the same pins for multiple purposes?
    – Hach Rbh
    Commented Jul 24, 2023 at 10:41
  • Hach Rbh, en.wikipedia.org/wiki/Bit_banging
    – Juraj
    Commented Jul 24, 2023 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.