Philip P. Ide

Author, programmer, science enthusiast, half-wit.
Life is sweet. Have you tasted it lately?

User Tools

Site Tools


Pi-Mars v1.1

Desktop screen shows time for the InSight lander. Pi screen shows time at Valles Marineris

Pi-Mars is a clock for the Raspberry Pi, that tells the time anywhere on Mars. It has options to nominate ad-hoc locations, pre-selected locations and sites of the various missions that made it to the Martian surface. It is skinnable and highly configurable.

Having written several clocks that tell the time at various locations on Mars for my Mars Weatherplugin-autotooltip__default plugin-autotooltip_bigMars Weather Reports

This webpage will soon be converted to be the top level page for Mars Weather Reports. It will contain links to the sub-pages, the clocks, the current location of Mars graphic and other data not spcific to the weather readings. The sub-pages will display the weather data from Insight, Curiosity and Perseverance.
page, I immediately knew I wanted to make a physical clock - something that could sit on my desk or such like, and tell the time on Mars.

The Raspberry Pi was a shoo-in for the job. Items required:

  1. Raspberry Pi 4B+ 2GbRAM (£34)
  2. Power Supply Unit (£8)
  3. 7“ Official Touchscreen (£60)
  4. SmartiPi Touch 2 case (£24)

Total cost: ~£130.00 plus SD card (16Gb) plus p+p. An 8Gb SD card is sufficient if you want to minimalize, but a 16Gb will have a longer life.

These were all standard components that fit together in just a few minutes. Writing the software would take a bit longer - this was after all, mainly a software task. Luckily, I'm a programmer. ← Mark Watney moment, did you spot it?.

As you can see, taking images of the Pi displaying the clock is not easy because it is backlit. I found that placing it in front of my PC monitor helped. Better still, since the software I was writing was multi-platform, I could take screenshots directly from the PC's raster, so you can see some of them below.


  • tell the time at any location (on Mars), so must have the ability to enter map coordinates
  • have pre-selections for all the missions that made it to the surface - successfully or otherwise
  • have pre-selections for major landmarks
  • work with any screen dimension
  • be skinnable to change background, fonts, colours etc. and positioning of elements
  • skins can decide which elements to show
  • can select maps for background to show current coordinates (Viking and MOLA maps)
  • override skin background to display any other image
  • create a slideshow of background images at intervals determined by the user
  • automatically update leap-second bulletins (necessary for Earth/Mars time conversions)
  • automatically detect and install new mission data when updated information becomes available
  • can be configured for an ftp-proxy if required
  • write to the SD card only when absolutely necessary, to help extend its life
  • optimised code wherever possible, but maintain flexibility and readability

v1.1 added power management options (quit the application, reboot and shutdown).

Optimising the code was essential. Although computers are great for repetitive tasks, making them work unduly hard at high frequency rates persistently reduces their lifespan. This clock was going to perform a large number of calculations and then repeat that task up to ten times every second (user configurable). Giving the clock a breather between each trip around the loop is just taking care of the equipment.

Maintaining flexibility was essential of course, but so was readability - which also translates into maintainability.


The logic of translating times on Earth to times on Mars is relatively straightforward, although at first glance it might seem otherwise. Essentially a Martian second is longer than an ISO second. This means that Earth time and Martian time represent two entirely different time streams that are both anchored at midnight on the morning of 11th April 1955. Earth also subtracts leap seconds, something that Mars doesn't, and this increases the divergence.

NASA produce (at the Goddard Institute for Space Studies) software called Mars24, which also tells the time anywhere on Mars (it can tell the time anywhen too), so I used that as my benchmark to ensure my times are correct. This creates an issue where the Ls is different from the code often used on the web, so I sided with the NASA software.

If NASA have this software, and it is freely downloadable (here), why make another clock? Mars24 is a tool, and what I wanted to create is an ornament, and as such it has more configuration options and capabilities. Plus it's a nerd-fest-in-a-box, right? Unless you work for a Mars mission team for a space agency, this clock is entirely useless to you, except for its nerd and ornamental value.


Full installation instructions can be found on this pageplugin-autotooltip__default plugin-autotooltip_bigPi-Mars Installation

You require an RPIv2 or later (to use the SmartiPi Touch 2 case, you require an RPI4). It will not run on an RPI1 or an RPI-Zero. This installation and configuration guide assumes you have installed an operating system on your Pi and can login either directly (with a keyboard/monitor attached to the Pi) or indirectly through SSH or VNC across a network.
. If you feel confident you can do it blindly, the software repository is here:


At this time, the sunclock is not working properly because the clock isn't calculating the times of sunrise and sunset properly. These will be fixed in a future update.

Installation instructions can be found on this pageplugin-autotooltip__default plugin-autotooltip_bigPi-Mars Installation

You require an RPIv2 or later (to use the SmartiPi Touch 2 case, you require an RPI4). It will not run on an RPI1 or an RPI-Zero. This installation and configuration guide assumes you have installed an operating system on your Pi and can login either directly (with a keyboard/monitor attached to the Pi) or indirectly through SSH or VNC across a network.



This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies


Enter your comment:
blog/articles/raspberry/phys_marsclock/pi_marsv1.txt · Last modified: 2020/11/20 11:08 by Phil Ide

Except where otherwise noted, content on this wiki is licensed under the following license: Copyright © Phil Ide
Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki
  • ISSplugin-autotooltip__default plugin-autotooltip_bigInternational Space Station

    This page has a portal through which you can view the current location of the International Space Station, updating in real-time. The tracker itself comes from the European Space Agency (ESA).

    There is also a handy link to get email notifications direct from NASA when the ISS is visible in your night sky.
  • Mars Weatherplugin-autotooltip__default plugin-autotooltip_bigMars Weather

    Weather Reports Insight Lander Perseverance Rover Curiosity data to come Follow Conjunctions as they occur.

    Martian Day

    The Martian day is 39 mins 35.244 secs longer than a standard day. This means that approx every 36.1 days the Earth weather date skips a day while the Martian Sol marches on as normal. You can see this in the Insight data. April 16th 2019 seems to be missing, yet the Sols on April 15th and April 17th are consecutive.
  • Downloadsplugin-autotooltip__default plugin-autotooltip_bigDownloads

    Orbital Calculator Current Version This is a portable application, meaning there is no installer. Just unzip into a folder and run the executable. Since it is portable, it can be run from a USB stick.

    A full description and a list of the features are available
  • Orbital Calculatorplugin-autotooltip__default plugin-autotooltip_bigOrbital Calculator

    I needed to calculate orbital characteristics for any orbit around any gravitational mass (because I write sci-fi stories), so I wrote this program because I'm a programmer and I'm too lazy to do it by hand all the time. The program has expanded over the last few years, sometimes from suggestions by other writers. I make it freely available and as simple to use as possible. It now has a list of functions as long as your arm (assuming you're not a tentacle user), and the numbe…
  • Cookie Policy & GDPRplugin-autotooltip__default plugin-autotooltip_bigCookie Policy & GDPR

    There are NO tracking cookies on this site!

    The Cookie policy is straightforward. This site only uses cookies that are required to make your experience of using this site better, and only uses session cookies (see exceptions below). Session cookies are deleted when you close your browser.
  • Book Reviewsplugin-autotooltip__default plugin-autotooltip_bigBook Reviews

    Here you can find all the book reviews, broken down by genre, and further subdivided by author. If you want me to review your novel, please read my Rules on Reviewing.

    * Science-Fiction * Fantasy * Non-Fiction
  • Contactplugin-autotooltip__default plugin-autotooltip_bigContact

    If you have a burning desire to contact me, use the discussion form below. Anything you say remains private between you and me.