Accessing 1-wire devices on Raspberry Pi using OWFS

To connect 1-wire serial devices to the RPi I am using a DS9490R USB 1-wire adapter (rather than wiring I2C 1-Wire master components to GPIO I2C – which I might look at sometime down the track)

Install packages

sudo apt-get install owfs ow-shell

Edit config file

vim /etc/owfs.conf

! server: server = localhost:4304
# USB device: DS9490
server: usb = all
######################### OWFS ##########################
mountpoint = /mnt/1wire
allow_other
####################### OWHTTPD #########################
http: port = 2121
####################### OWFTPD ##########################
ftp: port = 2120
####################### OWSERVER ########################
server: port = localhost:4304

Create Startup Script

I created a startup script for owfs modelled on the owserver script (not sure why this one is actually missing)

vim /etc/init.d/owfs

#!/bin/sh
### BEGIN INIT INFO
# Provides: owfs
# Required-Start: $remote_fs $syslog $network $named
# Required-Stop: $remote_fs $syslog $network $named
# Should-Start: owfs
# Should-Stop: owfs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: 1-wire file system mount & update daemon
# Description: Start and stop 1-wire file system mount & update daemon.
### END INIT INFO
CONFFILE=/etc/owfs.conf
DESC="1-Wire file system mount"
NAME="owfs"
DAEMON=/usr/bin/$NAME
case "$1" in
start)
echo "Starting $NAME"
$DAEMON -c $CONFFILE
;;
stop)
echo "Stopping $NAME"
killall $NAME
;;
*)
echo "Usage: $N {start|stop}" >&2
exit 1
;;
esac
exit 0

Starting daemons

/etc/init.d/owserver start
/etc/init.d/owfs start

Checking output

#ls /mnt/1wire/

Should show output similar to:

10.575349000000 12.95DD17000000 alarm simultaneous uncached
10.575349000000 12.95DD17000000 bus.0 statistics
12.57DD16000000 81.B2EA2E000000 bus.1 structure
12.57DD16000000 81.B2EA2E000000 settings system

cat /mnt/1wire/10.575349000000/temperature

Will then show the temperature of the particular DS18S20 temperature sensor.

Installing OMXPlayer on Raspberry Pi

Since I didn’t have any luck playing videos on the RPi using mplayer I found omxplayer after some search. It has the ability to use the RPi’s GPU thus taking some load of the CPU.


UPDATE 2013-04-01: omxplayer is now included in the Raspbian (Debian Wheezy) repositories and can be simply installed by one line.

sudo apt-get install omxplayer

Check another article on how to install Raspbian.


OMXPlayer binary (.deb) downloads can be found here: http://omxplayer.sconde.net/

Install dependencies

apt-get install libpcre3 fonts-freefont-ttf fbset libpcre3-dev libpcrecpp0 libva-dev libva-x11-1 libva1

Install omxplayer

wget http://omxplayer.sconde.net/builds/omxplayer_0.2.4~git20121205~ec7ac68f_armhf.deb
dpkg -i omxplayer_0.2.4~git20121205~ec7ac68f_armhf.deb

Play video

omxplayer -o hdmi video.mp4

Note: If there is no sound when playing through the HDMI interface make sure your /boot/config.txt file has the following line (and it’s not commented out).

hdmi_drive = 2

OMXPlayer Key bindings

Key Action
1 Increase Speed
2 Decrease Speed
j Previous Audio stream
k Next Audio stream
i Previous Chapter
o Next Chapter
n Previous Subtitle stream
m Next Subtitle stream
s Toggle subtitles
q Exit OMXPlayer
Space or p Pause/Resume
Decrease Volume
+ Increase Volume
Left Seek -30
Right Seek +30
Down Seek -600
Up Seek +600

Raspberry Pi – Text to Speech

Just a quick note on Speech Synthesis a Raspberry Pi project. I had to research some of the options on the Raspberry Pi while looking into a project where I need some audio announcements.

Configuring Sound

echo 'snd-bcm2835' >> /etc/modules
sudo modprobe snd-bcm2835

sudo apt-get install mplayer alsa-base alsa-utils pulseaudio mpg123
# make mplayer use mpg123 codec instead of default ffmp3float
echo "afm=mp3lib" >> ~/.mplayer/config

Since I am using Raspbian which is a Debian based (Wheezy) Distribution I used some Ubuntu documentation (https://help.ubuntu.com/community/TextToSpeech) as the starting point.

Festival

sudo apt-get install festival festival-english
echo "Hello World - Testing" | festival --tts

Plus: Local install (no internet connection required)
Minus: Mechanical sounding voice

Espeak

sudo apt-get install espeak
espeak -v en "Hello World - Testing"

Plus: Local install (no internet connection required)
Minus: Mechanical sounding voice (slightly better than Festival)

Google Translate

Create a shell script tts.sh
#!/bin/bash
mplayer -ao alsa -noconsolecontrols "http://translate.google.com/translate_tts?tl=en&q=$*" > /dev/null 2>&1

chmot +x tts.sh
./tts.sh "Hello World - Testing"

Plus: needs live internet connection
Minus: excellent human sounding voice

Google Speech API

I will most likely look at this in the long run to get better control rather than calling the Google Translate url too much.