Skip to content

Implement your own SMS exchange protocol to use on ATmega328P based Arduino boards and AiThinker A6 GSM module.

License

Notifications You must be signed in to change notification settings

alm494/A6TinyLibSms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A6TinyLibSms

Implement your own SMS exchange protocol to use on ATmega328P based Arduino boards and AiThinker A6 GSM module. Primary targets are Uno/Nano boards with 2K RAM so major efforts aimed at the both RAM and PROGMEM consume reducing.

Available options

Look at and edit C++ header file to set up your project to use SoftwareSerial, AltSoftSerial or HardwareSerial to communicate with A6 board. Everything is explained there in details:

#define UART_LIB 0         // <- 'SoftwareSerial' (default)
//#define UART_LIB 1       // <- 'AltSoftSerial' (Rx->8, Tx->9, Unusable->10 on Uno)
//#define UART_LIB 2       // <- 'HardwareSerial' (Rx->0, Tx->1 on Uno)

Also you may define digitalWriteFast usage option and FreeRTOS timing there:

#define digitalWriteFastLib
#define FreeRTOS

A6 module initialization

To initialize A6 board a power cycling method is used: pass the digital output pin number to 'init()' method.
Do not even try to power up your A6 board directly from this output pin! Use any appropriated MOSFET relay instead. Your relay schematic should be designed to open MOSFET with LOW value (GND) and close with HIGH (+5V).
For example, follow this checklist to use a low-side driver (p-channell MOSFET):

  • 'VCC' pin on A6 board should be connected to the +5V power via MOSFET relay;
  • 'PWR_KEY' pin on A6 board should be connected to its 'VCC';
  • 'POWER_PIN' on Arduino should be connected to the MOSFET driving point.
  • Just change 'HIGH' and 'LOW' values in the init() method if you are using different design.

How to use

This example replies with 'Hello!' message to any incoming SMS messages:

#include <Arduino.h>
#include <A6TinyLibSms.h>

#define powerPin 5
#define serialRx 8
#define serialTx 9

// using SoftwareSerial:
A6TinyLibSms A6M(serialRx, serialTx);

// using AltSoftSerial or HardwareSerial:
//A6TinyLibSms A6M;

void setup() {
  A6M.init(powerPin);
  //A6M.init(powerPin, "1234"); // provide SIM PIN if required
}

// You shoud define a callback function here to be fired by incoming SMS:
void onSmsReceived(char *callerId, char *message) {
  char mes[] = "Hello!";
  A6M.sendSMS(callerId, mes);
}

void loop() {
  A6M.checkIncomingSms(&onSmsReceived);
}

Limitations

  • Use ASCII symbols only in your exchange protocol: {31 < char < 128}, no Cyrillic, no Chinese, no unicode!
  • Modem AT-protocol is critical to RX/TX buffer length on connected UART device or software emulation. Examine A6TinyLibSms.h header file and you'll find there some tips how to solve this issue.
  • Please consider using shorter messages in your exchange protocol, this helps you to decrease RAM usage.
  • This project was completely created and tested in PlatformIO IDE. It may throw exceptions if you are compiling it in different development tools like Arduino IDE or Eclipse. Or may not :-)

Other libraries

You may also want to try this library: A6lib by skorokithakis. It is more advanced but uses SoftwareSerial and I couldn't read any SMS messages with it on Nano board due to unknown overflow or limitation.

About

Implement your own SMS exchange protocol to use on ATmega328P based Arduino boards and AiThinker A6 GSM module.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages