GPS
Setup
In order for the GPS module to have a signal throughout the entire measurement period and thus be able to request the location, you must ensure that the module is not covered by anything. Ideally, you should install it outside the housing for the measurement period.
For the power supply during the measurement period you can use a power bank. Some Powerbanks switch themselves off, too little power is drawn (e.g. when a mobile phone is fully charged), so it can happen that the Powerbank does not permanently supply the senseBoxMCU with power. Before measuring, make sure that this is not the case. The GPS sensor is connected to the I2C ports.
Programming
How the GPS module is programmed is illustrated here using a temperature measurement as an example. Each measured value of a mobile station is uploaded together with the corresponding values for latitude and longitude.
The first step is to create an instance of the sensors. Additionally we define 2 variables for latitude and longitude.
#include "SenseBoxMCU.h"
HDC1080 hdc;
GPS gps;
float lat; // Geographical latitude
float lon; // Geographical longitude
In the setup
function we now start the two sensors.
setup() Function
void setup(){
hdc.begin();
gps.begin();
}
The loop
function now queries the location of the station and uploads it together with the value for temperature to the openSenseMap.
loop() Function
void loop(){
lat = gps.getLatitude();
lon = gps.getLongitude();
temp = hdc.getTemperature();
osem.uploadMobileMeasurement(temp,"SensorID",lat,lon)
}