Heroic - Thank You - Going to try this out over the weekend
David and all who have helped before on this thankyou! have managed to get my lights talking to HA and can finally ditch the extra BR-mesh app. They re RGBW downlights Have managed to get them working with the RGB side of things well but cant get the 2700K white channel to turn back on if i change the colour on the RGB wheel or colour temp slider. i have to reattach them the BR-mesh to reset to white colour and then home assistant can toggle the white channel on and off. tried to dig into the RGBW code in your code David but was above my skill level to get it working
Cheers for all the help
Hi David, I have been playing with your code a bunch but still struggling to get the RGBW to work properly sorry to hassle you but any ideas on what i could try am very much a newb to all this but keen to learn. Also, any ideas on how to adjust the code so the ESP retains a connection to the lights after a power cycle without having to put the lights back in paring mode would be most helpful
Thanks in advance
Hello,
I know this is old but when i upload this code to my esp32, it crashes with a bad heap head.
From what i understand, after the line
pAdvertising->start();
I think its here that the heap is going.
Thanks
Hey,
I fixed this by downgrading my ESP32 Firmware to 2.0.1 from Espressif.
Hello and thank you all for this excellent addon to HA!
I have some Melpo flood lights and am trying to get your code (specifically dsclee1 - David’s) flashed to an ESP32, but did notice in your code that there was nowhere to enter the MQTT broker user and pass. Since yours is based off of millskyle’s work where he has these variables added I was wondering if you had any advice on this. I am looking forward to getting this working
Thank you again for your work!
Hello again!
I opted to try Millskyle’s code and obtained my key using ADB, altered the number of lights and passwords etc. got all the dependencies and went to compile but am getting this for line 395:
Compilation error: cannot convert ‘std::string’ {aka ‘std::__cxx11::basic_string’} to ‘String’
Any advice would be much appreciated!
Sorry for the noob question but this is all new to me
Thank you in advance!
Same error for me when using Millskyle’s code.
I am a PlatformIO noob so David’s instructions are greek to me. Any help for someone who hasn’t done any of this for several years? lol
I have the mqtt broker and all that configured. created a user in HA and (I think) configured the broker correctly… maybe I’m doing all of this out of order, I don’t know. I’ve gotten a bluetooth proxy working but that won’t control any BRMesh stuff, just my ember mug. Would be great to do both from one chip.
Anherrera! Thank you for replying as it at least confirms I am not the only one getting the same error and/or I am not hallucinating LOL
In the meantime, I have discovered the lights have memory of their last setting when the power is cut, so I simply have a SONOFF switch now on the wire run to turn them on and off with the sun and still use the app to change the colours when needed.
Hopefully someone with some experience in compiling this type of code has an answer
I switched back to trying to use David’s BRmesh-esp32-mqtt - and I got it to work finally by adding back the MQTT username and password constants as in Millskyle’s code then going down to the very bottom and changing
mqtt->begin(MQTT_BROKER_ADDR, 1883);
to
mqtt->begin(MQTT_BROKER_ADDR, 1883, MQTT_BROKER_USER, MQTT_BROKER_PASS);
this is after I had created the ‘user’ in HA itself with the username/password I want. mqtt addon will automatically let that user in. just call the user whatever as long as it’s not admin or homeassistant or addon. I called it mosquito.
in platformIO, basically, build and then upload. then have the light nearby where you or someone else can unplug and plug back in. once you’ve finished uploading and have serial console open go ahead and unplug the board and the light. then plug board back in and while the light is blue plug the light back in.
you can see whether the client connected successfully in the add-on logs. it’ll say something like this:
2024-09-29 16:15:49: New client connected from 10.0.0.197:63601 as <random_stuff> (p2, c1, k15, u'<USERNAME>').
and then I’ve found that using GitHub - thomasnordquist/MQTT-Explorer: An all-round MQTT client that provides a structured topic overview is incredibly helpful.
Good luck!!! I didn’t have to do anything special in PlatformIO (VSCode add on, anyway) to get the project to upload.
I got David’s code to build but I had to change line 7 from
#include <String>
to
#include <string.h>
and also did the same as anherrera which was pretty obvious since I run my mqtt port on 2883 instead of 1883:
mqtt->begin(MQTT_BROKER_ADDR, MQTT_BROKER_PORT, MQTT_BROKER_USER, MQTT_BROKER_PASS);
For the newbies who don’t work with esp32 often:
I built it in gitpod by clicking the “open in gitpod” button provided by the gitpod chrome extension, edited the src/main.cpp file in the provided vscode editor
I downloaded platformio into gitpod cloud container shell simply by the commands in the terminal window:
wget https://raw.githubusercontent.com/platformio/platformio-core-installer/refs/heads/develop/get-platformio.py
python3 get-platformio.py
then built using the command
/home/gitpod/.platformio/penv/bin/platformio run
the resulting firmware.bin is in the left tree of the vscode experience in .pio/build/esp32dev/firmware.bin which you can right click on and download.
The above process is also how I build Marlin for my 3D printers because I’m too lazy to maintain the toolchain everywhere.
Now you have your firmware; you probably need a real computer and to actually download something to it to flash. You can use esptool or whatever… using that provided example with the linked GUI tool, I only flashed 0x10000 firmware.bin as the device already had a boot loader
Some important features are missing: eg. caching the pairing of discovered lights and setting the modes for fade/flash etc. but overall it’s pretty awesome and considering I had an esp32 from a kids toy just hanging around I was able to get this going in an hour.
I seem to have to power the light on after the esp32 is booted. It shows up immediately in the devices section of home assistant and is easly found by sorting by last modified or searching for BRMesh
If you want to troubleshoot, you can install the esp serial drivers etc. which come with installing the aurdino ide and adding the ESP board blah blab… opening the serial port will show you David’s code logged out the key details for the light so you can probably use that key for compiling different software.
David’s software seems to complete the pairing process which then makes the light forget about the cell phone app connection.
@dsclee1 Hi David,
regarding “I found the code that generates the key (pulled the functions out of their classes and simplified here)”
The QR code for transferring settings from one mobile to another also contain the key. Decoding the QRCode using the class com.brgd.brblmesh.GeneralClass.AESOperator gives a JSON array of the exported lights, followed by a ‘;’ and the key.
[{“d”:“ec0bf1145d7f”,“v”:“4.4.0.3850.53”,“n”:“Light 5d7f”,“a”:3,“t”:1}];83988123