Tag Archives: berryGPS-GSM

Using u-Center to connect to the GPS on Raspberry Pi

u-Center from u-Blox is a graphical interface which can be used to monitor and configure all aspects of the GPS module on a BerryGPS-IMU or BerryGPS-GSM.

u-Center from uBlox
U-Center

 

u-Center only runs on Windows. It can connect over the network to a Raspberry Pi.  This will require us to redirect the serial interface on the Raspberry Pi to a network port using ser2net.

Pi Setup

Do an upt-get update and then install ser2net;

pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get install ser2net

Edit the ser2net config file and add the serial port redirect to a network port. We will use network port 6000

pi@raspberrypi ~ $ sudo nano /etc/ser2net.conf

And add this line at the bottom;

6000:raw:600:/dev/ttyACM0:9600 NONE 1STOPBIT 8DATABITS XONXOFF LOCAL -RTSCTS

This is a breakdown of the syntax for the line above;
TCP port : connection type : timeout : serial port : serial port speed speed : serial options

you can now start ser2net using;

pi@raspberrypi ~ $ sudo ser2net

And you can use the below command to check if it is running by seeing if the port is open and assigned to the ser2net process;

pi@raspberrypi ~ $sudo netstat -ltnp | grep 6000

If it is running, you should see something similar to the output below;

check result of ser2net

Windows PC Setup and Connecting to the GPS module

You can download u-Center from here.

Once installed, open u-Center. You will get the default view as shown below.  No data will be shown as we are not connected to a GPS.

u-Center default view

The next step, is to create a new network connection and connect to the GPS which is connected to our Raspberry Pi. You can create a new connection under the Receiver and then Network connection menus.

u-Center connect to Raspberry Pi
In the new window, enter the IP address of the Raspberry Pi and specify port 6000. This is the port we configured in ser2net on the Raspberry Pi.
u-Center Raspberry Pi Address

This is what the default view looks like when connected and the GPS has a fix.u-Center connected

 

u-Center

Below I will list of the more useful windows/tools within u-Center.
You can also click on the images below for a larger version.

Data View
This window will show you the longitude, latitude, altitude and fix mode. It will also show the HDOP, which is the Horizontal Dilution of Precision.  Lower is better, anything below 1.0 means you have a good signal.

u-Center Data View
u-Center Data View

Ground Track
This window will show you where the satellites are as well as what time.

u-Center Ground Track
u-Center Ground Track

Skye View
Sky view is an excellent tool for analyzing the performance of antennas as well as the conditions of the satellite observation environment.

u-Center Sky View
u-Center Sky View

Deviation Map
This map shows the average of all previously measured positions.

u-Center Deviation Map
u-Center Deviation Map

Continue reading Using u-Center to connect to the GPS on Raspberry Pi

Control the GPIO of a Raspberry Pi using SMS from a mobile phone

In this guide we will show you how to control the GPIO pins of a Raspberry pi by send a SMS to the Raspberry Pi from a mobile phone.

 

For this guide, the GSM modem we are using to receive the SMS is the  BerryGPS-GSM.

On the software side, we will be using Gammu, which is specifically designed to control  phones and GSM modules. It also has a daemon which will monitor the GSM modem for incoming SMSs.

We will configure Gammu to trigger a python script when a new SMS is received. We will use the contents of the SMS to control what happens in Python

LEDs are used here as an example, but you can do anything you like Eg. Open a garage door, turn on some lights, etc..

 

Wiring

Raspberry PI GPIO SMS

 

We will be using the three bottom right GPIO pins on the Raspberry Pi header. These are GPIO 16, 20 and 21.
Each is connected to a different color LED as shown above. The
The resistors used are 330 Ohm  and the GND pin (shorter pin) of the LEDs is connected to the GND power rail.

 

Setup

Install Gammu and python bindings;

pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get install gammu-smsd python-gammu

Edit the config file;

pi@raspberrypi ~ $ sudo nano /etc/gammu-smsdrc

Find the below lines and add port and speed.
For the BerryGPS-GSM, use /dev/ttyACM1 for port and at115200 for speed

port = /dev/ttyACM1
connection = at115200

At the bottom of the file, add the line below. This is the python script which will run when a new SMS is received.

RunOnReceive = sudo python /home/pi/smsReceived.py

We will do a quick test. Restart the gammu service so the new config takes effect;

pi@raspberrypi ~ $ sudo /etc/init.d/gammu-smsd restart

Send a test SMS to a mobile number. The mobile number below is an example, you will need to update this;

pi@raspberrypi ~ $ echo "This is a test from a Raspberry Pi" | /usr/bin/gammu --sendsms TEXT +614123456789

 

Python Script

This python script will run every time a new SMS is received.

pi@raspberrypi ~ $ nano ~/smsReceived.py

Copy in the below code

import RPi.GPIO as GPIO
import time
import sys
import re


RED_LED =  21
GREEN_LED =  20
BLUE_LED =  16

GPIO.setmode(GPIO.BCM)
filename=str(sys.argv[1])                               #Gammu will pass the filename of the new SMS as an argument
complete_filename="/var/spool/gammu/inbox/"+filename    #we create the full path to the file here

GPIO.setup(RED_LED , GPIO.OUT)
GPIO.setup(GREEN_LED , GPIO.OUT)
GPIO.setup(BLUE_LED , GPIO.OUT)

sms_file=open(complete_filename,"r")
#read the contents of the SMS file
message=sms_file.read(160) #note that a not-parted SMS can be maximum 160 characters

#search the contents and perform an action. Rather than use 'find',
# we will use regular expression (re) so we can ignore case.
#Most smartphones will have the first letter capitalised
if re.search('red', message, re.IGNORECASE):
        GPIO.output(RED_LED , GPIO.HIGH)
        time.sleep(2)
        GPIO.output(RED_LED , GPIO.LOW)
elif re.search('green', message, re.IGNORECASE):
        GPIO.output(GREEN_LED , GPIO.HIGH)
        time.sleep(2)
        GPIO.output(GREEN_LED , GPIO.LOW)
elif re.search('blue', message, re.IGNORECASE):
        GPIO.output(BLUE_LED , GPIO.HIGH)
        time.sleep(2)
        GPIO.output(BLUE_LED , GPIO.LOW)



GPIO.cleanup()

To troubleshoot you can view the syslog

pi@raspberrypi ~ $ tail -f /var/log/syslog

Using a button and the GPIO on a Raspberry Pi to send a SMS

In this guide we will show you how to send a SMS using a button connected to the GPIO pins of a Rasberry Pi Zero.

 

For this guide, the GSM modem we are using to send the SMS is the  BerryGPS-GSM.

On the software side, we will be using Gammu, which is specifically designed to control  phones and GSM modules.

Python will be used to monitor some buttons connected to GPIO pins and Gammu python bindings will be used to send a SMS.

Buttons are used here as an example, but you can use anything to trigger the SMS, E.g. Temperature sensor, water level sensor, light sensor, etc..

We have includes some LEDs so we can see when the buttons are pressed.

Wiring

Raspberry Pi LED button

We will be using the three bottom right GPIO pins on the Raspberry Pi header. These are GPIO 16, 20 and 21.
Each is connected to a button and different color LED as shown above. The internal pull-down resisters will be used on these GPIO.
3.3v and GND are connect to the power rails on the breadboard.
The resistors used are 330 Ohm  and the GND pin (shorter pin) of the LEDs is connected to the GND power rail.

Continue reading Using a button and the GPIO on a Raspberry Pi to send a SMS