#include BLEService weightService("0000181d-0000-1000-8000-00805f9b34fb"); BLEFloatCharacteristic weight("00002a9d-0000-1000-8000-00805f9b34fb", BLERead | BLENotify); float x = 185.3; void setup() { Serial.begin(9600); while (!Serial); pinMode(LED_BUILTIN, OUTPUT); if (!BLE.begin()) { Serial.println("Starting BLE failed!"); while (1); } BLE.setLocalName("MH Weight Scale"); BLE.setAdvertisedService(weightService); weightService.addCharacteristic(weight); BLE.addService(weightService); weight.setValue(0); BLE.advertise(); Serial.println("Bluetooth device active, waiting for connections..."); } void loop() { BLEDevice central = BLE.central(); if (central) { Serial.print("Connected to central MAC: "); Serial.println(central.address()); digitalWrite(LED_BUILTIN, HIGH); while (central.connected()) { x += 1; Serial.print("The weight is: "); Serial.println(x, HEX); weight.writeValue(x); delay(2000); } digitalWrite(LED_BUILTIN, LOW); Serial.print("Disconnected from central MAC: "); Serial.println(central.address()); } }