Well I’ve been sitting on this one for a while and finally have time to write it up. With my boat sitting on a mooring, I wanted a easy way to check it’s vital signs: such as position, battery voltage and bilge level. There are now dozens of internet connected microcontrollers available, and I happened to choose the MKR1000 from Arduino.
There are also now hundreds of cloud based IoT services for aggregating data from devices. I found that ThinkSpeak was easy to setup and free for low volumes of data. Click the following graph to see the live version currently in use on my boat:
Pretty cool huh? So let me show you how to create a basic boat monitor using the MKR1000 and ThingSpeak!
- An Arduino MKR1000.
- Mobile 3G or 4G Wifi Modem.
- A GPS Module.
- Float Switch to monitor the bilge.
- A few resistors to monitor battery level.
Firstly, check out ThingSpeak and create an account. Then create a channel, fill in the name, description and enable/label the first four fields like so:
Save your channel, and you should see some empty graphs. Next go to the API Keys tab and copy your “Write API Key”. We will need to put this in the Arduino code.
Wire up the MKR1000 as follows:
- You can use any sort of GPS module that spits out NMEA sentences. Just remember to change the baud rate in the code.
- You will need to power the MKR1000 via a USB cable. The VIN pin can only accept 5V, do not connect higher voltages or you will fry the board.
- The battery voltage measurement terminals use a resistor divider which lets them measure 0 to 18.8V.
First, follow this setup guide and make sure you can compile and upload sketches for the MKR1000.
Edit the code, and enter your ThingSpeak “Write API Key”, your Wifi SSID and password.
Essentially the code will connect to ThingSpeak every 60 seconds and report 4 values:
- Battery voltage on pin A1.
- The number of seconds between updates that the bilge switch has been on.
- GPS Latitude.
- GPS Longitude.
Compile your changes, and upload to the MKR1000. You should get something like the following out of the serial terminal. Check ThingSpeak and you should see a new data point on the graphs!
SSID: BoatWifi IP Address: 192.168.1.35 signal strength (RSSI):-82 dBm Setup Complete Connecting to ThingSpeak... field1=12.72&field2=0&field3=0.000000&field4=0.000000 HTTP/1.1 200 OK Content-Type: text/html; charset=utf-8 Content-Length: 1 Connection: close Status: 200 OK X-Frame-Options: ALLOWALL Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE, PATCH Access-Control-Allow-Headers: origin, content-type, X-Requested-With Access-Control-Max-Age: 1800 ETag: "c4ca4238b0b923820ecc509a6575849b" Cache-Control: max-age=0, private, must-revalidate Set-Cookie: request_method=POST; path=/ X-Request-Id: f7a7d01c-7bda-44e9-a0b2-7072e5d7bd57 X-Runtime: 0.036820 X-Powered-By: Phusion Passenger 4.0.57 Date: Sat, 04 Feb 2017 00:06:13 GMT Server: nginx/1.9.3 + Phusion Passenger 4.0.57
If you successfully made it this far, you can no doubt see there are a huge range of sensors that could be added and monitored remotely. It’s also possible to remotely control relays to turn on devices, such as a refrigerator. Using the ThingSpeak interface, the board can also send Tweets alerting you to potential problems:
I should provide a warning: the circuit I described for this post is in the simplest form to get the job done. It offers your MRK1000 board no protection from voltage spikes, bad wiring or electrostatic discharge. I have been working on a circuit board that will provide protection to the MKR1000 and add a whole bunch of features:
- Temperature, Humidity and Pressure monitoring.
- Possibly monitoring cabin gas levels (CO2 and Propane). Although doing this accurately becomes expensive.
- Primary and secondary battery voltages.
- Internal buzzer for backup bilge alarm.
- Build in GPS receiver.
- Built in power supply from 12V battery with transient voltage protection.
- NMEA 0183 interfaces to accept wind speed & direction (eg. from my Wind Board), could also be programmed to use any other NMEA sentences available (eg. depth).
- Interface to Victron BMV-700 series battery monitor. This allows access to battery health data such as voltages, current, state of charge.
- Ability to Tweet alerts and status.
- Remote control of a relay using ThingSpeak’s talkback function.
However I have had to put this project on hold due to lack of time. I may post further updates when I get the time, so feel free to subscribe to my blog and this will keep you updated.