I just bought one of these scales off of Amazon, and the data lines up perfectly.
I have never connected it to the app, so my theory is it cannot pull down new firmware.
I have written this code in Python to put nutrition info on the display, but nothing happens.
I am using Windows 10 and Bleak for Bluetooth, which is cross-platform. The check digit is also
correct, converted from TypeScript to Python. I am wondering what I did wrong to not get a result.
Here is my code
`import asyncio
from bleak import BleakClient # for bluetooh install with: pip install bleak
import struct
HEADER = bytearray(b"\xfe\xef\xc0\xa2") # Replace with your header bytes
# Set the nutrition data fields
fields = [calories, calories_from_fat, total_fat, saturated_fat, trans_fat,
cholesterol, sodium, potassium, total_carbs, dietary_fiber,
sugars, protein]
for i in range(len(fields)):
value = int(fields[i] * 10) # Multiply by 10 to match the scale's format
payload[i * 3: 3 + i * 3] = struct.pack('>H', value)
return payload
async def run():
Replace "Device Name" and "Device Address" with the name and address of your Bluetooth device
I just bought one of these scales off of Amazon, and the data lines up perfectly. I have never connected it to the app, so my theory is it cannot pull down new firmware. I have written this code in Python to put nutrition info on the display, but nothing happens. I am using Windows 10 and Bleak for Bluetooth, which is cross-platform. The check digit is also correct, converted from TypeScript to Python. I am wondering what I did wrong to not get a result. Here is my code `import asyncio from bleak import BleakClient # for bluetooh install with: pip install bleak import struct
HEADER = bytearray(b"\xfe\xef\xc0\xa2") # Replace with your header bytes
def uint8(value): return value & 0xff
def calculateChecksum(buffer, prevSum=0): uint8_buffer = bytearray(buffer) return sum(uint8_buffer, prevSum) & 0xff
def uint8ArrayBufferAppend(buffer, data, offset=0): buffer[offset: offset + len(data)] = data return offset + len(data)
def makePacket(header, type, payload, payloadLength=None, checksum=None):
packet = header + type (1 byte) + length (1 byte) + payload + checksum (1 byte)
def create_set_nutrition_payload(calories, calories_from_fat, total_fat, saturated_fat, trans_fat, cholesterol, sodium, potassium, total_carbs, dietary_fiber, sugars, protein): payload = bytearray(36)
async def run():
Replace "Device Name" and "Device Address" with the name and address of your Bluetooth device
if name == "main": asyncio.run(run())
` Any help into what I am not doing correctly would be amazing.