Raspberry Pi B+ with Neoway GSM M590 module

Raspberry Pi and GSM network- sending SMS, connecting to the Internet (IoT)

This time I’m going to connect to our Raspberry Pi a GSM module. Why? Internet of Things, in short IoT, as it was noted at Krakow’s PLNOG17  by Marcin Aronowski involves and depends on the network which should be easily accessible, and the very essence of IoT is the energy efficiency. Perhaps, he said, 3G will go away but 2G but will still remain. And we do not huge pipes – just enough bandwidth. 2G connection is still the cheapest in the implementation (also due to the cost of the module and a SIM card).

Therefore, I will try to show you how easy it is to connect very cheap GSM module Neoway M590 . It is a simple device that is a GSM modem (2G).

We will learn how to send an SMS and how to connect to the Internet.

Required

Software:

  • software: picocom, gammu, ppp (accessible via standard Raspbian’s repository)
  • turning off the console redirection to serial port on Raspberry Pi

Hardware:

  • Raspberry Pi – 1B, 1A, 2B, 3B, Zero – any model with installed Raspbian (mini version is enough)
  • Neoway M590 GSM module – preferably without extra letters at the end – get a version with everything soldered and 2×7 pins
  • Multimer for voltage and power supply check for GSM module
  • Optional: DC-DC step down converter – at least rated 2A, usually allows using 5-24V on input and keeping stable 3,9V at output – used to power the GSM module

    DC-DC step down module
    DC-DC step down module

Let’s begin!

I chose the Neoway M590 GSM modem module, because it is a bit underestimated – and one of the most important things is to have proper and stable power supply. Module is not as popular as SIM800/SIM900, but – it’s very, very cheap, and after few months of trails on two modules I can say it’s stable.

Please remember, in most cases the correct voltage is 3,7-3,9V, and power rating needs to be minimum 2A.

Connecting to Raspberry Pi

Neoway GSM module has a serial port – this is the standard way to talk – via connections TX, RX. However, the default serial port on Raspberry Pi is occupied by the system console – so if you connect our module to Raspberry’s serial port you will get overflow of text data. Edit the Raspberry Pi file /boot/cmdline.txt and remove the part console=/dev/ttyAMA0,115000. Yo can us it after reboot.
Connect the DC-DC step down power converter – you can also use a battery from an unused smartphone or battery type 18650 – provided that it has a rating of 3.7V – Li Poly or Li Ion battery. If you use are using smilar DC-DC converter as on the picture – with adjustable resistor – use a screwdriver when powered with no load, connect a multimeter and turn as long as the voltage suddenly begin to fall – the set 3,9V. Now connect the GSM module and verify the voltage – sometimes cheap module does not provide stable power supply under load – as a result we have a voltage drop that must be corrected. Do the final adjustment VERY carefully – do not damage the GSM module. Here is the power scheme and the connection to the Raspberry Pi. Diagram shows the version with 2×7 pin connector plates on Neoway M590 facing the SIM card:

Schema: RPI - Neoway M590
Schema: RPI connected to Neoway M590 GSM module
Neoway M590 connection
Neoway M590 connection

As you can see this is not hard to wire, please remember the GND connections. Neoway M590 needs GND connected to BOOT to start, hence the “extra” connection to the GND of the system. Again the connections from the view of the SIM card slot:
After inserting the SIM card powering the module – the first LED should lit red, and the second should bling to indicate the GSM network connections. Here’s the final view:

The Raspberry Pi with GSM M590 module
The Raspberry Pi with GSM M590 module

Sending first SMS

To get to now the module – you will need to install this:

then issue on the console:

You can exit picocom by CTR+A then Q.
At the very end, in line 21, I’ve entered the command “AT” and M590 answered “OK”. This means that we have properly (proper TX and RX) connected console. The AT commands with parameters are the natural language of modems – the old “analog” and the new GSM modems. If you’re getting “weird” characters – it’s the bad speed, and if we see what you write – it means that you haven’t deactivated the system console redirection to a serial port yet (in that case – please see above). Let’s see those commands in detail..

Let’s send the first SMS, first by picocom, and later “automatically” via gammu:

What happened here ? First we setup the modem to send SMS via GSM, then you need to change the “601xxx555” to a proper number for the recipient of the SMS. Next we will get the > sign – this is where you enter your SMS. To send it – press CTRL+Z. After 3-4 seconds you should get: “+CMGS: 46” and “OK’. Check your phone!

To use it with other software and use it wisely – we can use the gammu, that allows single line SMS:

Then edit the gammu’s config:

insert just this:

And now send your SMS like that:

Easy, ain’t it ?

Connecting to the Internet

Our module enables data transmission in GPRS mode. Combining that with the fact that we are @ 115kbps serial link, allows us to use the GPRS. Don’t forget – this is suited the task of running IoT solution, and not to use the browser in graphics mode (yet lynx, links or elinks do work without problem)
Let’s install the program to connect to the Internet. The ‘ppp’ will negotiate connection using a GSM modem, set ppp0 and append DNS entries, as well as the default route:

Create a file:

with:

Checkout the gprs file from chatscripts – it should be exactly like this:

That’s it. Connect to the internet using:

Check the logs in separate console (i.e.: tail -f /var/log/syslog)

It works Check the ifconfig output:

Turning off is also easy:

Logs will show:

That’s it – please remember that data plan can be costly. Check your data plan!