-64 is a good connection. Placing it closer will technically improve the connection, but -64 is already good at least for bots. I might be getting some curtains in the near future so I can see for myself how the esp32 interacts with them. Cheers
I have my esp32 very close to the switchbot button but I get only -75 rssi. Could you suggest me a reliable and powerful esp32 device I can buy?
Atm I have a WeMos D1 Mini.
Is it always reporting above 70? I am using a d1 mini and it works well but I have had a D1 mini that seemed to have a weak internal antenna compared to others. You might just have a dud
To increase range they do make esp32 with external antenna attachments. I havent purchased these but they look correct ESP32 DevKitC Core Board Development Doard ESP32 WROOM 32D ESP32 WROOM 32U for Arduino|Integrated Circuits| - AliExpress
you should also be able to use an esp32-cam with antenna, but they dont come with usb interface to flash
You can search for ESP-WROOM-32UE
Just got around to flash the wESP32, only had some issues with the LED pin, which was quickly solved. Still have to add device, but the webui already works!
Would it be hard to use ethernet instead of wifi instead for connectivity?
EDIT: Also added the curtains, they can now be controlled through HA! Awesome!
cool! editing the code for ethernet support is probably possible but would take some work. I havenāt purchased any ethernet esp32s yet to test with
Apologies for being a noob, but wish to check, is it possible that i add a PIR function such as AM312 to my ESP32 running this together so that it can also help do motion check.
I tried to piece stuff together, apparently, Iām not sure how to do it. Anyone has any working sample.
You should be able to add a binary sensor like a motion PIR sensor by adding the following code (with some modifications)
Where it says āexisting codeā this would be the setup and loop methods of the current ESP32 switchbot code
//EDIT
int sensorPin = 16; // sensor pin (PIR/Motion etc)
int publishSeconds = 10000; // publish every 10 secs regardless of state
bool retain = true; // retain mqtt sensor messages
//DO NOT EDIT
int sensorStat = 0; // sensor status
int sensorLastStat = 0;
long lastSensorPublish = 0;
void setup() {
/*
Existing code
*/
pinMode(sensorPin, INPUT);
}
void checkSensor()
{
sensorStat = digitalRead(sensorPin);
if (sensorStat == HIGH) { // MOTION DETECTED
if (((millis() - lastSensorPublish) >= publishSeconds) || (sensorStat != sensorLastStat)) {
if (client.isConnected()) {
client.publish("YOURTOPIC", "MESSAGE", retain);
lastSensorPublish = millis();
}
}
}
else {
if (((millis() - lastSensorPublish) >= publishSeconds) || (sensorStat != sensorLastStat)) {
if (client.isConnected()) {
client.publish("YOURTOPIC", "MESSAGE", retain);
lastSensorPublish = millis();
}
}
}
sensorLastStat = sensorStat;
}
void loop() {
/*
Existing code
*/
checkSensor();
}
class AdvertisedDeviceCallbacks: public NimBLEAdvertisedDeviceCallbacks {
void onResult(NimBLEAdvertisedDevice* advertisedDevice) {
checkSensor();
/*
Existing code
*/
}}
It may not work while the ESP32 is busy with switchbot control actions though
Thank you so muchā¦
I edited the code to also check the sensor while it is doing a BLE scan. the method checkSensor() is called in 2 places
let me know how it goes
This is something I wanted to try. Is there another way where these codes are in separate files so when there is an update we donāt have to paste the values back in?
Remove the client.publish messages you donāt need
I am not sure what to do with this part or what itās doing.
lol. I wrote 95% of that on my phone and havent had a chance to test it
Iāll see what I can do about making it easy to add to main codeā¦ if it works
I edited the code again. set retain true/false instead of removing client.publish lines
I did some quick testing. Seems to work
v6.5 includes last motion and last contact for motion and contact sensor
also a fix to replace spaces in device names with underscores _
Hey guys, I came across this from another HA SwitchBot thread and just wanted to say Iām super excited for this and thanks for offering an alternative.
I ordered 2 x ESP32 D1 Minis which should arrive later this week, hopefully on time to work on it over the weekend.
Iāve been using API for a while for 2 Curtain Bots and lately itās been an absolute nightmare. Iām fed up with it.
Iāve got 2 Hubs each very close to the bots with great Wifi signal but still get occasional (if not 50% of the time on the upstairs one) errors in the app on opening/closing.
Last night the rest api call wouldnāt even work at all for an entire evening!!! I saw that it simply wasnāt responding anymore in the HA logs. Iām aware of the 1000 max calls per day but Iāve set the 2 bots at 300 calls each to update status so it should have left me a pretty good margin considering the curtains open/close twice a day on average.
Iāve also noticed API calls take about 8 seconds to send the command to the bots which can be frustrating at times as I know Bluetooth is faster.
Anyway Iām very much looking to test this solution and will report back if thereās any issue.
Hey @notownblues . It sounds like the AWS outage affected switchbot cloud stuff yesterday
Good luck with the ESP32 setup. You should find it much more responsive and reliable. Let us know how it goes
Hi @devWaves , thank you for MQTT ESP 32 bridge which helps me a lot to control many Switchbot devices locally.
I also have a Humidifier not supported by MQTT ESP 32 bridge, so I tried the BLE check steps following your instructions while changing the mode of the Humidifier on/off/Auto/Manual.
Here is a result from nRF connect app on Android.
Iāve noticed some data changing of Service Data while checking with nRF connect on each mode.
I hope this will help you!
hey @innerzone . Iāve got the humidifier values figured out and actually have code that supports the states, but the hard part now is figuring out the control command byte array to send to it.
I canāt find those commands online and the examples Iāve seen use the same commands as the bot, which doesnt seem to work
Iāve confirmed the humidifier works with BLE only though by turning off wifi and data on my phone then controlling it and it works
basically I need the lines I would write for humidifier like thisā¦
static byte bArrayPress[] = {0x57, 0x01};
static byte bArrayOn[] = {0x57, 0x01, 0x01};
static byte bArrayOff[] = {0x57, 0x01, 0x02};
static byte bArrayOpen[] = {0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 0x00};
static byte bArrayClose[] = {0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, 0x64};
static byte bArrayPause[] = {0x57, 0x0F, 0x45, 0x01, 0x00, 0xFF};
static byte bArrayPos[] = {0x57, 0x0F, 0x45, 0x01, 0x05, 0xFF, NULL};
static byte bArrayGetSettings[] = {0x57, 0x02};
static byte bArrayHoldSecs[] = {0x57, 0x0F, 0x08, NULL };
static byte bArrayBotMode[] = {0x57, 0x03, 0x64, NULL, NULL};
Is it worth trying ānRF Sniffer for BLEā to analyze the BLE control command data of the humidifier?
I donāt know how to find that kind of data. Need more geek skills?
I donāt think so. I donāt think it provides the possible commands to send. I put in a request for humidifier BLE documentation here if you want to comment on it humidifier BLE request
Does anyone know why my curtains will randomly open sometimes? Seems to happen about once every few days but can be more often. I have one esp32 downstairs and one upstairs, it randomly happens on both and when it does, all curtains the esp32 controls will be opened.
I donāt think itās home assistant since whenever I catch it happening, home assistant isnāt aware of the opened state of the cover.
Iāve not been able to be quick enough to check the mosquitto broker when it happens, but even if I was, I wouldnāt really know what to look for. Maybe I could add some logging somewhere to try and catch any strange messages being sent to the broker?