From Autosport Labs
Jump to: navigation, search

Automatic Camera Control


This guide shows you how to enable automatic start / stop control of WiFi enabled cameras, such as GoPro using RaceCapture or PodiumConnect.

How it works

Most action cameras offer a WiFi interface for remote control. GoPro is one such camera, and allows shutter control via the WiFi interface, which RaceCapture or PodiumConnect can leverage for automatic triggering.

Currently supported versions of RaceCapture hardware

  • PodiumConnect
  • RaceCapture/Apex
  • RaceCapture/Pro MK3
  • RaceCapture/Track MK1 and MK2
  • RaceCapture/Pro MK2 with external WiFi add-on (see below)

Currently supported cameras

  • GoPro Hero 2/3
  • GoPro Hero 4/5 (experimental)

Note, We recommend GoPro 2/3 due to stability / reliability issues seen with the later GoPro devices.

Additional Camera support will be added with future firmware releases.


RaceCapture or PodiumConnect is configured so it's WiFi client connects to the camera's WiFi access point by specifying the camera's SSID and WiFi password.

When RaceCapture/PodiumConnect triggers the camera based on a sensor threshold such as speed, RPM or other value, it sends a command to the camera to start recording. When the sensor falls below the threshold, a command is sent to stop the recording.

Since the WiFi client feature is used on RaceCapture/PodiumConnect to connect to the camera, the Access Point remains available for the RaceCapture app to connect via WiFi, as usual. Or, via Bluetooth, if supported in the RaceCapture system.

Automatic camera control.jpg

Setting up Automatic Camera Control

Applies to

  • PodiumConnect
  • RaceCapture/Apex
  • RaceCapture/Pro MK3
  • RaceCapture/Track MK1 and MK2


  • Firmware 2.13.0 or higher

Set up WiFi client

Navigate to Setup / Wireless and ensure:

  • WiFi is turned ON
  • WiFi client is turned ON
  • GoPro SSID and password are specified in the WiFi client settings.

WiFi camera control config.png

Set up Automatic Control

Navigate to Setup / Automatic Control and ensure:

  • The desired sensor channel trigger is selected (Speed is the default)
  • Your start / stop and time thresholds are configured
  • Camera Control is turned ON and you have your camera model selected.

Automatic control camera settings.png

Write Settings

Write the settings back to RaceCapture by pressing the Write button under Setup.


Turn on the camera and ensure the camera has it's WiFi interface enabled.

Power up RaceCapture, connect the RaceCapture app and verify the WiFi client is connected under the System Status page. File:Verifying wifi client connected.png

It may take several seconds for the client to connect. If not, re-check the camera's SSID/password, and ensure WiFi is enabled on the camera.

  • Note: On GoPros, the Camera must be in 'App mode' with WiFi enabled.

Once it is connected to the camera, you can test the camera by triggering the configured camera's threshold.

  • Tip: For static testing, you can configure the camera control to one of the Accelerometer channels, such as AccelZ and trigger by inverting RaceCapture. Or, use RPM, battery voltage or similar.

RaceCapture/Pro MK2

While the automatic camera control firmware feature is not available for RaceCapture/Pro MK2, it can still be controlled via a Lua script.

RaceCapture WiFi GoPro control diagram.png

When WiFi is enabled on your GoPro camera it creates a network that other devices can connect to. A WiFi enabled version of RaceCapture/Pro can connect to this network and issue the appropriate commands to control various camera functions - in this case, starting and stopping video recording.

Starting and stopping the GoPro can be controlled by a variety of means: speed, RPM or based on other sensor data, enabled by a Lua Script running on RaceCapture/Pro.

This guide focuses on using GPS speed to trigger the camera; for triggering on other sensors see the Lua scripting guide as a reference for what other sensor data is available.


  • Currently, the WiFi module can only be used to enable GoPro triggering.
  • If running firmware version 2.10.x or higher To use this script, you must disable the built-in WiFi control, or else it will take over the connection and block the script from running.
  • Future versions of RaceCapture firmware and app will allow built-in firmware control of GoPro cameras, which will eliminate the need for this script.


  • RaceCapture/Pro MK2 running firmware 2.9.1 or higher
  • RaceCapture/Pro WiFi module
  • WiFi enabled GoPro Hero camera, with WiFi activated
  • GPS Connectivity (for speed measurement)


Configure your GoPro

Using the GoPro app, configure the WiFi network, making a note of the network name (SSID) and password.

Connect the WiFi module

Connect the RaceCapture/Pro WiFi module to the outermost (Auxiliary) port of RaceCapture/Pro.

  • When powered up, you should see the power LED illuminate.
  • This port is to the right of the Bluetooth Port.
    • The WiFi module does not interfere with the operation of the Bluetooth module.

Enable Lua script for GoPro connectivity

Customize the Lua script shown at the bottom with the GoPro's WiFi network name (SSID) and password, then copy and paste the Lua script shown at the bottom into the scripting window of your RaceCapture/Pro.


  • Connect RaceCapture/Pro to the RaceCapture app and read the current configuration.
  • Copy the Lua script into the Scripting window:
    • Ensure the script window is first blank by removing the default script by deleting the text in the window.
      • Note: If you have an existing script you want to keep, you will need to blend the camera functionality with your existing script. How to do this is beyond the scope of this guide; see the Lua Scripting Guide for more information.
    • Copy the script into the window by using the ctrl-v keyboard shortcut.
  • Write the configuration back to RaceCapture/Pro.

Gopro script.png

Bench testing

Once the Lua script is written to RaceCapture/Pro, it will attempt to connect to the network created by the GoPro camera. Once connected, it will be ready to issue start / stop commands to the camera.

GoProCameraControl RaceCapture.jpg

Before road testing, ensure RaceCapture/Pro can connect to the GoPro's WiFi network by observing the messages in the window below the script.

  • Tip 1: Touch or click the Poll Log to see the current message in the RaceCapture/Pro log
  • Tip 2: To restart the Lua script, touch or click the 'Restart' button.

Road testing

Mount the GoPro in the car as usual and power up RaceCapture/Pro, waiting for GPS achieve a lock.

  • Drive carefully above the speed threshold and observe the GoPro - you should hear and see the familiar beep and red light activate, just as if you manually started recording using the shutter button on the camera.
  • When you drop below the threshold, the GoPro should stop recording.

As RaceCapture/Pro starts and stops the camera, you will see the following information in the log:

[GoProWiFi] start GoPro
[GoProWiFi] stop GoPro


If RaceCapture/Pro cannot control the camera, check the following:

  • GoPro WiFi network name (SSID) and password: Ensure the name and password currently in the script matches how your GoPro was configured.
  • Enable WiFi on the GoPro: The blue LED on the GoPro should be blinking periodically
  • RaceCapture/Pro WiFi module connection: Ensure the module is plugged into the outermost RJ11 port and the green LED is illuminated.
  • Verify WiFi connection: Ensure RaceCapture/Pro can connect to the GoPro WiFi network. You should see the following messages in the log upon power-up:
[lua] Successfully loaded script.
[GoProWiFi] initializing
[GoProWiFi] ready for GoPro

If RaceCapture/Pro cannot connect to the GoPro's network you will see this in the log:

[GoProWiFi] initializing
[GoProWiFi] could not connect to GoPro
[GoProWiFi] initializing
[GoProWiFi] could not connect to GoPro
[GoProWiFi] initializing
[GoProWiFi] could not connect to GoPro
[GoProWiFi] initializing

Lua Script

The following Lua Script enables WiFi control of your GoPro camera.


You will need to edit the following fields at the minimum, located at the top of the script:


  • GoPro WiFi password: Specify the WiFi password used for the GoPro WiFi adapter
  • GoPro SSID: Specify the GoPro WiFi network name (SSID)


  • goproStart: Change this if you want to start recording at a different threshold.
  • goproStop: Change this if you want to stop recording at a different threshold. Ensure this is less than the start trigger
  • tickRate: Adjust this to update how often you want RaceCapture/Pro to perform a start/stop check. Value is in Hz. If uncertain, leave this alone
  • debug: If things aren't working as expected you can set this to 1 to see the conversation between the WiFi module and the GoPro.
    • This information shows up in the log window below the script window - check the box Poll log to see this information.
--Specify your GoPro wifi password here
goproPwd = '12345678'

--Specify your GoPro SSID here
goproSsid = 'aslhero1'

--Speed threshold to start recording
goproStart = 10

--Speed threshold to stop recording
goproStop = 5

--How fast we check, in Hz
tickRate = 10

--Set this to 1 to log communications between RCP & WiFi
debug = 0
--the serial port where the WiFi is connected
port = 4
--indicates wifiStatus
--0 = not init, 1 = init sent, 2 = got IP, 3 = ready
wifiStatus = 0
lastInitTime = 0
initTimeout = 20000

function logMsg(msg)
  println('[GoProWiFi] ' ..msg)

function sendCrlf()
  writeCSer(port, 13)
  writeCSer(port, 10)

function sendRaw(val)
  for i=1, #val do
    local c = string.sub(val, i, i)
    writeCSer(port, string.byte(c))

function sendAt(val)
  if debug == 1 then logMsg('send: ' ..val) end

function toInt(val)
  return string.sub(val, 1, -3)

function httpGet(url)
  local crlf = string.char(13) ..string.char(10)
  local get = 'GET ' ..url ..' HTTP/1.0' ..crlf ..crlf
  sendAt('AT+CIPSEND=' ..toInt(#get))

function sendGoProShutter(cmd)
  httpGet('/bacpac/SH?t=' ..goproPwd ..'&p=%' ..cmd)

function startGoPro()
  logMsg('start GoPro')

function stopGoPro()
  logMsg('stop GoPro')

recording = 0

function initWiFi()
  sendAt('AT+CWJAP_CUR="' ..goproSsid ..'","' ..goproPwd ..'"')
  wifiStatus = 1

function processIncoming()
  local line = readSer(port, 100)
  if line ~= '' and debug == 1 then print(line) end
  if string.match(line, 'WIFI GOT IP') then 
    wifiStatus = 2
  if wifiStatus == 2 and string.match(line, 'OK') then
    wifiStatus = 3
    logMsg('ready for GoPro')

function checkGoPro()
  if wifiStatus == 0 then
    lastInitTime = getUptime()
  if wifiStatus == 1 and getUptime() > lastInitTime + initTimeout then
    logMsg('could not connect to GoPro')
    wifiStatus = 0
  if wifiStatus ~= 3 then
  trigger = getGpsSpeed()

  if recording == 0 and trigger > goproStart then
    recording = 1
  if recording == 1 and trigger < goproStop then
    recording = 0

function onTick()