The Nespresso expert is a piece of shit and the app even more. So this project aims to replace the mobile app, and allow you to brew your own stuff. The only reason I started banging my head on this BLE protocol, was that the default "lungo" on the front dial added too much water, making it undrinkable, and to overcome the crappy App and the Crappy default settings on the machine.
The brewbutton, is a simple piece of code that connects to a Nespresso machine, and when triggered on the IO PIN, it will send a simple brew command. Right now, it's hard-coded to a 130ml coffee recipe brew. My idea is to have a small brew button that can brew my morning coffe the way I want it.
The code can be found here: https://github.com/petergullberg/brewbutton/
I have contributed a little to the reverse engineering of the Nespresso protocol, check on GitHub.HOW TO STARTHW and Environment Setup
The brew button is based on a simple ESP32 example, where I only added a debounced PIN, and stuff needed to program the Nespresso machine. There might be alternatives here, but I put it here as a reference.
- Arduino IDE 1.8.10
- NodeMCU ESP-32s(v1.1) with Bluetooth Low Energy support. https://hitechchain.se/iot/esp32-wemos-mini-d1-wifi-bluetooth
- ESP32 BLE Arduino v1.0.1 library
- LCD I2C 16x2 display
- GPIO2 <= with INTERNAL PULL_UP - hook up a button to ground..
- To setup the ESP32 environment in Arduino IDE, I followed this one: https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/
From the original setup I had to make a few changes
- I based the work on ESP32 BLE_Client
- I hardcoded the #define CONFIG_BLE_SMP_ENABLE, in BLEDEvice.cpp, and BLEClient.cpp to ensure security is enabled (to be honest I haven't spent enough time, understanding how to makefiles works in Arduino
- FIX a bug in BleRemoteService.cpp on line 175: uint16_t count = 1;
- Add the line: BLEDevice::setEncryptionLevel(ESP_BLE_SEC_ENCRYPT); in onConnect
On top of this, I also discovered a bug on my windows installation, that prevented me from compiling, but that was solved by a simple mklink....RETRIEVE AUTH-KEY
In order to get this to work, you need to retrieve the AUTH-KEY for your Nespresso machine. To do this, the most simple way I've found is this step-by-step instruction.
- Use an Android (I used Samsung Galaxy Note 4)
- Go to developer options in settings, enable BLE HCI snoop
- Start the Nespresso App (you need to have this already registered, and your machine setup)
- Select a brew.
- After you finished, stop BLE HCI snoop.
- Connect the mobile to USB/PC, and copy/email the file (On Samsung, the snoop is here: \Galaxy Note4\Phone\Android\data\btsnoop_hci.log)
- Install wireshark (wireshark.org), learn a little about it: https://medium.com/@urish/reverse-engineering-a-bluetooth-lightbulb-56580fcb7546
- Load the file in wire-shark
- Look for Write Request to 0x0014 (Service 06aa3a41-f22a-11e3-9daa-0002a5d5c51b), the data part is the AUTH-key
- Extract the AUTH-KEY (8bytes), mine is "879608e27cb1f96e"
- Downloaded the GATTBrowser from Renesas, you have it on both iPhone/Android
- Find and connect to the nespresso device
- Find auth service characteristics 06aa3a41-f22a-11e3-9daa-0002a5d5c51b
- Write AUTH-KEY to this register
- Find service characteristics 06aa3a42-f22a-11e3-9daa-0002a5d5c51b
- Write 03050704000000000105
- If you managed to do these steps above correctly you should be brewing an Americano
- Modify the AUTH-KEY in the source code
- Use the Arduino IDE and compile the software
- Upload it (make sure to press the right button on the board when Ardunio tried to connect and program the firmware
- Connect a button to GPIO2 to GND
- When pressing the button, it *should* work, if not, make sure you made the changes required to make the BLE stack to function properly.
- It's rather simple, you can make your changes to the code pretty easily.
It took some effort to reverse, and complete the details. Even though the code was quite simple, there were a few hiccups on the way.