Coder Social home page Coder Social logo

Using HardwareSerial about sim800l HOT 2 OPEN

cristiansteib avatar cristiansteib commented on September 3, 2024
Using HardwareSerial

from sim800l.

Comments (2)

stefanooliveira avatar stefanooliveira commented on September 3, 2024 1

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.

from sim800l.

sgamoct avatar sgamoct commented on September 3, 2024

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

from sim800l.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.