**3. System Overview**

*3.1. Electric Bike and Sensor Data* 

provide greater power than lower levels.

3.1.1. Assist Levels

This section describes the different elements that make up the final system proposed in this work. It is a personalized system whose purpose is to adjust the intensity of exercise for electric bicycle users, in this way facilitating their progress which is marked by the different ability levels. The objective of the system is to promote physical activity among users, with training that is constant and incremental in its intensity. Figure 1 shows the different components that make up the designed system. First, a user of an electric bicycle that is registered in the mobile application, activates the "training" mode and selects the route that they wish to travel. The selected route can be a mountain route or a simple ride, such as the usual route from home to work. Optionally, users can have a Heart Rate sensor which takes their pulse, it allows to measure progress, estimate effort and prevent fatigue. Once the user selects the route they want to travel, it is sent to the remote server which is in charge of managing the data of the platform. When obtained, the server divides the route into segments in order to calculate the power required to travel the route. This is done by establishing the assist level for each of the segments; this level is calculated by considering the user's physical characteristics (height and weight), his ability level (beginner, intermediate, advanced), the characteristics of the electric bicycle (power, battery, weight) and the profile of the route (slope and distance). The objective of calculating assist levels is to prevent excessive variations in velocity over the whole route, by combining the power supplied by the engine with the power provided by the user. The power provided by the user will increase gradually, with each of the exercises that he completes on the platform. Time will not be the only factor taken into account when calculating the difficulty of the travelled route, the slopes found on that route will also be considered. In this way, it will be possible to compare the different routes more effectively. *Sensors* **2018**, *18*, 220 5 of 21

**Figure 1.** Overall architecture of the system: (**1**) the route selected by the user; (**2**) segmented route; (**3**) user profile data; (**4**) calculated assist levels; (**5**) data collected over the course of the route; (**6**) score obtained on the route; (**7**) comparison of the scores of other users; and (**8**) final social rating. **Figure 1.** Overall architecture of the system: (**1**) the route selected by the user; (**2**) segmented route; (**3**) user profile data; (**4**) calculated assist levels; (**5**) data collected over the course of the route; (**6**) score obtained on the route; (**7**) comparison of the scores of other users; and (**8**) final social rating.

by the engine with a set of assist levels. Not all electric bicycle manufacturers configure assist levels in the same way. However, in the majority of cases, assist levels oscillate between 5 and 10 levels. There are also bicycles that have a lower power engine which only has a total of three assist levels. However, independently of the assist levels available in bicycles, their functioning is similar in the majority of cases. Each of the assist levels provides an incremental percentage of power. Higher levels

Figure 2 shows a graph of the power supplied by an electric bicycle with an engine of 750 W and a total of five assist levels. As it can be observed, the first assist levels provide less power, what means lower velocity, while the highest level provides the maximum power of the engine. In some bicycle models, it is possible to configure engine settings associated with assist levels. In this way, an advanced user could configure the established power profile, so that it suits his needs. The relation between watts and assist levels is obtained directly from the mobile application, since it is possible to monitor the intensity of the battery current at the different levels. Thanks to this possibility, the

system is suitable for different types of batteries and engines with no previous configurations.

**Figure 2.** Assist levels and power in an e-bike of 750 w.

When controlling assistance, it is necessary to have a device connected to the bicycle's control system, capable of increasing and decreasing the power. Commercial bicycles have a remote control

The resulting assist levels are sent to the user's mobile application, together with the waypoints indicating the beginning of each segment. Over the course of the ride, the assist levels will change automatically when the user reaches the different waypoints. Once the route is completed, the application will send the data registered over the course of the route to the server, which will proceed with their analysis. After the evaluation of the results, the system moves on to calculating the score obtained by the user in the route he completed. The scores obtained in different routes accumulate to a total and the general rating of the user is obtained. These data are necessary for evaluating the user's progress and for calculating the assist levels of future routes.

*Sensors* **2018**, *18*, 220 5 of 21

Finally, the system has an interactive component based on the development social competition. This element allows users to view their progress in comparison to others, to suggest improvements and routes based on their profile. It also allows motivating them through a series of general ratings and the ratings made by friends who use the application. **Figure 1.** Overall architecture of the system: (**1**) the route selected by the user; (**2**) segmented route; (**3**) user profile data; (**4**) calculated assist levels; (**5**) data collected over the course of the route; (**6**) score obtained on the route; (**7**) comparison of the scores of other users; and (**8**) final social rating.

#### *3.1. Electric Bike and Sensor Data 3.1. Electric Bike and Sensor Data*

#### 3.1.1. Assist Levels 3.1.1. Assist Levels

As described in the previous paragraph, PAS bicycles increase or decrease the power supplied by the engine with a set of assist levels. Not all electric bicycle manufacturers configure assist levels in the same way. However, in the majority of cases, assist levels oscillate between 5 and 10 levels. There are also bicycles that have a lower power engine which only has a total of three assist levels. However, independently of the assist levels available in bicycles, their functioning is similar in the majority of cases. Each of the assist levels provides an incremental percentage of power. Higher levels provide greater power than lower levels. As described in the previous paragraph, PAS bicycles increase or decrease the power supplied by the engine with a set of assist levels. Not all electric bicycle manufacturers configure assist levels in the same way. However, in the majority of cases, assist levels oscillate between 5 and 10 levels. There are also bicycles that have a lower power engine which only has a total of three assist levels. However, independently of the assist levels available in bicycles, their functioning is similar in the majority of cases. Each of the assist levels provides an incremental percentage of power. Higher levels provide greater power than lower levels.

Figure 2 shows a graph of the power supplied by an electric bicycle with an engine of 750 W and a total of five assist levels. As it can be observed, the first assist levels provide less power, what means lower velocity, while the highest level provides the maximum power of the engine. In some bicycle models, it is possible to configure engine settings associated with assist levels. In this way, an advanced user could configure the established power profile, so that it suits his needs. The relation between watts and assist levels is obtained directly from the mobile application, since it is possible to monitor the intensity of the battery current at the different levels. Thanks to this possibility, the system is suitable for different types of batteries and engines with no previous configurations. Figure 2 shows a graph of the power supplied by an electric bicycle with an engine of 750 W and a total of five assist levels. As it can be observed, the first assist levels provide less power, what means lower velocity, while the highest level provides the maximum power of the engine. In some bicycle models, it is possible to configure engine settings associated with assist levels. In this way, an advanced user could configure the established power profile, so that it suits his needs. The relation between watts and assist levels is obtained directly from the mobile application, since it is possible to monitor the intensity of the battery current at the different levels. Thanks to this possibility, the system is suitable for different types of batteries and engines with no previous configurations.

**Figure 2.** Assist levels and power in an e-bike of 750 w. **Figure 2.** Assist levels and power in an e-bike of 750 w.

When controlling assistance, it is necessary to have a device connected to the bicycle's control system, capable of increasing and decreasing the power. Commercial bicycles have a remote control When controlling assistance, it is necessary to have a device connected to the bicycle's control system, capable of increasing and decreasing the power. Commercial bicycles have a remote control installed on their handlebar, through which the user can control the behavior of the electric system. Figure 3 shows three different models of remote controls for electric bicycles. Generally, these remote

controls, besides an on/off button, also have two additional buttons: one for increasing the assist level and another for decreasing it. They also incorporate Bluetooth wireless communication technology. Some models, such as the iwok model (Figure 3b), incorporate auxiliary buttons, which make it possible to interact with the *ebikemotion* mobile application. Figure 3 shows three different models of remote controls for electric bicycles. Generally, these remote controls, besides an on/off button, also have two additional buttons: one for increasing the assist level and another for decreasing it. They also incorporate Bluetooth wireless communication technology. Some models, such as the iwok model (Figure 3b), incorporate auxiliary buttons, which make it possible to interact with the *ebikemotion* mobile application.

*Sensors* **2018**, *18*, 220 6 of 21

installed on their handlebar, through which the user can control the behavior of the electric system.

**Figure 3.** Example of three assist level commercial controllers: (**a**) Bafang controller; (**b**) *ebikemotion* controller; and (**c**) BionX controller. **Figure 3.** Example of three assist level commercial controllers: (**a**) Bafang controller; (**b**) *ebikemotion* controller; and (**c**) BionX controller.

The remote control is not the only control interface for the assist levels of an electric bicycle. Manufacturers incorporate a control interface in their communication protocols through commands sent by a third party, such as a mobile application. Thanks to this interface, the assistance of an electric bicycle can change automatically and it is not necessary for a user to intervene. This is a fundamental element in this work; as the user travels a route in the "training" mode, the system will change the assist levels in the e-bike in a dynamic and independent manner, by means of the application. The remote control is not the only control interface for the assist levels of an electric bicycle. Manufacturers incorporate a control interface in their communication protocols through commands sent by a third party, such as a mobile application. Thanks to this interface, the assistance of an electric bicycle can change automatically and it is not necessary for a user to intervene. This is a fundamental element in this work; as the user travels a route in the "training" mode, the system will change the assist levels in the e-bike in a dynamic and independent manner, by means of the application.

### 3.1.2. Heart Rate Sensor 3.1.2. Heart Rate Sensor

The system measures the heart rate by means of an external wireless heart rate sensor connected to the app by Bluetooth. Any of the current commercial sensors with Bluetooth 4.0 is compatible and can be used in the system. There are two reasons for which in the proposed system the user's heart rate is measured by an external sensor. On the one hand, to register the user's improvement along the different exercises he does, which is key for establishing the level of progress and physical development. Users who are not physically fit have a greater number of ppm (pulsations per minute) than users who are used to exercise. The continuous evaluation of changes in the heart rate, while the user performs physical activities, is an important indicator of the user's progress, as reported previously in different works [55]. The system measures the heart rate by means of an external wireless heart rate sensor connected to the app by Bluetooth. Any of the current commercial sensors with Bluetooth 4.0 is compatible and can be used in the system. There are two reasons for which in the proposed system the user's heart rate is measured by an external sensor. On the one hand, to register the user's improvement along the different exercises he does, which is key for establishing the level of progress and physical development. Users who are not physically fit have a greater number of ppm (pulsations per minute) than users who are used to exercise. The continuous evaluation of changes in the heart rate, while the user performs physical activities, is an important indicator of the user's progress, as reported previously in different works [55].

Similarly, the heart rate registered during a physical activity, such as cycling, provides a measure of the athlete's effort. When calculating the training thresholds, the time the user spent exercising at each of the training zones has to be considered together with the maximum heart rate. This value is calculated based on Equation (1), which has been previously described in the literature [56]. This is the most accepted way of calculating the heart rate even though it has a significant margin of error, so it should be considered as an approximate value and in no case as a precise value. Similarly, the heart rate registered during a physical activity, such as cycling, provides a measure of the athlete's effort. When calculating the training thresholds, the time the user spent exercising at each of the training zones has to be considered together with the maximum heart rate. This value is calculated based on Equation (1), which has been previously described in the literature [56]. This is the most accepted way of calculating the heart rate even though it has a significant margin of error, so it should be considered as an approximate value and in no case as a precise value.

$$\text{HR}\_{\text{max}} = 205.8 - 0.685 \cdot (\text{age}) \tag{1}$$

as described in [57]. The designed system can calculate the percentage of time that a user spent training in each of these zones, for each of the routes he travelled; this measures the quality of exercise. Zone 1 is considered as exercise that is safe for the heart and is recommended to users who are only beginning to introduce physical activity into their daily routine and who are not physically fit. Zone 3 is considered the anaerobic threshold and it is a turning point in the improvement of capabilities, Table 1, is a general list of the four main training zones for an athlete during physical exercise, as described in [57]. The designed system can calculate the percentage of time that a user spent training in each of these zones, for each of the routes he travelled; this measures the quality of exercise. Zone 1 is considered as exercise that is safe for the heart and is recommended to users who are only beginning to introduce physical activity into their daily routine and who are not physically fit. Zone

3 is considered the anaerobic threshold and it is a turning point in the improvement of capabilities, from here a decrease in performance can be observed. Lastly, training zone 4, can only be maintained during a few seconds and can only be achieved by users with a high level of physical training. **Target Zone Intensity% of HRmax (bpm) Training Benefit** Zone 1: Light 50–60% Increases overall health and metabolism

**Table 1.** Heart Rate training zones.

*Sensors* **2018**, *18*, 220 7 of 21

from here a decrease in performance can be observed. Lastly, training zone 4, can only be maintained

during a few seconds and can only be achieved by users with a high level of physical training.

Zone 2: Moderate 70–80% Improves aerobic fitness


The use of a heart rate sensor is not only important for measuring physical progress. In the designed system, the monitoring of the user's pulse is also seen as a security measure that helps to avoid and prevent fatigue. When the system detects the user's pulse to be very high, over the maximum threshold, the assistance system increases the power of the engine automatically. In this way, the user is helped in his exercise and their heart rate is reduced. This threshold can be established manually by the user on the mobile application or it can be calculated automatically with Equation (1). way, the user is helped in his exercise and their heart rate is reduced. This threshold can be established manually by the user on the mobile application or it can be calculated automatically with Equation (1). 3.1.3. *ebikemotion* App

maximum threshold, the assistance system increases the power of the engine automatically. In this

#### 3.1.3. *ebikemotion* App The *ebikemotion* project has been co-developed by the University of Salamanca and the company

*3.2. Route Segmentation*

The *ebikemotion* project has been co-developed by the University of Salamanca and the company StageMotion [58]. The *ebikemotion* application for mobile devices [59] is central to the system developed in this article. This application, is compatible with more than 20 electric bicycle brands on the market and it has more than 5000 users from all over the world. This application visualizes all the values of the electric bicycle in real-time (battery level, assist level, velocity, altitude etc.) as can be seen in Figure 4. This application is free and is available in the two main mobile operating systems, Android and iOS. The application was launched in the middle of 2016 and it is possible to use it with electric bicycles as well as with traditional bicycles for recording routes via GPS. StageMotion [58]. The *ebikemotion* application for mobile devices [59] is central to the system developed in this article. This application, is compatible with more than 20 electric bicycle brands on the market and it has more than 5000 users from all over the world. This application visualizes all the values of the electric bicycle in real-time (battery level, assist level, velocity, altitude etc.) as can be seen in Figure 4. This application is free and is available in the two main mobile operating systems, Android and iOS. The application was launched in the middle of 2016 and it is possible to use it with electric bicycles as well as with traditional bicycles for recording routes via GPS.

As part of this work, a "training" module has been designed for this application. This application will be in charge of registering the values of the different routes travelled by the user in the "training" mode and of automatically changing the assist levels on the basis of the parameters calculated by the server. The application is linked to the e-bike by Bluetooth wireless technology. Some e-bike models obtain their Bluetooth connection through the remote control while in other models this technology is incorporated in the casing of the battery of the e-bike. As part of this work, a "training" module has been designed for this application. This application will be in charge of registering the values of the different routes travelled by the user in the "training" mode and of automatically changing the assist levels on the basis of the parameters calculated by the server. The application is linked to the e-bike by Bluetooth wireless technology. Some e-bike models obtain their Bluetooth connection through the remote control while in other models this technology is incorporated in the casing of the battery of the e-bike.

**Figure 4.** Screenshot of *ebikemotion* app. **Figure 4.** Screenshot of *ebikemotion* app.

other. The aim of performing this segmentation is to be able to make an individual analysis of each

The routes travelled by the users through the exercise plan have a high number of GPS
