Fredrik Erlandsson

Logo

PhD in Computer science, data scientist at Consid AB.

Getting the PunchTrough LightBlue Bean to work 2025

2025-06-04

I bought a couple of LightBlue Beans in 2014 but never got my way around to get them into use. Here are some notes on getting an development environment up and running in 2025 (most of the original links and resources are removed).

The patching of the Arduino binary does not work entirely as expected, the libraries are not installed in the correct path. So the contents of the folder /Applications/Bean\ Loader.app/Contents/Resources/Arduino/hardware/ needs to be copied into ~/Library/Arduino15/packages/arduino/hardware. After some struggle with permissions (modern OS X are super conservative on running downloaded apps and letting apps patch each other), I managed to get an example sketch to compile and flash via the BeanLoader.

Documentation is still available trough WayBack Machine

Other resources:

The main idea is to get my Beans to talk BTHome. With the intention that the Bean would advertise sensor readings from eg. DS18b20 sensors. This is the current code, using the builtin BMA250 and battery level:

#include <Bean.h>

// Update interval 600 seconds
#define ADV_UPDATE_MS 600*1000

// BTHome advertising buffer
static uint8_t customAdvertData[] = {
  0x02, 0x01, 0x06, // Flags
  0x0a, // Length
  0x16, // Service Data - 16-bit UUID
  //BTHome data
  0xD2, 0xFC, // UUID
  0x40, // BTHome Device Information
  0x57, 0x00, // Temperature (°C)
  0x01, 0x00, // Battery (%)
  0x00, 0xFF // Packet Id
};

void setup() {
  Bean.enableWakeOnConnect(true);
  Bean.enableCustom();
  Bean.enableConfigSave(false);
  Bean.disableMotionEvents();
  Bean.setAdvertisingInterval(300);
}

void updateData() {
  // Patch temperature bytes into BTHome payload
  customAdvertData[9]  = Bean.getTemperature();
  customAdvertData[11] = Bean.getBatteryLevel();
  customAdvertData[13] += 1;

// Push updated advertisement
  Bean.setCustomAdvertisement(customAdvertData, sizeof(customAdvertData));

  // Broadcast advertisement
  Bean.enableAdvertising(true, 900); // advertise
}

void loop() {
  Bean.setLedGreen(25);
  updateData();
  Bean.setLedGreen(0);
  Bean.sleep(ADV_UPDATE_MS);
}