-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add Hunter BTT (BLE) as plugin #5158
Comments
Well it is just like a switch, so it would fit perfectly well in the ESPEasy architecture... However (there is always one of those ;) ) we currently have not any Bluetooth related code integrated in ESPEasy so far. This is one of the reasons I have not yet looked into Bluetooth myself to integrate it into ESPEasy. I am currently doing a complete rewrite of the WiFi/network related code, so I can keep this in mind. N.B. not all ESP32's support the same Bluetooth. So that's another caveat for adding Bluetooth support. Does your test setup use both WiFi and Bluetooth? |
Im currently testing/developing with the ESP32 connected with USB cable, so not via WiFi yet, I was not aware of this challenge. For this project it would be mandatory to use WiFi in combination with Bluetooth. I started this project to extend the very short Bluetooth range of this value over WiFi and off course add automation via ESPEasy. These are my board details:
I will include WiFi in my test to see what happens. |
I did some testing. I enabled Wifi and Webserver and created a simple page that triggers some BLE commands. When BLE is connected, the webpage is very unstable, not usable. When BLE is disconnected, the page works fine. After some researching I got it working stable with these code parts:
From what I understand it puts Webserver on core 0 where also wifi is serviced from. BLE is serviced from core 1. This works for me on a 250 lines sketch. Ping to ESP32 is fluctuating a lot, between 6 and 500ms. |
I expect the only way to get this stable is to let the WiFi negotiate a longer DTIM with the AP and keeping track of when a beacon interval is about to happen. But I think the only real stable option is to use Ethernet when using Bluetooth. |
And what about using an HM10 Bluetooth module? It has support for BLE. You can't use an BLE library, but I can create the AT commands to reach the same goal. Do you see any problems with using that module? |
It feels a bit backward to use an external BLE module on a unit that has BLE on-board (at least the ESP32 series), but it will probably be the simplest solution to communicate with Bluetooth devices. You'd probably have to use the Serial Proxy (P087) or Serial Server (P020) plugins to control that module and receive/process the response in rules. Not sure what the response speed would be though, but they seem to communicate at 115200 baud, so that should be fast enough for most types of sensors, once they are connected. |
With BLE speed is not very essential. Just ordered some HM10's and will do some testing. |
@BasvanH do you have list of AT commands for this module? |
@uzi18 I found this page quite helpful: https://www.martyncurrey.com/hm-10-bluetooth-4ble-modules/#HM-10%20-%20AT%20commands |
@tonhuisman but BLE module is not a problem here. Note.: The HM-10 is Bluetooth version 4.0 only. This means it cannot connect to Bluetooth 2/2.1 modules such as the HC-06 and HC-05. |
@uzi18 I already have reversed engineered part of the Hunter BTT BLE protocol. Im able to manually control the valve by giving x minutes to run. And I can manually close it. Open, run for 5 minutes: Service ID fcc0 / Characteristic fcd9
69 Manual control Close: Service ID fcc0 / Characteristic fcd9
69 Manual control Im busy gatchering the data for switching between Disabled / Manual and Schedule. If you want to do reverse engineering yourself, grab an android phone. Enable developer tools and enable HCI snooping. Reboot your phone. Then open Hunter BTT app and perform your actions, note down the time you execute those actions. Then pull the debug logs and drop them in Wireshark. There you can see the BLE packets and their service ID's and Characteristics. //Edit |
Nice, will compare these data with what have found on my own. |
If you found any, please share it with the community. |
@BasvanH did you find any kind of ACK from BTT about new state? |
No ACK, but it advertises the active state in service fcc0. When you WRITE for example ON with 5 minutes |
I see there is a Write response. This is the sequence:
Then you receive a Handle Value Notification:
And when it's written, you receive a Write Response
|
Im able to control the Hunter BTT valve with Serial Server and a HM-10. However, when I send a command with |
Events are visible in the log, but I wonder where you're looking for the logs.
So if you have debug log level included in the build, you can set the log level on the tools->Advanced page to this level. |
The plugin commands themselves will be reflected in the log, as said, but will/should not cause any events, unless of course the device sends some data back when the command is handled. Serial Server waits for a packet of data received, or the time-out reached, before an event is generated, but also requires either a TCP client to be connected to the configured port, or the setting Edit: And also Event processing should be set to Generic (the other options don't make sense for your device) |
On the web interface / Tools / Log I'm using the Tools / Command option to send commands. No rules or tasks yet.
I see my commands as an INFO event in the Log. The HM10 gives a result back after executing AT commands. This can take from a few ms until a few seconds, depening on the command. Those messages from th eHM10 are not shown as a INFO Log or so.
Yes, this I already figgered, this is set, still no Log items of the HM10 initiated messages. These are some of the commands Im sending which the HM10 gives various resonses to. What should I do to see those responses of the HM10? Enable Debug in my build? Edit: I do see the response messages of the HM10 on the COMport of the ESP32. |
Did some further testing. Enabled Single event with all values, and added rule:
When I execute commands, the HM10 executes it, I see the result in the USB serial connection on the ESP32, but no log and no event in the Log of the web ui Logs. |
I have received a few HM10 devices, but did not get to
The exclamation mark is needed for events that don't have numerical data in the first argument. |
Yes, tried that one already, also no events. Secondly, I notice when saving my rules the Serial Server stops working. I need to go into the device and Submit it again and then the AT commands work again. This is the sequence:
This happens everytime I save rule. And note the lacking of response AT events. |
Hi,
I'm reverse engineering the BLE protocol for controlling my Hunter BTT irrigation valve. As Im already using ESPEasy within my home ecosystem, I was thinking about writing a plugin for it.
Im using the NimBLE library to communicate with the Valve. I want to readout the battery status (done). I wish control open and close of the valve (done). And I wish to change it operating mode, schema / manual / disabled (WIP).
Plugin features:
I currently own the single valve version, there's also a double valve version. I can add support but I then need to BLE traffic dumps.
My questions:
Regards,
Bastiaan
The text was updated successfully, but these errors were encountered: