SIM 900 not able to connect with MEGA 2560

Hello,

Impossible to init modem error message on serial port.
AT command works with AT_debug sketch
I don’t find solution for 2 days…
SIM 900 use to communicate on HW serial

Thanks for your help.


#define BLYNK_PRINT Serial

#define TINY_GSM_MODEM_SIM900

// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30

#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "4f81139201fb4348ba644ea50e49036a";

// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[]  = "orange";
char user[] = "orange";
char pass[] = "orange";

// Hardware Serial on Mega, Leonardo, Micro
#define SerialAT Serial1

// or Software Serial on Uno, Nano
//#include <SoftwareSerial.h>
//SoftwareSerial SerialAT(2, 3); // RX, TX

TinyGsm modem(SerialAT);

void setup()
{
  // Debug console
  Serial.begin(9600);

  delay(10);

  // Set GSM module baud rate
  SerialAT.begin(2400);
  delay(3000);

  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  Serial.println("Initializing modem...");
  modem.restart();
Serial.println("hello");
  // Unlock your SIM card with a PIN
  //modem.simUnlock("1234");

  Blynk.begin(auth, modem, apn, user, pass);
}

void loop()
{
 /Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

image

I’ve never actually used a SIM900 for Blynk, but I have used one for SMS communication with a Mega.

Things to check…

Is the SIM900 set to the same baud rate as your sketch (2400) ?

Is the SIM900 actually powered-up (red LED lit) and is the power supply able to supply enough current?

Are the jumpers on the SIM900 set to hardware serial (usually shipped set to software serial by default) ?

You can also have issues with some SIM cards. I live in the UK and couldn’t get a SIM from “Three” to work, but a GifGaff SIM worked okay.

Hope this helps!

Pete.

Thanks for your answer.

Power source is OK, external, LED red ok, external source can deliver up to 3A
Jumper set on Hardware serial

One question How to set SIM900 baud rate?

thanks for this support!
jerom

Have you found AT comm reference manual for SIM900??

Page 41:

Pete.

Thanks to all, I’ve set to 2400 baud, still the same. I d’ont understand why it’s doesn’t run,…

I succeeded sending SMS, boards works…AT_debug works well also…

But Blynk still not??

right, still same message for 2 days…

I’ve been using Blynk with Sim900, but it was long time ago and many changes were introduced since… Currently have no idea. But one thing: set baudrate at 115200. Works fine with hardware serial

Maybe search for a working non-Blynk test sketch to test your Dora connectivity?

Pete.

thanks try also 115200 baud rate…still bad…

Will let you know how it is working for me. I’m using a simple “serial traffic monitor” (just a two NAND gates connected in series), so in case of issues monitor should pinpoint these :slight_smile:

Ok, I can unfortunately confirm, that current TinyGSM library DOES NOT work for me either. Although I’m further into connection than @gg09 (after little change in library file) I can’t go past CIPSTATUS, which returns:
1, CONNECT OK
so the connection is established.
Unfortunately the library doesn’t see this (or just doesn’t understands the answer) and after few seconds just disconnects :frowning:
. I’m investigating the cause, but my assumption is some unhandled response coming from waitResponse(), but i just started with this… Probably @vshymanskyy adopted library to different modem chipset or firmware version, as old libs were working with SIM900 just fine (although some disconnects appeared)

Yes I integrated few PRs some time ago… unfortunately can’t check with SIM900 (don’t have one).
You could try one of previous versions of TinyGSM lib and report back… I’ll see if i can revert some changes

Sure I will. For now you can just take a look at raw comm dump at this critical part between modem and MCU:

...)
AT+CIPSTART=1,"TCP","blynk.server.com",8442

OK
AT+CIPRXGET=4,1

+CIPRXGET: 4,1,0

OK
AT+CIPSTATUS=1

+CIPSTATUS: 1,0,"TCP","217.99.211.119","8442","CONNECTING"

OK

1, CONNECT OK
AT+CIPCLOSE=1

1, CLOSE OK
AT+CIPSSL=0

ERROR
AT+CIPSTART=1,"TCP","blynk.server.com",8442

OK
AT+CIPRXGET=4,1

+CIPRXGET: 4,1,0

OK
AT+CIPSTATUS=1

+CIPSTATUS: 1,0,"TCP","217.99.211.119","8442","CONNECTING"

OK

1, CONNECT OK
AT+CIPCLOSE=1

1, CLOSE OK
AT+CIPSSL=0

ERROR
AT+CIPSTART=1,"TCP","blynk.server.com",8442

OK
AT+CIPRXGET=4,1

+CIPRXGET: 4,1,0

OK
AT+CIPSTATUS=1

+CIPSTATUS: 1,0,"TCP","217.99.211.119","8442","CONNECTING"

OK

1, CONNECT OK
AT+CIPCLOSE=1

1, CLOSE OK
AT+CIPSSL=0

ERROR
AT+CIPSTART=1,"TCP","blynk.server.com",8442

OK
AT+CIPRXGET=4,1

+CIPRXGET: 4,1,0

OK
AT+CIPSTATUS=1

+CIPSTATUS: 1,0,"TCP","217.99.211.119","8442","CONNECTING"

OK

1, CONNECT OK

the server name is fictious, the IP is a real DDNS… :wink:

1 Like

Ok, @vshymanskyy i can confirm, the 0.2.0 downloaded from github WORKS just fine with SIM900. The latest 0.3.1 included in Blynk package DOES NOT. Time to sleeeep… :weary:

1 Like

thanks for this update, marvin7, may you please send me links on github to find new libraiy?

Google is amazing :stuck_out_tongue_winking_eye: just searching for TinyGSM found this

Go to releases and scroll down to 0.2.0

1 Like