Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GATT question #9

Open
sidequestboy opened this issue Sep 27, 2022 · 7 comments
Open

GATT question #9

sidequestboy opened this issue Sep 27, 2022 · 7 comments

Comments

@sidequestboy
Copy link

sidequestboy commented Sep 27, 2022

Hi, I'm looking at this code to try and port similar functionality (interacting with a Pearl scale) to an ESP32 microcontroller.

I see your code doesn't involve any service uuids, but only characteristic uuids. I also notice that the scale does not advertise service uuids, and I am not sure how to subscribe to a characteristic without the corresponding service uuid.

Example arduino code for connecting to a BLE device looks like this:

    BLERemoteService* pRemoteService = pClient->getService(serviceUUID);
    if (pRemoteService == nullptr) {
      Serial.print("Failed to find our service UUID: ");
      Serial.println(serviceUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }
    Serial.println(" - Found our service");


    // Obtain a reference to the characteristic in the service of the remote BLE server.
    pRemoteCharacteristic = pRemoteService->getCharacteristic(charUUID);
    if (pRemoteCharacteristic == nullptr) {
      Serial.print("Failed to find our characteristic UUID: ");
      Serial.println(charUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }
    Serial.println(" - Found our characteristic");

    // Read the value of the characteristic.
    if(pRemoteCharacteristic->canRead()) {
      std::string value = pRemoteCharacteristic->readValue();
      Serial.print("The characteristic value was: ");
      Serial.println(value.c_str());
    }

    if(pRemoteCharacteristic->canNotify())
      pRemoteCharacteristic->registerForNotify(notifyCallback);

Do you have any pointers for how to connect without the service uuid here?

thanks for the project

@darrenbrokeit
Copy link

Hey I don't have a good answer for you, but I wanted to check in and see if you had any more progress!

I don't know your exact use case, but I'm toying with the idea of using my lunar in a grinder to do grind by weight and also have my e61 espresso machine auto start the scale when I start a shot!

If you have a repository already I'd love to collaborate on an ESP32 port!

@sidequestboy
Copy link
Author

sidequestboy commented Feb 4, 2023

Hey @darrenbrokeit I have made some progress on this but haven't touched it in a couple of months!

The most promising technique I found was to decompile the official acaia "brewmaster" android app using a VSCode extension called "APKLab", and to inspect the code to learn the handshake procedure. I also combined this technique with inspecting bluetooth packets with wireshark after using the android app.

So far, I only have a couple things working on my ESP32: creating a persistent connection, and sending commands like "tare" to the scale. I also only have an Acaia Pearl 2021 scale to test on at the moment. This is significant because the older scales use a different set of GATT UUIDs. In particular this pyacaia repository doesn't actually work with my 2021 model, hence needing to go the reverse-engineering route.

I will revisit my code and clean it up a bit. Then I'll link you to it!

@darrenbrokeit
Copy link

Heya thanks for that detailed response! I'm waiting for my set of ESP32s to come in, so I've mainly been just reading up on this and seeing what people have done to connect to the scales!

I have access to a Pearl S (not 2021) and a Lunar 2021, if there's anything you want to try out! :)

Also, I haven't looked through it closely, but I found this project to make a early model La Marzocco GS3 smarter - alitai/GS3-Chimera, which uses the HM10 module with an arduino to connect to an acaia scale

@lukaszroszczak
Copy link

lukaszroszczak commented May 17, 2023

Hi guys,
@darrenbrokeit @sidequestboy
I'm also trying to connect the acaia scale to the ESP32. Please let me know if you have been able to communicate.

@darrenbrokeit
Copy link

I ended up using micropython with aioble on my project - I spent a couple of weeks testing things, and I have been able to connect to my Lunar 2021 and get it to start sending data back. I need to work a bit on the decoding portion before cleaning everything up to put up on a public repo. The handshake protocol is interesting, however, and I'm happy to share once I get a moment to get back into it!

@zweckj
Copy link

zweckj commented Jul 15, 2023

The handshake protocol is interesting, however, and I'm happy to share once I get a moment to get back into it!

@darrenbrokeit I ported the code from this repo to bleak & asyncio here to be able to add it to a Home Assistant integration, to connect my La Marzocco to my Lunar through Home Assistant (here). It appears to be working ok-ish, but any further insight to the handshake protocol would be much appreciated!

@tatemazer
Copy link

If you are still looking, I got the ESP32 working using the arduino IDE and its own ArduinoBLE library: https://github.com/tatemazer/AcaiaArduinoBLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants