Using screen on my Raspberry Pi

I recently got a Raspberry Pi Zero W to play with.  It is a fantastic little development board for only $10. I decided to use it with my smart-home setup to monitor my washer and dryer.

I mostly followed Shmoopty’s Raspberry Pi Appliance Monitor guide.  I, of course, had to use the multiple sensor expert mode instructions.  Why monitor just the washer when the dryer is RIGHT THERE?  With all those extra GPIO pin available, I also added a DHT11 Temperature and Humidity sensor so I can monitor what’s going on in the garage (where my appliances are located).

I did make a small change that I wanted to record here, just so I can possibly remember in the future.  The appliance monitor guide suggests editing the file /etc/rc.local/ to start your sensor monitoring python program in the background.  I thought I might be having some issues with it crashing, so I wanted to be able to jump in and check the output.  My thought was to use my favorite command line tool, screen, for the task.

I didn’t want to create my own .screenrc setup file, so I found one on github by Phawk.  I changed a few lines where he setups up his servers.  They were previously:

# Setup screens
chdir /home/vagrant/Sites # All screens start in ~/Sites folder
screen -t 'server' 0 bash # Make first screen for running server
screen -t 'specs' 1 bash # Make screen for running tests
screen -t 'workspace' 2 bash # Make screen for general work i.e. running git commands

and I changed them to:

# Setup screens
chdir /home/vagrant/Sites # All screens start in ~/Sites folder
screen -t 'washer' 0 python /home/pi/vibration.py /home/pi/vibration_settings.ini # Make first screen for running washer vibration sensor
screen -t 'dryer' 1 python /home/pi/dryer_vibration.py /home/pi/dryer_vibration_settings.ini # Make screen for running dryer vibration sensor
screen -t 'temp' 2 python /home/pi/mqtt.dhtsensor.py 'mqtt/garagetemp1' 'mqtt/garagehumidity1' 2 60 # Make screen for running temp & humidity sensor
screen -t 'workspace' 3 bash # Make screen for general work i.e. running git commands

Now screen 0 monitors my washer, screen 1 the dryer and screen 2 the temperature sensor.  I’ve left screen 3 for myself as a workspace.

I still want this to launch at startup on the Pi, so I added the following line to my rc.local file

runuser -l pi -c 'screen -dmS scripts'

This runs a command as the pi user (instead of root) and creates a detached screen called “scripts”

Now I’m off to the races and getting notifications on Home Assistant whenever my laundry is done!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.