Pages: [1]   Go Down
Author Topic: Comunicazione ArduinoUNO+Shield GSM  (Read 234 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ciao,

sto provando a far funzionare lo shield GSM (quello venduto dallo store Arduino) con un arduino UNO R3, utilizzando l'IDE Arduino 1.0.5.

Utilizzando l'esempio GsmScanNetworks mi sembra che lo shield GSM non stia comunicando nel modo corretto con l'arduino UNO, infatti solo qualche volta mi restituisce il codice IMEI, l'operatore a cui sono collegato e l'intensità del campo.

Ho seguito esattamente tutti i passi riportati nel tutorial, ma niente. Ho provato ad usare il seguente codice per fare il restart dello shield GSM in modo ciclico quando il codice IMEI risulta diverso da quello della scheda.

Code:

#include <GSM.h>
#include <GSM3CircularBuffer.h>
#include <GSM3MobileAccessProvider.h>
#include <GSM3MobileCellManagement.h>
#include <GSM3MobileClientProvider.h>
#include <GSM3MobileClientService.h>
#include <GSM3MobileDataNetworkProvider.h>
#include <GSM3MobileMockupProvider.h>
#include <GSM3MobileNetworkProvider.h>
#include <GSM3MobileNetworkRegistry.h>
#include <GSM3MobileServerProvider.h>
#include <GSM3MobileServerService.h>
#include <GSM3MobileSMSProvider.h>
#include <GSM3MobileVoiceProvider.h>
#include <GSM3ShieldV1.h>
#include <GSM3ShieldV1AccessProvider.h>
#include <GSM3ShieldV1BandManagement.h>
#include <GSM3ShieldV1BaseProvider.h>
#include <GSM3ShieldV1CellManagement.h>
#include <GSM3ShieldV1ClientProvider.h>
#include <GSM3ShieldV1DataNetworkProvider.h>
#include <GSM3ShieldV1DirectModemProvider.h>
#include <GSM3ShieldV1ModemCore.h>
#include <GSM3ShieldV1ModemVerification.h>
#include <GSM3ShieldV1MultiClientProvider.h>
#include <GSM3ShieldV1MultiServerProvider.h>
#include <GSM3ShieldV1PinManagement.h>
#include <GSM3ShieldV1ScanNetworks.h>
#include <GSM3ShieldV1ServerProvider.h>
#include <GSM3ShieldV1SMSProvider.h>
#include <GSM3ShieldV1VoiceProvider.h>
#include <GSM3SMSService.h>
#include <GSM3SoftSerial.h>
#include <GSM3VoiceCallService.h>

/*
 
 GSM Scan Networks
 
 This example prints out the IMEI number of the modem,
 then checks to see if it's connected to a carrier. If so,
 it prints the phone number associated with the card.
 Then it scans for nearby networks and prints out their signal strengths.
 
 Circuit:
 * GSM shield
 * SIM card
 
 Created 8 Mar 2012
 by Tom Igoe, implemented by Javier Carazo
 Modified 4 Feb 2013
 by Scott Fitzgerald
 
 http://arduino.cc/en/Tutorial/GSMToolsGsmScanNetworks
 
 This example code is part of the public domain
 */

// libraries
#include <GSM.h>


// PIN Number
#define PINNUMBER ""

// initialize the library instance
//GSM gsmAccess;     // include a 'true' parameter to enable debugging
GSMScanner scannerNetworks;
GSMModem modemTest;

// Save data variables
String IMEI = "xx";
String OPERATORE_Corrente = "";
String OPERATORE_Campo ="xx";

// serial monitor result messages
String errortext = "ERROR";

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  Serial.println("GSM networks scanner");
  scannerNetworks.begin();
 
  // connection state
 // boolean notConnected = true;
  //delay(1000);
 
  //notConnected = false;
  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  /*while(notConnected)
  {
    if(gsmAccess.begin(PINNUMBER)==GSM_READY)
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }*/
 
  // get modem parameters
  // IMEI, modem unique identifier
  Serial.print("Modem IMEI: ");
  IMEI = modemTest.getIMEI();
  IMEI.replace("\n","");
  if(IMEI != NULL)
    Serial.println(IMEI);

 }

void loop()
{
 
  // scan for existing networks, displays a list of networks
  Serial.println("Scanning available networks. May take some seconds.");
  Serial.println(scannerNetworks.readNetworks());
 
    // currently connected carrier
  Serial.print("Current carrier: ");
  delay(100);
  //OPERATORE_Corrente = scannerNetworks.getCurrentCarrier();
  Serial.println(scannerNetworks.getCurrentCarrier());
  //OPERATORE_Corrente = "";
    delay(100);
  // returns strength and ber
  // signal strength in 0-31 scale. 31 means power > 51dBm
  // BER is the Bit Error Rate. 0-7 scale. 99=not detectable
 
 
  Serial.print("Signal Strength: ");
  delay(100);
  OPERATORE_Campo = scannerNetworks.getSignalStrength();
  Serial.println(scannerNetworks.getSignalStrength());
  delay(100);
  //Serial.println(" [0-31]");
  Serial.print("Modem IMEI: ");
  IMEI = "xx";
     IMEI = modemTest.getIMEI();
     IMEI.replace("\n","");
     if(IMEI != NULL)
      Serial.println(IMEI);
     else
      Serial.println("Errore codice IMEI: "+ IMEI);
     delay(1000);
  if(IMEI != "862170018296259")
    {
      while(IMEI != "862170018296259")
        {
          Serial.begin(9600);
         
          Serial.println("GSM networks scanner");
          scannerNetworks.begin();
          delay(10000);
         
              Serial.print("Modem IMEI: ");
               IMEI = "xx";
               IMEI = modemTest.getIMEI();
               IMEI.replace("\n","");
               if(IMEI != NULL)
                Serial.println(IMEI);
               else
                Serial.println("Errore codice IMEI: "+ IMEI);
               delay(1000);
         }
         
   }
   
     
   OPERATORE_Corrente = "xx";
   OPERATORE_Campo ="xx";
   delay (3000);
}


Ringrazio anticipatamente, per l'aiuto
« Last Edit: August 04, 2013, 04:32:58 am by dino_80 » Logged

Pages: [1]   Go Up
Jump to: