Anchor watcher YAPP - remote boat monitoring from a mobile phone

AngusMcDoon

Well-known member
Joined
20 Oct 2004
Messages
8,818
Location
Up some Hebridean loch
Visit site
A few weeks ago I posted a thread about the latest incarnation of an anchor watcher app and communications device. This app receives boat data from the instruments via my device over Bluetooth and compares their values against some pre-configured parameters and sounds an alarm if anything goes beyond the limits. Also included was an atmospheric pressure sensor. The data watched are depth (min and max), windspeed, pressure change, heading change, speed over ground and position change. The device has both NMEA2000 and NMEA0183 interfaces and is a user interface-less black box that redirects the data from the boat networks to my app via Bluetooth. The watching app itself is an Android app running on a phone or table. The thread is here...

Anchor watcher YappApp

User sailoppopotamus suggested it would be better if it had an internet connection. Not being able to ignore a nerdy challenge like that, it now has. It still has the same features as before, so can still use Bluetooth when in range, but can now do anchor watching from sitting in the pub as well. Here's a diagram of what connects to what...

dataflow.png

That's might be a bit confusing, so here's what's going on...

- Data are arriving via NMEA0183, NMEA2000 and the in-built barometer. Air pressure is sent out via via NMEA2000 so your instruments can pick it up.
- Data are sent out via Bluetooth. This allows, when in Bluetooth range, to get your boat data into either the anchor watcher Android app or OpenCPN running on an Android or Windows device. AIS data are also sent if available via Bluetooth so OpenCPN can use it.
- Data are also sent out via a GSM internet connection to a server on the internet (MQTT in the diagram). There are free servers available for this purpose.
- Data sent out via the internet can be received by the Android anchor watcher app when out of Bluetooth range, i.e. you've left the boat at anchor and gone to the pub.
- Data sent out via the internet can also be shown on a webpage I've created that so that anyone can see where you are and what your boat instrument readings are.
- The BlueBridge device has no user interface, so you configure it by sending it SMS text messages. You can also get it to send you the boat data that way by reply text message to one you send it, or it can send a Google maps location link.

For the internet connection a SIM card is needed in the device. Most of the PAYG ones expire monthly, but 1pMobile do 4 month ones for £10. That gives a GB of data which is enough for an update every 5 seconds over that period.

UKs cheapest PAYG mobile tariff

The device is up and running right now. You can see what's going on by going to this webpage...

http://miniwinwm.000webhostapp.com/

When asked for the code enter... 62C7959D

This number uniquely identifies the device sending the data, i.e. the one I have here (if anyone else had one, they'd each have their own unique code as it's derived from the IMEI of the device). It is saved as a cookie on your computer unless you reject that option in which case you have to enter it every time you load the webpage. The webpage gets the boat data directly from the MQTT server. There's nothing going on at the website server other than sending you the static webpage.

The data comes through every 30s so you may have to wait. There's a counter which shows the time since the last data reception. If you leave the page it will eventually lose the connection so click the Refresh button to reconnect. Clicking the Show boat button shows where the boat is and its heading. This map and boat position/heading are not updated automatically - you have to press the button each time you want to see the location or after changing the scale.

So what's new in the hardware design from last time? It's still using a Espressif ESP32 as that comes with Bluetooth built in. I've added a SIMCom SIM800L modem which can be bought on a small development board. This is only GPRS capable but that's fine for what's needed. GPRS will be discontinued eventually, so when that happens I'll have to swap to another modem. Modems often have strange power requirements, and this modem is no different in that respect. It needs 4.2 Volts and bursts of up to 2 Amps. That's a bit of a kerfuffle to create so I've added an off the shelf adjustable 2 Amp buck power supply.

Here's the board layout...
Untitled.png

And here's what it looks like when assembled...
IMG_20220501_150903824.jpg

It's just a plain black box with 2 connectors, an aerial, an activity LED and an on/off switch...
IMG_20220501_151234930.jpg

The Android app is much the same with a few additions. You can now set up internet settings and choose between Bluetooth and internet. It also shows the time since data was last received, the reception period, and signal strength on the remote device...
Screenshot_20220501-151711.png

Android app development and javascript in webpages are not my thang, so they are a bit clunky and could probably be improved. In the device the software is built on the previous project with the modem and data publishing added. It's a multi-threaded design using FreeRTOS. Modems are a complete gonad ache to program, especially in a multithreaded environment like this, and much of the extra effort was getting the modem to work reliably. It's not helped by their manuals being a 1000 pages thick, but I've left it running for a week and it didn't fall over (the device, not the manual).

This project is all open source, and also relies on other's open source works, particularly the ttlappalainen NMEA2000 library which I ported from Arduino to ESP-IDF...

GitHub - ttlappalainen/NMEA2000: NMEA2000 library for Arduino

My source and hardware design files are all here released under the MIT license (do what you want with it, but don't claim it's your work or try to prevent me from doing anything I want with it)...

BlueBridge project

While it's all working, there's still some work to complete (no manual yet for example) and some minor additions and bug fixes. There's also a 3rd spin of the PCB on its way as what you can't see on the pictures above are a couple of modifications underneath. I'll update this thread if there's anything new to report.

While the device is running as I type, as I'm still tinkering it will come and go, so if the webpage link above doesn't do anything, try again later. I'll generally try to keep it running in the near future.

If anyone wants to have a go at making their own one I'll provide assistance. I've got a few spare PCB's and all the other parts are available from RS or ebay.
 
Last edited:

fifer

Well-known member
Joined
12 Apr 2013
Messages
353
Visit site
I missed this when it was posted. Who is your MQTT broker. Last time I had a look for one the free services had dried up a bit
 

AngusMcDoon

Well-known member
Joined
20 Oct 2004
Messages
8,818
Location
Up some Hebridean loch
Visit site
Yes, they have a bit. I use hivemq or mosquitto. Hive is ok although mosquitto being a test site comes & goes sometimes. I also got my own broker working as a backup on a raspberry pi zero although there are some (not irresolvable) NAT issues when using a home internet connection.

Hive only allows an insecure service for free whereas mosquitto allows both secure & insecure. I don't think security is particularly needed for boat data.

My device is not on at the moment because my cheap SIM account closed itself from lack of use but if there's interest in seeing it working I'll fire it up again.
 

lustyd

Well-known member
Joined
27 Jul 2010
Messages
12,286
Visit site
You don't show on the diagram, is there a local service bus brokering MQTT messages to avoid data loss when the connection goes down?
 

AngusMcDoon

Well-known member
Joined
20 Oct 2004
Messages
8,818
Location
Up some Hebridean loch
Visit site
Do you have a brief guide for compiling and flashing the hardware?

Here you go (I'll add them to Github doc folder later)...

There are two build processes - one for the Blue Bridge Android app and a second for the embedded app on the Blue Bridge board.

To build the Blue Bridge Android app:

1) Install Android Developer Studio and start it.
2) Choose Open Project and point to the app folder in the Blue Bridge folder structure.
3) Build the project using Build|Make Project
4) Prepare your phone by enabling developer options and USB debugging as described here: Configure on-device developer options | Android Developers
4) Connect the phone via a USB cable to the computer running Android Studio. In Android Studio choose Run|Run from the menu. You may need to give permission on your phone.

This will install the app on your phone and only needs doing once. You will find the app labelled Blue Bridge.

To build the Blue Bridge embedded ESP32 app:

1) Download and install the ESP32 IDF framework following instructions here: Get Started - ESP32 - — ESP-IDF Programming Guide v4.4.2 documentation
2) Start an ESP32 IDF command prompt and go to the root of the Blue Bridge folder structure
3) Run this command just the once, exiting out of the tool straight away. There is no need to do it again: idf.py menuconfig
4) To build, from the same location run this command that takes 10 minutes first time: idf.py build
5) When built plug in a USB cable between the board and the computer. Power up the board.
6) Go to Windows Device Manager and open up ports to get the number of the COM port that has appeared
7) To flash press the board's reset button and use this command (with your COM port number): idf.py -p COM7 flash
8) The code immediately starts running. You can see debug output with this command: idf.py -p COM7 monitor

You can combine the flashing and monitoring commands like this: idf.py -p COM7 flash monitor
 
Top