How I configure my Raspberry Pi (Part 2) Updating

See Part 1 for the first steps

After the initial configuration, it is a good idea to update all the packages at this time.

I always connect my Raspberry Pi’s with wifi.  Unless it is a critical application, the cheapest WiFi USB dongle I can find on Aliexpress.com works 🙂

Configure WiFi:

It is easy to do this in the GUI Desktop

Login as user pi  (Usernames, passwords and filenames are case sensitive!)

  1. Type startx at the command prompt
  2. The GUI will start showing a nice raspberry in the centre of the screen
  3. If you use your mouse left handed like me, first set the mouse buttons properly
    1.  In the left bottom corner, click the icon (remember the mouse is still right handed!)
    2. Select preferences and then Keyboard & Mouse
    3. Tick the left handed box – and your mouse is left handed for future use 🙂
  4.  Now select the WiFi Config icon
  5. Click scan,  and double click on the network you wish to connect to
  6. Fill in the required info – such as the network key and click appropriate
  7. See how the wifi connection is established.

Updating:

Open a terminal window

  1. Type sudo apt-get update
  2. Type sudo apt-get upgrade

Both commands require internet access, will use data (which can be substantial!) and will take a while to complete.

 

Posted in Computing, Raspberry Pi | Tagged | 1 Comment

How I configure my Raspberry Pi (Part 1)

As many users there are, as many ways there are to configure a Raspberry Pi.

My configuration follows below.  It works well for me – but I’m changing my procedure as time goes by.

I prefer using the Raspian image rather than Noobs.

In practice this would make very little difference in the way I would configure a new Raspberry Pi (or rather SD Card)

After booting the first time, the Raspi-config utility appears.  This allows one to configure your system from the start.  After closing this utility, one could at any time open it again by typing sudo raspi-config at a command prompt.

Configuration in Raspi-config:

Move between the fields with the up, down arrows and the tab keys

At times it takes a while before something happens after the enter key was pressed

Keep your eyes on the left bottom corner of the screen where text mode action could happen

  1. Change the password!
  2. Expand the filesystem (NOOBS users can skip this)
  3. Enable boot to Desktop/Scratch – I usually skip this initially and if needed configure this at a later time
  4. Set Internationalization Options
    • Change Locale – if you wish – I seldom do
    • Change Timezone – unless you want to live in a funny time 🙂
    • Change Keyboard Layout – depends on your keyboard – Generic 105-key (intl) PC for English (US) works fine for me. Keep the defaults for the other settings
  5. Enable the camera if required
  6. Advanced
    • Hostname: Give your SD card a unique name – at least you know which SD card is being used 🙂 (I use RaspberryPi01 etc)
    • Enable SSH
    • The rest can be set if required
  7. Finish and reboot

Rebooting could take some time.

To run this configuration in future again, just open a terminal window, and issue the command sudo raspi-config

Part 2 shows how to do configure WiFi and how to perform the software updating and upgrading

Posted in Computing, Raspberry Pi | Tagged | 1 Comment

Quick way to get the DS18B20 temperature sensor to work on a Raspberry Pi

The DS18B20is a very easy to use temperature sensor with the Raspberry Pi.

There are lots of articles explaining how to get things working.  Below the way I’m doing it – with reference to the source articles.

A bit of a rough and dirty guide 🙂

Follow process as described in Raspberry Pi 1- Wire Digital Thermometer Sensor

Make the modprobe statements permanent:

sudo nano /etc/modules

add the following lines at the bottom

w1-gpio
w1-therm

and save.

(Reference Adding Modprobe w1-gpio / Modprobe w1-therm to boot)

If required, configure Python:

sudo apt-get install python-pip
sudo pip install w1thermsensor

reference and sample code is available at https://github.com/timofurrer/w1thermsensor

Posted in Computing | Tagged , , | Leave a comment

Setting up your Raspberry Pi to work with a 3G dongle

Getting my Raspberry Pi to work with a 3G dongle was quite a mission.

I’m not a total newbie, but newbie enough to add the warning: Beware – you are entering crocodile infested waters. Don’t complain if the info below is wrong or gets you eaten 🙂

It appears as if there are quite a few myths floating around. Eliminating these myths and finding the real information made for quite a journey.

I have a need to connect my Raspberry Pi via 3G to the internet without any human intervention.

For this blog, I’ll be using a Raspberry Pi B Rev 2, running Raspian released 9 September 2014. I’ve connected a 4 Port USB hub to the Raspi, and in this is a keyboard, mouse and off course the 3G modem (Huawei E1820). This is a very old modem and I assumed that it would be supported.

This blog describes what was required to do after the initial configuration of the Raspberry Pi – all the raspi-config steps were completed as well as apt-get update/upgrade.

No additional packages were installed.

I configured the setup not to boot to X windows, as it adds lots of time on a reboot cycle during testing.   I used the text login screens available – switch between screens using alt-1 or alt-2 etc.

Ok, I did go into the GUI environment to capture the terminal screens 🙂

The 3G modem problem

3G modems are produced to be friendly to Microsoft Windows and to work without hassles in such an environment. To achieve this, such a modem has two modes. The first mode emulates a CD plugged into the USB port, and the second is the actual modem mode. When the modem is plugged into a Windows machine’s USB port, the CD mode is activated and if the drivers and supporting software is present on the computer, the mode is switched to function as a modem. If the drivers and software is not yet present, it is installed.

A very user friendly process – if one is using a Windows machine!

In the Linux environment this obviously won’t work. It is up to the master of the Raspberry Pi to do the configuration so all will work.

The solution

The core of the solution is to install a package usb-modeswitch.

More detail can be found at http://www.draisberghof.de/usb_modeswitch/

The key words from the documentation of usb-modeswitch is:

In most cases, you will be able to use your device without any interaction except plugging it in.

There is a lot of procedures where complicated configuration is required. From this single statement in the documentation, it is clear that this will seldom be required if a commonly available modem is used.

It seems as if the main problem is that the Raspberry Pi boots to slowly for the package to do its work. This could be solved quite easily by forcing the modem configuration step at the end of the boot sequence.

The process I followed involved a lot of Googling 🙂 And even more testing.

The amount of info below seems daunting – but I is not. Stripped to the bare bones, it is less than 10 minutes work to do the configuration. The only reason it looks so daunting, is because I added a lot of the testing steps I took to gain understanding of the process.

I learnt a lot during the process, and the testing approach taken below aims to transfer the same knowledge to you.

During the testing process I observed the following:

  • When booting from zero power, with the modem plugged into the USB-hub, it would not work.
  • Unplugging the modem, and plugging it again into the USB-hub caused the mode switch to happen (“Hot Plugging”)
  • Rebooting without getting the modem to switch resulted in the modem not to switch
  • Rebooting after the modem switching has happened, resulted in the modem being switched to the correct mode again after the reboot completed.

It is important to note that “Hot Plugging” works!

All of this are indicative that the usb-modeswitch package wants to do its work, but can’t at the moment it needs to because the boot process was not advanced sufficiently yet.

The process

Install the required packages

  • sudo apt-get install wvdial usb-modeswitch

(this requires an internet connection)

Now shut the Pi down with sudo shutdown -h now and when it is down, remove the power. It needs to be “cold”.

Boot you Pi with the modem plugged in

Login as user pi

Testing & setting the modem to modem mode

Now a few tests to establish the baseline:

Run the command lsusb – this will list the USB devices currently recognised

2014-11-11-105016_657x221_scrot

The line showing “Huawei” shows the modem is present – but in CD mode

Run the command ifconfig -a – this will show all the networking devices available

2014-11-11-105357_657x281_scrot

Note how few network interfaces are present!

For the 3G dial-up to work, a device link file /dev/gsmmodem is required. Check with ls -al /dev/gsm* if the file is present – it most probably is not!

2014-11-11-105622_657x86_scrot

Now unplug the modem from the USB-hub.

Do the tests again and note the differences against the above tests.

The key observation should be that the lsusb command does not list the modem in any way.

Plug the modem into the hub. Allow a few seconds for the modem to be recognised. Inserting a USB thingie while the computer is running is called Hot Plugging. When the system senses a new USB unit was plugged in, processes start to activate the unit and make it available.

Run the command lsusb – note that the entry for the modem is different.

2014-11-11-111617_657x296_scrot

The line showing “Huawei” shows the modem is present – but it should now be in modem mode.

Run the command ifconfig -a – this will show all the networking devices available

2014-11-11-111735_657x386_scrot

Note that a new network is available: wwan0

Check ls -al /dev/gsm* if the file is present – it should be there.

2014-11-11-111906_657x71_scrot

This proves that the modem can be activated with hot plugging.

Please play around with rebooting before and after hot plugging to see the effect – this is the way I realised how to solve the problem.

Dialing up

The dialup process is managed with wvdial

Edit /etc/wvdial.conf with sudo nano /etc/wvdial.conf

Mine looks like this:

[Dialer Defaults]

Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,”IP”,”internet”
Stupid Mode = 1
Modem Type = Analog Modem
ISDN = 0
Phone = *99#
Modem = /dev/gsmmodem
Username = { }
Password = { }
Baud = 460800

You many need to tweak this according to the settings of your service provider.

To test the dialup execute the command sudo wvdial

Quite a number of lines of informative text will scroll.

Once the command has completed (can take a few minutes), run ifconfig again.

Alternatively: Open another screen and run the ifconfig command while waiting for the above process to complete.

2014-11-11-115314_657x521_scrot

There should now be an entry for ppp0

In the ppp0 section, look for the inet entry – this is the IP number assigned by your service provider to your modem. For the fun, you should be able to log in with SSH from the outside to this IP number. WARNING: Your Raspberry Pi is now connected to the internet and a potential target from all the baddies outside! Make sure your login password is secure and strong!

In real life, one can’t hot plug a modem every time when required. Many applications require that a Raspberry Pi setup must be able to run unattended.

How does one trigger a hot plug event with software?

The answer is simple: The command sudo udevadm trigger

Read more about udev – the Linux Kernel device manager – at http://en.wikipedia.org/wiki/Udev

Using the udevadm trigger command as it is, triggers every device – a bit of a sledgehammer approach to target a single device. It can be refined to sudo udevadm trigger –subsystem-match=usb

Try sudo udevadm trigger –verbose –dry-run and sudo udevadm trigger –subsystem-match=usb –verbose –dry-run in the command line. The additional options are self explanatory.

Now that all is working, it needs to be configured to work at start-up.

For this, a small script file is required.

Do the following commands

sudo -i

cd /root

nano 3GModem.sh

(sudo -i makes you root! BEWARE -YOU HAVE SUPER POWERS!)

My script file contains the following:

#!/bin/bash

sleep 1m

udevadm trigger

sleep 1m

Wvdial

Save the file. Make it executable with chmod 755 3GModem.sh

A few notes on the script:

The first sleep is to ensure that the boot has completed. The second sleep is to allow time for the modem initiation processes to complete. Feel free to experiment and optimise!

Now edit the rc.local file:

nano /etc/rc.local

Add the following line before the exit 0 line:

/root/3GModem.sh &

And save.

The & at the end of the line is essential to allow the boot process to complete.

More info on the rc.local file is available at http://www.raspberrypi.org/documentation/linux/usage/rc-local.md

Now reboot, and you should have internet access via 3G after a few minutes.

The command ifconfig will confirm if the connection was successful or not.

Read more:

A word of thanks to those who assisted in this forum post:
Raspberry Pi Forum: Problems with usb_modeswitch http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=91283

How to setup a USB 3G Modem on Raspberry PI using usb_modeswitch and wvdial https://www.thefanclub.co.za/how-to/how-setup-usb-3g-modem-raspberry-pi-using-usbmodeswitch-and-wvdial

Raspberry Pi’s documentation on RC.LOCAL

http://www.raspberrypi.org/documentation/linux/usage/rc-local.md

Raspberry Pi Forum: GPRS usb modem, Huawei E171 http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=32307&p=624908&hilit=usb_modeswitch#p624908

Posted in Computing | Tagged , , | 5 Comments

LibreOffice on my Raspberry Pi

I had the need to convert some ancient documents created in OpenOffice long ago to MS Word.

Would the Raspberry Pi be up to it?

To install LibreOffice, a “successor” to OpenOffice, on the Raspbian image was quite easy!

All that was required was to open the GUI and click on the Pi Store icon.  This opened the Pi Store, and locating LibreOffice was quite easy.

It seemed if it was a mere click away.  Unfortunately, this was not true.  Before one can download from the Pi Store, one has to register with IndieCity where the store is hosted.

This was easy enough, and downloading and installing LibreOffice was easy.

Performance wise I did not expect much – the Raspberry Pi was never intended for heavy lifting 🙂

Opening LibreOffice took just less than a minute from clicking on the LibreOffice Writer link in the start menu section.

Opening a 4 page document of simple headers and text took about 15 seconds to open, and a 96 page document similar to the 4 pager took about 1 minute to load.

And yes:  The task of converting the documents from SWX to DOCX was a success.

 

 

Posted in Uncategorized | Leave a comment

Raspberry Pi – Information Sources

Once you have your Raspberry Pi, and configured your SD card and had it boot for the first time, it is time for a big shock: Actually the Raspberry Pi does nothing – unless you make it do something.

Yes, one of the reasons I bought a unit, was exactly this: It is a blank slate on which YOU must make your own painting. Yes, there are many tools to assist. But it still is YOU that must make it work.

I read lots about the active community and the support these people provide. And yes, this is true.

But only after one survived the second shock: It seems as if Noobs are in the minority – the forums is populated with people writing about weird and wonderful things – advanced uses.

And somewhere along the line Noobs need to start.

The wonderful thing is: Noob questions tend to be answered on the forums mostly in a very nice way.

Some of my articles are summaries of what I learnt from the Raspberry Pi forums.

As I grow, I guess I will also be able to start answering. But in the mean time, I will be publishing what I learn.

This page is dedicated to a list of resources I found.

A listing does not imply that I agree or recommend the content – at the most that I found the content behind the link interesting.

The list will grow with time.

The Raspberry Pi forum
The Raspberry Pi Guy on YouTube

Added 3 Jan 2013

Raspbian

Posted in Computing | Tagged | Leave a comment

First Python steps on my Raspberry Pi

Just to start: I share the experience of a novice – you are entering crocodile infested water – please don’t blame me if a crocodile bites you!

I received my Raspberry Pi and played around a bit.

Time to start learning.

I did some programming in my younger days – Fortran 77, Cobol, Basic on an Sharp ZX something – real state of the art stuff.

Later I did some work in PHP.

But Python is a new animal to me.

I downloaded the MagPi issue 1 (See http://themagpi.com) and started with the Python Pit.

An immediate flaw in the article struck me:  Nowhere it says how to run a Python script.

Fortunately the Raspberry Pi forums came to my aid – see http://nvdd.info/VuyZQt

I found three ways to run a Python script: Interactive and two ways from the commandline.

To run a script interactive, just type ‘python’ at the command prompt. Note no capital!

Now type

print (“*** Welcome to The Python Pit! ***”)

Followed by enter, and things happen.

I tried to exit with the trusted Cntrl-c, but received a well constructed error message – it actually made sense, and following the instructions even worked!

The second way is to actually store the code in a file on the SD card (or other disk space) and run it from the commandline.

The first step would be to create a directory to store the python file.

I did a cd /home/pi followed by mkdir Magpi and cd Magpi mkdir python cd python mkdir Issue1 cd Issue1

Then nano python1.py

I then copied the code from the MagPi

# PUTTING TEXT ONTO THE SCREEN
# By Jaseman – 23rd April 2012
print (“*** Welcome to The Python Pit! ***”)
print () # A line space
print (“Brought to you by The MagPi”)

Followed by Cntrl-X and responding appropriately to the prompts.

Doing ls -al at the commandline prompt returned
-rw-r–r– 1 pi pi 169 Dec 31 17:57 python1.py

As Linux users will know, the first few -rw…. characters indicate the rights assigment for the file – as there are no x’s, it means this file can’t be executed.

Easy to correct – just type

chmod 755 python1.py

ls -al should now return

-rwxr-xr-x 1 pi pi 169 Dec 31 17:57 python1.py

now try

python python1.py

and the script actually runs!

The next way to run the script is to add a line right at the start of the script – you can use nano python1.py

#!/usr/bin/python

Save, and then run the script with

./python1.py

at the command prompt.

So now I know how to run python on my Raspberry Pi.

Best of luck to all the readers of this article

PS: READ the MagPi – it is a great source of info! I’m learning lots from very knowlegable authors!

Posted in Computing | Tagged , , | 2 Comments

Raspberry Pi – Running Headless – GUI

Previously I wrote about setting up the SSH server on my Raspberry Pi.

I managed to get the GUI running as well.

An X-Windows session on my Windows 7 PC.

Actually it is quite easy – just follow the isntructions at http://www.penguintutor.com/linux/tightvnc in the finest detail!

It does not seem as if TightVNC allows sound to be remoted.  Does anybody know of a way to do this?

I did configure the SSH tunnel for security, but turned it off again.  I could not get my Android tablet to connect.  As I will be accessing the Raspberry Pi only from my home network, security is not much of an issue.

Now for some more fun 🙂

Posted in Computing | Tagged | Leave a comment

Raspberry Pi – Running Headless – Commandline

I prefer to run my Raspberry Pi headless – this is without screen, keyboard or mouse.  It simply saves space and avoids a lot of clutter.

It is also just so convenient – having my Raspberry Pi as just another window on Windows laptop.

The first level of running headless, is to have commandline access.

This requires to enable the SSH server on the Raspberry Pi, get the IP Address of the unit, and accessing the Raspberry Pi from the Windows laptop with SSH.

On the Raspberry Pi:

For this phase, a monitor and keyboard must be connected to the Raspberry Pi.  I used an ancient TV set. Readable but not great.

I’m using the latest Raspbian version.

Login as user Pi

run sudo raspi-config
(More help here)

This starts the Raspi configuration utility.

Select the ssh option, and enable the ssh server.

Select Finish. (Hint – use the TAB key)

Ensure the Raspberry Pi is connected to the LAN.

Get the IP address.  By default the unit is configured to use DHCP to obtain an IP Address.

Type ifconfig <enter>

Find the section for eth0 and in there

inet addr:192.168.1.100

The IP address will vary – possibly everytime you reboot.

On your Windows machine:

It is possible to get the Raspberry Pi’s IP Address on your Windows machine as well – essential if you don’t have a monitor and keyboard connected to the unit.

The IP Scanner downloaded from http://www.advanced-ip-scanner.com works great to get hold of your Raspberry Pi’s IP Address.

Install Putty – this is an SSH client for MS Windows.
PuTTY Download Page http://nvdd.info/UhEWDu

Open Putty and connect with SSH to the IP number for the Raspberry Pi.  Login as user Pi

You should now see a command line console.

 

Posted in Computing | Tagged | Leave a comment

Gross Domestic product – very visible

At

http://nvdd.info/TChlLr

one can graph the Gross Domestic Product of many countries (if not all) as well as groups of countries – eg the Euro Zone in comparison to each other.

As a South African, I found it very interesting to plot the GDP of South Africa against the USA, UK Germany and even the much maligned Greece.

Posted in General Interest, Uncategorized | Tagged | Leave a comment