By Michael Harper

In 2017, I purchased my first travel trailer. Soon after, I was also looking to buy a navigation system and a backup camera for the tow vehicle. After some research, I settled on the Garmin RV770 LMT-S GPS and the compatible wireless BC 30 backup camera. The GPS installs on the inside of the tow vehicle’s windshield via suction cup. The backup camera, on the other hand, requires more permanent mounting on the back of the trailer as well as wiring into its 12V circuit. The GPS itself is extremely useful for routing, distance/time estimates, and warnings for upcoming hazards like steep grades and sharp turns. But whenever the backup camera is on (e.g. it has power to it), the GPS screen is entirely taken over by the backup camera. Without some sort of ability to turn the power to the backup camera on and off remotely, the setup is less-than-ideal. Some RVers have wired the backup camera to the running lights on the trailer. This also seems less-than-ideal as whenever the tow vehicle’s headlights were on (when it’s dark out, for example), the camera would also be on, defeating the utility of the GPS. There’s a pin on a 7-pin trailer connector that comes on when the tow vehicle is in reverse. Unfortunately, my travel trailer doesn’t have backup lights. To use this approach in order to make the camera come on only when in reverse, I would have to run a wire from the entire length of the trailer and figure out how to fish it into the location where I need it. If only there were a wireless way to turn the backup camera on and off….

Among my numerous responsibilities as a veteran engineer for Flybuy, I have written a lot of code for communicating between mobile devices (primarily iOS and Android) and Bluetooth LE devices. Most recently, I wrote the iOS configuration app for the new Radius Networks RadBeacon E line of beacons. The app scans for Radius RadBeacon E devices, sets up a Bluetooth connection, and reads and writes values to and from the beacon’s Bluetooth characteristics. This straightforward approach is applicable to communicating with virtually any Bluetooth LE device, regardless of its function.

Having recently built a Bluetooth LE weather station using an Adafruit Feather 32u4 Bluefruit LE with a variety of environmental sensors, I figured I’d look for a BLE solution to my camera problem. That’s when I found the Adafruit Power Relay FeatherWing which looked like the perfect way to operate my camera from an Adafruit Feather nRF52832. Although my real-world problem is turning a camera on and off, the solution here simply turns a power relay on and off. That is, anything you can SAFELY connect up to this relay can be turned on and off.

You can do this, too.  Here’s everything you need to know:

Prerequisites

  • You need to be at least an intermediate level mobile and firmware developer. Basics of iOS and Arduino development will not be covered here, such as how to create a new project in Xcode or in the Arduino IDE.

  • Although the work here is on iOS/watchOS/tvOS, an experienced Android developer should be able to replicate the approach on Android without difficulty.

  • If you are interested in running the iOS/watchOS/tvOS code presented here in order to connect to your own Feather, you’ll need an actual iOS/watchOS/tvOS device since the simulators do not support Bluetooth.

  • If you want to build your own Feather + relay module, then you’ll need to be comfortable soldering as well as using the Arduino IDE to install firmware onto the Feather.

Materials

Assembling the Feather + FeatherWing

I chose to assemble the Feather with female headers on top of the board.

I then soldered male headers underneath the FeatherWing relay board so they can be assembled as a compact unit.

In order to tell the FeatherWing which pin to use as input to control the relay, you need to bridge the two pads next to the pin underneath the board with a spot of solder. I used A0.

Programming the Feather

Arduino code for the Feather can be found here.

I used the Adafruit Feather nRF52 Bluefruit Library to configure the GATT service and characteristic I needed for controlling the relay. I configured the characteristic for read, write, and notify. Writing 0x01 to the characteristic results in digitalWrite of 0x01 to A0 which in turn closes the relay providing power to the backup camera. Similarly, writing 0x00 to the characteristic opens the relay. Here’s a handy table to explain it all:

I also wasn’t happy with the behavior of the LEDs on the Feather, so I reprogrammed those. Now, whenever there is a Bluetooth connection, the blue LED is on solid. And whenever the board has power, the red LED flashes.

Writing the iOS App

Xcode project can be found here.

I encapsulated the Bluetooth LE conversation and functionality in a singleton class named Kevin (the name of the trailer). All of the peripheral discovery, connection, and conversation take place in that class. Since I expect there to be only one of these devices available, the app automatically connects to the first one it sees during the Bluetooth scan. Other than that, I simply wired up two buttons: one to connect or disconnect the Bluetooth connection, and another button for toggling the state of the relay once connected. Upon disconnecting from the Feather, the relay is automatically opened, turning power off to the backup camera.

Running the App on watchOS and tvOS

By encapsulating the Bluetooth LE functionality, it became a straightforward process to create equivalent apps that run on watchOS and tvOS. You can see these two additional targets in the Xcode project.

Results

Here’s a video of the relay being controlled from the app on my Apple Watch. You can see the red LED come on when the relay is closed and go off when the relay is opened. You may also be able to hear the clicking sound of the relay closing and opening.

Where do you go from here?

Using this project as a starting point, here are a few ideas that might be fun to implement:

  • Add a tactile button so that the relay can be operated manually in addition to using BLE/an app.

  • Add “Hey, Siri” support so that you can say, “Hey, Siri, turn on the backup camera.”

Epilogue

I started this project using an Adafruit nRF52832 Feather. After all was said and done, the board was not connectable from my iPhone when I was outside the trailer, even when I cranked up the transmit power of the nRF52832 to its maximum of +4dBm. I ended up purchasing an Adafruit nRF52840 Feather which not only goes up to a transmit power of +8dBm but also supports Bluetooth 5 “extended range.” Turning the transmit power all the way up to +8dBm did the trick in this case, and I was able to connect to the Feather inside the trailer from my phone inside my tow vehicle no problem! In addition to the higher maximum transmit power and extended range support, the newer Adafruit nRF52840 Feather has a number of improvements over its predecessor. I’d definitely recommend using it over the Adafruit nRF52832 Feather.