Comando dispositivi remoti con Arduino GSM

Tesine 2015-18

Scritto da Fiusco Andrea

Fiusco Andrea - Classe 5A-IPAI - AS 2015-2016
Comando dispositivi remoti con Arduino GSM
Applicazione con Arduino

Fiusco 2aIntroduzione
L'applicazione permette di attivare tramite GSM due dispositivi remoti (simulati con due LED rosso/verde).
SMS = Von e Voff - attiva e disattiva il Led Verde
SMS = Ron e Roff - Attiva e disattiva il Led Rosso.
Questa è solo una piccola dimostrazione ma lo stesso principio potrebbe essere usato per
azionare a distanza dispositivi di potenza (es. luci, chiudere e aprire cancelli, attivare una caldaia,  ecc…)

 

 

Materiale utilizzato
Arduino GSM Shield
Arduino Uno
Led (Rosso, Verde e Blu)
Resistenze da 220 ohm
BreadBoard

 

Schema                                                                   

 disegno tesina 2

Software di gestione

/*
Fiusco Andrea - Classe 5A-IPAI - AS 2015-2016
Comando dispositivi remoti con Arduino GSM
Questo indirizzo email è protetto dagli spambots. È necessario abilitare JavaScript per vederlo.
*/
#include <GSM.h> // Libreria GSM
GSM gsmAccess;
GSM_SMS sms;
int ledRosso=11;
int ledVerde=10;
int ledBlu=5;

void setup()
{
  pinMode(ledRosso, OUTPUT);
  pinMode(ledVerde, OUTPUT);
  pinMode(ledBlu,   OUTPUT);
  boolean connessione = true;
  while(connessione)
  {
  if(gsmAccess.begin()==GSM_READY)
   connessione = false;
  }
  digitalWrite(ledBlu,HIGH);
}
int i=0;

char vettore[10];
char ricevuto[10];
String accendi1="Ron";
String spegni1="Roff";
String accendi2="Von";
String spegni2="Voff";
String casting;

void loop()
{
  char c; 
  if (sms.available())
  {
   //Lettura sms
    while(c=sms.read())
    {
      Serial.print(c);
      vettore[i]=c;
      i++;   
    }
    delay(1000);
    
    for(int j=0;j<i;j++)
    ricevuto[j]=vettore[j];
    casting=String(ricevuto);
    if(casting.equals(accendi1))
    {
       digitalWrite(ledRosso,HIGH);
       i=0;
       pulisciStringa(ricevuto,10);
    }
      if(casting.equals(accendi2))
    {
       digitalWrite(ledVerde,HIGH);
       i=0;
       pulisciStringa(ricevuto,10);  
    }
    if(casting.equals(spegni1))
    {
        digitalWrite(ledRosso,LOW);
        i=0;
       pulisciStringa(ricevuto,10);
     }
     if(casting.equals(spegni2))
    {
        digitalWrite(ledVerde,LOW);
        i=0;
       pulisciStringa(ricevuto,10);
     }
    i=0;
    pulisciStringa(ricevuto,10);
    sms.flush();
    }
delay(1000);
}
void pulisciStringa(char* tmp,int dim)

{
int x;

for (x=0; x < dim; x++)
tmp[x] = 0;
tmp[0] = '\0';

}

 

APPROFONDIMENTO

 

Global System for Mobile Communications

In telecomunicazioni il GSM, sigla di Global System for Mobile Communications, è lo standard 2G (2ª generazione) di telefonia mobile cellulare e attualmente il più diffuso del mondo: più di 3 miliardi di persone in 200 paesi usano telefoni cellulari GSM attraverso l'omonima rete cellulare. In particolare il GSM è uno standard aperto. L'introduzione del GSM ha rappresentato una vera e propria rivoluzione nell'ambito dei sistemi di telefonia cellulare. Fondamentalmente i numerosi vantaggi rispetto ai precedenti sistemi cellulari sono stati: interoperabilità tra reti diverse che fanno capo ad un unico standard internazionale; comunicazione di tipo digitale; maggiore velocità di trasmissione grazie alle tecniche di compressione dati proprie della codifica di sorgente; nuovi più ampi servizi (es. SMS) grazie all'aumento della velocità di trasmissione.

ARDUINO  UNO
Arduino è un sistema open source che permette la prototipazione rapida e l'apprendimento veloce dei principi fondamentali dell'elettronica e della programmazione. Questa si basa su un circuito stampato che integra un microcontrollore con pin connessi alle porte I/O, un regolatore di tensione e un'interfaccia USB che permette la comunicazionecon il computer

 Shield GSM

Overview
The Arduino GSM Shield connects your Arduino to the internet using the GPRS wireless network. Just plug this module onto your Arduino board, plug in a SIM card from an operator offering GPRS coverage and follow a few simple instructions to start controlling your world through the internet. You can also make/receive voice calls (you will need an external speaker and microphone circuit) and send/receive SMS messages.

As always with Arduino, every element of the platform – hardware, software and documentation – is freely available and open-source. This means you can learn exactly how it's made and use its design as the starting point for your own circuits. Hundreds of thousands of Arduino boards are already fueling people’s creativity all over the world, everyday. Join us now, Arduino is you!
Requires an Arduino board (not included)
Operating voltage 5V (supplied from the Arduino Board)
Connection with Arduino Uno on pins 2, 3 (Software Serial) and 7 (reset).
Description
The Arduino GSM Shield allows an Arduino board to connect to the internet, make/receive voice calls and send/receive SMS messages. The shield uses a radio modem M10 by Quectel (datasheet). It is possible to communicate with the board using AT commands. The GSM library has a large number of methods to communicate with the shield.
The shield uses digital pins 2 and 3 for software serial communication with the M10. Pin 2 is connected to the M10’s TX pin and pin 3 to its RX pin. The modem's PWRKEY pin is connected to Arduino pin 7. The M10 is a Quad-band GSM/GPRS modem that works at the following frequencies: GSM850MHz, GSM900MHz, DCS1800MHz and PCS1900MHz. It supports TCP/UDP and HTTP protocols through a GPRS connection. GPRS maximum data downlink and uplink transfer speed is 85.6 kbps.To interface with the cellular network, the board requires a SIM card provided by a network operator.
The most recent revision of the board uses the 1.0 pinout on rev 3 of the Arduino Uno board.
The micro to nano SIM adapter is included in the box.
Power requirements
It is recommended to power the board with an external power supply that can provide between 700mA and 1000mA. Powering an Arduino and the GSM shield from a USB connection is not recommended, as USB cannot provide the required current when the modem is in heavy use.
The modem can pull up to 2A of current at peak usage, which can occur during data transmission. This current is provided through the large orange capacitor on the board's surface.
On board indicators
The shield contains a number of status LEDs:
On: shows that the Shield is getting power.
Status: switches on when the modem is powered and data is being transferred to/from the GSM/GPRS network.
Net: blinks when the modem is communicating with the radio network.
On board interfaces
The shield comes with a on-board audio jack as well, and it can be used for both microphone and line inputs. It is also possible to make voice calls. You don’t need to add a speaker and microphone.
There are two small buttons on the shield. The button labeled "Reset" is tied to the Arduino reset pin. When pressed, it will restart the sketch. The button labeled "Power" is connected to the modem and will power the modem on and off. For early versions of the shield, it was necessary to press the power button to turn on the modem. Newer versions of the board will turn the modem on automatically.
If you have an early version of the shield, and it does not turn on automatically, you can solder a jumper to the CTRL/D7 pad on the reverse side of the board, and it will turn on when an attached Arduino receives power.
Several of the modem pins are exposed on the underside of the board. These provide access to the modem for features like speaker output and microphone input. See the datasheet for complete information.