Buoy Electronics – *test mule*

Buoy - tempSensor - source-01.png

I hobbled together a “test mule” to streamline work on the buoy electronics. The test mule jargon is borrowed from the  automotive industry and typically refers to a prototype vehicle used for road testing which looks physically different from the production model – this is done to evaluate the performance of the vehicle without revealing the final exterior design.

I’m not concerned about revealing the final design of the buoy (no secrets there, pretty sure will be a yellow float!) but I wanted a bare-bones test platform to experiment with new features without worrying about integrating all the sensors and other bits. So I  stripped out the GPS, IMU, SD card and MEGA, and replaced it with the smaller nRF52 BLE Feather, 0.6W solar panelsolar charger,  LoRa module and DHT22 temperature sensor. Then I crammed everything inside a 3D printed container and put it outside. The container was printed in white PLA and coated with fiberglass resin to weatherproof it, hence the slight yellowish color. *We will see how this holds up during the foggy and moist environmental testing this week*

Buoy - tempSensor - source call out-01.png

*nRF52, not 95 like shown in the image- oops*

Now I can streaming temperature and humidity data to the base station in my kitchen while the test mule is outside in the backyard working away. Or, stream the data over the Adafruit app and see the data on your smartphone for debugging. The code tracks the number of data packets transmitted so it is easy to see if there was an error during transmision.

It may seem trivial, but I see this as a BIG ACCOMPLISHMENT – woot! I’ll see how long the battery can last and monitor if any data packets get dropped while the electronics live outside for the week.

Oh, and the base station saw some love too. It has a bigger antenna and some professionally installed electrical tape to provide all the necessary structural support. Gatta love tape.

Base station - call outs


Features that need to be added :

  • put the microcontroller to sleep in between sensor readings (10 second delay)
  • connect the base station to a Raspberry Pi and steam the data to a website
  • fix issue with signal interference, the BLE drops sometime when LoRa is broadcasting
  • add power monitoring hardware, to track solar panel output and microcontroller needs
  • add magnetic on/off/reset switch


All the example code and hardware is sourced from Adafruit – they are AWESOME! I need to clean up the code a bit before sharing, but when it is ready I’ll post the files on the downloads page. You can find all the other source files there also.


Circuit board – MEGA

Needed more program memory for all the breakout board libraries to run. Redesigned the circuit board to stack on top of an Arduino MEGA 2560 using all the same sensor components. Added a color changing RGB LED on/off switch. The LED acts as an indicator light to show the status of the buoy.

Front view:

Wave Buoy - MEGA - r2 - 1

Wave Buoy - MEGA - r2 - 5.JPG

Rear view:

Wave Buoy - MEGA - r2 - 4

Still working on the firmware to read all the sensors for the buoy. Close, but needs more work. This update demonstrates the framework I’ve created for having the buoy communicate with the base station and is based loosely on the BLE concept (from what I have read thus far). The base station will act as the central device while the buoy will act as a peripheral device. The central device (base station) is responsible for establishing a communication link with the peripheral device (buoy), then the central device determines back-and-forth communication speed.

The base station is seen below. This is one of the previous prototype circuit boards for the Arduino UNO. The UNO has enough program memory to run the base station code.

Base station - r2.JPG

Here is a quick example video showing the basic communication protocol for the buoy and base station:


Schematic design:

IMAGE - Wave Buoy - MEGA - R2_4

Circuit board design:


Download source files > sorry no github yet, coming soon!

Example running firmware on buoy (left) and base station (right).

Screen Shot 2018-05-13 at 2.55.24 PM

Base station successfully established communication link with the buoy,  and then the base station issues each of the different commands to the buoy to verify the response.

Screen Shot 2018-05-13 at 2.55.38 PM

Next up, need to get all the sensors working and sending real data back to the base station.

Circuit board with Arduino UNO


“Fail early and fail often”

In an effort to get something in the water as quickly as possible I decided to go back to the basics. A lot has happened since my last post – so this an effort to fill in the gaps.

This will talk about the first version of a new circuit board design. I’ve since completed a second version based on lessons learned.

——————————————————- FLASH BACK! ———————————————————–

I was having problems integrating the LoRa radio with the BLE nRF52 Feather. There seemed to be an issue with getting the RadioHead library to work with nRF52 hardware. According to Adafruit the nRF52 feather is under ongoing development. Here is the link to the customer forum post that is tracking this topic. The most recent updated says there is now a fix.  Pushing firmware updates to the buoy wirelessly over BLE would be handy – but it is certainly not required at this stage of the project.

So, I decided to drop the BLE for now. Digging around in my electronics bin I found two Arduino UNOs, one MEGA 2560, and two 10,000 mAH lipo USB battery packs. These Arduino boards all require 5V input – one reason I wanted to use a 3.3V rated microcontroller like the BLE Feather.  Not a big deal for now,  I can ditch the solar panel and charging circuit and use the lipo battery packs for initial testing. Awesome, just removed two more components from the build!

The electronics layout and design was done in Eagle CAD using my own custom library components. Creating each component was TEDIOUS… but now I can reuse the components in the future. My first design aptly named “Wave Buoy – Arduino UNO – V1”  had the UNO and the breakout boards mounted on the top surface of the board. This was done to minimize the overall height of the assembly since there was limited space inside the buoy.

Schematic - Wave Buoy - UNO - R3.png

Once the schematic is completed in Eagle you switch over to board layout mode and place all the components. This is where creating custom library components really helps because you can define the footprint and pinout for the actual hardware. In my case, most of the pieces being mounted to the circuit board are all breakout boards, not discrete surface mounted components.  Placement of the components is KEY. A clever arrangement will help minimize the number of vias and keeping the trace paths as simple as possible.

The schematic for revision 1 (R1) to revision 3 (R3) of the board did not change much, but the layout was improved during each revision. R1 was full of mistakes, the UNO was mounted in the wrong orientation and the board was only powered through the UBS port. R2 was a huge improvement and my first fully working board; it added an ON/OFF switch to control the lipo battery power, but the assembly process was slow as I had lot of vias to transfer traces from the bottom to the top layer. R3 reduced the number of vias  after moving the components around, and added ground planes to the top and bottom layers to minimize signal noise. I must have tried six unique layouts for before milling the first boards. Below shows R3 with *most* of the issues from R1 and R2 fixed.



I used an Othermill desktop CNC machine to fabricate all of the boards. This required a V-bit tool to engrave the traces and pads, and a 1/32″ flat end mill to droll the holes and cut out the board profile.


An image of the R2 board with the UNO and all the boards mounted. I didn’t want to solder the breakbout board directly to the copper board. Instead I soldered on headers to the copper board so that the breakout boards could be easily removed and reused. This was critical, since I went through three revisions of the board before fixing most of the errors. All of this could fit within the footprint of the lipo battery pack.

IMAGES - wave buoy - Arduino UNO Build - 9 copy

With the board fully assembled I tested each component individually to verify proper function. At this time I was only  interested in verifying each part was working as a stand-alone unit to test that all solder points and traces were OK.

The battery and circuitboard were then mounted to a thin flat mounting plate using lots of yellow and white electrical tape. Not a long term solution, but it works. The mounting plate was superglued to the underside of the buoy lid so everything was hanging from the bottom  and easy access and work on.

IMAGES - wave buoy - Arduino UNO Build - 6IMAGES - wave buoy - Arduino UNO Build - 8

Finally, I pulled all the example programs for each of the components into a single Arduino sketch and hit UPLOAD to the Arduino UNO……


The sketch size exceeded the available program memory on the UNO – and not by a trivial amount. So rather than modifying all the code and library files to minimize the memory requirements I decided it was best to use a different microcontroller with more memory. By comparison, the MEGA 2560 has 8x more flash memory than the UNO. This would give me plenty of extra memory to work with so I could focus on the firmware functionality and worry less about optimizing code to save bits of memory.

So, many lessons learned. Most importantly, it would have been better to create a sample firmware program BEFORE I chose to design the circuit board around the UNO microcontroller. Even an rough draft of the code would have indicated that all the libraries needed to support the breakout-board would be pushing the limits of the UNO. But, at least I have another reason to design and fabricate a new circuit board!

Next post, I redesign the circuit board to be compatible with the Arduino MEGA 2560 and dive into the firmware.


nRF52 – program sketches “Over the Air”

The electronics will be sealed in a water-tight canister. To simplify the debugging process I want to be able to wirelessly update the microcontroller’s firmware using Bluetooth LE from my iphone or laptop.

So I’ve upgraded to the Adafruit nRF52 Feather microcontroller. This board can be programmed using the Arduino IDE (super easy!) and offers users the ability to update the sketches wirelessly. This is referred to as Over the Air (OTA) Device Firmware Update (DFU) mode.

This is a quick tutorial on how I was able to get OTA DFU working. Please note the following warning about OTA DFU from Adafruit’s website, as of March 11, 2018:

Screen Shot 2018-03-11 at 4.08.29 PM

For this tutorial you will need the following items (sorry I’ve only tested usng iphone + mac)

  • Adafruit nRF52 Feather
  • Micro USB programing cable // connect computer to the Feather
  • iPhone // tested with iOS 11.2.6
  • NRF Toolbox app //to push OTA DFU, tested with V4.4.4
  • Adafruit Bluefruit Connect App // optional, tested with V3.3.1
  • iTunes // wireless file transfer zip files to iPhone, tested with V12.7.3.46
  • iphone data transfer cable // connect iPhone to laptop via USB
  • Arduino IDE // set to have verbose output during compilation, tested with V1.8.5


Step 0

Download and install the NRF Toolbox app. Optionally, you can also choose to install the Adafruit Bluefruit Connect App. *Note – the Adafruit App also offers OTA DFU, but I was not able to figure this out yet – hopefully in the near future this will work and then you would only need the Adafruit app. Also – I like the Adafruit UI better than the NRF Toolbox when testing UART messages, just a personal preference.*


Step 1

Setup your Arduino IDE following the instruction on the Adafruit Learning Guide. Then verify everything is working with their included blink.ino sketch in the nRF52 Feather examples.

Step 2

Upload the sketch “_03_TEST_BLE_UART.ino” (shown below) using a wired USB connection to the nRF52 Feather. This sketch will set the Feather into BLE search mode so that you can connect to the device. Once a connection is established you can open a UART connection and receive messages to the iphone.

This is an example for our nRF52 based Bluefruit LE modules

Pick one up today in the adafruit shop!

Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

MIT license, check LICENSE for more information
All text above, and the splash screen below must be included in
any redistribution



BLEUart bleuart;

void setup(void)
Serial.println(F("Adafruit Bluefruit52 Controller App Example"));


// Configure and start the BLE Uart service

// Set up the advertising packet

// Start advertising

// initialize digital pin LED_BUILTIN as an output.

void setupAdv(void)

// Include the BLE UART (AKA 'NUS') 128-bit UUID

// There is no room for 'Name' in the Advertising packet
// Use the optional secondary Scan Response packet for 'Name' instead

@brief Constantly poll for new command or response data
void loop(void)
// send message to BLE UART
bleuart.println(" BLE UART TEST - 00");

// flash the onboard red LED
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW



Step 3

Open up the Adafruit app and verify that the UART message is correct. It should look something like this:

Adafruit Bluefruit Connect App

Step 4

Setup the Arduino IDE for verbose output.

Screen Shot 2018-03-11 at 3.44.12 PM

Step 5

Modify the message within the sketch to say something new. I updated the end of the message so say “99” and saved it with a new file name “_03_TEST_BLE_UART_II.ino”.

Screen Shot 2018-03-11 at 4.20.42 PM

This is the new sketch that we want to wirelessly send to the nRF52 Feather and have it update over the air. At this point, hit the VERIFY button, but do NOT upload this new sketch to the board. This is how we test to verify the the OTA DFU worked in the later steps. If you accidentally upload this new code to the board, just change the message back to the original before proceeding.

With the verbose output during compilation turned ON, you should see messages at the bottom of the Arduino IDE screen. One of these messages tells us the location of a ZIP file that was created during the compile process – WE NEED THIS ZIP FILE!

Look for the directory location, it is a temporary file – copy and paste the address into the SEARCH toolbar. You may need to delete the zip file name, and just look for the folder.

Screen Shot 2018-03-11 at 4.26.58 PM.png

Once you find the folder that is holding the zip file, it will look something like THIS:

Screen Shot 2018-03-11 at 4.34.08 PM

Copy/paste the zip file to the desktop or your downloads folder.

Step 6

Setup your iphone + NRF Toolbox app to receive wireless file transfers.  The NRF Toolbox app provides instructions.

Open the NRF Toolbox app and click on the “DFU” button, then click on “Select File”, then click on “User Files” and then click on “How to…” for the instructions about syncing iTunes with the iphone for zip file transfer to the app.

With iTunes open and the iphone paired to the laptop, transfer the zip file to the NRF Toolbox app. You will need to use a USB to setup the paired connection, but once it has been setup you can wirelessly transfer the zip files from the laptop to the iphone app. YAY – no more cables!

Screen Shot 2018-03-11 at 4.44.34 PM

Step 7

Now when you open the NRF Toolbox app and go into the DFU mode,  you should see the zip file in your “USER” files. Pair to the nRF52 Feather, select the zip file and hit UPLOAD. You will see a progress bar to verify the upload is happening. If you see a “Connecting” message for more than 5 seconds then something is not correct and you will need to abort the upload. This may even require that you reflash the firmware via the USB cable.



Once the DFU process is complete, the nRF52 Feather will reboot itself. Open up the UART using the iphone app and check the message to see if it has changed to “99”. It should look like this if everything worked!



YAHOO! Now we can update the code running on the microcontroller wirelessly.

BUT remember, this has the potential to brick your microcontroller so it is not recommended that you do this – at this time. Based on the Adafruit help forum, is sounds like they are working to make this process safe and reliable from within the Adafruit Bluefruit Connect app – so I’ll try to figure that out later.



Buoy Float – pool filter

I’ve decided to resurrect an old idea and use a pool chlorine filter as the primary floatation for the buoy project. While I have been very attached to the yellow 3D printed sphere, I’ve had concerns that using an entirely 3D printed hull was not the most practical choice.

So… looks like I am back to one of my original designs…



The yellow sphere is not very easy to manufacture (long print time…) and it combined both the floatation and electronics housing into a single form factor. If something where to strike the yellow sphere and damage the hull, it’s likely the impact would cause a leak and ruin the electronics inside. After more consideration, I’d prefer to have a redundant design that would be more resilient to damage and allow me to quickly/easily transfer the electronics to a different float if needed.
For this latest idea the electronics are housed inside a canister that can be secured into the center of a standard pool float, the type used to dispense chlorine into residential pools. I sourced mine online and found several options ranging from $8 – $15  with free shipping.

Ocean Buoy - 1

The canister will be water tight. It is made up to three pieces: a top part that will hold a round solar panel, a bottom piece to hold the electronics and battery, and a black gasket sandwiched in-between the top and bottom pieces which forms a water tight seal. The top/bottom parts were 3D printed in white ABS on a Lulzbot Taz 6, super awesome printer! I printed my own gasket from black Ninja Flex filament, is is very flexible and feels like rubber. Not sure how it will hold up to sea water… more experiments are needed!

Ocean Buoy - 2Ocean Buoy - 3

The 3D printed parts are not yet water tight, so I’m going to try and infuse them with marine epoxy. Maybe I’ll try using a vacuum bag method or some way to force the epoxy into all the voids and crevices. This will give the parts added strength and make them suitable for being submerged underwater. Thats the thought, at least.

I’m use 316 stainless steel hardware ordered from McMaster-Carr. They have EVERYTHING! The twist-resistant threaded inserts were press-fit into the top of the canister after drilling out 4.7mm holes. They inserts appear to be holding up pretty well, even after repeated use. But it may be a good idea to use some epoxy for added strength during the installation. One change for next time, I’ll be ordering 10mm long machine screws.

Buoy - Hardware


The bottom part of the canister has two tabs that are designed to interlock with the pool float.  These mimic the same functionality as  the tabs molded into the lid of the pool float and provide a snap lock. To mount the canister into the pool float,  you drop the canister into the float,  insert to metal posts of the tool into the top of canister, and rotate 180 degrees to lock the canister securely in place. Ocean Buoy - 4Ocean Buoy - 5

The 3D printed tool has two metal posts, 1/8″ diameter riots, jammed into the handle. The metal posts fit into two receiving holes in the top of the canister and allow the user to lock the canister into the float.Ocean Buoy - 6Ocean Buoy - 7Ocean Buoy - 8Ocean Buoy - 10Ocean Buoy - 11

The top piece of the canister will hold a round solar panel. I’ll use marine epoxy to secure it in place. The solar panel is rated for a 0.6W output.  I am hopeful that I can drill a hole through the solar panel to allow the LoRa antenna to poke through. While this is a round solar panel,  the actual solar cells are rectangular so there is some empty space on either side of the cells. Ocean Buoy - 13



LoRa Radio – test #1 : one mile

LoRa Radio

I’d like to transmit data from a buoy floating in the water to a base station on shore. Power consumption and broadcast range are primary considerations. The amount of data being transmitted is expected to be minimal.

Screen Shot 2017-11-28 at 12.11.50 AM

I purchased two of the Adafruit RFM95W LoRa Radios to see if this might be a suitable solution. They were fairly inexpensive so I figured it was worth a test. The modules transmit on a license-free frequency and the Adafruit website says signals can travel 2 km – 20 km (1.4 – 12.4 miles) depending on the type of antenna used.

During the Thanksgiving holiday I had the opportunity to test the range of two LoRa radios in a neighborhood in Eugene, Oregon.  I wired up an Arduino Uno and Pro Trinket following the Adafruit provides tutorial, see their tutorial for all the details.

The Pro Trinket was setup as the Transmitter, this was located at the house. The Uno was setup as the Receiver and plugged into my laptop so I could watch the serial monitor as I walked around the neighbor hood. I was happily surprised, the radios transmitted one mile through in the suburban area with lots of trees and buildings in the way. While this isn’t ground breaking news, it was nice to conduct a real-world test and verify the websites claim. Below is the google maps screen shot from my phone that was used to verify the distance of approximately one mile.


Unfortunately I had to end the walk-about when it began to rain. But I plan to conduct more range tests to see how far these little radios and -2dB quad band antennas can broadcast. One interesting observation: I was not getting all of the data being sent from the transmitter at the house. The simple “hello world” example sketch included a counter to track the number of messages being sent out by the transmitter. At the end, it appears that every fifth message was being received. I’ll need to learn more about mitigating this issue in the future, but for now this is a good enough “first test”.

Screen Shot 2017-11-27 at 10.01.23 PM

Terrain will play in big factor  in determining maximum range, so I’d also like to run another test over a large body of water to see how the signal attenuates. This would be more similar to the conditions experience when the buoy is deployed. Maybe I can use a kayak and deploy a really simple buoy in the harbor and see if I can receive a message from my office building in Sausalito, CA.

More exploration onto the world or radios is needed!



New Circuit Board Design – r2

Version – 2

I’ve been learning how to use Eagle CAD to layout circuit boards and export gerber files. We have an Othermill CNC machine at work so I am beginning to prototype double sided boards for the buoy. This is the second version of my initial design – or what I am calling r2. *More info on my first design below…*


This copper board is essentially a larger “mother board” with headers for each of the smaller breakout boards to plug into. I used headers rather than soldering the breakout boards directly to the copper so that I can reuse the modules or replace them if needed. I expect I’ll go through several revisions and improvements as I learn more.

The following breakout boards are included on the copper board:

  • Microcontroller (MCU) >>> Adafruit Pro Trinket 3V 12MHz
  • Radio >>> Xbee Series 1 — sending data to second Xbee + FTDI cable + laptop
  • Inertial measurement unit (IMU) > Adafruit BNO055 sensor; accelerometer, gyroscope, magnetometer
  • GPS >>> GPS module for time and position information
  • Data logging > SD card read/write + micro SD card

So far so good, my r2 board is working and all of the individual modules are wired up correctly. But there are still improvements that need to be made. For example, the board cannot function on battery power yet. I included a connection for adding a small lipo battery + charger, but it is not hooked up correctly – I need to update the traces so that the BAT pin on the microcontroller goes to all Vin pins on the breakout boards instead of the BUS pin. *Ooops*

Version – 1

Below are images of my first double sided circuit board. I finished this one evening in October and soldered all the headers onto the copper board using some liquid flux and a small soldering iron with a sharp tip. You can see that some of the 1/64″ holes did not get drill through all the way.

Unfortunately, I made the mistake of connecting the microcontroller BUS pin to all my breakout boards via their 3V3 pins. The BUS pin provides 5V and up to 500 mA of current when the microcontroller is powered by the micro USB. When I attempted to upload the firmware via the USB cable, I accidentally burnt the Xbee radio and had to order two new modules. Luckily I only had the Xbee + MCU plugged into the copper board at that time so the delicate Xbee was the only fatality.

Lesson learned. Send all power into the modules via their 5V or Vin pins; Adafruit typically includes a 3v3 compatible voltage regulator so their boards are 5V/3V safe (if you wire up the correct pin).


More updates will include:

  • adding a Real Time Clock
  • adding an RGB LED
  • adding a temperature probe
  • redesign the board to be a circle shape
  • add a LoRa radio or other transmitter
  • fix the lipo battery problem
  • add a solar charger circuit

Version – 3

I’ve already started to incorporate updates to the design. Below is an example of the board with an added ground plane and the addition of an RGB LED and room for a digital temp sensor. Once I get the board to a more polished stage, I plan to share the source files and include a schematic drawing. But that has not been completed yet.

Screen Shot 2017-11-27 at 11.13.30 PMScreen Shot 2017-11-27 at 11.13.46 PM