Giter Site home page Giter Site logo

thehapyone / barebonesim800 Goto Github PK

View Code? Open in Web Editor NEW
47.0 10.0 18.0 64 KB

A BareBone Arduino Library For SIM800 Modules

License: GNU General Public License v3.0

C++ 66.85% C 33.15%
arduino sim800 gsm gsm-modem sim800library iot arduino-library sim800l

barebonesim800's Introduction

A BareBone SIM800l Library Module for Arduino

The Purpose of This library is to use the SIM800 module providing core functionalities while still maintaining strong performance and being memory efficient.

If you like BareBoneSim800 - give it a star, or fork it and contribute!

This Library uses the AltSoftSerial Library instead of the SoftSerial Library to allow for compatibility with other PinChange Interrupts Library and SPI Libraries

Applications and Features

  • Send SMS, Read SMS and Delete SMS
  • AT Command Test
  • Send and Receive HTTP data
  • TCP Connection
  • IoT Applications
  • Low power saving mode
  • Location and Time Update

Getting Started

Please kindly follow the examples in the example folder.

To download and Install

Go to Release and click the " Source Code (zip) " button to download the latest release, then rename the uncompressed folder to BareBoneSim800. Check that the BareBoneSim800 folder contains BareBoneSim800.cpp and BareBoneSim800.h and copy the folder into the Arduino Library directory in your documents folder. i.e Place the BareBoneSim800 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE and you are good to go.

OR

Go to arduino IDE Sketch >> Import Library >> add library... Select the folder BareBoneSim800

connections & pinouts

 PINOUT: 
     _____________________________
    |  ARDUINO UNO >>>   SIM800L  |
     -----------------------------
         GND      >>>   GND
     RX  8       >>>   TX    
     TX  9       >>>   RX
	 
  |  ARDUINO MEGA >>>   SIM800L  |
    -----------------------------
        GND      >>>   GND
    RX  48       >>>   TX    
    TX  46       >>>   RX
   
              
POWER SOURCE (3.8V - 4.2V) >>> VCC

You can regulate the voltage to the desired voltage by using a diode to step down th Arduino 5V to 4.2v or just use a Lipo battery

Methods and functions

Name Return Notes
begin() None Initialize the library
isAttached() true or false Checks if the GSM Module is attached or not.
flushSerial(timeout) None Flush out any unwanted data coming from the GSM Module.
setFullMode() true or false Activates the device to full functionality.
enterSleepMode() true or false Puts the GSM module into a power saving and sleep mode.
disableSleep() true or false Disable sleep for the device and wakes it up, gives error if device not in sleep before.
sendSms(number,text) true or false Sends sms.
readSms(index) String index is the position of the sms in the prefered memory storage
dellAllSMS() true or false Deletes all message in the SIM800 module.
getTime() String Gets time of the network in GMT+0
getLocation() String Gets approximate location of device
readSIMNumber() String Gets sim number stored on sim. Returns empty if sim number not found.
checkNewSMS() true or false Checks if a SMS has arrived. Needs to be call for sms index update
previousMessageIndex() Int Variable for holding the last stored sms index
currentMessageIndex() Int Variable for holding the latest sms index
getBattPercent() Byte Battery percentage
gorsConnect() true or false Connects to APN network
gprsDisconnect() true or false Disconnects from Gprs network
sendHTTPData(data) String Make an HTTP Request
closeHTTP() None Close connection

Thanks!

Thank you for downloading and enjoying the BareBoneSim800 library. I hope you find it useful. Heck, I wrote it for you- yeah, that's right- you.

This Library was inspired from the SIM800 Library from Cristainsteib(https://cristiansteib.github.io/Sim800l) and the Powerful TingGSMLibrary by Volodymyr Shymanskyy. Special Thanks to Paul Stoffregen that created the AltSoftSerial (http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html) Library, it's library was the backbone of this Library communication

Contributing to this software is warmly welcomed

License

This project is released under The GNU Lesser General Public License (LGPL-3.0)

barebonesim800's People

Contributors

marabesi avatar per1234 avatar thehapyone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

barebonesim800's Issues

http GET don't work after sleep

Im scratching my head for few days with this one. When i do GET request it works but when I put module to sleep and then do request it doesn't.

Here is my code:

#include <BareBoneSim800.h>

BareBoneSim800 sim800("internet.bob.si");  //to declare the library with an APN
const char resource[] = "m2msupport.net/m2msupport/test.php";

 const int port = 80;

void setup() {
  Serial.begin(9600);
  sim800.begin();
  while(!Serial);

  Serial.println("Testing GSM module For GPRS Connectivity");
  delay(8000); // this delay is necessary, it helps the device to be ready and connect to a network

  Serial.println("Should be ready by now");
    bool deviceAttached = sim800.isAttached();
  if (deviceAttached)
    Serial.println("Device is Attached");
  else
    Serial.println("Not Attached");

}

void loop() {
  sim800.disableSleep();
  sim800.setFullMode();

// Connecting the the GPRS APN Network
 Serial.println(" Connecting to APN");
 bool netConnect = sim800.gprsConnect();
 if(netConnect)
  Serial.println("Connected to Network");
 else
  Serial.println("An Error Occured");

  if(netConnect)
  {    
    Serial.println("Making HTTP Get Request");
    String result = sim800.sendHTTPData(resource);
    Serial.println("Received Info: ");
    Serial.println(result);
  
  }
    
    sim800.closeHTTP(); // disconnect from server
    sim800.gprsDisconnect();

    bool sleepActivated = sim800.enterSleepMode();    
      if(sleepActivated)
        {    
         Serial.println("zzzzZZZZZZzzzzz"); 
         delay(5000); 
      }
  }  

this is debug for first request

AT+CSCLK=0

OK

AT+CFUN=1

OK

AT+CFUN=1

OK

 Connecting to APN
AT+CIPSHUT

SHUT OK

AT+CGATT=0

OK

AT+SAPBR=0,1

ERROR

AT+SAPBR=3,1,"CONTYPE","GPRS"

OK

AT+SAPBR=3,1,"APN","internet.bob.si"

OK

AT+SAPBR=3,1,"USER",""

OK

AT+SAPBR=3,1,"PWD",""

OK

AT+SAPBR=1,1


OK

AT+CGATT=1

OK

AT+CIPMUX=0

OK

AT+CSTT="internet.bob.si","",""

OK

AT+CIICR

OK

AT+CIFSR

100.65.40.9

Connected to Network
Making HTTP Get Request
AT+HTTPINIT

OK

AT+HTTPPARA="CID",1

OK

AT+HTTPPARA="URL",m2msupport.net/m2msupport/test.php

OK

AT+HTTPACTION=0

OK


+HTTPACTION: 0,200,4

AT+HTTPREAD

+HTTPREAD: 4
test
OK

Received Info: 
AT+HTTPREAD

+HTTPREAD: 4
test
OK

AT+HTTPTERM

OK

AT+CIPSHUT

SHUT OK

AT+CGATT=0

+SAPBR 1: DEACT

OK

AT+SAPBR=0,1

ERROR

AT+CFUN=0

+CPIN: NOT READY

OK

AT+CSCLK=2

OK

zzzzZZZZZZzzzzz

here is the second one

AT+CSCLK=0


OK

AT+CFUN=1


+CPIN: READY

OK


SMS Ready


Call Ready

AT+CFUN=1


OK

 Connecting to APN
AT+CIPSHUT


SHUT OK

AT+CGATT=0


OK

AT+SAPBR=0,1


ERROR

AT+SAPBR=3,1,"CONTYPE","GPRS"


OK

AT+SAPBR=3,1,"APN","internet.bob.si"


OK

AT+SAPBR=3,1,"USER",""


OK

AT+SAPBR=3,1,"PWD",""


OK

AT+SAPBR=1,1



OK

AT+CGATT=1


OK

AT+CIPMUX=0


OK

AT+CSTT="internet.bob.si","",""


OK

AT+CIICR


OK

AT+CIFSR


100.67.23.115

Connected to Network
Making HTTP Get Request
AT+HTTPINIT


OK

AT+HTTPPARA="CID",
Received Info: 

AT+HTTPTERM


OK

AT+CIPSHUT


SHUT 
AT+CFUN=0


+SAPBR

OK

FF


AT+CSCLK=0


OK

AT+CFUN=1


+CPIN:

SMS Ready


Call Ready

Any idea how to fix it ?

How to Modify the TX and RX pin for SoftwareSerial

In my project, I was using a TFT LCD screen shield along with sim800 module, hence not able to use digital pin 8 and 9.
Is there any method to modify this by using barebonesim800.h or AltSoftSerial.h?

including call functions

Hey, can someone please include the call functions. That would help me a lot for my project. Because other lib´s are not that well with sending sms.

HTTPS Get Request doesn't work

Hello,

i try to do a http get request with an https url. In debug mode, i get the following result:

`Testing GSM module For GPRS Connectivity
Should be ready by now
AT

OK

AT+CSCS="GSM"

OK

AT+CMGF=1

OK

AT+CMGL="ALL",0

OK

Device is Attached
Connecting to APN
AT+CIPSHUT

SHUT OK

AT+CGATT=0

OK

AT+SAPBR=0,1

ERROR

AT+SAPBR=3,1,"CONTYPE","GPRS"

OK

AT+SAPBR=3,1,"APN","web.vodafone.de"

OK

AT+SAPBR=3,1,"USER",""

OK

AT+SAPBR=3,1,"PWD",""

OK

AT+SAPBR=1,1

OK

AT+CGATT=1

OK

AT+CIPMUX=0

OK

AT+CSTT="web.vodafone.de","",""

OK

AT+CIICR

OK

AT+CIFSR

100.73.30.57

Connected to Network
Making HTTP Get Request
AT+HTTPINIT

OK

AT+HTTPPARA="CID",1

OK

AT+HTTPPARA="URL",https://webapp.xxxxxxxxxxxxxx/t.php

OK

AT+HTTPACTION=0

OK

+HTTPACTION: 0,603,0

AT+HTTPREAD

OK

Received Info:
AT+HTTPREAD

OK

AT+HTTPTERM

OK

AT+CIPSHUT

SHUT OK

AT+CGATT=0

+SAPBR 1: DEACT

OK

AT+SAPBR=0,1

ERROR
`

What can i do?

[INFO] steps to active APN and data flow

First of all, thank you VERY MUCH for this wonderful lib which I've learned a lot reading the source code.

My question is how did you manage to get the flows? For example, in the following code you had to execute a series of commands to get the locations working:

this->SoftwareSerial::print (F(" AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\" \r\n" ));
    _buffer=_readSerial();  // set bearer parameter
    this->SoftwareSerial::print (F(" AT+SAPBR=3,1,\"APN\",\"internet\" \r\n" ));
    _buffer=_readSerial();  // set apn
    this->SoftwareSerial::print (F(" AT+SAPBR=1,1 \r\n"));
    delay(1200);
    _buffer=_readSerial();			// activate bearer context
    this->SoftwareSerial::print (F(" AT+SAPBR=2,1\r\n "));
    delay(3000);
    _buffer=_readSerial(); 		

First enable the GPRS, second setting the APN and so one, how did you know that?

I've found a PDF where I could understand better all the commands, but not the flows.

I am facing issue with char *mydataIn = strdup(tempData.c_str());

Hello,

I tried the BareBoneSim800 1.25 version library. It seems the line "char *mydataIn = strdup(tempData.c_str());" has the problem which results in NULL value for the *mydataIn pointer and the end result is "Status" value will remain 99.

For example, call to function sim800.isAttached() will always display "Not Attached" even if there was OK response from SIM800 for the "AT\r\n" command.

To use the Hardware Serial

Hello,

it would be nice to have the possibility to use your great library with Hardware Serial in board which have them plenty. Unfortunately it seems to be too "hardwired" to (alt)softserial.

PP

Can't put to sleep after HTTP GET

Hi there. First of all I love the simplicity of this library!

Here is the code that I use

#include <BareBoneSim800.h>
BareBoneSim800 sim800("internet.bob.si", "bob", "internet");  //to declare the library with an APN, UserName and Password
 const char resource[] = "test.com/send.php";
 const int port = 80;

void setup() {
  Serial.begin(9600);
  sim800.begin();
  while(!Serial);
  delay(8000); 
}

void loop() {
 bool fullMode = sim800.setFullMode();
  if(fullMode)
  {  

// Connecting the the GPRS APN Network
 Serial.println(" Connecting to APN");
 bool netConnect = sim800.gprsConnect();

  if(netConnect)
  {    
    Serial.println("Making HTTP Get Request");
    String result = sim800.sendHTTPData(resource);
    Serial.println("Received Info: ");
    Serial.println(result);
 
    sim800.closeHTTP(); // disconnect from server
    bool netDisconnect=sim800.gprsDisconnect();
    sim800.flushSerial(5000);

      bool sleepActivated = sim800.enterSleepMode();
    Serial.println("sleeeeeeeeeep");
    Serial.println(sleepActivated); 
    
      if(sleepActivated)
        {    
         Serial.println("zzzzZZZZZZzzzzz"); 
         delay(30000);   
           bool disableSleep = sim800.disableSleep();

      } 
  }   
  }
}

It works fine up to when is time to put module in sleep mode. Serial print for sleepActivated returns 0 and I cant understand why? If I just connect module to network I can than put it into sleep but not after HTTP request. Any idea why?

dtmf

Detection of DTMF tones - SIM800L module.

I get "OK" when I send 'AT+DDET=1,1000,1,1* ' over uart .
But it doesnt seem to detect anything afterwards.
Perhaps I am doing something wrong.
Would appreciate some feedback.

regards
Atul
ref : *SIM800 Series_AT Command Manual_V1.09

OBSERVATION ON HTTP SEND DATA

Ayo,
Good job.
It took me sleepless nights to understand the SIM800.

However, I have observation in this your BareBone library.
Check line 540 in .cpp file.

Under method sendHttpdata.
AT COMMAND for HTTP POST should ta value 1 not 0 as you indicated.

I maybe wrong anyway.

Secondly, can you give me idea, I wish to develop nonblock library to be used in rtos. But attempt s seem have not yield anything good.

AT Command

Hi, how can i use the AT commands in this library?

Not Attached

I'm getting "Not Attached" error with the example code of Send SMS. This the circuit i'd made:

pir2-03_2048x2048

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.