Home Assistant Integration for Lelit MaraX with ESPHome

I build an integration for my Lelit MaraX Espresso Machine for Home Assistant.

This integration is based on this great Reddit article

I used an Wemos Lolin32 to connect with the PID of the MaraX. The connection is done via UART.

The coffee machine sends the following data about 4 times a second:

C123b,095,112,063,1095,1

First Character: C or S for Coffee-/Steam-Priority. Followed by the current firmware version. Second value: Actual steam temperature Third value: Target steam temperature Fourth value: Actual Heatexchanger temperature Fifth value: Remaining timer for fast heating Sixth value: Heating on/off

When data is received it is shown on the display (Actual temperature of heat exchanger and steam) and sent to Home Assistant.

ESP32 in Coffee mode

ESP32 in Coffee mode closeup

If no data is received for 5s the current time is shown instead.

ESP32 in Clock mode

In Home Assistant the data can be used to build dashboards.

ESP32 in Clock mode

ESP32 in Clock mode

Case: Wemos Lolin 32 OLED Box by pangodream - Thingiverse

The code can be found here

@manyos-robert Im just doing this same thing with my Lelit Elizabeth V3 I found the Gicar control box (its not as easy to get to as your MaraX), and just looking at the pinsā€¦ could you remember or confirm which colours you added to which pins? it looks like pin 2 (green) and 3 (white) from left to right in this pic?

EDIT: Read the Reddit link article a bit closer and have my answer - Green wire (TXD) to Pin 3 and White (RXD) to Pin 4

1 Like

I absolutely love this!

I actually opened my Gicar unit to check the correct pinout, as it turns out (at least for the V2 version) all available pinouts are wrong. The 4th pin from the wall is the actual ground pin. By using this pin you can draw 12V fro the 12V pin of the buzzer connector labeled on the cartridge, that sits right next to the 6 pin aux port. The Tx pin is actually the one right next to the Ground pin (Pin 3 from the wall) and is all you need to hook up to read data from the Gicar. After all we donā€™t know any commands the Gicar understands anyway. Until somebody dumps the firmware of the ST mcu that does all the magic.


Marking on the MCU is:
STGK245
8S003F3P6
CHN148RJ7

1 Like

In case anyone is interested in trying to dump the ST MCU firmware, CN8 is the On-board Programming port. That being said, the firmware is very likely readout protected.

Fun fact, the board is extremely similar to the corresponding board in the Lelit Bianca, but the firmware is very different (in the Bianca, thereā€™s an additional board, the LCC, which does all of the interesting stuff like PID, so for that machine role of this board is basically just an IO board).

Iā€™ve documented the protocol on the Bianca at GitHub - magnusnordlander/lelit-bianca-protocol: Project notes for trying to sniff and reverse engineer the protocol used for LCC information on the Lelit Bianca. Iā€™ve also considered designing an open source replacement for these boards (Iā€™ve designed one that replaces the LCC), but Iā€™ve only done low voltage boards before, so doing a mains voltage one scares me :sweat_smile:

1 Like

Do you know the pinout of the programming port? I have a stlink v2, I could try a dump fwiw.
I was also considering doing my own electronics, but I figured especially in the Mara X the logic might be slightly more sophisticated than slapping a pid on some temp probes, as it seems Lelit really knows how to keep the hx temps in sane ranges and spent quite some effort getting these right.

The only thing Iā€™d ask would be to set my brewing temperatures independent of the 3 way switch we have in the mara. But Iā€™m pretty sure thatā€™s quite a stretch to ask for.

Nice work on the Bianca! I had an eye on here but she was just too far off budget, and I donā€™t have the space for her.

Just looking at an incomplete reverse engineering of the control board I did a while ago (where U5 is the MCU component):

Pin 1: +5V
Pin 2: U5_PD1
Pin 3: GND
Pin 4: U5_NRST

Iā€™ve uploaded the partial schematic to https://github.com/open-lcc/control-board-schematic (pull requests are welcome).

By the way, you didnā€™t by any chance snap a photo of the high voltage side of the assembly? Iā€™m a little interested to see if that is identical too.

1 Like

This is interesting!

I ordered my Mara X V2 last week and it did not arrive yet, but Iā€™m afraid the V2 needs some extra care to be turned on and off via a (e.g.) WiFi Plug
So Iā€™m reading a lot of threads what has been done already.
Iā€™m looking for an option to have (beside what seems possible already) the following functions:
Control Mains Power by a WiFi Plug (easy)

  1. When Mains Power is on, set Mara X to ā€œonā€ Mode with Standby-Mode activated
  2. Beeing able to wake up Mara X from Standby

Reason? It would be quite inconvenient when I need to get up 25mins earlier before having Morning-Coffee. I want that I can turn on Mara either manual via Home System, or having Mara turned on by Home System at a given time in the morning.

Iā€™m happy developing a small PCB with an (e.g.) ESP32 if someone could help me with the coding.

Edit: yesterday I received the MaraX and after beeing able to inspect it in practice, I have to correct some assumptions I made in an error.
So my machine was delivered with a mechanical on-off push button.
The means thereā€™s no problem operation the ā€œpower onā€ function with a WiFi plug.
This has been implemented yesterday and is working great!

2nd Edit: After watching the Energy consumption over the day, I end up at about 1 kWh with Stand By Mode deactivated. This equals 35Ct. ā€¦ even with StandBy Mode activated, it is not much less than that.
If I compare this to the price of a single coffee @ Starbucks, it stopped thinking about this.

Other point: even after reading hundreds of threads, nowhere is mentioned, which connector can be used for connecting to the AUX Port of the Gicarā€¦ From Pictures Iā€™ve seen it must be one from the TE catalogue, but not sure which series.
Is this publicly known?

Learning curve done!
A lot of nonsense is circulating around re MaraX serial connection.

Here a summary what & why and how to do it right: Lelit Mara X V2 Gicar Internals - Engineering Office Grafe

Hi Greminn,

Did you have any progress with this? I also have Lelit Elizabeth V3 and would like to connect it to Home Assistant.

Hi @dougie, first, I would like to thank you very much for your excellent article and the many corrections on the web that you have made regarding the wiring of the Mara X. You show a sense of responsibility to share your knowledge to keep other from harm, thatā€™s really worth a mention!

I am also trying to tap into the UART bus of the Mara X, but I am encountering the problem that it only speaks ā€˜gibberishā€™, as if an incorrect BAUD rate is set, see screenshot:

I have the same result with two different USB serial dongles, a PL2303HX RS232 and a FT232. The latter has 3,3V and 5V jumper options to avoid the voltage reduction when using the 5V TX from Mara X.

I have tried with voltage reduction, without, different cables, different devices, all baud rates, some different settings within putty and CoolTerm.

Also, I didnā€™t have luck with my ESP32 and the following code.

logger:
  level: DEBUG  # Ensures debug-level logs are shown
  baud_rate: 9600

uart:
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 9600
  id: uart_bus
  debug:
    direction: BOTH
    dummy_receiver: true
    after:
      delimiter: "\n"
    sequence:
      - lambda: |-
          UARTDebug::log_string(direction, bytes);  //Still log the data
          //Example to convert uart text to string
          std::string str(bytes.begin(), bytes.end());
          // Filter out non-printable characters
          str.erase(std::remove_if(str.begin(), str.end(), [](unsigned char c) { return !std::isprint(c); }), str.end());
          // Prepend "DEBUG: "
          std::string debug_str = "DEBUG: " + str;
          // Publish the cleaned string
          id(uart_string).publish_state(debug_str.c_str());

interval:
  - interval: 120s
    then:
      # send uart query
      - uart.write: "Hello World\r\n"

text_sensor:
  - platform: template
    name: "UART String"
    id: "uart_string"

The output shows only ā€œDEBUG: Hello Worldā€ and the sensor ā€œHello Worldā€, no UART from my Mara X.

Now, Iā€™m running out of ideas. Any ideas what to test next? Thanks in advance.

Solved my problem by inverting the UART from Mara X:

uart:
  tx_pin: GPIO1
  rx_pin:
    number: GPIO3 
    inverted: true
  baud_rate: 9600
1 Like