The Digital Weighing Scale Kit is designed to measure weight up to 5kg. It includes a load cell of 5kg, and an amplifier module that interfaces the load cell to micro:bit.
In this tutorial we will walk you through the steps to connect the Digital Weighing Scale Kit to micro:bit, and use our MakeCode extensions to calibrate and take weight measurement.
Before we start to create the program, we need to install the MakeCode extension for the scale kit. In MakeCode editor, go to "Advance" -> "Extensions", enter the link below in the search bar and click on search button:
Proceed to click on "SGBotic-scale" to compete the installation. A "scale" package under "SGBotic" will appear in your block menu:
The makecode extension contains pre-calibrated data for this scale kit. No re-calibration is required prior to using this scale kit. However if you prefer to re-calibrate the scale for better accuracy, you can use these calibration blocks:
The load cell amplifier uses a two-wire interface (Clock and Data) for communication. Hook up the amplifier to micro:bit as below:
For this example code, we use ubit:connect Interfacing Board to connect the scale kit to micro:bit. The Scale Extension provided above can work with micro:bit directly and other interfacing board; you just need to modify the code accordingly.
With no object placed on the scale, apply power to the micro:bit. The scale is ready to measure weight once the OLED display is turned on.
This example code includes code for re-calibration of scale. To re-calibrate, place an object with known weight (this example uses 1000 grams) on the scale, press 'B' button and wait for the "done" to appear on the OLED display. The calibration process usually takes few seconds. Note that this re-calibrated data will be lost when the micro:bit is reset or power down.