Hi!
I am working on a project using Arduino uno and SIM808. I want to send a message with the SIM808 module but I can see that it is not registered on the network. I used library Adafruit_FONA.h. I don't get any errors, but I can not make any action with the GSM module.
I have put the SIM in a phone and it is perfectly working. I don't know what is the problem. Can anyone help please?
Thanks!
Could you provide a schematic, code and more details?
Is the 808 board wired up as in: Wiring to Arduino | Adafruit FONA 808 Cellular + GPS Breakout | Adafruit Learning System
Please paste your code here using appropriate tags,
Andy
#include "Adafruit_FONA.h"
#include "SD.h"
#include "string.h"
// standard pins for the shield, adjust as necessary
#define FONA_RX 8
#define FONA_TX 7
#define FONA_RST 4
// We default to using software serial. If you want to use hardware serial
// (because softserial isnt supported) comment out the following three lines
// and uncomment the HardwareSerial line
#include <SoftwareSerial.h>
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;
// Hardware serial is also possible!
// HardwareSerial *fonaSerial = &Serial1;
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);
File myFile;
char message[160];
char latit[12];
char longit[12];
// Have a FONA 3G? use this object type instead
//Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);
void setup() {
while (! Serial);
Serial.begin(115200);
Serial.println(F("Adafruit FONA 808 & 3G GPS demo"));
Serial.println(F("Initializing FONA... (May take a few seconds)"));
fonaSerial->begin(4800);
if (! fona.begin(*fonaSerial)) {
Serial.println(F("Couldn't find FONA"));
while(1);
}
Serial.println(F("FONA is OK"));
// Try to enable GPRS
Serial.println(F("Enabling GPS..."));
fona.enableGPS(true);
Serial.println(F("Initializare SD card..."));
if(!SD.begin(4))
{
Serial.println("initializare gresita");
return;
}
Serial.println("Initializare reusita");
}
void sendSMS(String message)
{
// AT command to initiate text message
Serial.print(F("AT+CMGF=1\r"));
delay(100);
// AT command to set destination number
Serial.println(F("AT + CMGS = \"+40721071002\""));
delay(100);
// Message body
Serial.println(message);
delay(100);
// Termination character
Serial.println((char)26);
delay(100);
// \n
Serial.println();
}
void loop() {
delay(2000);
float latitude, longitude, speed_kph, heading, speed_mph, altitude;
myFile=SD.open("text.txt", FILE_WRITE);
if(myFile){
// if you ask for an altitude reading, getGPS will return false if there isn't a 3D fix
boolean gps_success = fona.getGPS(&latitude, &longitude, &speed_kph, &heading, &altitude);
if (gps_success) {
// Serial.print("GPS lat:");
// Serial.println(latitude, 6);
// Serial.print("GPS long:");
// Serial.println(longitude, 6);
// Serial.print("GPS speed KPH:");
// Serial.println(speed_kph);
// Serial.print("GPS speed MPH:");
// speed_mph = speed_kph * 0.621371192;
// Serial.println(speed_mph);
// Serial.print("GPS heading:");
// Serial.println(heading);
// Serial.print("GPS altitude:");
// Serial.println(altitude);
myFile.print("GPS lat:");
myFile.println(latitude, 6);
myFile.print("GPS long:");
myFile.println(longitude, 6);
myFile.print("GPS speed KPH:");
myFile.println(speed_kph);
myFile.print("GPS speed MPH:");
speed_mph = speed_kph * 0.621371192;
myFile.println(speed_mph);
myFile.print("GPS heading:");
myFile.println(heading);
myFile.print("GPS altitude:");
myFile.println(altitude);
myFile.close();
dtostrf(latitude, 1, 6, latit);
strcat(message,latit);
strcat(message,"+");
dtostrf(longitude, 1, 6, longit);
strcat(message,longit);
sendSMS(message);
} else {
Serial.println("Waiting for FONA GPS 3D fix...");
}
}
// Fona 3G doesnt have GPRSlocation :/
if ((fona.type() == FONA3G_A) || (fona.type() == FONA3G_E))
return;
// Check for network, then GPRS
Serial.println(F("Checking for Cell network..."));
if (fona.getNetworkStatus() == 1) {
// network & GPRS? Great! Print out the GSM location to compare
boolean gsmloc_success = fona.getGSMLoc(&latitude, &longitude);
if (gsmloc_success) {
Serial.print("GSMLoc lat:");
Serial.println(latitude, 6);
Serial.print("GSMLoc long:");
Serial.println(longitude, 6);
} else {
Serial.println("GSM location failed...");
Serial.println(F("Disabling GPRS"));
fona.enableGPRS(false);
Serial.println(F("Enabling GPRS"));
if (!fona.enableGPRS(true)) {
Serial.println(F("Failed to turn GPRS on"));
}
}
}
}
This is the code I am using.
I have the RX for the SIM on pin 8 and the TX on pin 7
The SIM I am using is this type. Modul 3 IN 1 GSM, GPS și Bluetooth SIM808 cu Antenă - Optimus Digital
And the Arduino board is this Placă de Dezvoltare Compatibilă cu Arduino UNO (ATmega328p și CH340) şi Cablu 50 cm
GPS_ce_pune_in_text.ino (4.03 KB)
I attached here what I can see in serial monitor. What can be the problem?
Thanks in advance!
Typically that error means the sim card is not supported...
You can often find firmware for the SIMXXX chips and re-flash them to support the sim card.
I had the same issue with a SIM900A and had to reflash with 900 firmware to remove the region lock on the sim card.
As a heads up its usually better to write your own code than use templated as it makes troubleshooting far easier when you know what youre intending to do, these libraries arent magic!
Ok, I understand, thank you, but can you help me please with some information on how I can do that? I must do it when it is in a phone or when it is here in the module sim808?