Skip to content

waterlinked/Modem-M16-Driver

Repository files navigation

Water Linked Python Modem-M16-Driver

About

This repository includes a simple app to interact with the modem, a driver for easy communication with the modem, an example report and two example scripts for sending and receiving messages through the modems. For more detailed information about the M16 modem and its interface, please visit the official documentation.


NOTE:

  • For consistency place both modems in the same bucket filled with water.

  • When reading a report the power level 4 will be shown as 0, the conversion is 4 - PL where PL is the power level from the report. For more information please visit the official packet structure documentation.

gui.exe

This executable can be found by opening the newest release from the github page (on the right side of this page), only the gui.exe needs to be downloaded. A prompt will show asking you to trust the author, this can be done by pressing more then run anyway. Alternatively compile your own .exe as descried in README_developers.md.

This executable provides a user-friendly interface to test and verify modem functionality. It demonstrates key features and allows for quick setup and communication testing between modems. Additionally it is a good starting point to get to know the functionality of the modem without Python. The app is a tkinter app that communicates with the modem through m16_driver.py.

The default port is set to COM3, the user may need to change this to the appropriate port.

m16_driver.py

A driver for simple interaction with the modem, it includes functionality for changing of modes, channels and levels. It also includes functionality for sending messages of both 2 bytes and longer length, as well as requesting and saving reports.

sending_examples.py

Simple script for requesting a report and sending a 2 bytes long message.

receive_example.py

Example script for continuously listening to the modem.

report.json

This is an example file that shows what a report decoded with the M16.decode_packet() from the modem looks like, saved to a .json file

Requirements

Installation

The driver and app has been developed with python3.10. In order to run the scripts Python must be installed, this can either be done with the link in the Requirements section or from the windows store. venv is standard in Pyhton3.10 on Windows but on linux the user may have to install it, that can be done with the command:

sudo apt update
sudo apt install python3 python3-venv

To be able to run the code this repository has to be cloned, that can either be done through the terminal, GitHub CLI or by downloading the ZIP file and extracting it to your desired location. The next step is to navigate to the repository on your machine, this can be done with the cd command below:

git clone https://github.com/waterlinked/Modem-M16-Driver.git
cd Modem-M16-Driver

Next we need to create a virtual environment, the easiest way is from the terminal. On Windows this can be done by pressing the Windows key and searching for terminal. On linux it can be done by pressing ctrl + alt + t. In the terminal run the command:

python3 -m venv venv

Next we need to activate the environment, in powershell on Windows the command is:

.\venv\Scripts\Activate.ps1   

NOTE: In powershell you may get an error saying cannot be loaded because running scripts is disabled on this system. Override this with the command:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

On linux use this command:

source venv/Scripts/activate

Finally, when the virtual environment is activated install the dependencies with the command:
(It is activated when (venv) appears before the terminal path)

pip install -r requirements.txt

After this the python scripts can be run with the command python <script_name.py>

GUI app for Linux

If you want to use the gui.py app on linux, tkinter has to be downloaded, this can be done with the command:

sudo apt install python3-tk

Screenshot

Screenshot of the app before connecting to the modem
App before connection to modem
Screenshot of the app after connecting to the modem and requesting a report.
App in transparent mode
Screenshot of the app while connected and in diagnostic mode
App in diagnostic mode

About

Water Linked Modem M16 Python driver, examples and configuration application

Resources

Stars

Watchers

Forks

Contributors

Languages