Quickstart
Build an app that connects a Movisens sensor by its name and prints tap markers and skin temperature.
The finished app connects to a Movisens sensor by its Bluetooth name and prints each tap marker and skin temperature measurement as JSON.
Prerequisites
- The setup in Installation, including the CARP Mobile Sensing (CAMS) setup it builds on.
- A Movisens Move4, EcgMove4 or EdaMove4 sensor, and its Bluetooth name:
MOVISENS Sensorfollowed by the five-digit serial number on the back of the sensor. - An Android phone with Bluetooth turned on, and the sensor paired with the phone in the Android Bluetooth settings. On iOS, and for a sensor that is not paired, the status never becomes
connected; see the known issue in Connect to the sensor.
Complete example
Replace the contents of lib/main.dart with this program, and set deviceName to the Bluetooth name of your sensor:
How it works
| Stage | What it does |
|---|---|
| 1. Register | Makes the Movisens measure types and the sensor known to CAMS. CarpMobileSensing.ensureInitialized() runs first, because registering needs an initialized CAMS. |
| 2. Protocol | Adds a MovisensDevice with the wearer's sensor location, sex, height, weight and age. The sensor uses these values for its activity algorithms, such as the metabolic equivalent of task (MET) and body position. |
| 3. Task | Runs TAP_MARKER and SKIN_TEMPERATURE on the sensor. Both are event-based measures, so an ImmediateTrigger starts them and they stream while the sensor is connected. |
| 4. Deploy | Configures CAMS, deploys the protocol on the phone and resumes sampling. The sensor's task waits until the sensor connects. The app adds the study only on the first run: on later runs, configure() restores the saved study. |
| 5. Print | Prints every measurement as JSON. |
| 6. Connect | Prints each new status of the sensor, binds the sensor by its Bluetooth name, asks for the Bluetooth permissions and connects to it. |
Tap markers arrive as soon as you tap the sensor, so they show quickly whether the connection works.
Run the app
Start the app on your phone
Allow the nearby devices and location permissions. The console shows
Movisens: connectedand thenMovisens: connectingagain, as the known issue in Connect to the sensor describes.Tap the sensor
A tap marker measurement appears at once:
Skin temperature arrives about once per minute, up to 84 seconds after the sensor measured it. Both timestamps are the phone's time when the value arrived: timestamp in local time and sensorStartTime in microseconds since the epoch.
To work with the values in code, check the type of the data:
For all the fields, see Measure types.
Troubleshooting
Run the app on an Android phone, and pair the sensor with the phone in the Android Bluetooth settings first. When movisens_flutter has to scan for the sensor, the status does not become connected, and no data arrives. See the known issue in Connect to the sensor.
On Android, check that the manifest declares ACCESS_COARSE_LOCATION and that the nearby devices and location permissions are allowed. See Installation.
Wait 2 minutes: values other than tap markers arrive up to 84 seconds after the sensor measured them. If none arrive, check that your sensor sends skin temperature; see Supported models.
Next steps
Connecting a device
Bind a sensor by its name, connect it and follow its status.
Measure types
The six measure types, their data types, fields and timing.
Triggers
Start tasks on a schedule or when an event occurs.