Useful Raspberry Pi Commands

To see all the ttyUSB connections enter ls /dev/ttyUSB*

To see all devices connected to USB enter sudo lsusb

Ctrl C normally quits from commands that provide a continuous output

To view installed packages enter dpkg -l | grep ii | less (that’s a lower case L not a 1) Use Enter to scroll down and q to quit.

To restart the Raspberry Pi enter sudo shutdown -r now


Using the Arduino’s Serial Monitor on the Raspberry Pi

Serial Monitor showing GPS data

once you have installed the Arduino IDE on the Raspberry Pi it is possible to use the Serial Monitor with almost any Serial device acting as a Terminal program like Putty on windows.

Two useful devices are a Serial to USB lead and a TTL to USB adaptor, both these are available on eBay for less than £5. I used. jY-MCU USB Adaptor for Arduino, this device had a full size USB connector and 5 pins to connect TTL signals. Any FT232 or PL2303 device should be OK. Try to get one with a full size USB connector that will plug into the Raspberry Pi, if not an adaptor lead will be needed.

Plug the TTL to USB adaptor into the Pi boot up and enter the following command

Sudo lsusb
This will list all the USB devices and my adaptor showed up as Future Technology FT 232. Shutdown the Pi and remove the adaptor. Four pins are needed, 5v supply, shown as VBus on my device, Gnd, Tx and Rx.
I wanted to connect an Adafruit Ultimate GPS board to the Raspberry Pi, but following the instructions on the Adafruit site and installing the recommended software I saw no output from the GPS device, even though it showed it had a Fix.

This was when I decided to try using the Arduino Serial Monitor. I connected the GPS board to the TTL to USB as follows

Gnd. —– Gnd
Vin. —- VBus or 5 volts
Tx —-Rx
Rx. —- Tx

Plug the adaptor into the Pi and boot up. From the desktop launch the Arduino IDE, select Serial port as ttyUSB0 and start the Serial Monitor. The speed should be set to 9600. Data from the GPS will be shown as in the picture above. Now it’s time to write the python script to read the data!

Installing the Arduino IDE on the Raspberry Pi

Installing the Arduino IDE on the Raspberry Pi allows you to program your Arduino fro the Pi. The normal instructions require you to use apt- get, but this installs an old version. Whitewitch has uploaded a script on GitHub to upload the latest Arduino IDE (August 2014).

Once you have finished installation you are asked if you want to add a desktop shortcut, the Arduino Is connected to the Raspberry Pi via the USB lead. I found that i had to set the port to /dev/ttyACMO in the Tools/Serial Port tab. To try the system out compile and upload Blink.

Many thanks to whitewitch for this.

Showing the memory usage on a Raspberry Pi

A simple way to show the memory usage on a Raspberry Pi is to open the terminal program and enter

free -h -s 1

-s 1 requests an update every second. A table is displayed showing the total memory available, memory used and memory remaining. I take the memory used, divide by the total memory and multiply by 100 to get the percentage memory used. In my case running Icecast2 and MPD I use 72% of the available memory.

Using the TinyOS Bluetooth Bee Shield with an Arduino

Setting Up

Arduino sketches for testing this shield can be found on my Github page here

Before you start you need to identify the location of several important parts. Hold the bluetooth Bee shield so that the Bluetooth Bee board is at the top. Arduino pins 0 and 1 will be at the top left. Top right of the board, alongside the Arduino Analog pins is a small silver swith with two positions. UART is the top position and DLine is the bottom position.

On the Bluetooth Bee board is a small black double switch, ensure both the small white switches are on the left hand side (normal running position).

Look carefully alongside the Arduino header pins 0 and 1 there are two pairs of very small rectangular pads marked 2 and 3.

An android phone works well when testing the Bluetooth shield. Install a bluetooth App such as Blueterm

Testing the shield using the hardware serial port:

1. Ensure the UART/DLine switch is in the UART position.

2. Ensure both the small white switches are to the left, closest to pin 10 on the Bluetooth Bee board.

3. Upload the Serial port sketch and switch on the Serial Port Monitor. Run Blueterm on your android. The green state led on the Bluetooth Bee board will be flashing green.

4. Click on Connect Device, then Scan for new devices you should see Bluetooth Bee (mine also showed it as 20:13:06:25:06:92). Select this and if requested enter 1234 as the pairing code.

5. The green led will switch off and the blue led will switch on showing the two units are paired.

6. Instructions for turning pin 13 LED on the Arduino On and Off are shown on the Android device.

7. Press key 1 on the Android keyboard and the Led will turn on. Press 0 (zero) and it will turn off. The LED status is shown on the Android device.

Testing the shield using the software serial port:

In the advertisment for this shield it made it sound like the Bluetooth board was connected to Arduino pins 2 and 3, in fact they are not until the two small solder pads marked 2 are soldered together and those marked 3 are soldered together. To give me more flexibility and to be able to use this shield on a Mega 256, I soldered a two pin female header to the prototyping area. Using very fine copper wire I connected this header socket to the two small through plated holes just blow the pads. Now, using jumper wire, I can connect to any pins I want to use for Software Serial.

1. Switch off the Arduino, move the UART/DLine switch to DLINE. Connect up the pins you want to use for Software Serial (or use 2 (RX) and 3 (TX) if you simply shorted the solder pads. Upload the Software Serial sketch.

Connect to your Android device using Blueterm, and messages can be sent from the Android to the Arduino through the Serial Monitor, and to the Arduino from the Android using Blueterm.

Sending AT Commands:

Switch off the Arduino, ensure the UART/DLine switch is in the DLine position and the top white switch on the Bluetooth Bee board is moved over to the RIGHT hand side.

1. Upload the AT Command sketch and the green State LED will flash slowly. Communication to the Bluetooth board is through the Software Serial at a speed 38400 and communication to the Arduino is through the Hardware Serial Port at a speed of 9600.

2. in the Serial Monitor ensure that NL & CR is selected from the drop down menue at the bottom of the screen.

3. Type in AT and click on the SEND button. OK will be printed in the Serial Monitor. Type in AT+UART? and click SEND. The current speed (9600,0,0) will be printed in the Serial Monitor.

4. Adjust the AT commands as you wish. Switch off the Arduino and return the top small white switch to the left hand side.

The board is now fully functional. The only problem I found was that I could not upload a sketch with the shield in place, even with the UART/DLine swith in the DLine position.

Icecast2 and the Raspberry Pi

Icecast2 is a free audio streaming server which supporting the shoutcast protocol. MPD is a music player daemon which serves as a backend for playing audio. MPD uses the shoutcast library to stream to icecast2. Fortunately, Raspbian MPD is compiled with libshout and also mp3 support by default so we don’t have to build any custom packages. MPC is a command line client to control MPD, for example to manage playlists or to start/stop playing a song.

This website provides a good explanation on how to add Icecast2 to the Raspberry Pi

MPC and MPD will have to be installed first along with ensuring audio is set up correctly.

Siemens TC35 Mobile Phone and Arduino Project Part 2

The easiest way to try out the TC35 is to connect it via a Serial to USB connector lead. These leads can be obtained from eBay for about £1.50 in August 2014.

A power supply is needed, I used a 5 volt 1.0 amp supply and although a 2 amp supply is recommended this only seems to be needed when transmitting voice. You will need a terminal program like RealTerm or Putty, both are free to download, but I prefer RealTerm.

You need to determine the Com port being used, so plug the USB to Serial lead into the PC and open up the Windows Control Panel. Click on the System / Hardware / Device Manager Tab and look for the Ports, (Com and LPT) make a note of the port used by the USB to Serial lead. Mine showed USB – SERIAL CH340 (Com7). Later versions of Windows , from Windows 7, should find the driver automatically. Earlier versions will need a driver which you can normally find on the Internet, I just searched for ‘driver for CH340’.

Now open up the terminal program, enter the port and speed details (9600 for the TC35). Make sure a SIM card has been inserted and connect the Serial to USB connector. Apply power to the TC35, the top left LED will light. Press the button and the top right LED should light up, flashing ON for 600 ms then OFF for 600 ms. This shows the unit is activated, but not connected to a Network. If the flash rate changes to a brief flash, followed by a long pause it shows the unit has connected to a Network. My unit has never connected automatically and I always manually connect it.

In your terminal program type AT followed by ENTER, the unit should respond with OK if not check the connections and that the correct port and speed have been entered. Type AT+COPS=? And the available networks will be listed. The five digit code is made up of 234 for the UK and 33 for Orange, 15 for Vodaphone and 10 for O2. To manually connect to your service type:
AT+COPS=1,2,23433 for Orange, or AT+COPS=1,2,23415 for Vodaphone. Note you can only connect to the network supported by your SIM, although an EE card will connect to Orange, One2One and TMobile.

To confirm you are connected the LED will flash briefly with a long pause. Type AT+CREG? And the response should be 0,5 to show the network was connected manually.

Once you have confirmed that the unit is working correctly you can move on to controlling it with an Arduino.