"init sim error"

Hi I'm using arduino for a month now, with the arduino uno card.
I'm facing a quite contradictory problem.
When I run my program, it's saying "init sim error" but the D3 LED on my SIM808 is bipping every 3seconds(which means it has established the connection). Kinda weird.. Because I checked on a phone and my SIM is definitely unblocked, this problem pop up but it use to work before with the same SIM and same connections.
Does somebody have a possible answer to this ?

In case, here is my program ( the goal is to give the humidity percentage and temperature when it's asked by sms communication):

#include <SimpleDHT.h>
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>
#include<String.h>

 

#define PHONE_NUMBER "+33*********"

 

//variable analysant temperature espace
#define DHT11_PIN 8
byte temperature = 0;
byte humidity = 0;
char tempHum[5];
 
SimpleDHT11 dht11(DHT11_PIN);
 
#define MESSAGE_LENGTH 160    
char message[MESSAGE_LENGTH];
int messageIndex = 0;   //initialisation de l'index des messages Ă  0 (entier)
char phone[16];
char datetime[24];

 

String msg;     //introduction de la variable msg en tant que chaîne
#define PIN_TX 10   //les branchements nécessaires sur la UNO
#define PIN_RX 11
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);   //pareillement pour la SIM808
//DFRobot_SIM808 sim808(&Serial);

 

void setup() {
  //pinMode(8,INPUT);
  mySerial.begin(9600);
  Serial.begin(9600);
  while(!sim808.init()) {                    //tant que la sim n'est pas initialisee renvoi de "error"
    Serial.print("Sim808 init error\r\n");
    delay(1000);                   //laps de temps pour ne pas que le programme s'emballe trop vite
  }
  Serial.println("Init Success, please send me an SMS");    //si initialisation effective renvoie de l'info
  sim808.sendSMS(PHONE_NUMBER,"initialisation reussie");
}

 

void loop() {
  int x;
//detecting unread sms command
  messageIndex = sim808.isSMSunread();          //affiche le nbr de messages s'il y en a un non lu, sinon affiche 0
  Serial.println("En attente de SMS");
  //Serial.println(messageIndex);
//si commande reçue
   if (messageIndex > 0) {                       //si index != 0 (index forcement positif)
    sim808.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);   //envoi des infos du SMS sur le moniteur série
    Serial.println(datetime);
    Serial.println("Sim808 read success");
    Serial.println("Start to send message ...");
    msg = message;
    
    //check si Température demandée "T?"
    x = msg.indexOf("T ?");
    Serial.println("Temperature demandée");
    if (x>=0) {
      dht11.read(&temperature, &humidity, NULL);
      Serial.print("la temp est de : ");
      Serial.print(int(temperature));
      Serial.println(" - Envoi");
      String(temperature).toCharArray(tempHum,5);
      sim808.sendSMS(PHONE_NUMBER, tempHum);
    }
    else {
     //Check si Humidité demandée
     x = msg.indexOf("Hr ?");
     if (x >=0 ) {
      dht11.read(&temperature, &humidity, NULL);
      Serial.print("l'humidité est de : ");
      Serial.print(int(humidity));
      Serial.println("% - Envoi");
      String(humidity).toCharArray(tempHum,5);
      sim808.sendSMS(PHONE_NUMBER, tempHum);  
      }
      else {
        Serial.println("Code non trouvé dans le sms");
      }
    }
  }

   sim808.deleteSMS(messageIndex); 
/*
   dht11.read(&temperature, &humidity, NULL);
        Serial.print("la temp est de : ");
        Serial.print(int(temperature));
        Serial.println(" - Envoi");
*/
}

@melodied, your topic has been moved to a moe suitable location on the forum.

And with the same program?

If the phone number in your code is a real one, I suggest that you remove it.
Bad connections? Broken jumper leads? Using breadbord?

If the phone number in your code is a real one, I suggest that you remove it.

well with the same program I could send an sms .
Okay thank you, yes it is a real one. But if I remove it, I will not be able to make a connection with a phone number? You mean try with a new phone number?
Now you said it since I'm sending and receiving sms to arduino uno, my phone is having trouble making connection.. You think it can comes from there?

I'm using a breadboard, but it does not come from there because I tried with differents ones.

I changed the jumper leads to.

No, we mean do not put your real [phone number in the code you publish on the Internet, even on such a "friendly" site as this. It is just a matter of your own security.

Just replace it with asterisks -""**********" in the code you show here, but use the proper number in the code you actually use.

In fact, you can edit your post, but this forum now remembers what you originally posted. :astonished:

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.