element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
RoadTests & Reviews
  • Products
  • More
RoadTests & Reviews
Blog Riding-the-Rails with a Raspberry Pi Zero 2W: Prototype
  • Blog
  • RoadTest Forum
  • Documents
  • RoadTests
  • Reviews
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join RoadTests & Reviews to participate - click to join for free!
  • Share
  • More
  • Cancel
  • Author Author: colporteur
  • Date Created: 17 Mar 2022 12:29 AM Date Created
  • Views 1993 views
  • Likes 6 likes
  • Comments 9 comments
Related
Recommended
  • raspberry pi 2W
  • pi camera

Riding-the-Rails with a Raspberry Pi Zero 2W: Prototype

colporteur
colporteur
17 Mar 2022

Welcome to the sixth and final blog post, in the series to support the Raspberry Pi Zero 2W Roadtest. The blog posts will explore different aspects of the product while attempting to engage the E14 Community members. Comments and questions to the blog posts are welcomed and encouraged. The blog posts will serve as the resources for assembling the RoadTest Review document.

The project objective is to pair a Raspberry Pi Zero 2W with a camera, assemble it on a HO scale model railroad car with a power source and stream or record video of the train in motion.

I will start the post with a video that was one of the deliverables from the application.  The content shown is recorded as the Pi camera assembly is being moved by a locomotive. The assembly can be pushed or pulled by the engine.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

PiZero2W can ride the rails and deliver video! Four separate videos are spliced together. A side view from the traincam, a front view from the traincam, a front view from an iPhone and another iPhone video shot.

The model railroaders and myself were surprised at how smooth the actual ride of the camera was. We were expecting the camera to be shaking, making for poor video quality as the well car moved along the track. This did not happen. The assembly, mostly hidden by container cars doesn't obstruct any movement on the layout. Positioning the camera for different video shots of the layout was something the model railroaders really took to.

 

Prototype Assembly

The model railroaders modified a HO scale well car to hold a battery and Pi with camera assembly. A servo motor to reposition the camera was a feature added during development.

{gallery}Pi Railcar Prototype

image

Two rail cars supporting the PiZero2W camera system

image

GPIO connector cable assembly

image

Great plastic work by the modelers

image

camera system hidden insider container car

image

battery hidden inside rail car

image

power off button painted to blend in with rail car top

image

camera mounted on servo motor to facilitate movement

 

To hide most of the load, container boxes were modified to cover the electronics. The final fitting of all the components inside the container cars made for a tight fit. Support frames inside the cars were carved away to enable the housing to cover the assembly. The USB power cable diameter was large in order to ensure a sufficient gauge wire. The cable was difficult to position. An exact knife was needed for trimming away plastic to achieve a fit.

Late in development, a need for a method to power down the PiZero2W was determined. A push switch was integrated into the container box that covers the Pi. Pressing the switch triggers a python power shutdown routine script.

 

Prototype Wiring

One of the challenges of the project was to determine how to supply power. The normal USB mini-B connection provided on the Pi couldn't be used because of space limitations. A wiring harness was developed using six pins. 

image

Power from the battery & ground is inserted on pins 4 & 6 of the Pi. Pin 8, GPIO14 is the servo data input. Pin 10 GPIO 15 is the power off trigger generated when the button is pressed. The button connection uses a connector to allow the container box to be separated.

Two python scripts were developed. One to control the servo position and the other to initiate a power shutdown when the button was pushed.

The PiZero2W was configured to connect to a Wifi router. Connecting to the Pi console from a laptop, commands were issued to generate the video that was displayed on a Linux laptop. It was possible to display the video on the laptop with both the Pi and laptop using a wireless connection. At times this resulted in latency that caused to video to pause. A wired connection of the laptop to the wifi router resulted in smoother streaming video.

Duration Test

A test was conducted to determine how long the system could stream video on a full battery charge. The setup had the PiZero2W streamed content over wifi to a laptop. A script was set up to record the time when the PiZero2W shutdown. On the 4500mAmp/hr battery fully charged the system lasted 11 hours. A similar power test was conducted without the video being streamed and the system lasted 15hours.

This concludes the blog post in support of the review. The next stop is the RoadTest review itself.

 

  • Sign in to reply
  • colporteur
    colporteur over 3 years ago in reply to beacon_dave

    I fired up a train the other day for the first time. I needed to test something and no one was around so I grabbed a CAB controller and managed to get the train to move. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave over 3 years ago

    Looks like this model railway thing could take off as a hobby... Slight smile

    https://www.raspberrypi.com/news/ride-a-model-railway-from-the-train-drivers-pov/

    Spotted in Raspberry Pi Weekly recently.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • colporteur
    colporteur over 3 years ago in reply to robogary

    The configuration is a repurposed wireless router from the second-hand store for wifi connection to the PiZero2W. The viewing device, in this case my Ubuntu laptop, is wired. The video stutters when both devices are wireless.

    The next time I am at the playground (i.e. layout) I can move the router for some distance testing to determine if there are any issues. We have sent the car through a tunnel and found no impact.

    I'm thinking the router provides some options for viewing once we take it on the road. I'm hoping to improve the ability for others to view the content once some books on ffmpeg arrive to give me some ideas.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • robogary
    robogary over 3 years ago

    Awesome !  Your videos are so much better than the ones I shot using an analog FPV camera (10 years ago ) mounted  on a robot for a robot parade. How far away could your PC be located from the train track and stay connected to the Wifi.

    Some suggestions are to hide the camera, but it maybe more fun to keep the camera conspicuous and have a video display monitor nearby. 

    Maybe another next step is to pickup power from the rails to keep the battery charged. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave over 3 years ago in reply to beacon_dave

    If multicam appeals then another area for experimentation may be the 360 degree panoramic using two fisheye lenses back-to-back with synchronised camera boards.

    https://www.arducam.com/best-raspberry-pi-stereoscopic-camera-module/

    Things perhaps to keep in mind:

    • Part of your field of view is likely to be blocked by other wagons so an end wagon location may give you the best coverage.
    • Resolution is much more limited as your imager is now having to capturing the whole sphere as opposed to just a small cone out of it.
    • Spherical to equirectangular conversion will be required to recover the video frame.

    You could also use a single fisheye to get a 180 degree panoramic. A M12 S-Mount fisheye lens could be placed in the end of a container wagon and would be barely noticeable.

    /challenges-projects/project14/photography/w/documents/27346/project14-photography-we-re-giving-away-raspberry-pi-hq-camera-kits-for-projects-that-use-them?CommentId=61399d89-3b63-43d9-a90b-7543271ce0fb

    Alternatively go for a flatbed wagon and chain on some appropriate freight and hide the camera in that. No stitching / synchronisation required and a lot easier than a 360 set-up with only a little less usable coverage.

    "All aboard... Tickets please..."

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube