Our autonomous cooler has two modes: GPS Streaming and GPS Waypoint. While in GPS Streaming mode, the cooler will follow you by streaming coordinates from your phone. In GPS Waypoint mode, you can send a predetermined set of coordinates that the cooler will travel to.
Disclaimer: When testing the cooler, we noticed that the GPS coordinates streamed from Blynk were often inaccurate. While it works for some locations, it doesn't for others. If you want high precision, we highly suggest creating your own Android app to stream GPS coordinates.
All files for this project are contained in the /cooler
directory. Open the directory and click the cooler.ino
. The Arduino IDE should open with all of the files in that directory.
You need to make sure to install the following dependencies through the Arduino library manager (Sketch->Include Library->Manage Libraries...)
- Adafruit Sensor
- Blynk
- Adafruit_HMC5883_Unified
You'll need to configure a few variable definitions for the code to work with your configuration. CoolerDefinitions.h
contains variables that you can edit to switch pins, tweak parameters, and configure your Blynk app.
The most notable is the char auth[]
variable. Replace the auth string (inside the quotes) with the auth token generated by your Blynk app.
Most of the components on this robot are connected via Digital I/O pins. These pins can be changed by adjusting the following variables in CoolerDefinitions.h
.
#define SERVO_PIN 3
#define GPS_TX_PIN 6
#define BLUETOOTH_TX_PIN 10
#define BLUETOOTH_RX_PIN 11
#define MOTOR_A_EN_PIN 5
#define MOTOR_B_EN_PIN 9
#define MOTOR_A_IN_1_PIN 7
#define MOTOR_A_IN_2_PIN 8
#define MOTOR_B_IN_1_PIN 12
#define MOTOR_B_IN_2_PIN 4
Make sure that the following pins are connected to PWM ports (we had no available PWM ports left when everything was attached):
#define SERVO_PIN 3
#define GPS_TX_PIN 6
#define BLUETOOTH_TX_PIN 10
#define BLUETOOTH_RX_PIN 11
#define MOTOR_A_EN_PIN 5
#define MOTOR_B_EN_PIN 9
The following variables were used for configuration. Adjust them as you see fit.
// If one motor tends to spin faster than the other, add offset
#define MOTOR_A_OFFSET 20
#define MOTOR_B_OFFSET 0
// You must then add your 'Declination Angle' to the compass, which is the 'Error' of the magnetic field in your location.
// Find yours here: http://www.magnetic-declination.com/
// Mine is: 13Β° 24' E (Positive), which is ~13 Degrees, or (which we need) 0.23 radians
#define DECLINATION_ANGLE 0.23f
// The offset of the mounting position to true north
// It would be best to run the /examples/magsensor sketch and compare to the compass on your smartphone
#define COMPASS_OFFSET 0.0f
// How often the GPS should update in MS
// Keep this above 1000
#define GPS_UPDATE_INTERVAL 1000
// Number of changes in movement to timeout for GPS streaming
// Keeps the cooler from driving away if there is a problem
#define GPS_STREAM_TIMEOUT 18
// Number of changes in movement to timeout for GPS waypoints
// Keeps the cooler from driving away if there is a problem
#define GPS_WAYPOINT_TIMEOUT 45
In order for our servo-driven lid to work, we had to fine tune the start and stop angle so that we could get the right leverage on the lid. They can be given a value between 0 and 180.
// PWM write for servo locations
#define SERVO_LID_OPEN 20
#define SERVO_LID_CLOSE 165
Once you have everything configured property, verify and upload the code to your Arduino. If you are outside, it will take a few seconds for the GPS to acquire a satellite lock. Once it does, it will begin flashing.
Make sure your android device is paired with HC-05 bluetooth module. If it asks for a password, it should be default 1234
. Open Blynk and press play!
If your computer is connected via USB, you can also open the serial monitor and observe events on 4800 baud rate.
If you have any problems, please post an issue and we'll try to help solve it.