Skip to content

Commit 57f40ac

Browse files
committed
Extend README documentation. Add files for Raspberry Pi set-up.
1 parent 594fedc commit 57f40ac

5 files changed

Lines changed: 117 additions & 0 deletions

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,33 @@ the - lead needs to be connected to ground (I chose pin 6).
3434

3535
The web client only displays the indoor temperature and humidity values when connected to the
3636
web server on `localhost:8080`.
37+
38+
I can't guarantee that I'm recalling every important step I took to create my own set-up, but
39+
hopefully the following is a more-or-less complete guide to setting up a Raspberry Pi to
40+
automatically boot up as a full-screen astronomy/weather clock:
41+
42+
1) Install the Chromium browser if it's not already installed:
43+
`sudo apt-get install chromium-browser`
44+
2) Install unclutter (this will hide your mouse cursor after 30 seconds of inactivity so it doesn't
45+
obscure the display): `sudo apt-get install unclutter`
46+
3) Install an up-to-date node.js. (You can find instructions for this step here: https://www.w3schools.com/nodejs/nodejs_raspberrypi.asp.)
47+
4) Copy the contents of this project's `server` folder to `/home/pi/weather`.
48+
5) If you wish to use an indoor temperature/humidity sensor, follow the previously mentioned
49+
steps to install the BCM 2835 library and connect the sensor.
50+
6) `cd /home/pi/weather`
51+
7) `npm install`
52+
8) Build the client project as described above, and copy the contents of the `dist` directory to
53+
`/home/pi/weather/public`.
54+
9) Copy the included file `weatherService` to `/etc/init.d/`. Make sure the file is owned by
55+
`root` is set to be executable. Follow the instructions listed inside that file to set up
56+
the necessary environment variables, including setting `HAS_INDOOR_SENSOR` to `true` if you're
57+
connecting an indoor temperature/humidity sensor.
58+
10) Use the command `sudo update-rc.d weatherService defaults` to establish the service that
59+
starts up the weather server.
60+
11) Copy the included files `autostart` and `autostart_extra.sh` to
61+
`/home/pi/.config/lxsession/LXDE-pi/` and make sure they're executable. This launches the
62+
astronomy/weather clock client in Chromium, in kiosk mode (full screen, no toolbars). It also
63+
makes sure Chromium doesn't launch complaining that it was shut down improperly.
64+
12) I'm not sure about the current copyright disposition of these fonts, but for improved
65+
appearance I'd recommend finding and installing the fonts "Arial Unicode MS" and "Verdana".
66+
These appear to be freely available for download without licensing restrictions.

raspberry_pi_setup/autostart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@lxpanel --profile LXDE-pi
2+
@pcmanfm --desktop --profile LXDE-pi
3+
/home/pi/.config/lxsession/LXDE-pi/autostart_extra.sh
4+
@xscreensaver -no-splash
5+
@point-rpi
6+
@chromium-browser --kiosk http://localhost:8080/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
/bin/sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/pi/.config/chromium/Default/Preferences
3+
/bin/sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/pi/.config/chromium/Default/Preferences
4+
/usr/bin/unclutter -d :0 -idle 30

raspberry_pi_setup/weatherService

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/sh
2+
#/etc/init.d/weatherService
3+
#
4+
# Based on: https://www.exratione.com/2013/02/nodejs-and-forever-as-a-service-simple-upstart-and-init-scripts-for-ubuntu/
5+
#
6+
### BEGIN INIT INFO
7+
# Provides: weatherService
8+
# Required-Start: $local_fs $remote_fs $network $syslog $named
9+
# Required-Stop: $local_fs $remote_fs $network $syslog $named
10+
# Default-Start: 2 3 4 5
11+
# Default-Stop: 0 1 6
12+
# Short-Description: starts weatherService
13+
# Description: starts weatherService using start-stop-daemon
14+
### END INIT INFO
15+
#
16+
17+
NAME="weatherService"
18+
NODE_BIN_DIR="/usr/bin/node"
19+
NODE_PATH="/usr/lib/node_modules"
20+
APPLICATION_PATH="/home/pi/weather/app.js"
21+
PIDFILE="/var/run/weatherService.pid"
22+
LOGFILE="/var/log/weatherService.log"
23+
MIN_UPTIME="5000"
24+
SPIN_SLEEP_TIME="2000"
25+
26+
# Define DARK_SKY_API_KEY, HAS_INDOOR_SENSOR, etc., in the file below:
27+
[ -f /etc/default/weatherService ] && . /etc/default/weatherService
28+
29+
PATH=$NODE_BIN_DIR:$PATH
30+
export NODE_PATH=$NODE_PATH
31+
32+
start() {
33+
echo "Starting $NAME"
34+
forever \
35+
--pidFile $PIDFILE \
36+
-a \
37+
-l $LOGFILE \
38+
--minUptime $MIN_UPTIME \
39+
--spinSleepTime $SPIN_SLEEP_TIME \
40+
start $APPLICATION_PATH 2>%1 > /dev/null &
41+
RETVAL=$?
42+
}
43+
44+
stop() {
45+
if [ -f $PIDFILE ]; then
46+
echo "Shutting down $NAME"
47+
forever stop $APPLICATION_PATH 2>&1 > /dev/null
48+
rm -f $PIDFILE
49+
RETVAL=$?
50+
else
51+
echo "$NAME is not running"
52+
RETVAL=0;
53+
fi
54+
}
55+
56+
restart() {
57+
stop
58+
start
59+
}
60+
61+
case "$1" in
62+
start)
63+
start
64+
;;
65+
stop)
66+
stop
67+
;;
68+
restart)
69+
restart
70+
;;
71+
*)
72+
echo "Usage: {start|stop|restart}"
73+
exit 1
74+
;;
75+
esac
76+
77+
exit $RETVAL

0 commit comments

Comments
 (0)