Skip to content

Instantly share code, notes, and snippets.

@sk-t3ch
sk-t3ch / gps-radio-receiver.ino
Created March 2, 2021 21:42
Smart Buoy - Receive GPS data with nRF24L01 Radio
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(8, 7); // CE, CSN
struct dataStruct{
double latitude;
double longitude;
@sk-t3ch
sk-t3ch / gps.ino
Created March 2, 2021 21:36
Smart Buoy - How to use a GPS module to get datetime and location
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
TinyGPSPlus gps;
SoftwareSerial ss(4, 3);
struct dataStruct{
double latitude;
double longitude;
unsigned long date;
@sk-t3ch
sk-t3ch / water_temperature.ino
Created March 2, 2021 21:05
Smart Buoy - How to use a Water Temperature sensor (DS18B20)
#include <onewire.h>
#include <dallastemperature.h>
OneWire oneWire(6);
DallasTemperature sensors(&oneWire);
float water_temperature;
void setup() {
Serial.begin(115200);
sensors.begin();
@sk-t3ch
sk-t3ch / wave_power.ino
Last active March 2, 2021 21:03
Smart Buoy - Crude Wave Power
// Wave power formula: P = 0.5 height ** 2 * period // https://en.wikipedia.org/wiki/Wave_power
#include "Wire.h"
#include "I2Cdev.h" // Get these libraries from https://github.com/jrowberg/i2cdevlib/tree/master/Arduino
#include "MPU6050.h" // ^
#include <MS5611.h> // Get this library from https://github.com/jarzebski/Arduino-MS5611
MPU6050 mpu;
MS5611 baro;
long pressure;
@sk-t3ch
sk-t3ch / wave_period.ino
Created March 2, 2021 21:00
Smart Buoy - Crude Wave Period
#include "Wire.h"
#include "I2Cdev.h" // Get these libraries from https://github.com/jrowberg/i2cdevlib/tree/master/Arduino
#include "MPU6050.h" // ^
#include <MS5611.h> // Get this library from https://github.com/jarzebski/Arduino-MS5611
MPU6050 mpu;
MS5611 baro;
long pressure;
double altitude, min_height, max_height, mid_point, smudge_factor;
@sk-t3ch
sk-t3ch / wave_height.ino
Created March 2, 2021 20:58
Smart Buoy - Crude Wave Height
#include "Wire.h"
#include "I2Cdev.h" // Get these libraries from https://github.com/jrowberg/i2cdevlib/tree/master/Arduino
#include "MPU6050.h" // ^
#include <MS5611.h> // Get this library from https://github.com/jarzebski/Arduino-MS5611
MPU6050 mpu;
MS5611 baro;
long pressure;
double altitude, min_height, max_height, wave_height;
@sk-t3ch
sk-t3ch / gy_86_barometer.ino
Created March 2, 2021 20:56
Smart Buoy - How to use a GY86 MS5611 (Barometer) to measure air pressure and temperature
#include "Wire.h"
#include "I2Cdev.h" // Get these libraries from https://github.com/jrowberg/i2cdevlib/tree/master/Arduino
#include "MPU6050.h" // ^
#include <MS5611.h> // Get this library from https://github.com/jarzebski/Arduino-MS5611
MPU6050 mpu;
MS5611 baro;
double temp;
long pressure;
@sk-t3ch
sk-t3ch / gy_86_magnetometer.ino
Created March 2, 2021 20:54
Smart Buoy - How to use a GY86 HMC5883L (Magnetometer)
#include "Wire.h"
#include "I2Cdev.h" // Get these libraries from https://github.com/jrowberg/i2cdevlib/tree/master/Arduino
#include "MPU6050.h" // ^
#include "HMC5883L.h" // ^
MPU6050 mpu;
HMC5883L mag;
int16_t mx, my, mz;
@sk-t3ch
sk-t3ch / gy_86_accelerometer_gyroscope.ino
Created March 2, 2021 20:52
Smart Buoy - How to use a GY86 MP6050 Accelerometer/Gyroscope
#include "Wire.h"
#include "I2Cdev.h" // Get these libraries from https://github.com/jrowberg/i2cdevlib/tree/master/Arduino
#include "MPU6050.h" // ^
MPU6050 mpu;
int16_t ax, ay, az;
int16_t gx, gy, gz;
@sk-t3ch
sk-t3ch / bad_wave_direction.ino
Created March 2, 2021 20:48
Smart Buoy - Wave Direction using MP6050 (Accelerometer/Gyroscope) and HMC5883L (Magnetometer)
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#include "HMC5883L.h"
#include "Wire.h"
MPU6050 mpu;
HMC5883L mag;
int16_t mx, my, mz;
#define INTERRUPT_PIN 2 // use pin 2 on Arduino Uno & most boards