Envoi de SMS par le RaspberryPi

J’ai un projet où le Rasp doit envoyer des informations par SMS.

J’ai acheté 10€ une clé 3G d’occasion pour l’utiliser avec Gammu

  • Informations sur la clé
 $ dmesg | grep tty | grep usb  
 [ 1014.053491] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB0  
 [ 1014.062066] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB1  
 [ 1014.069542] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB2  
 $   
 $ lsusb | grep -i Huawei  
 Bus 001 Device 006: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem 
 $
  • Installation de Gammu
sudo apt-get install gammu
  • Paramétrage
$ gammu-detect   
 ; Configuration file generated by gammu-detect.  
 ; Please check The Gammu Manual for more information.  

 [gammu]  
 device = /dev/ttyUSB0  
 name = Phone on USB serial port HUAWEI_Technology HUAWEI_Mobile  
 connection = at  

 [gammu1]  
 device = /dev/ttyUSB1  
 name = Phone on USB serial port HUAWEI_Technology HUAWEI_Mobile  
 connection = at

 [gammu2]  
 device = /dev/ttyUSB2  
 name = Phone on USB serial port HUAWEI_Technology HUAWEI_Mobile  
 connection = at  
 $

Dans /etc/gammurc on met juste:

[gammu]  
 device = /dev/ttyUSB0  
 name = Phone on USB serial port HUAWEI_Technology HUAWEI_Mobile  
 connection = at
$ gammu identify  
 Périphérique : /dev/ttyUSB0  
 Fabricant : Huawei  
 Modèle : unknown (K3565)  
 Firmware : 11.111.11.11.11  
 IMEI : 222222222222222  

Si un code PIN est activé

 $ gammu getsecuritystatus  
 Waiting for PIN.  
 $ gammu entersecuritycode PIN 1234  
 $ gammu getsecuritystatus  
 Nothing to enter.  
 $
  • Envoi de SMS
 $ gammu sendsms TEXT 0612345678 -text "Test 1"  
 If you want break, press Ctrl+C...  
 Sending SMS 1/1....waiting for network answer..OK, message reference=1  
 $
 $ echo "Test 2" | gammu sendsms TEXT 0612345678  
 If you want break, press Ctrl+C...  
 Sending SMS 1/1....waiting for network answer..OK, message reference=2  
 $
  • Divers
 $ gammu getlocation  
 Latitude : 48.XXXXXX  
 Longitude : 2.XXXXXX  
 Range : 50000  
 Number of samples : 70  
 $

Gammu envoi la CellID sur le site web du projet open source OpenCellID (GET HTTP).
(Il faut un accès Internet dans ce cas, donc je ne pourrais l’utiliser)

  • Conclusion

Nous avons donc pour 10€ de clé, et 2€ (voir 0€ ) de forfait mensuel une solution d’envoi de SMS illimité.

Pour toutes les infos, voir la doc .

Vus : 1112
Publié par Uggy : 252