bonjours j'ai reçu il y a peu mon shield GSM Arduino avec antenne intégré
j'utilise une nouvelle carte sim (FREE) testé au préalable sur mon téléphone elle fonctionne
j'ai tout d'abord installer la carte sim branché l'arduino au PC puis téléversé le programme d'exemple arduino pour envoyer des SMS. à savoir celui là
/*
SMS sender
This sketch, for the Arduino GSM shield,sends an SMS message
you enter in the serial monitor. Connect your Arduino with the
GSM shield and SIM card, open the serial monitor, and wait for
the "READY" message to appear in the monitor. Next, type a
message to send and press "return". Make sure the serial
monitor is set to send a newline when you press return.
Circuit:
* GSM shield
* SIM card that can send SMS
created 25 Feb 2012
by Tom Igoe
This example is in the public domain.
http://arduino.cc/en/Tutorial/GSMExamplesSendSMS
*/
// Include the GSM library
#include <GSM.h>
#define PINNUMBER "1234"
// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;
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("SMS Messages Sender");
// connection state
boolean notConnected = true;
// 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);
}
}
Serial.println("GSM initialized");
}
void loop()
{
Serial.print("Enter a mobile number: ");
char remoteNum[20]; // telephone number to send sms
readSerial(remoteNum);
Serial.println(remoteNum);
// sms text
Serial.print("Now, enter SMS content: ");
char txtMsg[200];
readSerial(txtMsg);
Serial.println("SENDING");
Serial.println();
Serial.println("Message:");
Serial.println(txtMsg);
// send the message
sms.beginSMS(remoteNum);
sms.print(txtMsg);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
}
/*
Read input serial
*/
int readSerial(char result[])
{
int i = 0;
while(1)
{
while (Serial.available() > 0)
{
char inChar = Serial.read();
if (inChar == '\n')
{
result[i] = '\0';
Serial.flush();
return 0;
}
if(inChar!='\r')
{
result[i] = inChar;
i++;
}
}
}
}
Mais quand j'ouvre le moniteur série
même en attendant un peu toujours rien
après avoir consulter la doc Arduino j'ai bridgé le pont CTRL/D7
j'ai refait le teste toujours rien même à la fenêtre cela ne marche pas
Salut, après un rapide coup d’œil, tu bloque ici : while(notConnected), tu ne fait ni ce qu'il y a après ce while ni ce qu'il y a quand tu doit rester dedans, donc je pense que tu dois avoir un soucis, je pense que la condition est toujours vrai mais tu ne sort pas de la boucle while, ce qui est bizar c'est que c'est un exemple arduino :s
Mets des traces :
while(notConnected)
{
Serial.println("Connected or not that is the question !?");
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
Serial.println("Connected");
else
{
Serial.println("Not connected");
delay(1000);
}
}
Comme sa tu sera ce qui ce passe dans ton while ( ou tu reste bloque si tu veux mon avis )
Skizo.
/*
SMS sender
This sketch, for the Arduino GSM shield,sends an SMS message
you enter in the serial monitor. Connect your Arduino with the
GSM shield and SIM card, open the serial monitor, and wait for
the "READY" message to appear in the monitor. Next, type a
message to send and press "return". Make sure the serial
monitor is set to send a newline when you press return.
Circuit:
* GSM shield
* SIM card that can send SMS
created 25 Feb 2012
by Tom Igoe
This example is in the public domain.
http://arduino.cc/en/Tutorial/GSMExamplesSendSMS
*/
// Include the GSM library
#include <GSM.h>
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;
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("SMS Messages Sender");
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
Serial.println(1);
while(notConnected==true)
{
Serial.println(2);
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
{
Serial.println(3);
notConnected = false;
}
else
{
Serial.println(4);
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
}
void loop()
{
Serial.print("Enter a mobile number: ");
char remoteNum[20]; // telephone number to send sms
readSerial(remoteNum);
Serial.println(remoteNum);
// sms text
Serial.print("Now, enter SMS content: ");
char txtMsg[200];
readSerial(txtMsg);
Serial.println("SENDING");
Serial.println();
Serial.println("Message:");
Serial.println(txtMsg);
// send the message
sms.beginSMS(remoteNum);
sms.print(txtMsg);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
}
/*
Read input serial
*/
int readSerial(char result[])
{
int i = 0;
while(1)
{
while (Serial.available() > 0)
{
char inChar = Serial.read();
if (inChar == '\n')
{
result[i] = '\0';
Serial.flush();
return 0;
}
if(inChar!='\r')
{
result[i] = inChar;
i++;
}
}
}
}
/*
This file is part of the GSM3 communications library for Arduino
-- Multi-transport communications platform
-- Fully asynchronous
-- Includes code for the Arduino-Telefonica GSM/GPRS Shield V1
-- Voice calls
-- SMS
-- TCP/IP connections
-- HTTP basic clients
This library has been developed by Telefónica Digital - PDI -
- Physical Internet Lab, as part as its collaboration with
Arduino and the Open Hardware Community.
September-December 2012
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
The latest version of this library can always be found at
https://github.com/BlueVia/Official-Arduino
*/
#ifndef _GSM3SIMPLIFIERFILE_
#define _GSM3SIMPLIFIERFILE_
// This file simplifies the use of the GSM3 library
// First we include everything.
#include <GSM3CircularBuffer.h>
#include <GSM3MobileCellManagement.h>
#include <GSM3MobileClientService.h>
#include <GSM3MobileNetworkRegistry.h>
#include <GSM3MobileServerService.h>
#include <GSM3ShieldV1AccessProvider.h>
#include <GSM3ShieldV1BandManagement.h>
#include <GSM3ShieldV1ClientProvider.h>
#include <GSM3ShieldV1DataNetworkProvider.h>
#include <GSM3ShieldV1ModemVerification.h>
#include <GSM3ShieldV1PinManagement.h>
#include <GSM3ShieldV1ScanNetworks.h>
#include <GSM3SMSService.h>
#include <GSM3VoiceCallService.h>
#define GSM GSM3ShieldV1AccessProvider
#define GPRS GSM3ShieldV1DataNetworkProvider
#define GSMClient GSM3MobileClientService
#define GSMServer GSM3MobileServerService
#define GSMVoiceCall GSM3VoiceCallService
#define GSM_SMS GSM3SMSService
#define GSMPIN GSM3ShieldV1PinManagement
#define GSMModem GSM3ShieldV1ModemVerification
#define GSMCell GSM3CellManagement
#define GSMBand GSM3ShieldV1BandManagement
#define GSMScanner GSM3ShieldV1ScanNetworks
#endif
j'ai installer la librairie puis téléversé le programme exemple de la librairie a savoir
#include "SIM900.h"
#include <SoftwareSerial.h>
//If not used, is better to exclude the HTTP library,
//for RAM saving.
//If your sketch reboots itself proprably you have finished,
//your memory available.
//#include "inetGSM.h"
//If you want to use the Arduino functions to manage SMS, uncomment the lines below.
#include "sms.h"
SMSGSM sms;
//To change pins for Software Serial, use the two lines in GSM.cpp.
//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.
//Simple sketch to send and receive SMS.
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
void setup()
{
//Serial connection.
Serial.begin(9600);
Serial.println("GSM Shield testing.");
//Start configuration of shield with baudrate.
//For http uses is raccomanded to use 4800 or slower.
if (gsm.begin(2400)) {
Serial.println("\nstatus=READY");
started=true;
} else Serial.println("\nstatus=IDLE");
if(started) {
//Enable this two lines if you want to send an SMS.
//if (sms.SendSMS("3471234567", "Arduino SMS"))
//Serial.println("\nSMS sent OK");
}
};
void loop()
{
if(started) {
//Read if there are messages on SIM card and print them.
if(gsm.readSMS(smsbuffer, 160, n, 20)) {
Serial.println(n);
Serial.println(smsbuffer);
}
delay(1000);
}
};
je suppose que c'est plutôt bon signe par contre si je doit utiliser cette librairie pourrait tu m'indiquer un site où son détaillé les différentes fonctions avec leurs utilités
Pas vraiment il reboot en boucle ... En plus je viens de relire la page officiel du shield, c'est pas clair mais la définition des pins semblait être la bonne, et la lib que je t'ai donnée ne devrait pas l'être en revanche ...