Lessons and the learning game

Build an ocean data buoy

An ocean data buoy on an Uno: water temperature, significant wave height, position, solar power and compact LoRa telemetry, sleeping between reports.

The finished buoy

Every lesson opens on the same wiring:

  • Water temperature: a DS18B20 on pin 7, with its 4.7k pull-up on the module. 12 bits gives steps of 0.0625 C.
  • Motion: an MPU6050 on I2C at 0x68, read register by register on the 2 g range.
  • The heave rig: a potentiometer on A0 that sets the mean wave height, from 0 to 1 m.
  • Position: a NEO-6M GPS on SoftwareSerial pin 4, read with TinyGPS++, moored in the Chesapeake Bay off Annapolis.
  • Power: a 6 V solar panel through an INA219 at 0x40 into a 33 ohm load standing in for the charger.
  • The radio: an SX1278 LoRa module at 433 MHz, spreading factor 9.

How it works

Waves from motion. Mokxi's MPU6050 feels tilt, not a swell, so the sketch adds the vertical acceleration of a train of 4 s waves to what the chip reads, the way wave sensors are tested on a heave rig. The wave heights cycle through nine factors of the knob's mean (0.5 to 1.9 times it). The sketch takes gravity away with a slow running mean, starts a wave each time the acceleration crosses zero going down (exactly when the sea surface crosses its mean going up), and turns each wave's acceleration range into a height: for a wave close to a sine of period T, the height is the range over w², where w = 2 pi / T. The significant wave height, Hs, is the mean of the highest third. At the knob's halfway point that is 0.83 m, with a period of 4.0 s.

The watch circle. A moored buoy swings around its anchor on a slack chain. Farther than 50 m from the mooring, it is adrift: it sets a flag and reports every record.

The power budget. Each report the buoy is awake about 30 s at 60 mA and on the air 0.4 s at 120 mA, and asleep the rest at 0.2 mA. A report every 10 minutes averages 3.27 mA, against 60 mA awake all the time; once an hour, 0.71 mA. With under 100 mW from the panel the buoy sleeps longer.

The packet. Each report is 18 bytes: id, sequence number, temperature in hundredths of a degree, Hs in centimeters, period in tenths of a second, latitude and longitude in hundred-thousandths of a degree, panel power and flags. The same report as text is about 70 bytes, and the first report goes out both ways so the airtimes can be compared.

Sleep. Between records the radio and the MPU6050 are told to sleep and the Uno powers down until the watchdog wakes it 8 s later.

The catalog lists this course on an ESP32. It is built on the Uno, whose firmware has every library it needs and whose sleep modes the simulator models.

The course

Build an ocean data buoy gets there in six lessons, each a sketch on the same wiring:

  1. Water temperature: OneWire, resolution and the time it costs.
  2. Wave height from motion: zero crossings, height from acceleration, Hs.
  3. Position: a GPS fix and the watch circle.
  4. Solar power: the INA219 and the duty cycle.
  5. LoRa telemetry: 18 binary bytes against 70 bytes of text.
  6. Project: a bay buoy: the whole cycle, with sleep, drift and low sun.

Every step but the last is checked against the running circuit.