Custom firmware ESPHome-Xiaomi_bslamp2

Have you fully read my flashing guide?
I have a lot of pictures and info there. Also info about and various solutions for handling the two grounds.
The table containing the solder points is from that guide, so it looks like you’re well on your way.

I’m not 100% sure what you mean by “connected the 2 pins in 3V”.
If you mean that you put the 3.3V versus 5V jumper to the 3.3V setting, then this is exactly what you need. That is what I see on your photo too, so that is fine.

afbeelding

You can use the two GND holes for connecting to GND and GPIO0 on the device. That is okay. If you solder the GPIO0 wire to GND, then beware that the device will always boot in flashing mode when the serial adapter is connected. Therefore, it might be best to connect GND to a GND hole on the adapter, but use a wire with a connector to connect GPIO0 to the GND pin on the adapter. That way you can easily disconnect GPIO0 from GND, allowing you to use the adapter for example for getting serial logging.

Do not connect anything to the 3.3V hole. The 3.3V that is mentioned in the table, indicates that the serial adapter should use 3.3V (and not 5V) for sending signals to the RX pin on the lamp. It does not mean that 3.3V must be connected to it.This is what dictates the use of the voltage jumper on 3.3V on the serial adapter.

The TX on the lamp must be connected to RXD on your serial adapter
The RX must be connected to TXD

Note that these two are also available as pins that you can use a wire with a connector for. Either the hole or the pin is okay. The exact pinout of the pins is written on the serial adapter board, but with these it can be hard to see because the 3.3V/5V jumper is a bit in the way.

Don’t use RXL and TXL, because those are used for status LEDs to indicate when there’s dat being sent over the lines (hence the “L” in their name).

When soldering the RXD/TXD holes, then the layout would probably be best like this:

So with the GPIO0 to GND connection done in a way so it can be detached.

I use a Windows10 laptop myself for flashing, using the Esphome-Flasher tool.

I hope this helps!

Thank you! Now everything is very clear regarding the hardware. I am a little confused regarding the flashing tool. I am reading this GitHub - esphome/esphome-flasher: Simple GUI tool to flash ESPs over USB

but I am not sure what I have to yet.

That is the correct repository for it.
The actual windows executable can be downloaded from the releases page (link at the right side of that page).

ok, I found it. So the next steps if I get it right are to go in home assistant espHome and do the following and download the firmware to my laptop.

so if you bear with me

  1. if I just use only the example.yaml (with my credentials) will it be ok? I only need to be able to turn them on - off - in various colors and modify the brightness. (at least for the begging). I think yes.

  2. I am not sure what to use in API. I am using only 1 ESP8266 right now and the API is blank.
    Should I set an API password? (is it necessary?)

image

  1. I am not sure about the OTA password also. in the d1mini I already have there is a long password but never asks for password when I make an update. Is it necessary to use one?

  2. I am not sure where is this " <CONFIG_DIR>/<NODE_NAME>.yaml ." I think it is in directory of esphome of HA. is that right?

  3. Right now both lamps have particular ip address (from router). Is that a problem?

  4. I think I find out how to compile it (but with no ota or api password). is it ok?

  1. The example.yaml is a fully operational configuration, so yes. Once you got that working, you can start thinking about modification that you’d like to apply.

  2. An API password is not required, but it is of course better for security.
    It’s not hard to use. When you set a password in the api: section, then Home Assistant will prompt for the password when you add the device to it. Enter the password that you used in the firmware and things will work just fine.

  3. Same as with API: an OTA password is safer. If you have no password, anybody could flash your devices as long as they are on your network. The reason that you don’t get a prompt for the OTA password, is that the ESPHome already knows the password that it needs to use for flashing (since it’s right there, in the configuration file :wink: )

  4. Yes, you simply create a new device in ESPHome and then edit the configuration. You can create any kind of device, and simply replace the full contents of the generated YAML file with the example.yaml from my GitHub repo. Or you create the yourlampwhatever.yaml file directly on disk in the ESPHome HA directory (where you’ll have the other YAML file too). Both will work.

  5. No problem, ESPHome uses a dynamic discovery protocol (mDNS) for finding on what IP address a device can be found. It doesn’t matter if your router assigns the same of a different IP, and whether or not that IP can change at a later time because of dynamic assignment. It is possible to setup a static IP-address for the lamp in the YAML wifi section, but normally that is not needed.

  6. The compile looks okay, but it’s recommended to set an OTA and API password.

1 Like

Thanks a lot for the clarifications (and the lessons). I hope that I can manage first of all with the soldering (first time too) and the rest procedure. I will let you know if I have news…

I hope it all works out, good luck!

Hi I think (hope) I am close. I tried to flash and got the following

Using 'COM7' as serial port.
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Detecting chip type... ESP32
Connecting...

Chip Info:
 - Chip Family: ESP32
 - Chip Model: unknown ESP32 (revision 1)
 - Number of Cores: 1
 - Max CPU Frequency: 240MHz
 - Has Bluetooth: YES
 - Has Embedded Flash: NO
 - Has Factory-Calibrated ADC: YES
 - MAC Address: 5C:E5:0C:38:AF:42
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
 - Flash Size: 4MB
Unexpected error: The firmware binary is invalid (magic byte=4D, should be E9)

Can you understand what is wrong with the firmware?

ok I did it!

image

Although the lamp is working fine, I am trying to change the name. I am getting the following error
if you have time please let me know what should I do to fix it

INFO Successfully compiled program.
INFO Resolving IP address of notify-lamp.local
ERROR Error resolving IP address of notify-lamp.local. Is it connected to WiFi?
ERROR (If this error persists, please set a static IP address: https://esphome.io/components/wifi.html#manual-ips)
ERROR Error resolving IP address: Error resolving address with mDNS: Did not respond. Maybe the device is offline., [Errno -2] Name or service not known

the lamp is connected and I can change turn it on and off.

edit:

so I added in the yaml file the following

wifi:
  ssid: xxx
  password: xxx
  manual_ip:
    static_ip: 192.168.1.xx
    gateway: 192.168.1.1
    subnet: 255.255.255.0

and it is fine. Tomorrow I hope I can fix and my 2nd lamp.

Thanks a lot!

Well done! :slight_smile:
You are now a master hacker.

1 Like

Hello. Tell me where I could be wrong After firmware - nothing works · Issue #82 · mmakaay/esphome-xiaomi_bslamp2 · GitHub ?

Home Assistant on my virtual machine (kvm) esphhome collects the firmware and it even successfully flashes - but after the firmware there is no reaction of the buttons …

I’ll respond in the github ticket instead of here.

1 Like

Just a huge thank you! I just misunderstood your instructions :slight_smile:

1 Like

Does anyone know if this is at all compatible with the Bedside Lamp D2 (YLCT01YL)? I have the firmware running on my Bedside lamp 2 (MUE4093GL) at present

I don’t own a D2, but I am quite sure that bslamp2 is incompatible with it. That would require a different firmware.

Hello,

I am using this firmware and it really works great.

Is it possible to access to the ESPhome web interface as other devices?

Kind regards.

You mean using the web_server: component in your configuration file, so the lamp can be visited using a web browser? That is not yet possible I think.

Because of two special properties of the device chipset (single core ESP32 and a broken built-in MAC address checksum), ESP-IDF is used instead of the Arduino framework for building the firmware. And for ESP-IDF, web server support has not yet been implemented.

As soon as ESPHome implements the web server support, the feature can be enabled in the firmware by simply adding the web server component to the configuration YAML file.

Hello,

I have a bslamp_d2. I tried to work on top of the bslamp2 esphome repo to make it work but I failed. Seems that embedded C is above my capabilities. :frowning:
If there is anyone willing to help with adding esphome to bslamp_d2, I can donate one fully working bslamp_d2 and ship it for free.

Thank you

Thanks for great firmware Maurice. Been using it for a while and works great. I moved into a new home recently and set up a new network and wireless etc. Is there a way to reset the bedside lamp so it can be connected to new home assistant instance? Or do I have to flash again?
Thank you.