TiDiGino: remote control based on Arduino increases the performance

By on September 10, 2014
Pin It

TiDiGino_profilo

We’ll show you today how, with just a few modifications, we can apply the GSM/GPS shield management library to the Arduino compliant TiDiGino open source remote control, so you can manage optimally the capabilities of the SIM900 mounted on it to implement cellular connectivity.  As you may know already, TiDiGino is the development and prototyping platform we designed and published for developing remote control systems, gate opener, remote alarms and similar artifacts working with connectivity provided over GSM cellular networks: all this is also made in line with the open source philosophy. The core of the TiDiGino is indeed based on Arduino Mega architecture  in turn based on the Atmel ATmega 2560 microcontroller. This shield adds a certain amount of hardware to the basic Arduino setup, ranging from DTMF decoding hardware to temperature sensors, opto-isolated inputs and TTL, relay outputs.

 

Interfacing through a USB channel and using the same Arduino development environment, TiDiGino platform manages to maintain the ease of use and programming approach of the Arduino family, even if it adds many valuable functionalities at hardware level.

 

Among the additional hardware, we find the GSM SIM900 module of SIMCom. The SIM900 is a GSM and GPRS that allows you to make phone calls, send text messages and manage your Internet connection exploiting it to its full potential (client applications, server applications, HTTP, TCP / IP sockets, GET / POST methods, email management). The module includes virtually everything needed to be used, and requires only to add a GSM antenna and a few discrete components, in addition to the SIM card socket.

TiDiGino combines the versatile hardware that integrates, to a flexibility granted by the ability to use all of the add-in cards designed for Arduino, since it is 100% compatible with the Arduino family.

Currently it a library with instructions is available to allow you to install it within the Arduino IDE. The TiDiGino latest library is limited in some features, especially when compared with the one developed for GSM / GPRS & GPS Shield. For this reason, we have decided to extend TiDiGino features catching the most valuable ones from the GSM/GPRS Shield.
The library provided with this shield implements several functions with a particular focus on Internet interaction, making in this way easily accessible to everyone the so-called IoT (Internet of Things).

The idea behind this article is to show the steps to be taken in order to use the library developed for the shield with TiDiGino.

 

NEW FEATURES OF THE TiDiGino LIBRARY

TiDiGino_3

Before diving into the necessary steps for the configuration, let’s see the main new features implemented in this release of the software library, now at version 3.06.

In addition to a number of bug fixes aimed at better product utilization by improving the stability, we find a new function for decoding DTMF tones.

Previously on this blog we have shown how it is possible, during a call, to send DTMF tones using the dedicated functions of the library. In this post we will instead show how it is possible to receive and decode the tones sent by the other caller and associate them to the functions to be executed.

 

The following table summarize all the DTMF tones management functions, and their usage.

void SetDTMF (int DTMF_status) If the entire DTMF_status is equal to 1, will enable the decoding of DTMF tones, if DTMF_status is 0 DTMF tones are disabled call.SetDTMF (1)
char DetDTMF () Check the in serial buffer the presence of any DTMF decoded by the SIM900. If present, this function returns the char received, otherwise, in case of no tone detected, it returns the character “_”. char DTMF_char = ‘_’;DTMF_char=call.DetDTMF();if (DTMF_char! = ‘-‘){Serial.println (DTMF_char);}
void SendDTMF (char * number_string, int time) Allows, during a phone call, to send DTMF tones or tone strings. The string will be specified by the pointer, while the duration of the tone is defined by the int variable call.SendDTMF (“0”, 1);

 

 

 

CONFIGURATION LIBRARY

Fig. 6 - Il TiDiGino funzionante dopo il caricamento di uno sketch da 80kB

The TiDiGino is sold equipped with its own library that can be downloaded from the official website.

In the following steps we’ll see how to configure the TiDiGino to use the library originally designed for GSM/GPRS & GPS Shield.

First you have to specify that, using the module SIM900, the TiDiGino cannot exploit the whole potential of the library, since the SIM900 does not have the geolocation hardware module onboard (the GPS is on the SIM908 module). The steps are the following:

  • We download from the website the latest version of the Arduino development environment (IDE), currently 1.0.5.
  • From the site where the project is hosted https://code.google.com/p/tidigino/downloads/list we download the zip file containing the files to configure the Arduino IDE with this new card.
  • Replace the file board.txt located under the folder C:\Program Files\Arduino\hardware\arduino with the one present in the zip file you downloaded previously.
  • Create the folder “tidigino” in the path C:\Program Files\Arduino\hardware\arduino\variants.
  • Insert in the newly created folder the file pins_arduino.h, which is also present in the downloaded zip.
  • On the website www.gsmlib.org (in the download section) you can find the GSM / GPRS & GPS library for TiDiGino (denoted by TDG). Once you downloaded it, put it in the folder C:\Program Files\Arduino\libraries and finally start the IDE.
  • To test the correct installation, check the presence of TiDiGino under Tools – Types of Arduino. Once selected, we shall load an example contained in the related folder inside the library and verify that it can be compiled without any problems.

 

EXAMPLE

Before putting our hands on these new additional features of the library, we would remind the reader that each sketch developed for the GSM / GPRS & GPS shield can be compiled for TiDigino and vice versa (except functions that are not related to the GSM library), thus maintaining the maximum compatibility and versatility.

Now that we have everything we need, we move on with an example that shows how DTMF decoding works, binding the execution of different functions to the specific tone received. In this case, whatever the received tone is, we will print it on the serial port.

 

In the setup function, executed only once at power on, we enable the decoding of DTMF tones through the function call.SetDTMF (1); 

Firstly, you will need to identify an incoming call with

/ / Check status of call

stat = call.CallStatus ();

if (stat == CALL_INCOM_VOICE) {[…]}

and then respond with the function call.PickUp (); in this way each incoming call will be accepted. If we want to set up a filter and select only the incoming calls made ​​from certain numbers, we must use the

call.CallStatusWithAuth ();

At this point, while the call is active while (stat == CALL_ACTIVE_VOICE) {[…]} it will check the presence of DTMF tones with the function call.DetDTMF ();

Keep in mind that the function returns a char equal to the character of the DTMF tone decoded. If it does not find any decoded character, then returns an error character “_”.

All the possible characters that could be received are: 0,1,2,3,4,5,6,7,8,9,0, *, #.

When the function returns a character, different from the error char “_”, we will write it on the serial port and show it on the Arduino serial monitor.

 

CODE 

#include "SIM900.h"

#include <SoftwareSerial.h>

//we include only the call class since we don’t need any other else

//#include "inetGSM.h"

//#include "sms.h"

#include "call.h"


//example to show DTMF tones decoding


//instantiate the object related to phone calls class (that includes also DTMF tones encoding/decoding functions)

CallGSM call;


char number[20];

byte stat=0;

int value=0;

int pin=1;

char value_str[5];

char DTMF_char='_';

int count=0;


void setup()

{

 pinMode(pin,INPUT);

 Serial.begin(9600);

 Serial.println("DTMF testing.");

 if (gsm.begin(9600))

   Serial.println("\nstatus=READY");

 else Serial.println("\nstatus=IDLE");

 //enable DTMF tones decoding

 call.SetDTMF(1);

};


void loop()

{

 //check phone calls status

 stat=call.CallStatus();

 //we answer if a call is incoming

 if(stat==CALL_INCOM_VOICE)

 {

   Serial.println("Pick Up");

   delay(50);

   call.PickUp();

 }

 //while the call is active, we check DTMF tones

 while(stat==CALL_ACTIVE_VOICE){

   for (int k=0; k<100; k++)

   {

     DTMF_char=call.DetDTMF();

     if(DTMF_char!='-')

       Serial.println(DTMF_char);     

   }

   stat=call.CallStatus();

 }

 delay(1000);

};

The example code was designed to be extremely simple to allow anyone to get a close look to these new features of the SIM900 module. Nothing prevents you to call different functions depending on the received tone and complicate the sketch, as you like.

For example:

if (DTMF_char! = ‘0 ‘)

  Function0 ();

elseif (DTMF_char! = ‘1 ‘)

Function1 ();

elseif (DTMF_char! = ‘2 ‘)

Function2 ();

elseif (DTMF_char! = ‘3 ‘)

  Function3 ();

 

 

 

REFERENCES

Given the pretty huge user base of the two products mentioned in this article and therefore the continuous development of the library we recommend to the reader some references to stay up to date with the latest software release.

Regarding TiDiGino, the reference site is https://code.google.com/p/tidigino/ where you can find the original library.

Similarly, the libraries for GSM / GPRS and GPS Shield with its variants for the TiDiGino, can be found on the following website www.gsmlib.org .

 

STORE

TiDiGino

GSM/GPS shield

SIM900 module

About Boris Landoni

Boris Landoni is the technical manager of Open-Electronics.org. Skilled in the GSM field, embraces the Open Source philosophy and its projects are available to the community.

Leave a Reply

Your email address will not be published. Required fields are marked *