Venturing into Uncharted Waters: Creating a Waterproof IoT Device for Lap Swimmers
IntroductionIn the ever-evolving landscape of innovation, one retired Senior Software Engineer, armed with a wealth of experience and a passion for embedded systems, seeks to revolutionize the world of lap swimming. The challenge at hand? Designing and implementing a waterproof IoT device that will not only assist in enhancing the swimming experience but will also mark a significant departure from existing solutions.
This journey into uncharted waters will be guided by a foundation of offered free hardware kits, with additional peripherals and sensors sourced from a well-equipped IoT workshop. The goal? To create a device that not only defies the constraints of conventional swimming aids but also caters to the unique needs of swimmers.
As for the specifics of how this innovative solution will function and its key features, well, that's a part of the excitement. The exact design remains a mystery, as it hinges on the capabilities of the hardware kit ultimately selected. However, rest assured that the selected hardware will serve as the nucleus around which this groundbreaking idea will take shape. Development environments will be harnessed, and creativity will flow freely.
Intriguingly, the choice of hardware isn't set in stone. It depends on the outcome of the application for the Inclusive Innovation Challenge Hardware. This flexibility exemplifies the adaptability and readiness to embrace novel possibilities.
Our intrepid engineer isn't new to the world of challenges. With previous triumphs in Hackster and Element14 challenges, the stage is set for yet another grand endeavor. Whether this project enhances an existing creation or springs forth as an entirely new innovation is a question that only time will answer.
So, stay tuned as we dive headfirst into the realm of waterproof IoT for lap swimmers, guided by the expertise and passion of a seasoned software engineer. The possibilities are as deep as the waters we aim to conquer.
Free HardwareI registered for the challenge and submitted an application for free hardware.
I was awarded the Blues Hardware kit from BLUES one of the 5 sponsors of the challenge. I received an email on September 1st 2023, from Blues that they were getting my order ready, and would let me know when it would be sent.
I received the kit via UPS Express on September 19, 2023. The blues office is located in Beverley Massachusetts, USA, and is 60 miles from my home in central massachusetts.
Blues Wireless Hardware Kit includes:
- Global Cellular Notecard, a device-to-cloud data pump that reduces the complexity of building connected solutions with secure, reliable cellular;
- Wi-Fi Notecard, a device-to-cloud data pump that reduces the complexity of building connected solutions with secure, reliable, low-power wireless technologies, including Wi-FI;
- Notecarrier A, a companion development boards designed to make it easy to prototype and deploy IoT solutions with the Notecard.
- Swan, a low-cost, embeddable STM32L4-based microcontroller designed to accelerate the development and deployment of battery-powered IoT solutions;
I also received a Person Sensor from Useful Useful Sensors, another sponsor of the challenge. I received this via Fedex on September 9, 2023
I will need to get to know these components before I can really design them into my project for the challenge. So please bear with me as I learn this new tech in the next few sections. If your already familiar with these components, free free to skip down to the
PERSON SENSORThis came from Hackster and there were no instructions included in the package just the sensor. Which I found kind of odd. Then I went to the person Sensor link on the web page, and found the "person sensor page" as described below. This page also has a link to the a Github repo page with a developer guide.
Main page of website showing product link HERE
GitHub page
I will read through this document to try to understand how to connect and use the person sensor in my project. To be honest, I'm not sure I'll be needing this sensor for my project at the moment, so I'll move onto getting up to speed on the Blues Hardware Kit. The Next sections describe my journey. If you already familiar with using Blues hardware you can drop down to the MY project, which describes my Design and how I used the Blues Kit to implement my idea for the contest
Blues Wireless Hardware KitThe Blues Starter Kit contains everything you need to start building connected solutions with the Notecard and Notehub.io. Start with LTE Cat-1 Cellular Notecard or Wi-Fi NoteCard and build your first MCU-powered app with the Notecarrier A and the Swan MCU. These four parts included in the kit are described briefly below:
- Swan, a low-cost, embeddable STM32L4-based microcontroller designed to accelerate the development and deployment of battery-powered IoT solutions;
- Global Cellular Notecard, a device-to-cloud data pump that reduces the complexity of building connected solutions with secure, reliable cellular;
- Wi-Fi Notecard, a device-to-cloud data pump that reduces the complexity of building connected solutions with secure, reliable, low-power wireless technologies, including Wi-FI;
- Notecarrier A, a companion development board, designed to make it easy to prototype and deploy IoT solutions with the Notecard.
The Blues WEBSITE
Is located here https://blues.io/
The website site index:
Resources
The first 3 links are where I will spend most of my time to learn how to use the components of the kit.
- Developers This page contains the Quickstart tutorials that will help you get up and running with a Blues Starter Kit.
Learn how to connect to the Notecard, how to set up the Notecard’s companion cloud backend, Notehub, and how to start working with data. Learn how to set up the Blues Swan included in your Starter Kit. After this step you'll be ready to communicate with the Notecard from an MCU. Learn how to write firmware using the Notecard SDKs. You'll collect temperature and humidity readings and send them to the cloud at a regular interval. Learn about Notehub routes, which allow you to securely send your data from Notehub to your cloud of choice.
- Community Forum This a helpful resource if you need answers to questions along the way with the tutorials.
- Webinar Library Browse and watch from a curated selection of webinars and videos
- Newsletter Subscribe to the Blues newsletter and/or browse past news letters.
Support
Company
- Customers
- Blog Technical articles on everything in the Internet of Things, from Arduino to Zephyr. Written by developers, for developers.
- Careers
KIT GUIDES
But the real developer information is at dev.blues.io and get ready for a cellular IoT experience that just works!
Blues Quickstart PAGE This link will take you to a tutorial page that will walk you through connecting all the parts of the kit, building your first IoT App with the connected kit, and send data to the cloud.
After understanding the fundamentals of Notecard and Notehub, you're prepared to use your knowledge for an actual project. Additionally, there are 50 comprehensive project accelerators available to assist you in this endeavor.
Tutorial 1. - Use the Notecard to Send DataWith this tutorial, I learnet how to connect to the Notecard, how to set up the Notecard’s companion cloud backend, Notehub, and how to start working with data.
Start the Notecard Quickstart, this tutorial will get started with a Notecard and Notecarrier-A. It introduced me to the Blues kit components that I received, covering the Notecard, Notecarrier, and Notehub.
In this guide, you'll issue serial requests to configure the Notecard, simulate sensor data transmission to the Notecard, and synchronize this data with the cloud. By the end of the tutorial, you'll have a basic grasp of the process for creating connected solutions with Blues.
I found the following key concepts, form the foundation of this tutorial and understanding them proved essential as I proceeded with this tutorial and the other tutorials to follow.
The Notecard:
This is a device-to-cloud data pump designed to simplify the creation of connected solutions with a secure, dependable cellular or Wi-Fi connection. It's a System-on-Module (SOM) that's easily integrated into any project.
Notecarriers:
These are development boards that facilitate a quick start with the Notecard. Different Note carriers are available to suit various needs, whether you're prototyping with a Feather-based MCU or deploying a production solution.
Notehub:
This is the cloud service utilized by the Notecard for secure data transmission. Notehub also offers a console for fleet management and secure connectors for routing data to third-party cloud applications.
Notes:
Notes are JSON objects containing developer-provided content and serve as the primary means for sending data to and from a Notecard.
Bidirectional Wireless Communication:
Notecard and Notehub collaborate to provide bidirectional wireless communication capabilities, both outbound (from your microcontroller or single-board computer to the cloud) and inbound (from the cloud to your microcontroller or single-board computer).
I followed the steps to Connect my WiFI Notecard and Notecarrier-A. I will try to use the Cellular later. I then connected the uFL cable as directed. Since Notecard WiFi does not have onboard GPS, and therefore does not have a GPS
socket, I only connected the u.FL cable to the socket labeled MAIN on the Notecarrier-A to the MAIN socket on the Notecard.
To set up the Notecard and Notecarrier, start by connecting a USB cable from the Note Carrier's USB port to your computer's USB port. Since I'm using the Notecard WiFi, as suggested I followed the guide connecting to a Wi-Fi Access Point, As this guide describes, to connect your Notecard WiFi to a local Wi-Fi access point, you have two options:
Using a Notecard API Command:
You can configure the connection by issuing a Notecard API command.Using Your Smartphone:
Alternatively, you can use your smartphone to facilitate the connection.
Important: Before proceeding, the guide makes this point:
Be aware that Notecard WiFi is compatible only with 2.4 GHz Wi-Fi access points. Combining 5 GHz and 2.4 GHz under the same SSID may lead to issues with the Notecard. Additionally, make sure your Notecard firmware version is at least v3.3.1.
I followed the Smartphone instruction in the guide, and completed the guide by connecting and verify the connection successfully. Now back in the Quickstart guide, I completed the sections on setting up Notehub and setting up Notecard.
Now with a Notehub project created and my Notecard set up and configured as a device on Notehub, I was able to sends Notes to my NoteHub project, by following instruction in the final 4 sections:
Queue Notes to Your Notecard
Send Notes from Notecard to Notehub
View Notes on Notehub
Send Notes from Notehub to Notecard
Next I worked through the remaining 3 tutorials:
- Set Up Your Microcontroller
- Build Your First IoT App With Blues
- Send Data to Your Cloud
Set Up Your Blues Swan, in this tutorial, I learnet how to set up the Blues Swan included in my Kit.
I had problems getting my COM port to work, it might be because I have so many COM ports on my Windows 10 PC from other embedded projects. I was able to build but not upload. I received the following error:
No DFU capable USB device available
*** [upload] Error 74
==========[FAILED] Took 56.52 seconds =============
image1759×877 164 KB
I finally was able to get it working on my PC consistently, but I don’t know why. I installed the STM32CubeIDE and the STM32Cube Programmer and ever since then I am able to use PlatformIO and Arduino IDE on my windows10 PC. I'm not using either of the Stem32Cube tools at the moment.
I finished the tutorial using PlatformIO with no more problems. now I know how to program the Swan MCU, Fantastic. Now, with this tutorial completed, it's onto the next tutorial, to communicate with the Notecard from the Swan.
Tutorial 3. - Build Your First IoT App With BluesBuild Your First App, in this tutorial I learnet how to write firmware using the Notecard SDKs. It describes how to collect temperature and humidity readings and send them to the cloud at a regular interval. The tutorial uses mock sensor readings for simplicity, by using the Notecard Pseudo Sensor Library.
The Tutorial walks you thru a series of sections to:
Setup the hardware
Create a Notehub Project
Write Firmware
View Data in Notehub
Use Environment Vaiables
I was able to get the tutorial done in about an hour. Here is a video from my completed tutorial 3..... Enjoy
Now, with this tutorial completed, it's onto the next tutorial, to learn how to send (and visualize) your data in a cloud application:
4. Send Data to Your CloudRoute Data to Your Cloud, in this tutorial I learned about Notehub routes, which allow you to securely send your data from Notehub to your cloud of choice. The Tutorial walks you thru a series of sections to:
Create a Route in Cloudhub
Use JSONata to transform JSON
Route to an External Service
There are several tutorials which can be accessed from the Route Data to Your Cloud tutorial page by selecting the backend from a dropdown control "Get started with:" as shown below:
I selected General HTTP/HTTPS as a backend. In this tutorial I was instructed how to create a simple route to an HTTP/HTTPS endpoint. To do this you'll use webhook.site, an online service that lets you create an HTTP endpoint and monitor all incoming requests. Very Cool!
I plan to come back to this tutorial and try the Azure IoT Central, MQTT and Initial State backend tutorials, but this one gave me a general idea on how Notehub can be used to send data to an external site.
One minor thing I noticed, at the time I was doing the tutorial, was that the Tutorial instruction screenshots were not consistant with the Routes UI on Cloudhub. No big deal, but I thought I would mention it.
Project Examples using Blues -- AcceleratorsThese Examples are fully documented reference applications for assembling Notecard and Notehub powered solutions. Check out the Blues Accelerators Blues has created a set of 50 fully-documented project accelerators.
I tried one of these accelerators https://dev.blues.io/accelerators/roadway-impact-detection/
This was of interest to me because of the relation to my idea of detecting the walls of a pool. It uses the Notecard attached to a Notecarrier-A to detect a collision and sends the impact to Notehub.
The github page is at https://github.com/blues/app-accelerators/tree/main/22-roadway-impact-detection#you-will-need
The card.motion API is at https://dev.blues.io/api-reference/notecard-api/card-requests/#card-motion
Next StepsNow that I know the basics of how the Blues Notecard, Notecarrier-A, Swan MCU and Notehub work, I'm ready to apply what I've learned towards a real project.I really enjoyed working through the 4 tutorials and reviewing some of the Accelerator Example Project. Also, the Community Forum was very useful in helping me overcome some of my issues with the HArdware, I highly recommend using it.
Some other references to consider walking thru to gain more Blues Kit knowledge.
- Bookmark the Notecard API for quick reference.
- Follow the Notehub Walkthrough to get more out of using Notehub.
Now onto the Design and implementation of my project for the challenge.
MY Project --- Waterproof IoT for Lap SwimmersThis section will describe my project, Waterproof IoT for Lap Swimmers. It describes my Design and how I used the Blues Kit and the Person Sensor to implement my idea.
The IdeaI wanted to come up with a solution to allow lap swimmers with impaired vision to swim laps in a pool. One of the dangers of lap swimming in an unknown swimming pool, is the walls on each end of the lap pool. Not to mention staying within the lane lines. I came up with idea of using a Boogie board with a waterproof enclosure bungied onto it. The electronic components will be enclosed in the Waterproof enclosure. For this first phase of the prototype, the swimmer will use this boogie board as a kicking exercise, but can be expanded to use a hands free waterproof enclosure possibly strapped to the swimmers body. The swimmer will hold the board with both hands while kicking through the water.
Functional SpecTo accomplish the goal of allowing an impaired swimmer to detect the walls and assure that the swimmer does not hit the walls of the pool , I came up with the construction of a flotation device that the swimmer can use to detect the walls of an unknown pool.
I also came up with two modes of operation to accomplish this. A learning mode and a swim mode.
LEARN MODE - LEARNING THE POOL ENVIRONMENT
To detect the 2 walls in a resort swimming pool. a dry run involving Machine learning to learn the location of each wall and the correct track taken between the 2 walls of the pool . When the front of the board hits the wall, it will indicate to the swimmer to halt and reverse direction. I will also track the coordinates of a straight line between the 2 walls of the pool. If lane lines are available in the pool, like the walls it will learn to avoid hitting them similar to detecting the walls.
SWIM MODE
Once the layout of the walls is determined, then Its time to put the device in swim mode. This mode will track the GPS coordinates of the Track the swimmer is taking. Based on the model generated from the Learn mode, it will beep a warning beep when the boogie board gets close to a wall of the pool. If the swimmer goes of track. An off track beep can alarm them to straighten out there course based on the sound of the beep.
The BUILDThis section will describe the build of the flotation device that will contracted for this prototype.
A Waterproof Enclosure
The Boogie board + bungee cord + Waterproof Enclosure
The Power source
The Hardware components
The Power source + The Hardware components + waterproof enclosure
Assembled and ready to attach to the boogie board
The whole thing put together and ready for the Water.
Programming with the notecard is slightly different then Programming firmware using the toolchains of other platforms using scripting or compiled Languages like C/C++ or Python. You can use Arduino to write firmware to communicate with the Notecard and send data to the cloud. There is a full API that can be called using the Jason request command from the api.
Using the techniques that I learned from the tutorials 1 through 4, I was able to figure out how to use the Swan and the Notecard to implement my Idea. But first I needed to spec out the flow of the firmware. As I mentioned above, 2 modes, Learn Mode and Swim Mode are used to aid the swimmer using the system. I will describe the flow of each mode in the following sections.
Learn Mode
start to track sending a card.location.track command to the notecard.
take readings of each track and send to Notehub.
If a wall/object is hit... Beep a warning and send the track to Notehub
- Repeat one more time.
Swim Mode
start the swim
Is the wall detected? if so BEEP (danger Wall) repeat
else
Read the Notehub data .....
Is the wall detected? if so BEEP (danger Wall) repeat
else
Still on track? If not Beep (Off track)
Repeat
To test the waterproof enclosure can test the operation of the 2 modes by setting up a test pool, which can consist of two pieces of wood acting as walls and moving the enclosure by hand on a flat surface between the boards,
to test the request sequence of the the motion command use the cli example by
first, With the Notecarrier connected to your development PC, navigate to https://dev.blues.io open the in-browser terminal, and connect to the Notecard. Then enter the JSON commands into the terminal.
Use the example mentioned above , It uses the Notecard attached to a Notecarrier-A to detect a collision and sends the impact to Notehub You can test the "card.motion" API to implement the motion detection for this project.
Then send the same request object to the notecard from the Arduino IDE using the arduino library. note-arduino is the official Arduino library for communicating with the Notecard over serial
Sending Notecard requests and reading responses follows the same pattern:
- Create a JSON object that includes a valid Notecard API Request.
- Call one of the
notecard
methods and pass in the request JSON object. - If you called a method that returns a response, make sure the response contains the data you need.
The firmware is written using the Arduino IDE.
The Library used for the WiFi Notecard, Notecarier A, Blues swan is the
https://dev.blues.io/tools-and-sdks/firmware-libraries/arduino-library/
The API request commands are from the API Reference/ Notecard API/ card.Requests
https://dev.blues.io/api-reference/notecard-api/card-requests/#card-requests
at the following pages:
card.motion -- Returns information about the Notecard accelerometer's motion and orientation. Motion tracking must be enabled first with card.motion.mode
. Otherwise, this request will return {}
card.motion.mode
-- Configures accelerometer motion monitoring parameters used when providing results to card.motion.
card.motion.sync -- Configures automatic sync triggered by Notecard movement.
card.motion.track -- Configures automatic capture of Notecard accelerometer motion in a Notefile.
The following use the GPS function of the Cellular Notecard.
card.location -- Retrieves the last known GPS location of the Cellular Notecard and the time at which it was acquired. Use card.location.mode to configure GPS settings.
card.location.mode -- Sets location-related configuration settings. Retrieves the current location mode when passed with no argument.
card.location.track -- Store location data in a Notefile at the periodic interval, or using a specified heartbeat. Only available when card.location.mode has been set to periodic.
The card card.Request section of the API Reference contains many more request commands that can be used to configure the behavior of the Notecard, its pins, its use of GPS and accelerometer data, and to query the state of the Device, its network connection and peripherals. All of these requests begin with the card prefix. Be sure to check it out, it is very complete.
The code for the firmware is attached in the code section. I used what I did learn in the tutorials, the API reference, and the app-accelerators to implement my Idea in firmware.
Running the system.Proceed by attaching the waterproof enclosure to the boogie board.
Put the system in LEARN mode.
And first, train the model by doing one lap until the wall is reached and a beep is given by the system. Also pay attention for the Off course Beep and compensate.
After hearing a wall beep, reverse direction and swim until the wall is reached and a beep is given. Now stop.
Now the system is put into SWIM mode.
Start your 1st lap and listen for the wall beep. Also pay attention for the Off course Beep and compensate. When the Wall beep is sounded reverse direction...
proceed by swimming laps.
To stop the system swim to the left or right and the system will stop.
I am still in the process of coding the firmware and the deadline is fast approaching. I hope I will be judged for my research on the Blues hardware. and I will continue to work on my firmware.
I was never able to experiment and research with the person sensor. And will need to use it in the next prototype to possibly detect the walls.
I only used the Blues Notecard WiFi and need to experiment with the Blues Notecard Cellular card.
I only scratched the surface of the possibilities here for aiding a vision impaired traveler to do lap swimming in a hotel pool.
I will continue to enhance the prototype to allow for better collision detection, tracking, wearability options, audio warnings and overall software improvements.
The Blues hardware is great, and I might enhance the prototype with other components that I have.
Thank you for reading through my project. It was fun. Please comment on your thoughts.
Comments