Sim900a modem cannot init


// Select your modem:
//#define TINY_GSM_MODEM_SIM800
#define TINY_GSM_MODEM_SIM900
//#define TINY_GSM_MODEM_M590
//#define TINY_GSM_MODEM_A6
//#define TINY_GSM_MODEM_A7
//#define TINY_GSM_MODEM_BG96
//#define TINY_GSM_MODEM_XBEE

// 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 <BlynkSimpleTinyGSM.h>

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

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

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

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

TinyGsm modem(SerialAT);

int ledPin = 3; 
int inPin = 0;
 
void setup()
{
  // Debug console
  Serial.begin(9600);
  delay(10);

  // Set GSM module baud rate
  SerialAT.begin(115200);
  delay(3000);
   
  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  Serial.println("Initializing modem...");
  Serial.println("Connecting to apn");
  Serial.println("Connecting to blynk-cloud...");

  modem.restart();

  // Unlock your SIM card with a PIN
  modem.simUnlock("1234");

  Blynk.begin(auth, modem, apn, user, pass);
  
  pinMode(13, OUTPUT);
  pinMode(0,INPUT);
}

void loop()
{
  Blynk.run();
  digitalRead(inPin);
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);
  
}```


so the code seems to be but

```Initializing modem...
Connecting to apn
Connecting to blynk-cloud...
[14225] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Uno

[14318] Modem init...
[24552] Cannot init
Initializing modem...
Connecting to apn
Connecting to blynk-cloud...
[14227] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Uno


Initializing modem...
Connecting to apn
Connecting to blynk-cloud...
[14225] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Uno

[14318] Modem init...
[24552] Cannot init
Initializing modem...
Connecting to apn
Connecting to blynk-cloud...
[14227] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Uno

[14320] Modem init...
[24553] Cannot init
Initializing modem...
Connecting to apn
Connecting to blynk-cloud...
[14227] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino```

I connected all, also the shared ground. I hope that you can solve this problem

@Don_Jules please edit your post using the pencil icon at the bottom and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

It also helps to add triple backticks at the beginning and end of your serial output, as this also makes it display correctly.

Pete.

Okay tq sir… So do know how to solve my problems??

You are trying to use the same hardware for the hardware serial port and the software serial port. This won’t work!.

Pete.

8 posts were merged into an existing topic: SIM 900A cannot Connect to Blynk Cloud

Oh i see, so what suggestions you sir…
Btw, I’m a beginner and this is my first time do this stuff …

The UNO has one physical serial port, which is connected to pins 0 and 1, and also to the USB connector via a TTL to serial chip.
This is the port that you are using to upload code, and to view your debug messages in your computers serial monitor.
You cant use this same hardware port for talking to a device like your SIM900 board, as the data meant for the serial debug monitor would get mixed-up with the commands being sent to the SIM900 - a bit like tow phone conversations taking place on the same line at the same time.

So, the solution is to create a simulated serial port using software, and use that for communication with your SIM900. This can use any two pins, provided they aren’t the two pins that are connected to the hardware serial port (0 and 1).

In addition, you have to give your software serial port a name that you can use to refer to in in your code. In this case you are using SerialAT, but, you are defining this twice:

The first of these commands is intended to be used with a Mega, Leonardo or Micro board, which have multiple hardware serial ports. As you are using an UNO you should comment-out this first #define statement.

Also, you have to tell your UNO to talk to the SIM900 at the same speed that the SIM900 wants to talk to the UNO (image a phone conversation again, where two people,ke are talking across each other at different speeds).
You do this with this line of code:

The problem is that the SoftwareSerial library has to simulate this serial port using processor time, and if you try to use a baud rate that is too fast, the slow processor and limited memory of the UNO can’t keep up. This means that it’s not recommended to use baud rates faster than 9600 for the software serial port.
Of course, as I said earlier, the SIM900 and the UNO have to be talking to each other at the same speed, so you’ll need to tell the SIM900 to use the baud rate of 9600 as well.
You’ll need to google how to do this, via an AT command.

Now you know why we don’t use Arduino UNOs!

Pete.