-
Notifications
You must be signed in to change notification settings - Fork 205
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
New esphome component for pvvx firmware + "Custom" advertising #89
Comments
More relevant is support for Xiaomi Mijia encoding and fix drops when receiving ads in ESP32. |
Ads format from the original firmware is already supported by the bundled xiaomi_lywsd03mmc components. |
ESPHome does not work on Android and Windows. Requires specific knowledge, additional costs for unnecessary components and assembly of the system from ordinary users. |
Well, ESPHome is working great for me as a cheap Wifi bridge for my LYWSD03MMC devices and I just thought this component might be useful for other people too... |
The component can be useful when fixing ad-packet reception skipping in ESP32 drivers. Otherwise it is not a working solution. |
I can see the benefit when using Home Assistant or other Home Automation. In my case, I need additional ways to listen for advertising packages (home automation server bluetooth does not reach all corners of house) and relay them back to main server; so in my setup (Xiaomi LYWSD03MMC->ESP32 Tasmota->Node Red->Home Automation Server). I have not had any joy with ESPHome and my ESP32s, so curious if this would work |
Reception of advertisements on JDY-10 (TLSR8266) or CC2540 USB Dongle. |
Even if packets are lost, even receiving new values for temp and humidity every couple of minutes is good enough for me for that kind of sensors.
I'm using it with Home Assistant for sensors that are too far from my Raspberry Pi.
I can understand that it might not fit some people needs, but it's very much good enough for my needs, especially for the price and easy of use.
… Le 12 avr. 2021 à 17:33, Victor ***@***.***> a écrit :
I need additional ways to listen for advertising packages (home automation server bluetooth does not reach all corners of house) and relay them back to main server;
Reception of advertisements on JDY-10 (TLSR8266) or CC2540 USB Dongle.
https://github.com/pvvx/UBIA/tree/master/Sniffer/OpenWRT_SnifferAd
Reaches several hundred ad packages per second...
https://www.youtube.com/watch?v=MqFcY5Hovpw
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Smart Home users are not interested in sensor readings. They are interested in the execution of scripts, which requires a certain response of timely triggering according to data from the sensors. And also the reliability of the system, which is not provided in the HA. According to the scheme of building a smart home system with ESPHome and BLE, the most unstable component today is ESP32. |
Indeed, in the case of my switches and automations. My heating is a different story (updates every minute).
Guess I've been lucky, as these have been stable without a reboot/restart for over 4 months now.
..or in my case a few thousand Euros of equipment; but understand many HA systems are hacked together bits and pieces that require never ending maintenance to keep running. |
This is another advertisement without confirmation. Xiaomi LYWSD03MMC with custom firmware is able to switch heating without assistance. |
Graphs in the thermometer itself are recorded in more detail. And we are talking about the speed of receiving information and without dropout. Actual for PID and more accurate adjustments. Show on your schedule actually accepted glasses that the thermometer transmits every 10 seconds. Not a diagram that has interpolation to display. ESPHome with ESP32 forces you to duplicate ad packets and transfer them as often as possible, which greatly affects the battery consumption of the sensor. Comparison of the modified hcitool says that the ESP32 program needs to be fixed. |
I've also observed issues with using ESPHome for receiving BLE advertisements. I've spent a little bit of time trying to fine tune the Fundamentally I think the problem is that an ESP32 can't be listening for BLE advertisements while simultaneously sending/responding to network requests over WiFi. I suppose you could set one up to use ethernet instead, but it seems like a rather roundabout solution. Here's a graph of the number of advertisements received over a 24 hours period of three of my BLE sensors grouped by periods of 5 minutes. While I certainly don't expect this to be a perfectly flat line, less than one advertisement being captures for a given sensor over a period of five minutes just doesn't work for the use cases I have in mind. |
@
I guess one way to prove where the issue is in the ESP32 system is combine an ESP32 with a ESP8266 (or second ESP32), and send the received data from the ESP32 listener (without any WiFi functions) to the ESP8266 via serial for the ESP8266 to send to HA (or wherever the target is). Could use MQTT instead of ESPhome service as well... |
Questions about missing advertise packages for ESP32 are available on many Internet resources. For comparison, I tried many options:
MQTT on weak platforms limits performance and does not have time to service a large network of sensors. |
Xiaomi LYWSD03MMC. TLSR8251 has USB2.0 FS. USB pins are available on the board... |
Note that while the ESP32 will never be the device to use if you need high availability for BT+Wifi, you can improve BLE adv reception by enlarging the scanning window, which is very small by default. I'm getting about 35% of them with these parameters in a quite noisy environment - which is enough for what I'm using it for - you'll decide if it is good enough for you :)
Default is 350ms/30ms |
What prevents the RF receiver in ESP32 from working permanently? The CPU does not take part in the reception. Usually, a packet received by the radio path causes an interrupt and is processed by DMA. I compared the number of dropped ESP32 packets without Wi-Fi enabled with the output to the UART. Changes to scan parameters have very little effect on packet rejection rate. At the same time, other chips with weaker processors and characteristics of the radio path have a lower percentage of drops. Perhaps this is due to a malfunction of the automatic reception level control system in the ESP32. But it is more likely that these are algorithms applied in the RF driver itself. It was noticed that the processing time of data from ad packages also affects the number of lost packages. It looks like the drivers are not buffered and not designed to work with two cores ... |
I appreciate the insights @pvvx -- honestly this isn't something I've had much time to research thoroughly. Are there any "plug and play" solutions that could be either used with MQTT or easily adapted to use with Home Assistant? Not that I don't like tinkering with these things, but my time is at a premium right now. Part of the appeal of ESPHome was the fact that the time it took to set it up was trivial. |
@kelchm you can use the custom component below to integrate your devices with home assistant. It works great. |
From what I understand, WiFi and BLE are multiplexed, thus you can't be in 'BLE rx' mode all the time. |
One important note, why is this important: ESPhome + temp sensor (as those ble ) is perfect solution for smart automation, especialy heating. ESPhome has native support of checking availabilty of HomeAssistant ( whole automations can be run in super "smart" way, HomeAssistant+NodeRed+whatever you want) but in case of power outage, server failure etc, ESPhome can automaticly "switch" to safe mode and act as regular thermostat (maybe little bit smarter with some simple automations written directly in esp). Im using this "safe" scenario even for wall switches. |
Testing was carried out with the pin in the UART. WiFi is off. |
If your script does not take into account the change of the metering counter, then for an hour there should be 60 * 60 / 2.5 = 1440 received AD packets.
Disabling the recording of measurements in Flash will give no more than 1% battery savings. |
As someone who also uses HA (Homeassistant) withy ESPHome, I can say I also experienced degraded ADV RX performance on an ESP32 (M5Stack Atom Lite); somewhere above 80% packet loss. I have switched to a raspberry pi zero w with BlueZ and (the unfortunately deprecated) HCITool. I now get just 10~20% packet loss, depending on connection distance. Many thanks for the project PVVX! |
@camaz I too struggled with bluez and python ble on rpi and ubuntu. I wrote a rather rough c app that runs on both rpi and intel ubuntu. I collect from 20 sensors with good success for going on 6 months now. I don't collect missed packet data as I collect from govee sensors as well as xiaomi. That said from sensors that update sub-minute I see those sensor reading consistently. Perhaps it will give you some ideas : https://github.com/deepcoder/bluetooth-temperature-sensors |
|
Thanks - was wondering why I couldn't get any sensor data using this firmware. Any plans to get (attempt) this merged with upstream? |
Just as a side note, the C3-versions of the ESP32 chips seem to have a much better BT stack and hardware than earlier editions of the ESP32 chips. There's still around 15% packet loss, but this already means that with 4x broadcast per value the drop rate is inconsequential. It might be possible to drop the package loss further by optimising the code on top of the stack. |
@jddonovan that's great news, thanks for sharing. I will definitely have to order some to give it a try. I spent some time trying to get a scanner up and running on the Wio Terminal (which has the ATSAMD51P19 + dedicated RTL8720DN for bluetooth + wifi), but never got it fully working. I think there are some bugs in the libraries provided by Seed studio. |
@kelchm just be warned that support for C3 is still limited. Esphome is practically unusable: using I2C oled display freezes the board after around 15 mins (memory leak?), bluetooth libraries and MQTT support is missing and PWM output silently fails. My tests were with using Arduino, the readily available BT library and MQTT. I had no issues with this simple setup. Your mileage may vary though. :) |
USB-BT and other BT adapters on Windows do not accept BLE ads. But you can do it on a cheap JDY-10 module or similar - AdScanerTrg - BLE ADV repeater. When connected to AdScanerTrg, it transmits ad packets from other devices. The losses are minimal, less than that of the ESPxxxx. |
Seed studio uses the interface on SPI and after fixing to UART (reverse recovery in AT-files from files from SDK Ameba) everything works successfully. |
Available here :
https://github.com/airy10/pvvx_mithermometer
Mainly a copy of the esphome atc_mithermometer component with updated decoding code
The text was updated successfully, but these errors were encountered: