This collection features three web applications built with plain JavaScript, HTML, and CSS, demonstrating various functionaly available through Web Bluetooth Low Energy (Web BLE), Wifi and Web USB. These apps aim to open up new ways to interact with your Half Decent Scale, providing powerful tools for quality control, precise weighing, and simplified dosing directly from your web browser.
Experience the Apps: Live Demos
Get hands-on with our web tools. (Currently available for desktop/laptop browsers, Android and iOS (via the scale's wifi connection) devices.
Weigh and Save: Your go-to app for general weighing tasks. Precisely measure items within a set timeframe and easily export the results for analysis or record-keeping.
Quality Control Assistant: Perfect for ensuring consistency. This app allows you to repeatedly weigh the same items, simplifying data tracking and quality checks.
Dosing Assistant: Simplify your dosing process with an intuitive interface designed for achieving accurate and repeatable measurements.
Getting Started: How to Connect & Use
Connecting your Half Decent Scale to our web apps is straightforward. Follow these steps:
Browser Check: Ensure you're using an up-to-date version of Google Chrome (version 136 or newer) or Microsoft Edge (version 136 or newer).
Open an App: Navigate to one of the app links provided above.
Enable Pairing Mode: Put your Half Decent Scale into Bluetooth pairing mode.
Connect via App:
Click the “Connect” button within the web application.
A pop-up window will appear, listing available Bluetooth devices.
Select “Decent Scale” from the list.
Connection Confirmed: Once connected, the “Connect” button will turn red and change its text to “Disconnect.” You will also see live weight updates from your scale displayed on the screen.
Begin: Click the “Start” button and follow the on-screen instructions specific to the app you're using.
Using USB-C Connection (Optional for “Weigh and Save”): The “Weigh and Save” app also supports a direct USB-C connection. If you opt for this method:
First, connect your device to the Half Decent Scale via a USB-C cable.
Select the USB connection from the drop-down menu, click “Connect,” and choose “USB Serial” from the pop-up list.
After it is connected you will see live weight updates displayed on the screen.
Purpose & Audience
These web applications serve two main goals:
For Scale Users: To provide practical, easy-to-use tools that enhance the functionality of your Half Decent Scale for everyday tasks.
For Developers: To offer a real-world demonstration of Web Bluetooth and Web USB capabilities, encouraging exploration and innovation with these technologies.
These apps are ideal for:
Decent Espresso Machine and/or Half Decent Scale Owners: Enhance your daily weighing and coffee preparation routines.
Quality Control Professionals: Streamline weighing processes, improve consistency, and simplify data collection.
Developers & Tech Enthusiasts: Explore a practical implementation of Web BLE and Web USB in an IoT context.
For Developers: Technical Deep Dive
All code for these web apps is available in the web_apps directory of the openscale repo.
Foundation: Built with standard HTML, CSS, and JavaScript.
Styling:Tailwind CSS is used for a utility-first approach to styling, ensuring a responsive and modern interface. (Note: While Tailwind is a CSS framework, the core logic remains in plain JavaScript, avoiding heavy JS frameworks.)
Web USB API: Provides an alternative wired connection method.
Browser Compatibility: Google Chrome (version 136 or newer) or Microsoft Edge (version 136 or newer), iOS and Safari using the scale's Wifi connection.
Data Storage: Data such as readings and presets are stored locally in the browser's local storage. Users can download their data as JSON or CSV files.
Code Structure & Key Modules
The codebase is designed to be understandable and adaptable. “Weigh and Save” and “Dosing Assistant” feature a modular structure, while “Quality Control Assistant” uses a monolithic structure for a potentially simpler overview of function interactions.
Key JavaScript modules and their roles:
scale.js: Handles BLE protocol, communication with the Half Decent Scale (HDS), and core dosing mode functionality.
constants.js: Stores pre-programmed 10-byte messages for HDS communication and various threshold values.
state-machine.js: Implements the core logic for “Dosing Assistant” and “Quality Control Assistant” using a Finite State Machine model.
export.js: Manages the functionality for exporting weight readings and evaluation data as CSV or JSON files.
presets.js: Allows users in “Dosing Assistant” and “Quality Control Assistant” to save target weights as presets, cached locally by the browser.
ui-controller.js: Manages updates and changes to the HTML interface.
modules/connection/ (in “Weigh and Save”): Contains the specific implementations for BLE and USB connection methods.
To get a local copy up and running, follow these simple steps:
Download the web_apps Directory: GitHub doesn't offer a direct download for subdirectories. You can use a specialized tool for this. Here are a couple of options:
Paste the URL to the web_apps directory on GitHub: https://github.com/decentespresso/openscale/tree/main/web_apps
Follow the tool's instructions to download the directory as a ZIP file.
Extract the downloaded ZIP. This should give you a web_apps folder.
Navigate into the project directory:cd web_apps/dosing_assistant
Serve the files with a local HTTP server: Since these are web applications using Web BLE, they need to be served over https:// or http://localhost You can use a simple NPX HTTP server or any other local server you prefer.