Thanks Arduino for creating the Cloud Games. You've created an opportunity for many of us to learn and get to know one another. I am very grateful for the opportunity and for the hardware that you supplied.Overview
I need someone to look after my boat. My wife and I have a boat that we use for fun and relaxation. The boat is fairly big, so it stays in the water and is tied up in Marina several miles from home. We want to know that our boat is safe and we want to remotely turn on a battery charger and an ice maker so that when we get to our boat on a warm summer day, we're ready to jump aboard and cruise.
Our boat is named "River Roost," shown here in the American River near Sacramento, California, USA.
My solution is to use Arduino and the IoT Cloud to create a remote boat monitoring (and control) system. I have divided my monitoring into two categories: 1) GeoFencing and other alarms; and 2) Fuel and environment. I can also remotely activate two separate relays to power some important stuff.
I have written and tested my code and assembled circuit boards and sensor mounts. Next steps include: installing the system in my boat and adding webhooks to my alarm code so that I get a text when an alarm is triggered.
If you look at my photos and videos, you might notice that this system is not on a boat. It's currently on a testing table so that I can debug before installation. Rather than lug huge marine batteries into my kitchen, I'm simulating the batteries with a 12 volt DC power supply. GeoFencing (location) and Other Alarms
Knowing my boat's location is really important. Boat theft is a real thing and I want to be notified if my boat has been moved. This project uses the CloudLocation capability of Arduino IoT Could and a GPS board to tell me my boats location and trigger an alarm if the location is outside of a determined GeoFence. I can set the center and radius of the GeoFence through my dashboard.
I also have other alarms on my dashboard. If someone crashes into our boat, the included Accelerometer will know. If the computed tilt angle exceeds a threshold, a tilt alarm will be triggered. Alarms will also be triggered if either of the boat's doors are opened or if water fills the bilge (translation: if the boat is sinking). Each alarm can be reset from the dashboard.
Next step for this project is to have my code send me a text whenever an alarm is triggered. I have used Webhooks with Aruino and IFTTT to send text messages, but have not yet combined this process with IoT Cloud. Fuel and Environment
Our boat can hold up to 300 gallons (1100 liters) of diesel fuel so that we can cruise long distances. Currently, I have to climb into the boat's engine room (basically a crawl space) and use a measuring stick to check the fuel level. This project includes an Chemical eTape liquid level sensor to measure the depth of fuel in my two connected tanks. I had fun working out the geometry of those tanks so that my code can convert depth to volume. Both depth (inches) and volume (gallons) are displayed on my dashboard so that I can compare my new method to the old one.
Our two large marine batteries also provide fuel - when the engine is not running. In the summer, we often cruise to a remote place and drop anchor for a couple of days. (boaters call this "being on the hook"). During this time, we rely on our two batteries to power our refrigerator, water pump, toilet, lights, stereo, and phone chargers. If the batteries get too low, we can't start the boat and return home. So this project monitors the voltage in both batteries using a pair of INA219 power sensors. These sensors are designed to measure current and voltage drop across a load to determine how many watts are being consumed. I am only using the bus voltage portion of the sensor to get my voltage readings. Please note that I am simulating the battery voltage by tapping into each side of my 12V to 5V converter. That's why the left and right batteries read about 12 and 5 volts, respectively.
The graphing widget on the dashboard will be extremely useful when we are on the hook because the trend in voltage over time is more important than individual voltage readings in helping determine how long we can stay before the battery charge is too low.
Just to round out the monitoring system, I have added some temperature & humidity sensors in the boat's cabin and engine room to keep track of those parameters. And finally, because any boater worth their salt watches the barometer, I added a pressure transducer and code that displays the results in inches of Mercury.Remote Control
Our big boat also has a little boat, called a dinghy. Think of the dinghy as the Shuttle Craft to our Starship Enterprise. The dinghy is powered by an electric outboard motor that must be charged for 12 hours before use. This project includes a set of relays, one of which will be hooked up to the dinghy's battery charger so that I can start the charging from home the night before an outing. To simulate the dinghy's battery charger, I've connected one relay to my power drill's batter charger.
Boating pleasure is greatly enhanced by a cold beverage. Instead of dragging a bag of ice with me, I have a small ice maker on board the boat that will also be powered remotely (using my second relay) so that we will have plenty of fresh ice waiting for us when we arrive.Loops and Timing
I experimented a bunch with loop timing while working on my code. I read that IoT Things updates do not like the "delay()" function or other blocking code. I also want to be frugal in my data upload traffic because I will be using a mobile hotspot with a limited data plan for internet connection on the boat.
My code includes a couple of loops that are nested in my main loop. At the top of the main loop I connect with Things (IoT), read my sensors and count the number of loops.
Then I have a "fast" loop that uses "millis()" to run about every 2 seconds. This loop processes and posts the most time sensitive data, including Tilt, door status, and bilge wetness. These are conditions that can change quickly, and I want to keep close track. For each of these sensors, I take the sum of readings since the last Fast Loop and divide by the number of loops to take the average reading. This helps dampen signal noise.
My "sloe" loop get called every few minutes using "millis()" and processes/posts less time sensitive stuff, such as GPS, temperature, fuel, and battery voltage. These readings don't change very quickly, so no need use extra upload bandwidth reading them frequently.
An animated GIF that illustrates my nested loops
These looping strategies probably seem fairly simplistic to most coders, but this approach was utterly mind-blowing to me.Conclusion
I have really learned a lot in this project. Until about 6 months ago, I had never worked with Arduino or coded in C. I am recently retired and completing projects like this are on my bucket list. I am very thankful to the folks at Arduino for including my project in the #CloudGames. Without the deadline of this awesome activity, I probably wouldn't have finished this project.
Thank you Arduino!
My wife, floating in the water behind out boat.