Applications of TinyML in Backyard Astronomy

Mark Grandau
5 min readSep 10, 2022

What is TinyML?

TinyML is machine learning running on small microprocessor boards that are close to the data input mechanism. This data input is usually in the form of some type of sensor data.

A Problem in Backyard Astronomy — The Two Coordinate System Problem

When observing through a telescope, there are different coordinate systems usually at play.

The first is the RA/Dec (RA — right ascension and Dec-declination). This coordinate system identifies a position in the sky as if you were observing from the center of the planet. We use this along with time to give specific position of objects in the night sky.

The second coordinate system in play is Alt/Az (Alt — Altitude and Az -Azmuth). Alt is the angle of your telescope. Az is the compass heading of the scope based on the point where light enters the scope. This identifies where you are looking at based on your geolocation. There are well-defined transformation functions with the inclusion of geo-positioning to convert Alt/Az to RA/Dec.

There are mechanical mounts for equatorial mounted telescopes that maintain the Alt-Az position and allow a single motor to track an object based on time. My telescope is a 15" Dobsonian mounted refractor. It doesn’t do that. But in either case, there is value in identifying the Alt-Az of the scope, so we can convert it to RA/Dec.

Two Sensors

There are sensors that can help solve the problem.

The Accelerometer. This is the same sensor that is in your phone. With it, you can measure the tilt of an object. In our case, that is the Alt of the telescope. It does this by splitting the acceleration it senses due to gravity. It can do this without actually falling. Just mounted to the side of the scope.

In my case it splits that into 3 axis (x, y, and z). I want the angle about the x-axis. Horizontal is 0 degrees. 90 degrees is pointed straight up.

This can be described in a geometric equation (my git repo). The sensor is sinusoidal and non-linear in nature. Basically, it is more accurate being horizontal than vertical. The problem is, using these small sensors can have lots of error based on environmental effects of the problem domain. How is the sensor mounted? How does the telescope track as it raises? Tolerances in the electronics of the sensor? Etc.

For a first order solution, we calibrate the setup at 0 and 90 degrees. We identify the error. It is a non-constant value, so the first attempt is to correct the value with a linear based error correction value specific to my scope, the position of the sensor on the scope and the specific sensor.

The Magnetometer. This sensor is used in your phone to give you a compass direction on things like map application. Or in our case it is the Azimuth of the telescope. It measures the magnetic effect due to magnetic north. Because the sensor is bipolar in nature, we can identify the direction the sensor is pointing by observing the 3 axis (x, y and z) of the sensor.

This also needs to be calibrated. A linearized error factor is applied, because the sensor can be effected like real compasses, by metal objects, power lines, other magnetic items in the area and of course the sensor tolerances. That error as you can imagine is highly non-linear. But a first order linear corrected approximation will get us to within a degree or two.

Backyard Astronomical Observing

So, as you see, the above sensors can be effected by non-linear error. Are they still useful?

Yes.

To begin with, we will first attempt to use them to get us close to the object we are looking for. This is often called a “Go To” scope. When observing, it will get us in the area quickly, and we can correct it slightly to get to what we want to see.

Second, because my observing is based usually from one specific location, the area in the sky I am observing has a reduced set of angles due to trees, buildings, etc. This means large portions of the equation space is “don’t care”.

So what we hope for is a high degree of accuracy within the small area of possible inputs to our equations.

Why TinyML over Traditional Algorithmic Approach?

As you can see:

  • In both cases, the error is highly non-linear.
  • Because I want it for first order location, my workflow is conducive to “Supervised Learning”. This is where a user can feed back corrections to what the model generated.
  • What is important is gathering the data and the expected result. Machine Learning is a highly automated process for generating models. So instead of spending time working to fit a non-linear function, we let the ML training do it. We concentrate on data gathering. This also means that if the problem shifts due to other factors like temperature or other things, the ML model can adjust based on the statistics of the data.
  • Because the model is a simple regression model, it should be able to run on the small microprocessor board (Nano33 BLE Sense). The sensor data and results will be recorded. Thus allowing the model to get better and better to whatever the precision of the system will allow.
  • The value is in the data. That same data can be used in other ways. For example, by using well known astronomical software, the RA/Dec of an object can be predicted through the sky. That can be used to generate an Alt/Az script to roughly move the scope for tracking, if we can get the precision high enough.
  • We can incrementally improve the model. First, get it good enough to position based on the low resolution finder camera. Then work the same data problem to get it to work for the higher resolution Optical Tube Assemblies (OTA) main camera.

I hope this helps give you ideas of how you can apply TinyML into your areas of interest. Look for those non-linear problems. See if you can identify how they could be solved with simple sensors. Play. Most of all, have fun and keep learning.

--

--

Mark Grandau

I’ve been a developer for 30+ years. 20 of them as a Software Architect. Software is the modern day junction point of Science, Math, Philosophy and Art