Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using HardwareSerial #26

Open
ntdgo opened this issue Oct 6, 2018 · 2 comments
Open

Using HardwareSerial #26

ntdgo opened this issue Oct 6, 2018 · 2 comments

Comments

@ntdgo
Copy link

ntdgo commented Oct 6, 2018

SIM800L module and it run perfectly fine with SoftwareSerial. I need to expand I/O so I need to use HardwareSerial. Please teach me how to use HardwareSerial for this module.
Thank you so much.

@sgamoct
Copy link

sgamoct commented Jan 6, 2020

I have same problem, any news to change from SoftwSerial to HardwareSerial?

@stefanooliveira
Copy link

I made it work with HardwareSerial with ESP32 NodeMCU. Here is how:

1) You need to change Sim800l.h defines first, like that:

#define RX_PIN 16 // This goes to your RX on UART 2 port, acordding to your hardware (ESP in my case)
#define TX_PIN 17 // This goes to your TX on UART 2 port, acordding to your hardware (ESP in my case)
#define BAUD_RATE 9600

2) Now you need to change Sim800l.cpp global variable SoftwareSerial to HardwareSerial:

 /* This goes in your global scope. Remember, we initialize with HardwareSerial object(2) because we are using UART 2 with pins RX2(GPIO 16) and TX2 (GPIO 17)*/
HardwareSerial SIM(2);

3) Modify Sim800l begin method in Sim900l.cpp:

void Sim800l::begin(){
	SIM.begin(BAUD_RATE, SERIAL_8N1, RX_PIN, TX_PIN, false);
      Serial.begin(9600);
  #if (LED) 
    pinMode(OUTPUT,LED_PIN);
  #endif
  _buffer.reserve(255); //reserve memory to prevent intern fragmention
}

4) In your main.cpp, just use it like usual, e.g:

Sim800l mySIM;
String text = "Testing library";
String number = "+999999999999";

void setup(){
	mySIM.begin(); // initializate the library.
      Serial.begin(9600);
	// error = mySIM.sendSms(number,text);
      mySIM.signalQuality();
}

Hope it helps! Best regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants