RaspberryPi with SM5100b GSM GPRS cellular shield

RPi

I am going to try porting my PC python script for interfacing to the SM5100b directly to the RPi instead of converting it to an Arduino program.

UPDATE: Wow… it was easier than I thought it would be. I was able to quickly get to the same level of functionality as that previous post in less than an hour. Here is the push message posted to Prowl app using the cellular shield by a python script running on the Raspberry Pi.

Updates project files should show up on my github soon.

IMG_3379[1]

Advertisements

My RaspberryPi Config

Setup for first boot

I bought an 8GB micro SDHC card which came with a USB card reader and an SD adapter. I used the windows disk image writer for setting it up with the latest raspbian wheezy image.

Then I powered the card using a usb cable and used a ethernet cable to connect it to my router. I then setup my router to assign The RPi a reserved easy to remember IP address.

$ ssh pi@192.168.1.2

On first login its best to setup the following config using your preferences.

pi@raspberrypi ~ $ sudo raspi-config

At this point I was using ~1.5GB of the card.

Please note that the following tidbits have been scraped from various parts of the internet and I did not really have to figure out any of this myself.

Here is a good index page from the embedded linux RPi wiki for quickly looking up information.

rpi

Installing Packages

Next I upgraded all the installed packages, this takes a while to finish.

$ sudo apt-get update ; sudo apt-get upgrade

The upgrade pushes the card upto ~1.6GB.

General packages

$ sudo apt-get install vim ctags tcsh screen tightvncserver python-setuptools git

Automatically Adjust Clock speeds – Save Power

$ sudo vi /boot/config.txt

arm_freq_min=100
force_turbo=0

Install the cpufrequtils package, which allows control over the CPU speed based on demand and reboot:

$ sudo apt-get install cpufrequtils
$ sudo cpufreq-set -g ondemand
$ cpufreq-info
...
...
  current CPU frequency is 100.0 MHz.

GPIO packages

$ sudo apt-get install python-dev
$ sudo apt-get install python-rpi.gpio

Packages for OS X screen and file sharing

$ sudo apt-get install netatalk avahi-daemon
$ sudo update-rc.d avahi-daemon defaults

Miscallaneous setup

OS X File and Screen sharing

$ sudo vim /etc/avahi/services/afpd.service
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
 <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
 <service-group>
 <name replace-wildcards="yes">%h</name>
 <service>
 <type>_afpovertcp._tcp</type>
 <port>548</port>
 </service>
 </service-group>

$ sudo vim /etc/avahi/services/rfb.service
<?xml version="1.0" standalone='no'?>
 <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
 <service-group>
 <name replace-wildcards="yes">%h</name>
 <service>
 <type>_rfb._tcp</type>
 <port>5901</port>
 </service>
 </service-group>

Note that rfb port 5901 implies :1 display.

$ sudo /etc/init.d/avahi-daemon restart

I2C

sudo vim /etc/modules

and add these two lines to the end of the file:

i2c-bcm2708
i2c-dev

Next for python support:

sudo apt-get install python-smbus
sudo apt-get install i2c-tools

And finally try the following to test:

sudo i2cdetect -y 1
sudo i2cdetect -y 0

Setup config files

~/.vimrc

 set expandtab "et"
 set sw=4 "shiftwidth"
 set smarttab "spaces for tabs ?"
 set ts=4 "tabstop
 set shiftround
 "Indentations and line numbers
 "set number "nu"
 set autoindent
 set cindent "ci"
 set incsearch "incremental search
 set hlsearch "highlight search
 "line break - causes word granularity wrapping
 set lbr
 set wrap
 "Folding
 syntax on
 syntax sync fromstart
 set foldmethod=indent
 filetype plugin indent on
 syntax enable
 "set invlist
 set showmatch "sm"
 set smartcase "scs no ignore case when pattern has uppercase
 set backspace=2 "bs how backspace works at start of line
 filetype on "filetype detection on
 "dont indent when pasting with middle clicks
 set paste
 " Make shift-insert work like in Xterm
 map  
 map!  
 set nocompatible "dont emulate bugs
 " configure command line completion
 set wildmode=list:longest,full
 " setup status line
 set statusline=%F%m%r%h%w\ [%{&ff}]\ [%Y]\ [%07l,%07v][%p%%]\ [%L]
 set laststatus=2 " always show the status line

~/.cshrc

 set prompt="%~ %# "
 bindkey -v
 set history = 5000
 set savehist = (5000 merge)
 set histfile="$HOME/.tcsh_history"
 history -L
 # Make command history (arrow keys) use history search operations
 bindkey -k down history-search- forward
 bindkey -k up history-search-backward
 setenv MANPAGER less
 alias l ls -lh
 alias cls clear
 alias vi vim -p
 alias vim vim -p

Disable root ssh

$ sudo vi /etc/ssh/sshd_config

Change to following:

PermitRootLogin no

Measure Core Temperature

$ /opt/vc/bin/vcgencmd measure_temp
temp=45.5'C

For other options possible with this command run:

$ /opt/vc/bin/vcgencmd commands

Serial port setup

Remove the following text from the /boot/cmdline.txt file:

console=ttyAMA0,115200 kgdboc=ttyAMA0,115200

And comment out the following from /etc/inittab file:
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

You also might want to install minicom for monitoring:

$ sudo apt-get install minicom

To setup the serial port packages required for use with python:

$ sudo easy_install pyserial

Reboot time

As per my rough measurement it takes around 90-120 seconds for the raspberry pi to be able to accept ssh connections after initiating a reboot. I suspect that this is partly because of my slowish class 4 memory card. I was getting much quicker boot times with the 45MBps UHS-I SD card from my camera.

Change hostname

Update it in the following files and reboot:

$ sudo vim /etc/hostname /etc/hosts

And lastly

Once you are happy with your config remember to make a backup img of your card which you can restore if anything goes wrong.
A useful suggestion I found here was to zero out the free space to get better compression.

# cat /dev/zero > /zeroes ; rm /zeroes

Focus follows mouse on Windows 8

Setting this up is one of the first few things I do after a fresh windows install.

xmouse

Fireup regedit.exe and head to:

HKEY_CURRENT_USER\Control Panel\Desktop

Then tinker with the following (full details of all those regkeys here):

UserPreferencesMask

Bit UI Setting Default Value Meaning
0 Active window tracking 0 Active window tracking disabled.

ActiveWndTrkTimeout

Data type Range Default value
REG_DWORD Milliseconds 0

Specifies time (in milliseconds) that the mouse needs to remain over a window before the window is activated.