An open-source solution for accurate food-intake monitoring

People with special nutritional needs must monitor their food intake as accurately as possible. One of the problems with food-intake monitoring is a correct estimation of portion sizes. This paper presents an open-source solution to the problem of portion-size estimation consisting of a pocket-sized kitchen scale and a demo mobile application. It is implemented as a soft real-time, low-power consuming embedded system with a Bluetooth connection to the smartphone. Releasing both the hardware and software of the system as open source paves the way towards accurate nutrition tracking and personalized nutrition. This can lead to important advances in the field of nutrition research, as well as practice. This is demonstrated with a proof-of-concept integration of our solution with a commercial mobile application that helps users to keep track of their health and lifestyle goals.


I. INTRODUCTION
One of the cornerstones of accurate, personalized nutritional interventions is portion-size estimation. Individuals who need to follow a prescribed diet or eating plan, or people who have specific dietary goals (e.g., athletes), are often required to self-monitor their dietary intake. Tracking dietary intake is helpful for both the individuals and their dietitians to understand their eating habits and to decide on whether personalized dietary changes are needed [1]. Recording dietary intake is not an easy task, as it requires a continuous collection of several pieces of information over a certain period. For example, the type of food/beverage, the amount, the time and location of consumption, the presence of other people, activities performed while eating/drinking, and feelings when the food/beverage has been consumed. The monitoring and collection of such complex information over a long period of time can be very challenging. Research and practise indicate that dietary-intake records become incomplete after seven days of recording [2]. However, recent advances in the field of automated food-image recognition can ease the process of recording dietary intake.
There have been projects that tried to extract information about food, food quantity and the contained nutrients, from different points of view, using wearable sensors [3], mobile devices [4] or cameras [5]. Several solutions and even some commercial mobile applications are based on deep learning [6], [7] and estimate food intake from images taken with a smartphone's camera. However, to the best of our knowledge, none of the existing solutions or applications can estimate portion size, which is necessary to evaluate the nutrient profile from the food record.
This paper presents our open-source, pocket-sized, wireless kitchen scale called Libra and highlights the advantage of open-source solutions for accurate portion-size estimations. It also shows the benefits of implementing such open-source solutions in practice as well as for nutrition research, and proposes a solution. Greater emphasis is placed on the hardware, for two reasons. Firstly, the costs related to the development of the hardware are high and the know-how is inaccessible to many. Therefore, releasing it as open source can be seen as the main contribution of this research. Secondly, the hardware for the complete food-intake monitoring solution presented here is the best defined and does not change as much as the software part, which can differ depending on where the solution will be applied (e.g., hospital environment or health club vs. home use), regional specifics (e.g., European vs. Asian food) or branding requirements.
The rest of the paper is organized as follows. Section II presents the need and the requirements for a portionsize estimation solution and introduces the first open-source, pocket-sized kitchen scale called Libra, initially designed as an accessory for patients with diabetes [8]. Section III details the evolution of Libra and its current state of development, including the technologies used, the battery consumption, etc. Section IV highlights how open sourcing Libra leads to better nutrition solutions by presenting the Ballerina project, where the Libra scale was integrated with a 3rd-party solution, the Libro -Food Diary & Nutritional Analysis mobile application [9] from Nutritics. Finally, Section V concludes the paper, summarizing the main contribution of having Libra as an open-source solution, so as to encourage the widespread use of these smart kitchen scales for nutritionassistance purposes in various nutrition-related areas.

II. PORTION-SIZE ESTIMATION
Portion-size estimation is an important part of self-reporting for dietary intake. It is relevant for patients with special dietary requirements (e.g., diabetes, kidney disease) and their dietitian, for people who want to lose weight or body fat, for people with a specific health or fitness goal, such as pregnant/lactating women or athletes, and for individuals who want to monitor the foods they consume.
Different methods can be used to self-monitor food intake. A recent systematic literature review of food-intake monitoring focused on an aging population demonstrated that a variety of different technologies for food-intake monitoring exists, for example, image-based techniques, smartphone technologies, smart home, IoT, etc. [10]. In addition, [11] presents numerous wearable sensors that have been used by researchers and are able to monitor food activity. But despite the fact that a lot of different technologies already exist, and can detect and monitor food intake, the majority of them cannot accurately estimate portion size.
To make a dietary assessment as accurate as possible, it is most important to accurately estimate the size of the food portion, because otherwise healthcare professionals cannot create a true picture of an individual's dietary intake. However, it has been postulated that lay adults [12]- [14] as well as experts [15] have difficulties in accurately assessing portion sizes.
The ability to accurately estimate portion size can increase an individual's awareness of the volume of food consumed, and therefore help them to fulfill their dietary needs and to follow dietary recommendations and guidelines [1], [16]. Moreover, it can allow dietitians to correctly assess the nutritional status of their clients. An accurate portion-size estimation is also crucial for people who need to consume enough food to meet their increased energy and nutrient needs (e.g., athletes, pregnant and lactating women).
Portion-size education and interventions can have a positive impact on improving the ability to estimate portion sizes [17]. For example, a useful educational tool is the use of portion-size measurement aids (PSMA), which are items used to directly measure food portions [16]. Frequently used PSMAs are household measures, such as measuring cups; spoons; food replicas; rulers; wedges [18]; food photographs [19] or common objects (e.g., tennis ball, card) [1]. Despite the fact that PSMAs can be useful, a lot of them are not practical for regular use [20], which makes them less likely to be used outside the home [21]. Furthermore, people struggle with estimates of amorphous foods and foods that have irregular shapes [22], [23], as well as of foods presented in multiple units and different meal types [24]. Research also indicates that self-reported food records can underestimate the amount of consumed foods and beverages [25]. Table 1 briefly summarizes different portion-size estimation methods suitable for portable food monitoring.
In addition, people struggle with portion-size estimation because of the existence of different measurement units around the world. Although most countries use the metric system, household measures such as cups and spoons are frequently used as food measures. International differences in the sizes of measuring cups can be even more confusing for consumers, and many European countries do not use cups in recipes, dietary recommendations or on food labels, which makes assessing the food portions even more difficult [26]. Using a kitchen scale allows us to overcome these difficulties, and can further facilitate the estimation of portion sizes.
Even though a lot of educational tools and aids already exist, in general people still have difficulties assessing food-portion sizes. Therefore, there is a need to develop a practical, portable and effective m-Health tool to assist people in estimating and selecting more appropriate portion sizes and informing them of the nutritional quality of foods [27].

A. FROM PORTION-SIZE ESTIMATION TOWARDS PORTION-SIZE MEASUREMENT
The most accurate food tracking can be achieved by providing measurements of the mass/volume of the food or beverage. Kitchen scales are inexpensive devices that serve just this purpose, but have several limitations when used for daily nutrition tracking.
Electronic scales are now popular appliances in modern kitchens, but most commercial products generally lack the ability to store and share the measured data. The idea of a kitchen scale having a connection to external electronic devices that allow further processing of the data is not new. In order to provide easy monitoring of a healthy diet LOW (prone to error and highly dependent on user) Image-recognition Estimation of weight based on images HIGH (part of application on mobile phone) LOW (prone to errors due to volume estimation based on 2D images) Image-based recognition with physical aids Estimating food volume from images based on reference object that is also included in the image LOW (need for mobile phone and object physical object which is not flat as the scale) MEDIUM (improved accuracy over image-based methods due to reference object) and efficient management of food intake, which require the storage and processing of data, different solutions were considered and patented over the last decade, e.g. [28]- [33].
To interpret measured amounts in a nutritional context, food-composition data are needed. Today, there are several affordable, smart, wireless kitchen scales available on the market. The commercially available devices are mainly of standard sizes (for use in the kitchen) and are connected to apps that allow some basic conversion of nutritional values from internal databases. Some of these devices [34]- [43] are briefly described and compared in Table 3. In addition to food-composition data, the real-time monitoring of food intake with an interactive connection to the dietitian and home-based remote patient monitoring, even outside the home environment, is sometimes desirable.
Portability, appropriate measuring range and accuracy are rarely found together in the same off-the-shelf scale. Various types of accurate, pocket-sized scales available on the market generally have a lower measuring range, typically up to 300 g, and are not suitable for weighing the usual mass of individual meals, where the food is usually served on a plate. Moreover, such scales mostly do not have any connections to external devices, nor access to nutrition databases. On the other hand, domestic kitchen scales typically exceed the size or weight of what could be considered a portable device for on-the-go, 24/7 measuring. The size and weight of such a device should be similar to the size and weight of a smartphone, as these are the devices that we have continuously with us. One last requirement for the portability of a scale is a low-power consumption, i.e., the maximum battery life with one charge.
Finally, a pocket-sized kitchen scale should be open to be connected and integrated with any other nutrition solution. There are many providers of software-based nutrition solutions for different user groups from healthy individuals to researchers, hospitals, dietitians, athletes and patients with specific needs. All these services can be improved with accurate nutritional-intake recording provided by a scale. The reason they are not is mainly due to the lack of knowledge and financial resources to develop a portable scale. Table 3 lists scales that come close to fulfilling the requirements, yet each falls short in some aspect. The closest one being the "Smart food scale" [43], which is nearly portable and connected to an app providing data and services (but with dimensions 12.5 cm × 10.5 cm × 1.7 cm exceeds pocket size). Its main drawback is that it is not completely open, although it allows connection to 3rd-party solution providers such as "Fitbit", [44], Google Fit or Apple Health [45]. On the other hand, the smallest smart scale we came across is eCoaster [42] with dimensions 10 cm × 10 cm × 1 cm, but it falls short on connectivity and openness.

III. METHODS: OPEN SOURCING THE LIBRA SMART POCKET-SIZED KITCHEN SCALE
A complete solution for accurate dietary-intake recording consists of three components: hardware, software, plus the data and information ( Figure 1). By data, we mean food-composition data (FCD), that contains information about the nutritionally important components of the foods, providing values for energy, nutrients and non-nutrients, such as water and fiber. Today, FCD is present in foodcomposition databases and includes data for generic and branded foods. While, for example, the US FCD found in the USDA National Nutrient Database is open, most European countries still do not provide FCD as open data. By information, we mean dietary recommendations, which are designed to provide dietary advice about the amount and kinds of foods needed for the health and overall well-being of individuals.
In this section we focus mostly on the first component (hardware, the Libra scale with its evolution) and partly on the second one (software, the demo Libra Logger Android client), while in the next section we also demonstrate an example of a complete solution (i.e., Ballerina -an VOLUME X, 2021 example of the integration of the Libra scale with Nutritics' commercial Libro [9] mobile application).
Our idea of developing a portable, wireless kitchen scale came several years ago when we were looking for a solution to support diabetic patients in counting carbohydrates [8] and were unable to find it on the market. Although recently new products have emerged that could partially meet the needs (as described in the previous sections), we are still unaware of a solution that would fully meet all our needs, so we continued our investigations/developments in this direction, deciding to make Libra available as an opensource solution. In this way it can be integrated with various mobile applications and be further improved by a wider community of developers. Libra was implemented as a soft real-time, embedded system. The customized kitchen scale allowed the weighed value to be automatically transferred to the smartphone via a Bluetooth wireless connection. Bluetooth was selected because it has low power consumption, it is not restricted to the line of sight, and has become a standard feature of smartphones.

A. EVOLUTION OF THE LIBRA PORTABLE KITCHEN SCALE
The initial version of the wireless kitchen scale developed in 2011 consisted of a generally available and low-cost digital household kitchen scale that was upgraded with a Bluetooth module. In later years, we designed and developed our own scale named Libra. Some major modifications (see Table 2) include downsizing (version 2015), introduction of BLE v4 (version 2017) [46] and BLE v5 (version 2019). The recent Libra is smaller than most of the state-of-theart smartphones and up to date with the latest Bluetooth technology (see Figure 2). While the dimensions of the first version were 135 × 20 × 210 mm and its weight was 395 grams, the newest version dimensions are only 69 × 9 × 117 mm and it weighs 73 grams (including battery). Still, the pocket version is operational up to 5 kg with a resolution of 1 g, which is accurate enough for food-intake recording.
The most relevant updates were aimed at easier portability of the device (i.e., a pocket size and reduced weight), and a reduction of the energy consumption for longer battery autonomy. Table 3 shows a comparison of the Libra's characteristics with some commercial smart kitchen/nutrition scales. In terms of size, Libra is comparable to special commercial pocket precision scales for weighing small masses (typically up to 300 g, with a precision of 0.1 g or higher, depending on the measuring range). These types of scales do not have any smart functions and are not connected to external/mobile devices, and are therefore not included in Table 3.
Regarding FCD and dietary recommendations, Libra can employ any FCD used by the connected mobile app. For example, in the Ballerina solution (presented in Section IV), data for both generic and branded foods are available and provided by the partners implementing Ballerina. However, providing these data is outside the scope of the presented open-source solution, as shown in Figure 1.  The updated Libra scale hardware was developed with more recent, highly integrated components, resulting in a lower cost and better energy efficiency. The major parts of the scale are a precision measurement circuit with a Wheatstone bridge, a microcontroller with Bluetooth capabilities, and a power-supply circuit as depicted in Figure 3. The scale design also includes some optional parts like a wireless charger, UART interface, and physical buttons. They provide additional functionality at the expense of cost and power consumption. If such functionality is not needed, they can be omitted during production. In order to control and monitor the power supply of all the peripheral devices, to control the measurement circuit, and to indicate the scale's operational state, 14 I/O signals were used together with the UART, I 2 C, and custom SPI interfaces.
A Nordic Semiconductor nFR52832 device was selected as a scale microcontroller. The nRF52832 System-on-Chip (SoC) is built around an ARM Cortex M4 CPU and provides numerous digital I/O interfaces, an analog interface, an ISM band radio, serial communication interfaces, timers, and an internal power supply. It supports Bluetooth 5 (BLE5), which enables a higher data throughput compared to older Bluetooth technologies and reduces the power consumption.

VOLUME X, 2021
In the design phase we were looking for a compromise regarding the energy consumption, size, and price; therefore, smaller nRF52810 and larger nRF52840 devices, as well as the smaller QFN32 and bigger QFN48 packages, were considered. Among the considered SoCs only the nRF52810 device is available in the smaller QFN32 package, and when using this package not enough I/O pins are provided. While all three SoCs are available in the larger QFN48 package with a sufficient number of I/O pins, the nRF52810 device proved to have insufficient memory. The scale's firmware was developed using the Nordic SoftDevice programming stack and together they do not fit into the nRF52810 device's memory. On the other hand, the nRF52840 device has more interfaces than needed, it consumes more energy, and it is more expensive.
The measurement part is composed of a high-precision, analogue-to-digital converter (ADC), a precise referencevoltage source, and a Wheatstone bridge built from four weight sensors. Our previous versions of the kitchen scale used discrete components; however, such a solution is more expensive in terms of the cost of parts as well as the manufacturing costs. During the hardware development the HX711 device proved to be the cheapest solution that integrates the necessary functionality. Some other integrated solutions from renowned IC producers (i.e., Analog Devices, Texas Instruments) were investigated, but while providing additional and unnecessary functionality, their costs were significantly higher. The HX711 device was chosen as a measurement device. It was developed for weighing-scale and similar applications that use measurement bridges. It includes a high-precision 24-bit ADC, analog power-supply regulator, and a serial communication interface for connection to the processing device.
The power supply is composed of a lithium polymer (LiPo) battery, a Power Management IC (PMIC), and optional wireless-charging circuit. The LiPo battery was chosen because it provides a higher specific energy than other types of batteries. The power supply must include controllable voltage regulators and a battery charger. They can be implemented discretely, but an integrated PMIC solution is preferable since it is smaller and reduces the number of elements. The MAX77734 is a small PMIC that integrates an adjustable, low-dropout, linear regulator (LDO), a Li+ battery charger, current sinks for the LED indicators, and an analog multiplexer for power monitoring. It was chosen as a compromise between power efficiency and the cost of the device. The MAX77640 PMIC was also considered because it has three DC/DC converters that have a wider battery-voltage operating range and an efficiency of around 85%. However, it was decided that the lower price of the MAX77734 outweighed the slightly reduced energyconsumption of the MAX77640 device.
Additionally, the effect of the wider battery-voltage operating range is negligible, since its extension is in the range where the battery is practically depleted.
The wireless-charging circuit can optionally be included in the power-supply part. While wireless charging is an attractive feature, but it significantly increases the scale's price. Principally, the scale is designed to be operated by a smartphone app. The scale is controlled by virtual buttons and in the most simple case, the weight is displayed on a smartphone screen. While such usage is normally sufficient, there might be some cases where physical buttons are preferable. An optional part that implements physical buttons is provided in the scale's design.
The serial communication interface is another part that is optionally included in the scale's design. Since the scale is charged via a USB-C interface, a USB-UART bridge was added to the scale. The disadvantage of using a UART interface to operate the scale is that it affects the accuracy because of the USB's wiring. However, the UART interface proved to be very useful for debugging and accessing the electronics during the development of the smartphone app.
After the assembly the scale must be calibrated to ensure accurate weight measurement. The scale calibration procedure is supported by the scale firmware and can be performed as a maintenance task using Bluetooth protocol given that privileged user was authenticated.
Special attention was paid to lower the power consumption of the scale and increase the battery's run time. Since the scale does not have a display, some LED indicators were added to monitor its operation. The power consumption of the LED indicators is comparable to the power consumption of the weight sensors and/or power consumption of the BLE device with active radio. Thus, the operation of the LED indicators was minimized to display only the BLE communication activity. The power consumption was further lowered by switching off the power supply to the measurement circuit when the scale is not operating.

C. POWER CONSUMPTION
Some preliminary measurements of the scale's power consumption were conducted using a standard current meter and a Power Profiler Kit from Nordic Semiconductor. The Power Profiler Kit is a measurement tool for measuring the current and power of low-energy embedded devices.
The power consumption of the scale depends on the type of operation: • In the off mode, the scale is advertising its presence to nearby smartphones or tablets, • In the stand-by mode, the scale is connected to the smartphone, but the measurement circuit is powered off, • In the weight-measurement mode, all the parts of the scale are powered on.
Since the power consumption of the scale significantly varies with its operating mode, the estimation of the battery's run-time must assume a typical daily usage for the scale: how many times the scale is used per day and for how long. Table 4 gives the scale's operating modes with the corresponding average power consumption in terms of average current, expected daily operation, and expected daily energy consumption. The average power consumption was measured on a set of scale prototypes and the largest average power consumption was used in the reported estimations. The scale is powered by a thin, 500 mA h LiPo battery, and with typical consumption the battery run time is estimated to be 38 days. We believe that this is long enough to provide comfortable use.

D. LIBRA FIRMWARE
Libra's firmware controls the scale's hardware features, reads the measured values from measurement circuit, and reports the measured data as well as the scale's internal state to the remote application using the developed BLE services. The firmware was written in the C programming language, and was developed and tested in the Nordic Semiconductor development environment using Nordic nRF5 SDK and SoftDevice.
Nordic nRF SDK is used to access and control the peripheral devices. Many of the scale's features, like measurementcircuit power management, digital-part power management, and LED control, are configured and monitored using general purpose I/O pins. Some internal features of the Power Management IC (PMIC) are additionally controlled via an I 2 C bus. Similarly, the weight data measured by the ADC are accessed using a simplified version of the SPI bus. When the measurement circuit is active it performs measurements at a sampling rate that is also controlled by a general-purpose I/O pin. To reduce the noise effects, the measured weight is averaged over a predefined number of samples.
The Nordic Softdevice is used to implement the Bluetooth Low Energy client, which provides measured data to and is controlled by the app. It is a Bluetooth-Low-Energycompliant protocol stack that complements the nRF52 SoC. Among others, it supports the L2CAP, ATT, and SM protocols, it provides the BLE GATT and GAP APIs, and implements the GATT client and server. The scale, when not connected, advertises its presence using advertising packets that are sent every 250 milliseconds. To reduce the energy consumption the advertisement packets only include the scale's name, flags, and appearance. The BLE services, which are identified by custom 128-bit UUIDs, provide scale data to the app. All the BLE services, with the exception of the weight BLE service, are read and/or write services, which means that the data are exchanged on demand. On the other hand, the weight BLE service is also implemented as a BLE indication.
The scale's firmware provides the following BLE services to be used by 3rd-party applications connecting to the scale: 1) Device information services They provide general information about the kitchen scale: BLE device name, serial number, hardware revision, firmware revision, etc.

2) Authentication service
Its main role is to prevent unauthorized connection to the scale, since such a connection blocks a legitimate user from accessing the scale. Additionally, some scale BLE services, like modifications of the scale's internal parameters, were designed for the scale's maintenance and they should be accessed only by a user with privileges. Pairing with a pin code is not suitable for this task, because it does not support different user roles. The authentication service implements a simple pin-code authentication. The user's pin code is stored in the non-volatile memory of the scale and can be changed by the user. The user's pin code is a hash generated by the scale's hardware ID. In this way, each scale has a unique, privileged user pin code.

3) Measurement service
It is primarily used for weight measurements and it supports BLE indications. In this way, once a service is subscribed to, the data is automatically delivered to the app. To avoid frequent BLE indications, a lower bound to the indication interval is used. To further reduce unnecessary weight transmissions the weight BLE service triggers an indication only if the change of the measured weight is above a predefined threshold or when the weight remains unchanged during a predefined period. The last rule guarantees that a stable weight is transmitted.

4) Control services
The main control services are used for the implementation of virtual buttons, like the power and tare button. Other control services, like the scale calibra-VOLUME X, 2021 tion, affect the scale's behaviour and are developed for maintenance purposes.

5) OTA update service
This service implements over-the-air updates for the scale, which enables upgrades of the scale's firmware once the scale is at the end-user. It also simplifies firmware development. All the data exchanged by BLE services are in an easily parsable text format. In this way, the communication can be easily monitored and debugged with general-purpose BLE apps.

E. LIBRA SOFTWARE -DEMO ANDROID CLIENT
The Libra scale can be accessed by any device enabled with Bluetooth 4.0 or higher. Currently, because of the wide popularity of smartphones, the most obvious connection is to a smartphone within a dietary-intake tracking application. To aid the integration of such devices, a proof-of-concept demo client and its source are provided. Besides showcasing the integration of Libra, the demo client provides a rudimentary stand-alone food logger.
The client offers some basic functionality for the enduser. This is the part to be later replaced by the software the client is integrated into. The user is able to scan for available Libra scales in the range and connect to it by clicking on one and providing a password. Once a scale is connected, in the main view of the application, the user can see the current weight measured by the scale and is able to reset the tare weight with the button (Figure 5, left). Finally, the user can also enable logging of the measured weight in a file on the smartphone.
More importantly, the demo client showcases developeroriented functions implementing the connectivity module with the scale from Figure 1. The settings view displays and make it possible to edit settings such as: refresh rate, idle time after which the scale turns itself off, scale password and device details (device name, manufacturer name, model number, serial number, MAC address, firmware and hardware version and battery-charge status). In the OTA update pane, developers can test the over-the-air functionality of the app before deploying it in their solution.
Following the example of the Android demo client, other clients, e.g., iOS, are straightforward to implement. The connection to FCD sources is not provided by this client as it is up to the integrator to decide which open or proprietary databases to use within their solution and how to use it.

IV. DISCUSSION: IMPLICATIONS OF AN OPEN-SOURCE SOLUTION FOR PORTION-SIZE ESTIMATION
Libra is, to the best of our knowledge, the first open-source solution for portion-size estimation or measurement in personalized nutrition. The kitchen scale's hardware schemes and APIs, including software and documentation, are freely available at [47].
Accurate dietary recording is one of the basic prerequisites for sound nutrition research and providing meaningful dietary advice. As explained in the introduction section, humans are not good at estimating portion sizes, which hinders our ability to keep accurate dietary records (in addition to being inconsistent and forgetful). There are many ways to solve this problem, one of them is the use of additional hardware, as presented in this paper.
Given the importance of the problem and the fact that developing hardware is a time-consuming and costly operation that not many research facilities dedicated to nutrition can undertake, we decided to release our Libra portable kitchen scale as open-source hardware, which is the main contribution of our work to the field of nutrition research.

A. OPEN-SOURCE
The Open-Source Hardware Association defines opensource hardware as "hardware whose design is made publicly available so that anyone can study, modify, distribute, make, and sell the design or hardware based on that design" [48]. In light of this definition, anyone interested in Libra can find the following documents online at http://libra.ijs.si [47]: 1) The electronic-circuit schematic in KiCad format, 2) The PCB layout in Gerber format, 3) CAD drawing of the scale housing in STEP format suitable for 3D printing, 4) Git repository containing the source code of the scale's firmware, 5) Git repository containing the sample Android client. More specifically, the hardware is licensed under the CERN OHL v1.2 license and the software under the GNU general public license v3.
The intended users are research institutions in need of accurate portion-size recordings for their studies, companies in the field of nutrition interested in advancing their products and services along with the clients using their solutions (e.g., hospitals, dietitians, sport clubs, personal trainers, etc.) and 'maker' communities interested in nutrition. For anyone who would like to start using the Libra solution out-ofthe-box, there is also the possibility to order assembled kits (see exemplary scale enclosure and electronic circuit in Figure 4).

B. PROOF-OF-CONCEPT INTEGRATION OF THE LIBRA SCALE WITH THE LIBRO MOBILE APPLICATION
In this section the "Ballerina" solution developed within the TETRAMAX Technology Transfer Experiment [49] is presented. Aimed at personalized dietary-intake monitoring, Ballerina connects the above-presented, open-source, pocket-sized Libra with "Libro", the Nutritics' commercial mobile application for dietary analysis [9]. This showcase integration with the Libro app demonstrates how Libra can be seamlessly integrated into an existing product or service. Libra and Libro together make a complete solution for dietary-intake monitoring, as presented in Figure 1.
The Nutritics' portfolio includes software-as-a-service (SaS) products for nutrition professionals in healthcare, ed-ucation and research, sports nutrition and the food industry. More recently, Nutritics has introduced a mobile app for consumers, which connects these industries. Integrating the Libra scale into their portfolio was motivated by the desire to better cater to the needs of their customers and users through more accurate estimations of food intake.
Libro is a powerful tool aimed at dietitians and nutritionists. They can give access to Libro to their clients who are the actual end-users of the mobile application Libro. The aim of the tool is to keep track of health and lifestyle goals, including nutrition habits and exercising. The tool allows dietitians to invite clients to record their daily food intake and exercise with one click and to view and analyze their records remotely. To increase the ease of use, records can be kept with voice commands and external hardware for the automatic logging of activity, e.g., step counters.
To simplify and increase the accuracy of dietary-intake recording, the Libra open-source scale was integrated into Libro. Figure 5 shows the details of how data from the scale is visualized within Libro's user interface. After choosing the type of food consumed, e.g., the rice in Figure 5, the previous way of estimating the portion size was to slide through PSMA images that help with an estimation of the portion size. For example, for rice the proposed portion sizes were: 1/2 cup or 90g, 1 cup or 180g, 1 serving or 65g. The user then had the option to input the multiplier of the portions eaten or optionally, the exact weight in grams. After this, the record could be confirmed. The integration with the Libra scale simplified this procedure, so once the food is placed on the scale, the user only needs to confirm the record. The mass of the weighed food is displayed in the blue circle in the middle of the portion-size image slider.
Libro allow users to choose and record all sort of foods, from simple foods (e.g., rice) to more complex, mixed foods or even dishes (e.g.,cakes), as long as those exist in the database. If certain food or dish does not exist in the database, the user will not be able to record it and further dietary analysis will not be possible. However, recording of mixed foods in a dish can still be performed by weighing and recording each food separately. If the dish requires cooking, its dietary analysis is approximate as retention and yield factors are not considered.

C. EXPECTED BENEFITS
Based on Nutritics' experience to date and the results of the internal tests performed in our lab, we strongly believe that the added value of Ballerina's integration will be better services (a more accurate food-quantity estimation and the resulting actionable food choices) not only for Nutritics' customers, but also other users. The Nutritics company seeks to enable as many research organizations as possible to use the Libra pocket scale since this would make the best practices 'semi-weighted food diary' more accessible and contribute to advancing the field of nutrition science. Moreover, this also consolidates their position in the field.
Finally, cost savings through improved efficiency for nutritionists and thus increased revenues are also an expected consequence of adding a portable kitchen scale to existing nutrition solutions.
More generally, the expected benefits of Libra include: • Increased awareness of food intake among individuals The simple act of keeping a food diary [50] through weighing food has a positive impact on an individual's awareness of the food being consumed, leading to a healthier, more balanced diet. • Accurate data for nutrition professionals Having their clients or patients using a scale to track intake gives clinical dietitians and nutritionists a better, more accurate picture of the food intake of their clients, potentially increasing the quality of their service and their efficiency. • Achieving goals With accurate data, it is easier to achieve goals and adhere to nutrition regimes [46]. These can be imposed by a clinical condition such as diabetes or phenylcetonuria or self-inflicted as part of training programs in the case of top athletes. Accurate food-intake monitoring has long been an important open-research question [51]. • Research options Both the increased accuracy and ease of use leading to more data are also beneficial in nutrition research. Additionally, a connected scale enables remote monitoring, increasing the physical range of researchers that now have the option to work with the subject over a wider area. For example, running a large-scale clinical trial on the effects of a ketogenic diet (high-fat, adequate-protein, low-carbohydrate intake) on patients with depression or other mood disorders is difficult to run in a local environment with inaccurate data about food intake. • Better tools Using a scale along with other portion-size measurement aids eventually leads to a better understanding [46] and use of portion-size estimation aids for both humans and machines; camera-based portion-size estimation techniques could be trained with the data obtained simultaneously using the scale and the technique itself.
Although the group of end-users involved in the feasibility study was small (6 adults with diabetes type I), their feedback was thrilling, therefore, we believe that the described solutions have innovation potential. Today, there already exists smartphones that can be turned into a working scale, however, they can measure up to few hundreds grams only. The Libra scale makes possible to weigh food of few kilograms (up to 5kg). Connecting the scale with the app and its underlying bases (of food composition data and evidence-based dietary recommendations), provides usable solution which can be even more useful once the app is able to automatically recognise food from the photo. So, the VOLUME X, 2021 FIGURE 5. Demo client and integration example: displaying measured weight in the available Android demo client (left) and the main interface for recording meals in Nutritics' Libro application with detail of the visualization of data from the connected Libra (right). The measured weight of the dish reported by the scale is displayed in the blue circle. Left and right of it are images that serve as portion-size measurement aids for users who do not have a scale connected. strategy is to interconnect different software and hardware approaches to develop the most optimal device. We believe that by opening the concepts described in this paper the scale will become such an optimal device in the near future.

V. CONCLUSIONS
In this paper we present the first, to the best of our knowledge, open-source hardware and software solution for use in nutrition research and practice. It is a low-power consuming, pocket-size (117 mm x 69 mm x 9 mm), kitchen scale "Libra" implemented as a soft real-time, embedded system with BLE connection to the smartphone. Powered by a thin, 500mAh LiPo battery, the battery run time under the typical operation regime of the scale is estimated to be over one month (around five weeks). The open source scale's firmware provides the following BLE services: Device information service, Authentication service, Measurement service, Control service and OTA update service, to be used by 3rd-party applications connecting to the scale. All the data exchanged by BLE services are documented in an easily parsable text format, so the communication can be easily monitored and debugged with general-purpose BLE apps. The Libra scale was designed using BLE 4.0 interface and can be accessed by any device enabled with Bluetooth 4.0 or higher. To aid the integration of such devices, a proof-of-concept demo client and its source are provided. An integration of the Libra Scale connected with the commercial Libro mobile application was demonstrated as well. Making this solution open source contributes to the field of nutrition by making accurate food-intake monitoring on-the-go possible and accessible to a larger audience. The open-sourced documents are available at http://libra.ijs.si.
An interesting aspect of future research includes the validation of image-based, portion-size estimation techniques with the use of the Libra scale and the development of similar open solutions for other aspects of nutrition research and practice, e.g., continuous glucose-monitoring devices.