Comments (7)
Hey @hapklaar,
When the radio sleeps it won't be able to receive any packets but the access point will queue them and send them when it wakes up again. This will add latency (hence the higher round-trip-time) but should no affect packets sent by the ESP (logs, MQTT publishes, etc.).
It will affect MQTT topics you want to send to the ESP when you want to write to a BLE characteristic but you don't mention those as a problem.
The WiFi issues @jamesfcurran mentioned were mostly remedied by using the suggested ESP-IDF version in the README file.
Anyway, please try adding that line in your setup and let me know if it really does make a difference for you for anything other than pings.
Thanks
from esp32-ble2mqtt.
Hi Assaf,
Can you tell me where I should add this to test? It seems to also need esp_wifi.h.
Thanks,
Erwin
from esp32-ble2mqtt.
Hey,
I would probably add it at the end of wifi_initialize().
esp_wifi.h is already included.
Good day
from esp32-ble2mqtt.
This certainly reduced RTT tenfold, but I guess you have a point about packets being initiated from the esp32 should not be affected. At least I learned something as I'm a complete n00b in programming.
I'd like to play around a little more to see if I can reduce power consumption, as I run this on an 18650 cell. Would it be an easy change to just listen for Beacons and publish their values to MQTT server? Ideally it would only listen for this, store the last value it got which could then be pulled by a client of some sorts. The module then only would have to listen and not transmit and thus use less power. But I guess this is not in the scope of your program.
from esp32-ble2mqtt.
Hey,
Making the following changes in main/ble.c would avoid sending out any BLE packets:
diff --git a/main/ble.c b/main/ble.c
@@ -17,7 +17,7 @@
static const char *TAG = "BLE";
static esp_ble_scan_params_t ble_scan_params = {
- .scan_type = BLE_SCAN_TYPE_ACTIVE,
+ .scan_type = BLE_SCAN_TYPE_PASSIVE,
.own_addr_type = BLE_ADDR_TYPE_RANDOM,
.scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL,
/* Scan interval. This is defined as the time interval from
@@ -559,6 +559,7 @@ static void gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
param->scan_rst.rssi, broadcaster_ops);
}
+ break;
device = ble_device_find_by_mac(devices_list, param->scan_rst.bda);
/* Device already discovered, nothing to do*/
The first change would change the BLE scanning mode to passive (doesn't send out scan requests) and the second will not notify the application when a new BLE device is discovered (and so it won't try to connect to it).
Event with these changes I'm not sure how long you can run off batteries as the entire setup isn't that geared toward low power, but it's a step in the right direction.
Good day
from esp32-ble2mqtt.
Hi Assaf,
fyi setting scan type to passive gave me one hour extra on battery, now 18 hours. This isn't much but nice to have!
thanks,
Erwin
from esp32-ble2mqtt.
Nice!
You might be able to scrape a bit more by lowering the BLE transmit power (depending on the distance between the ESP32 and your BLE peripheral) by removing the call to esp_ble_tx_power_set()
in main/ble.c.
from esp32-ble2mqtt.
Related Issues (20)
- Rate limit possible? HOT 3
- Issue trying to write characteristic to ThermoPro TP-25 HOT 8
- Unable to build HOT 6
- Switchbot meter broadcasters HOT 15
- What's the connection flow and how to control it? HOT 2
- /get and /set issues HOT 4
- How to set config.json can receive the encrypted broadcast advertise raw data? HOT 1
- Help needed: Vogel MotionMount not showing HOT 7
- Issuing commands to Opal Ice Maker HOT 3
- Connecting to a custom device is causing stack overflow crash HOT 5
- Setting values is not consitant HOT 10
- Maintain BLE connection on WiFi disconnect HOT 5
- Support repeating UUIDs HOT 7
- Ask for custom code/job HOT 1
- ESP32s3 HOT 5
- Configure Scanning? HOT 3
- BLE Advertisment publishing? HOT 3
- bug in ble2mqtt_task() function HOT 1
- How to Pair? HOT 1
- BLE Scan / certain broadcasters crash device HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp32-ble2mqtt.