Tutorial: How to create a new Sensing-on-the-Go Experiment
This guide will go throught the basic setup and development process for creating a new Experiment Plugin for Sensing-on-the-Go app.
OrganiCity provides a set of common Experiment Plugins to be used. You can find and install all provided Experiments from the Experiments tab.
- Wifi Scanner Experiment
- Noise Level Experiment
- Ble Reader Experiment
- Temperature Experiment
Development Environement Setup
To setup a new Experiment Plugin you will need to follow these steps:
- Download and install Android Studio
- Clone the Sensing-on-the-Go repository and especially the ExampleExperiment located in the experiments directroy
- Open the ExampleExperiment project with Android Studio and install any missing packages
Setting up your own Experiment
When you open the ExampleExperiment project, navigate and open ExampleExperiment.
As you can see there are multiple TODO comments through out the code. Below are listed the key methods you need to pay attention during the development:
getExperimentResult is called when Sensing-on-the-Go app requests result from your experiment. A description of the method's parameters is found below:
- bundle: a Bundle object containing data collected from all the Sensor Plugins running at that time.
- jsonMessage1: a JsonMessage object that will be used to report the Experiment result back to Sensing-on-the-Go app.
In the screenshot below you can see a simple example of getting GPS and Noise data from Location Sensor and Noise Level Sensor, respectively, and then add that data to a JSONObject to be used as payload to our jsonMessage1 object.
A list of the
CONTEXT_TYPE provided by OrganiCity can be found below: