Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- //Create software serial object to communicate with SIM800L
- SoftwareSerial mySerial(10, 11); //SIM800L Tx & Rx is connected to Arduino #3 & #2
- void setup()
- {
- //Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
- Serial.begin(9600);
- //Begin serial communication with Arduino and SIM800L
- mySerial.begin(9600);
- Serial.println("Initializing...");
- delay(1000);
- mySerial.println("AT"); //Once the handshake test is successful, it will back to OK
- updateSerial();
- mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
- updateSerial();
- mySerial.println("AT+CNMI=1,2,0,0,0"); // Decides how newly arrived SMS messages should be handled
- updateSerial();
- }
- void loop()
- {
- updateSerial();
- }
- void updateSerial()
- {
- delay(500);
- while (Serial.available())
- {
- mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
- }
- while(mySerial.available())
- {
- Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement