The for the past few decades model railroading has been looking more like 1970s Silicon Valley garages. Electronics bits strewn everywhere. On deck today is prototyping a microphone for our CabCams. It is turning out to be easier said than done.
Another success, hopefully next year we get to do this in person as well.
If you joined us for our Fall Virtual Open House thanks for joining us and we hope you had a good time. If you would like to inquire about a remote operations or in person membership please email firstname.lastname@example.org.
The day started off with some JMRI troubles but after a quick pivot we got trains running and were able to get our trains back on schedule pretty quickly. As the day progressed it became apparent that even with our new Raspberry Pi Zero 2 W powered CabCams we could use more wireless access points to alleviate some issues with the small antenna on the Zero 2.
And now for some photos.
A different remote engineer pilots Northern Pacific 6504 past the orange groves of Fremont and Farmer Jensen’s produce.
Well that is all for now, keep an eye on our events page for the next virtual open house and hopefully our summer in person open house. If you subscribe to our YouTube you should get notified of all our live streams.
Thanks for joining us!
This is a updated version of the CabCam instructions as recent package updates and new versions of Raspberry Pi OS have broken the old instructions. This is a much simpler version as most of the work has been done and placed in a SD card image for you. The old instructions will still be visible on the website but will have a warning that you should NOT use them right now.
As Silicon Valley Lines adapts to the current global pandemic, it has become clear we will not be meeting as a full club in person for some time. This has spurred our search for a solution to allow us to run operating sessions and have fun with trains as SVL is foremost a operating layout. We tried a few approaches but it quickly became apparent that we need to give remote operators a way to get immersed with running a train on the layout. We wanted to provide a view from the locomotive cab that is fast and responsive. Thus the SVL CabCam Project was born. In addition we provide layout overview cameras and/or views from key locations on the railroad.
This write-up is the result of a lot of trial and error, getting products fully running then realizing the end-to-end latency was so severe it wouldn’t be workable. It is intended as a general overview for hobbyists wishing to get a track-level view of their own layout, and provides technical instructions for replicating our approach.
A cab view camera is useful for more than remote operations during COVID. Local ops sessions can benefit from this as well.
We describe how to set up a small computer to stream cab view video from an HO locomotive. This allows remote operation of trains at local or remote layouts, optionally connecting it to video conferencing software like Google Meet or Zoom.
- Easy to set up and maintain.
- Easy to access the cab view via a URL or via conference software eg. Zoom or Meet.
- Distribute the setup to others for the betterment of the hobby.
- Provide a low latency video stream to enable remote control via Engine Driver/WiThrottle
- Keep the hardware within HO NMRA clearances.
- Use commonly available components and open-source software where possible.
Hardware: We are using one Raspberry Pi Zero W 2 per CabCam car. The original Zero works as well but is slower.
Camera: The Pi Zero Spy Camera works well for our purposes.
Software: The project uses Raspian Buster running MJPG Streamer on the CabCam car. This streams video from a URL on the local network. The video can be viewed locally or streamed to conference software via OBS and the OBS VirtualCam plugin. This software runs Raspberry Pi OS Buster(Debian 10). Debian 11 or Raspberry Pi OS Bullseye does NOT work as of yet.
Power: The Juiceb0x Zero is a “hat” for the Pi Zero. While the Pi Zero WH comes with the required header already installed, soldering is required to install header pins on the Juiceb0x Zero board.
Rolling Stock: The easiest approach is build a mounting sled out of styrene as shown below. With a little bit more work the setup can be installed inside a dummy engine, too.
This section describes the setup in more detail. Some familiarity with Raspberry Pi and respective software management is helpful.
1. Gathering the hardware
You will need for the self contained unit.
- Raspberry Pi Zero 2 W
- Juiceb0x Zero
- 160 Degree Pi Zero Camera
- 2×20 header pins 0.1in
- 3.7V Li-Ion battery 2000 mA or larger
- SDHC card 4GB or larger
- Male 2×20 header
- USB charger with microUSB charging cable
For the cheaper unit running a battery bank:
2. Setting up the hardware
Solder the male header to the Pi Zero 2. Connect the camera to the Pi Zero 2 W. Solder the header pins to the Juiceb0x Zero per the instructions that come with it and attach it to the Pi Zero 2. Connect the battery to the Juiceb0x Zero. Connect the USB charger to the Juiceb0x Zero to charge the battery.
Never connect power to the USB ports of the Pi Zero 2 W while the Juiceb0x Zero is attached.
For the cheaper version you need plug in the camera then plug the USB micro cable into the power bank and then into Pi Zero. Be mindful of your NMRA gauge, if you need to you can build a sled to hold the Pi Zero on its side so the USB cable is vertical.
3. Burning the image and setting up the software
Here is where things start to break away from the old setup instructions.
Download our CabCam public image below. This Buster OS and it already has MJPEGStreamer installed on it and is ready to go with just the addition of the WiFi Supplicant. You should change the passwords on these once they are on your WiFi as it is using the default credentials for everything.
SHA256 Hash: 11D6D5388142DD15DAB0957B5E9CB5D9240B2DC95022F612576B157152BA7EF1
You can check this link to see exactly how things were configured.
Download Balena Etcher for your OS. If you run Google Drive on your computer make sure to exit out of it for this next process. Open balenaEtcher and click flash from file, then select CabCamPublic.img. Then in the next spot over select your 8gb SD card. balenaEtcher should not let you select your OS drive but double check you have the right one. Then hit Flash. This will flash your file to the card and verify it. If it fails check your file to make sure it fully downloaded then check to make sure you don’t have Google drive or another type of network drive mounted.
Remove the SD card when it succeds and insert it into the raspberry pi and let it power on. Please give the Pi 5 minutes to boot up and expand the filesystem. Once this is done unplug the Pi and insert the SD card back into your computer for the next step.
4. WiFi Setup
Now we will configure wifi for your home or club network. With a text editor (Notepad++ on Windows) create a file named wpa_supplicant.conf in the boot folder on the SD card. Paste the following text to this file.
Change the country code to your two character country code per the ISO 3166 alpha-2 country code. For many of us it will likely be US or GB. SSID refers to your wifi network name and PSK is your network’s password. Do not remove the quotes. Make the respective changes for your network and save the file.
SSH is already enabled.
Eject and remove the SD card from your computer, insert it into the Pi, and power up the Pi by moving the small slider switch on the Juiceb0x Zero to On. The blue LED on the Juiceb0x Zero should light up, and you should see flashing green lights. Some cameras have LEDs on the connector strip, those should light up briefly as well. Give the Pi about two minutes to boot up.
5. Logging in to the Pi
Find the IP address your Pi is using via your router and log in using ssh as user pi. You may get away with just typing cabcam.local
The default password is raspberry.
On a Mac use Terminal. On Windows use PuTTY (you may have to download it) and put in the IP of your Pi in the Hostname block. Try cabcam.local if you can’t find the IP. When you connect, the default username is pi and the password is raspberry.
On many networks the following also works:
6. Configuring the Pi
Once on the Pi command line type
to enter the configuration page for the Pi. First enter Change User Password and enter a new password if you want to secure the device. Next enter Network Options, select Hostname, and give your Pi a unique name like CabCam1 or similar. This is helpful to identify which Pi is which if your network supports hostnames. After that finishes, exit the configurator and allow the Pi to reboot.
7. MJPG Streamer is already installed.
Now we are going to configure the software to allow us to stream the cab POV and you can configure the settings you want.
Test the stream with the following command that uses the parameters we use at SVL.
mjpg_streamer -i "input_raspicam.so -x 480 -y 360 -fps 10" \-o output_http.so
Point the browser on your computer to http://IP:8080?action=stream (replace IP with the IP address for the Pi from earlier). If you see output from your camera you are ready to move on. In the terminal, hit Ctrl+C to close the stream.
The Internet uplink bandwidth at SVL is quite limited. For cab control with remote operators we found that SD resolution is sufficient and limits bandwidth demand. We are using a frame rate of 10 images per second. The stream doesn’t get smoother turning this up. If your camera is upside down you may need to insert -rot 180 before -fps.
The camera stream is set to startup on boot. You will need to edit this if you change the settings above.
Enter the following
sudo nano /home/pi/startcam.sh
The following text will be in the text editor, edit it as needed.
-i "input_raspicam.so -x 480 -y 360 -rot 180 -fps 10" \
Hit CTRL+X to leave the editor, hit Y and Enter to write the file to the SD card.
Reboot the Pi with sudo shutdown -r now. After reboot you should be able to see the stream in your browser at the URL you used above. After placing the camera on a flatcar, it should look something like this.
Put your CabCam car on the front of a train, and run the train while watching the video stream in the browser.
Bernhard wrote down some thoughts on camera placement and car choice on his blog.
9. What’s Next?
To stream the video to remote operators we use OBS with the built in Start Virtual Camera option, configured with CabCam feeds. This is connected to Google Meet and can even stream to Youtube Live. Other video conferencing software like Zoom, Duo, Skype, etc. can be used, too. Remote operators join the video conference and use Engine Driver or WiThrottle to control trains via JMRI over a VPN. We’ll cover that in a separate post.
Hardware: While we are using a Raspberry Pi Zero 2 W, any Pi with built-in Wifi will work.
Camera: Any compatible Raspberry Pi camera can be made to work. Possible options are the official Pi camera, the spy cameras, or other compatible cameras available from e.g. Adafruit.
Power: The Zero2Go board is an alternative to the Juiceb0xZero. However, the Zero2Go can’t charge the battery. In either case, do not power the Pi from the onboard USB while the power solution board is attached.
Some people had success with using a small form-factor USB power bank connected to a Pi Zero without additional hardware.
Over time we have made corrections to these instructions, or fine tuned settings. Below is a list of important revisions.
- Fixed a bug with double quotes in the startcam.sh example above.
- Reduced video resolution from 640×480@15fps to 480×360@10fps to help with bandwidth usage in certain Wifi environments.
- Various spelling and grammar corrections.
UPDATE: Sign ups will be closed at midnight PST. Join us on our YouTube stream.
Nov 13th 2021 10am to 3pm PST
Still plenty of slots open!
Pick up a throttle(virtually) to take a virtual spin around the Silicon Valley Lines layout for our Fall 2021 open house event. This event is open to all ages, first time operators and professionals alike.
What: SVLs Virtual open house where you can take control of a train on our 23’x73′ layout and get a engineers POV of our layout and a light demonstration of our virtual operating sessions ran monthly.
When: Saturday November 13th from 10am to 3pm PST in half hour running blocks.
Where: Your home, office, RV on a camping trip with good camp ground WiFi, another club, etc. The virtual throttle and camera feed can be run from an Android/iOS phone or tablet or a Windows/Mac/Linux based computer running a modern browser like Chrome or Safari.
How: Use this link to sign up, information will follow before the Open House.
If you are unsure about participating we have some demonstration and examples below.
The Second Virtual Open House was a big success. We applied the learnings from last time, and relaxed our schedule a bit to allow the crew in the layout room some breathing room. We still had 40 operator slots during the Open House and all available slots were full a week before the event. A few last minute cancelations allowed club members to run trains remotely, too, and keep the main line busy.
Once again we used a modified JMRI Web Throttle to enable remote operators to control trains with no need for any software installs. This approach worked very well and minimizes potential technical problems. We prepared a tutorial video to explain how to use the throttle. Since operators knew what to expect they also could tell us when things didn’t work as advertised. Case in point: The Web Throttle Stop button becomes non-responsive if there isn’t operator activity for a while. Adjusting the locomotive speed with the slider always worked, so remote operators could always regain control over their respective trains, but this bug caused a few run red signals and will need to be addressed.
All our guests paid extra attention to run their trains carefully and with appropriate speed. We have found that remote operators run their trains slower than in-person operators. The cab view camera contributes to a more immersive operator experience and naturally leads to running trains more at scale speeds that “feel” right.
During one session we ran the layout in nighttime mode with the work lights in the room turned off and the layout lighting set to a blue tone that resembles a pale moon at night. Remote operators enjoyed this change in atmosphere immensely, and reported good video picture quality despite the reduced light.
While remote operators enjoyed the view from their personal cab camera within their throttle as they were running their train, we also streamed the cab view camera feeds from all 4 active trains, plus additional rail fan cameras, on Youtube Live during the event. A recording is linked below.
Everyone had a great time today: The support team in the layout room, the online SVL crew, and of course our virtual guests from all over the world. Thank you for joining us, and while we have not picked a date yet, we are planning to offer a similar event again later this year.