stanleyhuangyc / Freematics

Official source code repository for Freematics
https://freematics.com
418 stars 345 forks source link

SIM800: No support for software serial? #14

Open tcados opened 8 years ago

tcados commented 8 years ago

Hi, Im trying to use the SIM800 library in accordance with your example.

Is there a reason why software serial won't work? I modified the test code as follows and it still doesn't work:

GPRSTest.ino: added:

include

SoftwareSerial SIMSer = SoftwareSerial(2, 3);

SIM800.h // change this to the serial UART which SIM800 is attached to

define SIM_SERIAL SIMSer

when I try to compile I get the following error:

In file included from ... SIM800/SIM800.h: In member function 'bool CGPRS_SIM800::available()': .... SIM800/SIM800.h:14:20: error: 'SIMSer' was not declared in this scope

define SIM_SERIAL SIMSer

                ^

/Users/troycados/Documents/Arduino/libraries/SIM800/SIM800.h:79:14: note: in expansion of macro 'SIM_SERIAL' return SIM_SERIAL.available(); ^

Am I doing anything wrong in particular? or does the library just not support software serial?

Thanks! -T

geologic commented 8 years ago

The same for me, i need to use library with other digital pins than TX/RX UART

qwerty13 commented 8 years ago

The same for me, i have this problem too

rox85 commented 7 years ago

In SIM800.hyou could comment the line number 14 // #define SIM_SERIAL Serial1

In SIM800.cpp you should insert the following lines at the start of the file:

#include <SoftwareSerial.h>
SoftwareSerial SIM_SERIAL(10, 11); // RX, TX

You have also to redefine the "available" function

In .cpp

 bool CGPRS_SIM800::available()
 {
    return SIM_SERIAL.available() > 0;
 }

In .h, delete the commands

bool available()
{
      return SIM_SERIAL.available()>0; 
}

and replace with:

bool available();