Sony Infrared Remote Control Shutter Using Circuit Playground Express (CPX)
by kevinjwalters in Circuits > Cameras
172 Views, 0 Favorites, 0 Comments
Sony Infrared Remote Control Shutter Using Circuit Playground Express (CPX)
The shutter for cameras sometimes needs to be fired remotely or without a physical press to avoid jogging the camera risking blur on long exposures or changing the position of the camera. In the past mechanical shutter releases with a physical push rod style shutter release cable were often used. These screw into a thread on the shutter but this isn't present on modern cameras. Current cameras tend to offer Bluetooth and/or extensive remote functionality via Wi-Fi but infrared was popular for a number of years.
This article shows how the Adafruit Circuit Playground Express (CPX) board can be used as an infrared remote shutter release for a Sony NEX camera. This board conveniently features a small infrared LED and can be easily battery powered. This may be an attractive alternative for an owner of a board like this to avoid buying yet another rarely used device.
The program written in CircuitPython also features intervalometer functionality for regular, periodic shutter releases. This is useful for time-lapse photography.
Supplies
- Adafruit Circuit Playground Express (CPX): DigiKey | Mouser
- Battery (both must have the correct polarity on the JST PH connector, LiPo will need a separate charger)
- LiPo battery: DigiKey | Kitronik
- Galleon 400mAh Hard Case LiPo Battery: Pimoroni
- 3 AA battery pack for alkaline batteries: DigiKey | Mouser
Installing CircuitPython and Software
If you are not familiar with CircuitPython then it's worth reading the Welcome to CircuitPython guide first.
- Install the latest version of CircuitPython (10.1.4 on March 2024) from https://circuitpython.org/ - this process is described Adafruit Circuit Playground Express: CircuitPython.
- Verify the new installation by connecting to the serial console over USB. The REPL prompt shows the version number. The version can also be checked by inspecting the boot_out.txt file on the CIRCUITPY drive.
- Install these libraries from a recent bundle from https://circuitpython.org/libraries into the lib directory on CIRCUITPY:
- adafruit_irremote.mpy
- neopixel.mpy
- Download the wav audio files in audio-num-20260315.zip and place the num directory in the top level directory of CIRCUITPY.
- Download the cpx-ir-shutter-remote.py program to CIRCUITPY by clicking on the Raw button on the page and then Save link as...
- Rename or delete any existing code.py file on CIRCUITPY, then rename cpx-ir-shutter-remote.py to code.py. This file is run when the CircuitPython interpreter starts or reloads.
The versions used for this article were:
- CircuitPython: 10.1.4 (and 8.2.10 and 5.3.1).
- CircuitPython library bundle: adafruit-circuitpython-bundle-10.x-mpy-20260311
Demonstration
The video above is quick demonstration of the software on a battery-powered CPX. The board starts in intervalometer mode (default period is 30 seconds) and is used to make a quick stop motion animation which is then shown. The manual mode is shown briefly at the end.
- 00:00 Battery-powered CPX
- 00:06 Reset (intervalometer mode)
- 00:12 Adjusting the period to 5s
- 00:24 Making animation
- 01:50 The animation
- 02:04 Switching to manual mode
The lithium polymer (LiPo) battery shown in this video isn't physically robust. It's suitable for an adult to use on a desk at home but an AA battery pack or a cased LiPo battery like the Galleon LiPo battery are safer in a less controlled environment.
Example Animation Using Stop Motion Photography
This video was made by carefully moving the figures and firing the shutter using the CPX remote in manual mode and then assembling the frames using ffmpeg into a 25fps video. Each frame was replicated to make 7 frames giving an effective frame rate of 3.571fps.
Photography for stop motion animations can benefit from
- avoiding natural lighting as it tends to be too variable,
- fixing exposure and white balance settings,
- using a camera on a sturdy tripod located where it is unlikely to be nudged,
- only taking the photograph when things that have been moved have settled
- and ensuring people are not near the set as this can change the lighting in subtle, visually apparent ways.
This animation was made for Instructables: Making a Full Adder With LogicBoard From MH-EDU-Electronics.
Example of Time-Lapse Photography
This is a video with 150x speed up made by assembling the frames from firing the shutter every 10 seconds using the CPX remote in intervalometer mode and duplicating each frame to provide an effective 15fps in a 30fps video.
For long recording sessions it's useful to set the camera to use minimal power by disabling screens and the like or use external power if that's an option.
This time-lapse recording was made for Instructables: Soil Moisture Sensing With the Maker Pi Pico.
IR LED Beam Spread and Range
Datasheet
The Circuit Playground Express uses an Everlight IR95-21C/TR7 or Everlight IR91-21C/TR7 infrared LED. These have very similar specification and identical beam angles (show above) in the datasheets. The beam appears to be contained within a +/-15 degree spread based on the radiant intensity diagram.
An Attempt at Viewing the Beam Spread
The photograph is an attempt to capture the reflection of the beam on a piece of white paper at a range of 100mm (4in) from the parallel CPX board. The Sony NEX is doing a 4s exposure at ISO 25600 with incandescent white balance** in a very dark room with the CPX's IR LED on for just under 4 seconds at 20% duty cycle (at 40kHz). The CPX was powered by a USB 2 port and had the light from its green power LED blocked.
The image has had its brightness doubled and the perspective crudely corrected. The ruler has been composited in from a second photograph where a small amount of ambient light allowed the ruler to be seen. Digital cameras sensors are sensitive to infrared and have an internal filter to attenuate non-visible light in the ultra-violet and infrared regions. These filters aren't perfect which is what allowed this very faint, noisy image to be captured.
The CPX board is atypical as the IR LED is controlled with a bipolar transistor (see above) without a current limiting resistor leaving only the gain of the transistor to control the current. This could allow 0.5A to 2A to flow for each pulse. This means it's critical to only pulse it for short periods and not to turn it fully on for long periods. The 4s test at 20% duty cycle is a harsh test and it's unwise to run this more than a few times.
A camera without an IR filter would be far better choice to look at the beam pattern. Some of the Raspberry Pi cameras are available as a "NoIR" variant making them very suitable for this.
** Raw mode would have been a better choice.
Practical Tests with CPX Remote and Sony NEX
The CPX remote works surprisingly well at close range. At below about 1m (3ft) the CPX doesn't need to be pointed at the (front of the) camera and will work at 30-60 degrees away from the IR LED beam's centre. If the CPX is pointed in the general direction of the camera it will work at least 6m away indoors.
Adafruit CircuitPython IR Library - a Missing Feature Required for Sony Cameras
The vast majority of computers store data in bytes (8 bits) and this is often the smallest quantity of data which can be processed. When data is transmitted over a serial protocol it is may be sent as a whole number of bytes but not always. The adafruit_irremote library was only capable of sending data in byte quantities but the Sony NEX cameras have infrared commands which have 20 bits (2.5 bytes) meaning it wasn't capable of sending those.
The library was enhanced with an nbits optional argument on the transmit method to allow fewer bits to be sent than the total number of bits (a multiple of 8) contained in the data.
Adafruit CircuitPython IR Library - an Error
During the development of the Sony NEX features for the adafruit_irremote library it became evident there was an error in the CircuitPython example code and CircuitPython library for the unrelated NEC codes. The encoding was the wrong way around but as it was consistently wrong between the examples and library it still worked. This was ticketed as it was likely to eventually cause confusion and turn into a bug.
Adafruit CircuitPython - an OLD Infrared Bug
During the original development of the program back in 2021 the CircuitPython interpreter was upgraded from 5.3.1 to 6.2.0 and the shutter release stopped working. The infrared pulses could be captured optically and decoded but fortunately an easier method was/is available. The pulseio library can be used with any pin - this allowed the same pulses to be sent to an easily accessible pad and the pulses captured with a normal logic analyzer. The good and bad output is shown above.
Reverting to CircuitPython 5.3.1 was an obvious solution as a quick remedy was needed.
This was fixed in GitHub: adafruit / circuitpython: pulseio.PulseOut timing very wrong on CPX (SAMD21) on 6.x - breaks infrared sending #4602.
Going Further
Ideas to explore:
- Make a sound triggered remote using the onboard microphone on the CPX. Care may be needed with memory use as this is a bit tight with the existing program.
- Make an infrared remote control for other products.
- Make a Bluetooth remote control for a camera/other device using the Circuit Playground Bluefruit. There is a C++ example of this on https://github.com/coral/freemote shown in the video Building a custom BLE remote for the Sony A7 III camera (YouTube).
- Look at infrared beam pattern using a digital camera without an IR filter.
- Use a power profiler to look at how much current is used by typical infrared transmissions when powered by USB and LiPo battery power.
Related guides, tutorials and projects:
- Infrared
- Adafruit Learn
- Infrared Receive and Transmit with Circuit Playground Express
- Circuit Playground Express Treasure Hunt
- Zombie Tag Game with Circuit Playground Express
- Infrared Hand Gesture Robot Control Glove
- Adafruit Infrared IR Remote Receiver
- Core Electronics: Infrared (IR) Control with Circuit Playground & CircuitPython (YouTube)
- Instructables: Code a TV Remote Using Circuit Playground Express and CircuitPython - this example uses a 38kHz carrier wave.
- Instructables: River Cam - an example (from 2016) of using a Rapsberry Pi with a NoIR camera.
- Time-Lapse
- Instructables: Simple Arduino Camera Trigger - a simple intervalometer using IR and Arduino UNO.
- Raspberry Pi Projects: Time-lapse animations with a Raspberry Pi
- John Builds Things: Stunning Star Time Lapse Videos with a Raspberry Pi Camera and AllSky (YouTube)
A selection of stop motion animations, time-lapse films and similar:
- San Francisco Museum of Modern Art: Slices of Time: Eadweard Muybridge’s Cinematic Legacy (YouTube)
- Kino Klassika Foundation: The Cameraman's Revenge (1912) (engsub) (YouTube)
- The Royal Ocean Film Society: How Ray Harryhausen Combined Stop-Motion and Live Action (YouTube)
- Magic Roundabout: Mr Rusty Meets Zebedee (YouTube) / Le Manege Enchante: Le Pere Pivoine reçoit un colis (YouTube)
- London Screen Archives: Soho Square Time-lapse - Meter Feeding
- Kindred: The Mouse Mill - Bagpuss (YouTube)
- National Geographic: Amazing Time-Lapse: Bees Hatch Before Your Eyes (YouTube)
- FilmSpektakel: A Taste of New York (YouTube)
- tomosteen: Lego Breakfast - Lego In Real Life 5 / Stop Motion Cooking & ASMR (YouTube)
- Michael Shainblum: NEW ZEALAND | 8K UHD (YouTube)
- Ben Nightingale: Aardman Academy - Stop Motion 1 (YouTube)
Further reading:
- Infrared
- Ken Shirriff's blog: Understanding Sony IR remote codes, LIRC files, and the Arduino library
- Rangefinder Forum: Sony alpha/nex wireless control with arduino - one source for the Sony NEX/DSLR IR codes.
- Linux Infrared Remote Control (LIRC)
- MakeCode Circuit Playground Express Remote (IR) LEDs
- SparkFun: IR Communication
- Arduino Libraries: IRremote includes the file ir_Sony.hpp
- MIT: Introductory Digital Systems Laboratory (6.111): 6.111 Lab #5b - "In this lab, you will design finite state machine(s) to “learn” four Sony Infrared Command (SIRC) and use it to control a Sony television."
- Instructables: Simple Audio Player on Adafruit Circuit Playground Bluefruit (CPB) - this includes a comparison of the three Circuit Playground boards.
- Lensvid: Best Wireless Remote Control for Sony Cameras - shows the original Sony RMT-DSLR2 infrared remote and some other radio and bluetooth ones.
- Stop motion
- Adafruit Industries: JOHN PARK'S WORKSHOP LIVE 10/4/18 Stop Motion Animation - stop motion basics discussed from 16:30, mention of onion skinning at 20:32, recommendation of two books: Preston Blair's How to Animate Film Cartoons and Richard Williams' The Animator's Survival Toolkit.
- Thunderbird Releasing: MY LIFE AS A COURGETTE - Making-Of Featurette