Today we will see how to send and receive text messages with your NadHat and a Raspberry Pi using Gammu from command line.


To send sms, your Raspberry Pi must be connected to a GSM network of an operator. To do this, we will use a SIM card with a subscription including a 2 hours limited calls and unlimited sending/receiving of sms and mms. Most operators offer packages of this kind for cheap.

Gammu installation

Gammu is an utility that will allow you to control your phone.

We will first update the system with the following command:

pi@raspberry:~ $ sudo apt-get update

Next install gammu with:

pi@raspberry:~ $ sudo apt-get install gammu

 Gammu configuration using gammu-config

Run the following command to open the gammu configuration utility.

pi@raspberry:~ $ sudo gammu-config

This utility will allow us to specify our parameters in order to communicate with our SIM card via gammu.

Our NadHat board is connected to the Raspberry Pi 0 through the ttyAMA0 serial port at a speed of 115200 bit / s. So we will configure the following parameters:

  • Port: /dev/ttyAMA0
  • Connection: at115200

Then save with "Save", then "yes" and "ok" to validate the new configuration and exit the gammu configuration interface.

Starting NadHat

In order to test gammu we need to communicate with our SIM card. To do so, we have to start our NadHat board up.

you can get the bash startup script "" on our GitHub with the following link:

Run the script as below:

pi@raspberrypi:~/nadhat/software $ ./ 
pulse low PWRKEY pin on GPIO26 for 1s to startup SIM800...

Check on the NadHat board that the green led is ON and the orange led is flashing.

Send and receive SMS

Now that our NadHat board is powered on we can finally test gammu :)

Check the communication with our SIM card with the following command:


pi@raspberrypi:~/nadhat/software $ gammu identify
Device               : /dev/ttyAMA0
Manufacturer         : SIMCOM_Ltd
Model                : unknown (SIMCOM_SIM800C)
Firmware             : Revision:1418B04SIM800C24
IMEI                 : 862631036779410

If you get information as above your SIM is well accessible and you can go further. If this command does not work check the uart port used and that your NadHat card is powered.

The first thing to do before sending or receiving text messages is to unlock the SIM card with the required PIN code. Here we use a SIM card from the ORANGE operator so the PIN code is 0000.

pi@raspberrypi:~/nadhat/software $ gammu entersecuritycode PIN 0000

After a few seconds you should see the orange LED go from a fast blink to a slow blink.

Now there is only the following command to execute to send your sms:

pi@raspberrypi:~/nadhat/software $ echo "Sending sms with gammu" | gammu sendsms TEXT 06XXXXXXXX
If you want break, press Ctrl+C...
Sending SMS 1/1....waiting for network answer..OK, message reference=93

In order to get your received sms you can execute the following command:

pi@raspberrypi:~/nadhat/software $ gammu getallsms

You now know the basic gammu commands, we will soon see how to use a python script to start sending an SMS.

See you soon!

traduit du français, article original