Feature

Little Sun Gazer

A Raspberry Pi Based Sun Tracker

Dmytro Panin

Issue 64, November 2022

For many makers, an Arduino or Raspberry Pi-based weather station would be commonplace on their workbench. This maker’s display is a little different. It simulates the position of the moon and Earth around the sun, along with the time and sunrise/sunset times. We caught up with Dmytro to find out more about his curious-looking display.

Tell our readers a little about yourself and what got you interested in electronics?

I’m 32, born and raised in the eastern part of Ukraine, but have been living in the capital for about 9 years now.

I wrote my first line of code when I was about 8 years old and couldn’t stop ever since. Almost all my life I’ve been working with software, hence, my career path was pretty straightforward Software Developer -> Software Architect, but a couple of years ago I decided to switch to a non-technical position and became a Delivery Director. It was about that time that I started making these little projects.

Even though I had enough experience with more mainstream software development, embedded / physical components / 3D printing required a completely new set of skills and this became a very hobby which is satisfying my technical’s side cravings.

It’s great to be able to mix your software skills with affordable hardware. What was the motivation behind designing and building your Star Gazer project?

We tend to forget how sophisticated yet choreographed the universe is. Yet, sometimes we stop in awe, mesmerised by the realisation of the bigger picture, only to forget about it in a few minutes. So I wanted there to be something that I could look at every day to see how as time progresses, the Earth makes its trip around the Sun to try and prolong this feeling of the bigger picture. I have been looking to build a device to keep track and visualise the Sun path ever since I built the Pico Solar System (https://github.com/dr-mod/pico-solar-system). One thing I knew I wanted to implement differently is that I had to make it to be battery powered. Additionally, I realised I didn’t get to explore the Moon position, I really wanted to visualise it and be able to see how it circles around the Earth as time passes by.

One of the things that I wanted to achieve with this project is that it wouldn’t need to be connected to the internet, so all calculations are done on-board. While I will be adding more features in the future, at the moment it calculates and shows the following:

  • The angle of the Sun relative to the spectator's position on Earth.
  • Sunrise / Sunset
  • Position of Earth around the Sun (when the Earth is directly above the sun it’s the beginning of a year)
  • Position of the Moon relative to the Earth.
  • Time (HH:MM)

Do you have a background or fascination with astronomy?

My background is in software engineering, I always dabbled in astronomy, but astronomical formulas and calculations are definitely not my strong suit. So to get familiar with the subject and put together the model, I had to consult multiple sources and examples such as:

  • Astronomical Algorithms by Jean Meeus
  • Computing planetary positions by Paul Schlyter
  • https://www.noaa.gov/

Sounds like plenty of research to keep you out of trouble. What parts are you using?

The project uses the following:

  • Raspberry Pi Pico
  • Precision RTC Module (DS3231)
  • Waveshare e-Paper 3.7
  • Pimoroni LiPo SHIM
  • Li-Po 2000mAh 103450

As the project was supposed to be battery powered I had to go with a microcontroller and not a SoC computer such a RPi zero due to the power consumption limitations. Therefore, Pico was my first choice as it has enough RAM to keep a frame buffer and a deep sleep mode which allowed me to save some battery. Additionally, I wanted to experiment with a 3.7 eink display and waveshare had a “plug-n-play” version of the display for Pico which cemented the choice.

How long does it run for on a charge, and can the project work from USB or disposable batteries?

Based on my calculations it should run for just over a month on a single charge. Truth be told, I never got it to the point when the battery was fully drained. As for USB, not only Little Sun Gazer can run from it, but it also charges the battery while it stays connected to a USB power adapter or port.

We assume the ePaper wouldn't draw much power. Do you employ any deep sleep methods to keep power draw to a minimum?

Not for the display. Based on my crude measurements it only draws power when updates (it’s corroborated by its datasheet as well). The Pico, on the other hand, is quite power hungry. It draws around 20mA with the default configuration. So in order to save some battery, I managed to tap into Pico’s deep sleep mode. Disabling some additional features, I managed to get around 2.3 mA, which is still a lot, but again, my experiments had to stop.

How frequently does it update?

It updates once per minute, or to be more precise, it updates when a minute changes. e.g. if the device is turned on at 23:59:58 the next screen update will take place in 2 seconds.

Did you do any prototyping and what challenges did you need to overcome?

The funny part is that the state this project is in now at the moment is a pre-prototype, I didn’t intend to release it unfinished. But since I couldn’t get back to my home-lab due to the invasion for a few months, I just uploaded what I had stored on my laptop.

Did you write from scratch or repurpose someone else's code and libraries?

One could argue that in this day and age there is no code that’s not based on something else. Provided the sheer variety of libraries, Pico’s SDK, drivers for the peripherals and astronomical algorithms from the books and articles I listed above, I cannot say that it’s written “from scratch”. For example, I repurposed a part of my other project, Pico Solar System, for calculating the Moon’s position in Little Sun Gazer.

It’s great that you have been able to 3D print your own enclosure. What design software and printer do you use?

As a 3D design tool, I mainly use Fusion360 and sometimes Blender. As for the printer, I very much enjoy my Pursa mini+.

Great to hear you own a printer. What do you have planned next for your project?

There were a few more things I wanted to explore and implement when the project’s development was suddenly abrupted by the war. For example:

  • Visualisation of how the Earth’s position corresponds to what month it is.
  • Showing the battery’s percentage that would be in keeping with the theme of the device.
  • Partial update of the display (not all things should be calculated every time).
  • The codebase itself is in a deplorable state, the code is not readable, it was a playground or a sandbox for exploring features and ideas rather than actual software development at that point.

There were also many great ideas suggested by the Internet community, which I’m definitely planning on experimenting with. At the same time, I also want to continue developing some of the features I didn’t get to create in the first place, starting from the case and ending at the diagrams/widgets/functionality.

As you know, I had to stop working on this project quite abruptly. I like the state this project is in now, but it wasn’t supposed to be neither the final iteration nor what people would see. For example, I wanted to show and incorporate Noon, the code for it has been written, but I never got to add it in the diagram. Another example could be that there is still no easy way for a user to change time, set their time zone or coordinates.

If our readers want to build one for themselves, is everything they need to know on your GitHub?

While I try to document the projects I open source so that they could be repeated easily, this one is still unfinished and I didn’t get a chance to finish a proper guide. I know that some people have already built their own Sun Gazers based on what I shared on GitHub, so it’s definitely doable. It’s just that the instructions for this project are not as straightforward as, for example, those for Pico Solar System. https://github.com/dr-mod/little-sun-gazer

Wonderful. We thank you so much for your time, Dmytro. We hope you continue to stay safe and back to your normal way of life soon.

Dmytro Panin

Software Developer and Maker, Ukraine