Controlling Mobius enabled VorTech pump using 0-10V (and BLE)

brendann993

New Member
View Badges
Joined
May 2, 2021
Messages
3
Reaction score
1
Location
Perth Australia
Rating - 0%
0   0   0
I don't know if its a lack of knowledge or something else going (my c++ knowledge fairly limited) but I've been unable to get the library working. Originally I was just testing the CRC part seperately in a c++ compiler which appears to not like the CRC16_TABLE as it spits out alot of errors "narrowing conversion of ‘-32504’ from ‘int’ to ‘uint16_t {aka short unsigned int}’ inside { } [-Wnarrowing]" SoI tried moving to the Arduino compiler thinking that maybe thats the issue but get the same errors there .
My hope is to somehow add the functionality to ESPHOME which is a esp library but I feel Im so far off understanding the basics thats unlikely to occur
 

LVReef

Community Member
View Badges
Joined
Feb 13, 2021
Messages
64
Reaction score
57
Location
Livermore, CA
Rating - 0%
0   0   0
I took at this library and there are several issues so far:
  • The narrowing warning you get. Although this can be solved with -Wno-narrowing
  • The library incorrectly assumes that 01ff0100-ba5e-f4ee-5ca1-eb1e5e4b1ce0 is specific to Mobius when it's a wireless UART service. I get 8 devices when I do a scan.
  • Uses an old deprecated version of the BLE library. For example, the tries to make a call to bool BLERemoteCharacteristic::writeValue when in fact the signature is void.
I played with it for 30 minutes, excluding MAC addresses that didn't work but ultimately I wasn't able to get the coveted "Scene 0" output. The best I got was scene 65535, which is likely an error.

Not sure if @mard is still around or if I should try to fork and fix the library.
 
OP
OP
mard

mard

Community Member
View Badges
Joined
Jul 8, 2020
Messages
35
Reaction score
81
Location
Minnesota
Rating - 0%
0   0   0
Yep, I am still around. :)

I haven't touched the library since I created it (in June 2021) because it has been working wonderfully for me. Since it has been about 2 years it does not surprise me there newer versions of the dependencies.
If you would like me to make some updates, I certainly could but it will be several weeks before I will have time to sit down and work on it in earnest (in addition to setting up my dev environment again).
Constructive feedback and recommendations are always welcome. And if you would like to create a PR I would be happy to merge it (after testing it of course ;))!
 

LVReef

Community Member
View Badges
Joined
Feb 13, 2021
Messages
64
Reaction score
57
Location
Livermore, CA
Rating - 0%
0   0   0
Awesome! I’ll likely do a PR then; much simpler. Hopefully I get some time this weekend to try a few things. My main goal is to trigger feed mode for my 3 MP40s. I also have 4 xr30 so I might see some interesting traffic as well.
 

LVReef

Community Member
View Badges
Joined
Feb 13, 2021
Messages
64
Reaction score
57
Location
Livermore, CA
Rating - 0%
0   0   0
Good and bad news. I made some progress but the ESP32 crashes when receiving the response. I was going to continue troubleshooting this weekend but Neptune just released their MXM module which solves my 1 push feed problem. So as much as I want to geek out on figuring that one out, I went the easy way and bought an MXM module.
 

BeanAnimal

5000 Club Member
View Badges
Joined
Jul 16, 2009
Messages
5,071
Reaction score
8,108
Rating - 0%
0   0   0
I took at this library and there are several issues so far:
  • The narrowing warning you get. Although this can be solved with -Wno-narrowing
  • The library incorrectly assumes that 01ff0100-ba5e-f4ee-5ca1-eb1e5e4b1ce0 is specific to Mobius when it's a wireless UART service. I get 8 devices when I do a scan.
  • Uses an old deprecated version of the BLE library. For example, the tries to make a call to bool BLERemoteCharacteristic::writeValue when in fact the signature is void.
I played with it for 30 minutes, excluding MAC addresses that didn't work but ultimately I wasn't able to get the coveted "Scene 0" output. The best I got was scene 65535, which is likely an error.

Not sure if @mard is still around or if I should try to fork and fix the library.
New to Arduino - where can I set -Wno-narrowing flag? Please don't tell me I have to edit the root config for arduino?

Would much prefer to fix this - but have not looked at the code to see where the cast needs to be done. Narrowing really should not be ignored - and I think always should have been an error, but GCC used to fire them as warnings, not errors. Looks like Arduino is now using up-to-date GCC??

Can you share any other code updates that you made? The Mobius app is pretty bad IMHO and I would like to get the Profilux controlling my MP10s.
 

BeanAnimal

5000 Club Member
View Badges
Joined
Jul 16, 2009
Messages
5,071
Reaction score
8,108
Rating - 0%
0   0   0
I took at this library and there are several issues so far:
  • The narrowing warning you get. Although this can be solved with -Wno-narrowing
  • The library incorrectly assumes that 01ff0100-ba5e-f4ee-5ca1-eb1e5e4b1ce0 is specific to Mobius when it's a wireless UART service. I get 8 devices when I do a scan.
  • Uses an old deprecated version of the BLE library. For example, the tries to make a call to bool BLERemoteCharacteristic::writeValue when in fact the signature is void.
I played with it for 30 minutes, excluding MAC addresses that didn't work but ultimately I wasn't able to get the coveted "Scene 0" output. The best I got was scene 65535, which is likely an error.

Not sure if @mard is still around or if I should try to fork and fix the library.
I think the function can be rewritten to remove the narrowing error - but my C is rusty.

uint16_t MobiusCRC::crc16(uint8_t* data, int length) {
uint16_t crc16 = 0xFFFF; // Initialize with 0xFFFF
for (int i = 0; i < length; i++) {
uint8_t dex = (data ^ (crc16 >> 8)) & 0xFF;
crc16 = (crc16 << 8) ^ Mobius::CRC16_TABLE[dex];
}
return crc16;
}

OR using cast


uint16_t MobiusCRC::crc16(uint8_t* data, int length) {
uint16_t crc16 = static_cast<uint16_t>(-1);
for (int i = 0; i < length; i++) {
uint8_t dex = (data ^ static_cast<uint8_t>(crc16 >> 8)) & 0xff;
crc16 = static_cast<uint16_t>((crc16 << 8) ^ Mobius::CRC16_TABLE[dex]);
}
return crc16;
}
 
Last edited:

fendanto

Community Member
View Badges
Joined
May 6, 2023
Messages
64
Reaction score
59
Location
Boston
Rating - 0%
0   0   0
I wrote up a PR for the ESP32-MobiusBLE library to switch over from ESP32_BLE_Arduino to NimBLE-Arduino. Hopefully this resolves some issues for anybody trying to use it. Others can pull down my fork if they want to try it. Thanks for the hard work on that library!

 

Paulo Hanashiro

Community Member
View Badges
Joined
Jun 4, 2013
Messages
56
Reaction score
29
Location
Sydney/Australia
Rating - 0%
0   0   0
Thanks @fendanto, was able to compile it successfully.

I was assuming all devices working inside the Mobius app (Including AI) would work. But struggling to get the Nero pumps to work.

AI prime is working with no issues, Can query the scene, set feed mode, etc.
But the scanForMobiusDevices only returns the Prime.

using the sample scripts but changed to
count = MobiusDevice::scanForMobiusDevices(scanDuration, deviceBuffer, 3);

I was suspecting the service ID was different, but my BLE scanner is reporting 2 BLE devices with name MOBIUS and same service_uuids

[Device MAC]
MOBIUS AdvertisementData(
local_name='MOBIUS',
manufacturer_data={1: b'\x01\x01\x01\x01\x00\x00\x00p\xfb4J75002200RBA2'},
service_uuids=['01ff0100-ba5e-f4ee-5ca1-eb1e5e4b1ce0'],
rssi=-64)

[Device MAC]
MOBIUS AdvertisementData(
local_name='MOBIUS',
manufacturer_data={514: b'M\x01\x01\x00\x00\x00\x00p\xfb2Y9975A030R1C0'},
service_uuids=['01ff0100-ba5e-f4ee-5ca1-eb1e5e4b1ce0'],
rssi=-67)

Is anyone else hitting similar issues?

Any assistance is welcome and much appreciated as my coding is REALLLY rusted and I'm struggling here :beaming-face-with-smiling-eyes:

Regards.
Paulo
 

Paulo Hanashiro

Community Member
View Badges
Joined
Jun 4, 2013
Messages
56
Reaction score
29
Location
Sydney/Australia
Rating - 0%
0   0   0
After power cycling the AI Nero, the scanForMobiusDevices reported all my AI devices. But the issue now is that after some time (30 minutes), it went missing again. Would there be a way to persist the device addresses so we can also try to connect to items not reported by the latest scan?
 

BeanAnimal

5000 Club Member
View Badges
Joined
Jul 16, 2009
Messages
5,071
Reaction score
8,108
Rating - 0%
0   0   0
I gave up fiddling with it for now, mostly because the Vortechs are so buggy to begin. I will revisit one day when I have time.
 

Simonv92

Active Member
View Badges
Joined
Oct 21, 2014
Messages
145
Reaction score
105
Location
Italy
Rating - 0%
0   0   0
Hi All,
I'm building a Reef-Pi Controller which I'll integrate in my Home Assistant setup.
It'll be very nice to have a device like the MXM module for Apex to control our Vortech pumps.
The latest firmware on GitHub works only with the M5Atom board?
Thank you!
 

Paulo Hanashiro

Community Member
View Badges
Joined
Jun 4, 2013
Messages
56
Reaction score
29
Location
Sydney/Australia
Rating - 0%
0   0   0
Does anyone know if all the scenes information is stored inside each device or only on the Mobius App?

Trying to understand if we can grab all the available scenes using the MobiusBLE library without touching the Mobius App.

Thanks
 

Simonv92

Active Member
View Badges
Joined
Oct 21, 2014
Messages
145
Reaction score
105
Location
Italy
Rating - 0%
0   0   0
I think that the scene is in the mobius app. Device receive the command from the app.
I'm waiting my ATOM Lite to do some test. what is the procedure to grab the mac address of my devices? (2x MP10)
Thank you!
 

Sisterlimonpot

Effortless Perfection
View Badges
Joined
Jul 15, 2009
Messages
4,260
Reaction score
8,615
Location
Litchfield Park
Rating - 0%
0   0   0
Does anyone know if all the scenes information is stored inside each device or only on the Mobius App?

Trying to understand if we can grab all the available scenes using the MobiusBLE library without touching the Mobius App.

Thanks
I'm of the opinion that they're saved locally in each device. The reason for that conclusion is how "verify settings" work.

It verifies that the information stored in the app is the same as what's stored in the device.

This way when the app sends out the call (via ble) to perform a particular scene, it simply sends a command that all devices receive (via mesh network) and the devices that are set to act upon that command will initiate the scene.

In my mind an easy way to test this is to sniff the unique command for a particular scene and then recreate it and see if the devices will perform that scene.
 

Paulo Hanashiro

Community Member
View Badges
Joined
Jun 4, 2013
Messages
56
Reaction score
29
Location
Sydney/Australia
Rating - 0%
0   0   0
I think that the scene is in the mobius app. Device receive the command from the app.
I'm waiting my ATOM Lite to do some test. what is the procedure to grab the mac address of my devices? (2x MP10)
Thank you!
We have a few options here.

I'm working with the MobiusBLE library updated to use NimBLE, but also using a few python scripts in my PC just to scan for BLE devices named "MOBIUS".

The script below should give you the mac address(es) for the MOBIUS device(s) around you (At least in my tests, all devices advertise themselves with "MOBIUS" name).

Python:
import asyncio
from bleak import BleakScanner
from collections.abc import Iterable

async def main():

    devices = await BleakScanner.find_device_by_name('MOBIUS',timeout = 30.0)
  
    if devices is not None:
       if isinstance(devices, Iterable):
          print('iteract Dev3')
          for d3 in devices:
              print(d3)
       else:
          print('Dev3 by Name')
          print(type(devices))
          print(f"Device: {devices.name}, Address: {devices.address}")
          print(devices)
  
asyncio.run(main())

And once you have the address list, the script below will report on advertised UUIDs for a given address:

Python:
"""
Service Explorer
----------------

An example showing how to access and print out the services, characteristics and
descriptors of a connected GATT server.

Created on 2019-03-25 by hbldh <[email protected]>

"""

import argparse
import asyncio
import logging

from bleak import BleakClient, BleakScanner

logger = logging.getLogger(__name__)


async def main(args: argparse.Namespace):
    logger.info("starting scan...")

    if args.address:
        device = await BleakScanner.find_device_by_address(
            args.address, cb=dict(use_bdaddr=args.macos_use_bdaddr)
        )
        if device is None:
            logger.error("could not find device with address '%s'", args.address)
            return
    else:
        device = await BleakScanner.find_device_by_name(
            args.name, cb=dict(use_bdaddr=args.macos_use_bdaddr)
        )
        if device is None:
            logger.error("could not find device with name '%s'", args.name)
            return

    logger.info("connecting to device...")

    async with BleakClient(
        device,
        services=args.services,
    ) as client:
        logger.info("connected")

        for service in client.services:
            logger.info("[Service] %s", service)

            for char in service.characteristics:
                if "read" in char.properties:
                    try:
                        value = await client.read_gatt_char(char.uuid)
                        logger.info(
                            "  [Characteristic] %s (%s), Value: %r",
                            char,
                            ",".join(char.properties),
                            value,
                        )
                    except Exception as e:
                        logger.error(
                            "  [Characteristic] %s (%s), Error: %s",
                            char,
                            ",".join(char.properties),
                            e,
                        )

                else:
                    logger.info(
                        "  [Characteristic] %s (%s)", char, ",".join(char.properties)
                    )

                for descriptor in char.descriptors:
                    try:
                        value = await client.read_gatt_descriptor(descriptor.handle)
                        logger.info("    [Descriptor] %s, Value: %r", descriptor, value)
                    except Exception as e:
                        logger.error("    [Descriptor] %s, Error: %s", descriptor, e)

        logger.info("disconnecting...")

    logger.info("disconnected")


if __name__ == "__main__":
    parser = argparse.ArgumentParser()

    device_group = parser.add_mutually_exclusive_group(required=True)

    device_group.add_argument(
        "--name",
        metavar="<name>",
        help="the name of the bluetooth device to connect to",
    )
    device_group.add_argument(
        "--address",
        metavar="<address>",
        help="the address of the bluetooth device to connect to",
    )

    parser.add_argument(
        "--macos-use-bdaddr",
        action="store_true",
        help="when true use Bluetooth address instead of UUID on macOS",
    )

    parser.add_argument(
        "--services",
        nargs="+",
        metavar="<uuid>",
        help="if provided, only enumerate matching service(s)",
    )

    parser.add_argument(
        "-d",
        "--debug",
        action="store_true",
        help="sets the log level to debug",
    )

    args = parser.parse_args()

    log_level = logging.DEBUG if args.debug else logging.INFO
    logging.basicConfig(
        level=log_level,
        format="%(asctime)-15s %(name)-8s %(levelname)s: %(message)s",
    )

    asyncio.run(main(args))

in regards the MobiusBLE library, the discovery example can be easily modified to do a Serial.print with the basic info to get you started. Soon I should have a modified version of this library that provides more information already available as an advertised UUID, but it is not ready yet.


In this while, I'm still looking on how to extract the scenes from each device (As I also believe it is stored inside the device somewhere and not only on the Mobius App/Cloud).

Any help is indeed much appreciated. As I'm NOT a SW engineer by trade and it is a big struggle to understand the code + also learn the bluetooth protocol.


Cheers
 

Simonv92

Active Member
View Badges
Joined
Oct 21, 2014
Messages
145
Reaction score
105
Location
Italy
Rating - 0%
0   0   0
Hi All,
today I've received my Atom Lite board (it's super tiny!!)
I've upload the Discover sketch found in the ESP32_MobiusBLE library and it seems to work (while it search for devices my MP10 controller leds blink.
Next step is to control my pump. How can I do that? I've tryed the Control sketch with an external potentiometer to simulate the 0-10V state but it does nothing. Do I have to modify something in the sketch?
Thank you!
 

Simonv92

Active Member
View Badges
Joined
Oct 21, 2014
Messages
145
Reaction score
105
Location
Italy
Rating - 0%
0   0   0
I think I make it work... Simply uploading again the software.
If I set the 0-10V pin to a corresponding 5V it triggers the Feed mode on my pump. There's a way to keep the feed mode until the pin is at 5V?
 

theatrus

Valuable Member
View Badges
Joined
Mar 26, 2016
Messages
2,223
Reaction score
3,632
Location
Sacramento, CA area
Rating - 0%
0   0   0
Somehow wasn’t aware of this thread but it does raise the question of “why isn’t there a Home Assistant integration for this”. Even if it’s just feed mode setting.
 
Back
Top