Timelapse Astrophotography With ESP32 IR Remote

by make_crazydays in Outside > Backyard

114 Views, 3 Favorites, 0 Comments

Timelapse Astrophotography With ESP32 IR Remote

DSC_0714.JPG
Screenshot 2025-10-08 at 8.50.13 PM.png

Years ago I saw a timelapse of the night sky with the stars spinning overhead and I was awed by the beauty and decided I needed to figure out how to do the same. I started researching the camera I had available (Nikon D5100) and found there are IR remotes available. The remotes are too simple and required a button press to take a picture. With some additional investigation I found the specific IR commands needed to control the shutter on the camera and this project was looking possible.

My specific implementation of this project requires a Nikon camera which can be controlled through an IR remote and a beginner level of knowledge of ESP-IDF and Flutter since all of the code is written. It may be possible to adapt the ESP32 code to another brand of camera, but having only a Nikon I have not researched the IR commands for other brands.

Supplies

  1. Camera (Nikon)
  2. Lens Warmer
  3. Tripod
  4. Remote
  5. ESP32 board
  6. IR LED
  7. Jumper wire
  8. Breadboard
  9. Mobile phone (Android or iOS)

Camera Settings

Screenshot 2025-10-11 at 2.43.48 PM.png
Screenshot 2025-10-11 at 2.43.12 PM.png

Astrophotography is outside the normal daylight conditions for most photography and as such will likely require using some settings which are well beyond the normal bounds. Since the settings are outside of the normal bounds it is necessary to set the camera to manual mode to make most adjustments other than focus.

Focus

Auto focus is unlikely to work in the low light conditions of astrophotography. But that doesn't mean it is entirely useless. While it is still daylight and the camera is set to auto focus taking a picture of high clouds or the horizon can help set the focus for astrophotography or at least get the camera in the ballpark. Otherwise with auto focus turned off on both the camera and lens, spin the focus out to infinity and usually back it off just a hair. This is one of the most finicky parts of astrophotography, so after playing with the other settings it may still need to be fine tuned.

ISO

The simple and wrong definition, but good enough for our purposes, is that ISO is the sensitivity of the sensor in the camera. Normal values run between 100 and 6400. A well lit scene will work fine at 100, but since astrophotography typically takes place at night in the dark, a larger value will be required. It might be tempting to jack that ISO setting to 6400 right out of the gate and for test shots give it a try. The problem with 6400 is that the image begins to look grainy. My personal experience is that 1600 to 3200 yields decent results so test those values also.

Shutter Speed

The shutter speed refers to the duration the shutter is open to allow the sensor to collect light. During daylight shutter durations will be fractions of a second. The night being much darker will require longer durations to get an appropriate exposure. Dusk can start around 1-2 seconds to collect enough light, but by the time you have lost the glow on the horizon and are truly dark you will want to leave the shutter open for 4 - 12 seconds or even longer. Depending on the lens you are using longer durations can cause star trails as the earth rotates. As a general rule the greater the level of zoom the shorter duration before you start getting noticeable trails. I find a standard 35mm lens will start showing slight trails around 12 seconds.

Aperture

Inside a lens is a gate which allows light to reach the sensor, similar to an iris in the eye. The units of aperture are called f-stops or f-numbers and are a little counter intuitive as the smaller numbers allow more light and larger numbers allow less light to reach the sensor. The lower the number in astrophotography is ideal since it is a low light condition.

Camera Setup

Screenshot 2025-10-10 at 8.37.08 PM.png
Screenshot 2025-10-10 at 8.34.09 PM.png
Screenshot 2025-10-10 at 8.37.59 PM.png

While nothing can guarantee a good night, there are a number of items which can increase the chances of a good astrophotography session.

Tripod

A tripod or otherwise stable mount is essential for astrophotography. The shutter will be open for a minimum of several seconds and any movement (even wind) will reduce the quality of the shots. The tripod should be somewhere stable as possible, like the ground or otherwise unmoveable platform. Docks, truck beds, or even high decks may have issues due to wind or someone inadvertently walking across the surface.

Power

While you can find batteries that will last all night for some cameras, it is often a better option to pick up a power cord to power the camera. The camera I am using (Nikon D5100) has a battery / power adapter which allows me to plug it into an extension cord. Since you will likely need to power the ESP32 (see below) and a lens warmer you will already be running a cord out to the camera location anyway so it is a great option and better than finding out it was too cold and the battery went flat partway through the night.

Lens Warmer

In climates and seasons when dew or frost is an issue a lens warmer ensures the lens does not accumulate dew or frost over night. There is little more frustrating than waking up in the morning and looking at the results and finding out everything past 11:00 pm is wasted due to dew or frost on the lens. A lens warmer is usually a velcro strap with a small resistance heater wire embedded which keeps the lens warmer than the cooling air temperature so moisture will not accumulate on the lens. The proper order of operations is to wrap the lens prior to working on any focusing as it will likely throw of focus wrapping it. It can remain unplugged until the session starts though.

ESP32 IR Controller

Screenshot 2025-10-10 at 8.32.25 PM.png

This is a pretty trivial project to layout on a breadboard and get working as it only requires the ESP32, an IR LED, a single jumper wire, and a breadboard. The ESP32 is a small little micro computer with bluetooth and wifi connectivity. There are numerous dev boards available online and most should work without issue.

Layout

The layout for the project is very simple. The ESP32 should be plugged into the breadboard straddling the center. The ground pin should be jumpered to the ground rail of the breadboard. Then the IR LED should have the anode (long lead) plugged into pin 4 (defined in code) and the short pin plugged into the ground rail. A different ESP32 may have a different layout, but with good eyes or readers you can tell what each pin is from the screen print on the PCB.

Source Code

https://git.crazydays.org/nikon-ir-remote/nikon-ir-remote-esp32

Build and Install

Going through installing the ESP development environment and loading the firmware on the board is outside the scope of this project, but there are probably other Instructables on how to do that or referencing the ESP32 documentation [https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/index.html] should include instructions.

Mobile Application

I wrote the mobile application in flutter so the application should work on Android and iOS, but I only have an Android device to test it on. It is pretty bare bones and simply searches for the device once it is powered. Then connecting to the device with BLE it allows you to set the rate it sends the signal to control the shutter.

Source Code

https://git.crazydays.org/nikon-ir-remote/nikon-ir-remote-flutter

Build and Install

Similar to the ESP32 development environment, it is outside the scope of this project to explain how to build and install the mobile application. There should be an Instructable one how to install the development environment and install the application on your phone or tablet or the flutter documentation [https://docs.flutter.dev/get-started/quick] is pretty good. To build and run on an iOS device you will need to have a Mac to build the application and an iOS developer account.

Night Photography

Screenshot 2025-10-11 at 2.48.12 PM.png
Screenshot 2025-10-11 at 2.43.33 PM.png
Screenshot 2025-10-11 at 2.55.00 PM.png
Screenshot 2025-10-11 at 2.55.36 PM.png

It is best to prepare your night shots prior to the sun setting rather than hoping everything works out fumbling around in the dark.

Preparation

The Sky Live [https://theskylive.com/] planetarium is a great way to see if there is anything interesting currently in the night sky that is visible at a specific location. Entering the coordinates and setting time will show what will be visible in the night sky. For things like comets it is important to look up the magnitude to determine if you will have any chance to capture it or not. Space Weather [https://spaceweather.com/] is another great site to check northern latitudes if there is a chance for Auroras.

Frame Scene

Once a target is selected setup the camera pointing in the proper direction. Keep in mind that a low horizon (like farm fields) and high horizon (close tall trees) will change where a target might appear and the time it will clear the horizon. I personally like to have the horizon in my shots to give a feeling of being grounded, but your tastes may differ. Test the scene by snapping a few shots to ensure you like the framing. While it is still light change the settings to manual, ensure auto focus is off, configure your ISO, shutter speed, and aperture, and shut off the camera. Verify the lens warmer and the ESP32 are powered also.

Final Adjustments

Once the sun sets and the light levels are as dark as expected, turn on the camera. Manually snap a shot and pull the memory card and review the shot. Look for focus issues, brightness of the shot, and make adjustments as necessary. This process, especially the first time, will likely take many attempts.

Enable Auto Shooting

Once everything is set, it is time to enable the remote. Set the camera from manual mode to remote mode. This will allow the ESP32 remote to control the camera for the rest of the session.

Mobile App

Launch the mobile app on your phone and hit the search button. This will find the ESP32 remote with Bluetooth LE and list, Stop the scan and click on the device. This will present delay configuration and an on / off toggle. If you have played with this prior, the last delay value used will be loaded up.

The objective is to maximize the shutter open time. The camera takes time to write to the memory card once the shutter is closed and will not be ready for the next shot for at least part of a second. With the memory cards I use with an 8 second exposure it takes about 500ms - 700ms to write the image to the card. So to ensure a slow write doesn't miss a frame I use 8.750s between shots.

Once the timing is setup toggle enable. About 5 seconds later the camera ought to open the shutter and then after the shutter speed time close the shutter. If the camera had sufficient time to write the image to the memory card before the delay time it will open the shutter again. If there wasn't sufficient time that second shot will be missed and have to wait the delay time. Tune the delay time to ensure every shot has the shutter closed for the shortest time between shots.

Stopping

Once the session is over, for instance morning, use the app to stop the remote listening for the shutter to close the last time. Then shut the camera down and grab the memory card which should contain all of your shots from the session.

Create Timelapse

DSC_0947.JPG
DSC_0031.JPG
DSC_0272.JPG
DSC_0766.JPG
Meteor20220531.jpg
Meteor20220818.jpg

The final step is to create the timelapse video of the all of the shots. The tool ffmpeg [https://ffmpeg.org/] can create a timelapse video from a bunch of still images. There are a ridiculous number of options for the program, but the script I have below is sufficient to make a decent timelapse video.

Source Code

This is a helpful script which will process a downloaded SD card into a video. It should be easy enough to read if you are using Windows instead of Mac or Linux.

https://git.crazydays.org/nikon-ir-remote/tomovie

Things to Spot

Once you create a timelapse, you will get questions about various items in the video.

  1. Air plane: Planes and helicopters will usually have dotted light streaks as they pulse and will usually over the course of a couple frames traverse from one edge to another. Most commonly they will be mistaken for meteors by folks who have not seen timelapses of the night sky before.
  2. Starlink: For a couple days after a Starlink launch the satellites will travel together in packs along a single blue line near sunrise or sunset. These can be disconcerting the first time folks see them at dusk or dawn. These will stop showing up once the satellites disperse on their own orbits.
  3. Aurora: Also known as Northern Lights for those above the equator. These are easier to capture with long exposure than seeing with the naked eye. The Space Weather link above can give predictions of potential for Auroras based on sunspot activity and CMEs.
  4. Constellations: A number of the well known constellations are easy to pick out. I find they are often easiest in the timelapse and with a horizon in the picture.
  5. Meteors: These are the second reason I picked up astrophotography. I am always on the hunt through frames looking for a nice fireball. These will usually only be on a single or two frames. These tend to start and end with a point if they are on a single frame. Or when split between frames the will be narrow at one end and abruptly stop.

Gallery

I've put together a gallery of some of the timelapses I've created over the last couple years, some better than others.

https://photos.crazydays.org/s/AstrophotographyTimelapse