Skip to content

Instantly share code, notes, and snippets.

@nickharris
Created February 14, 2013 03:39
Show Gist options
  • Save nickharris/4950450 to your computer and use it in GitHub Desktop.
Save nickharris/4950450 to your computer and use it in GitHub Desktop.
insert sensor reading from .NET MF to Mobile Services
void temperatureHumidity_MeasurementComplete(TemperatureHumidity sender, double temperature, double relativeHumidity)
{
//may as well take a light reading as well
double lightPercentage = lightSensor.ReadLightSensorPercentage();
//create a new sensor reading and set the values
var reading = new SensorReading()
{
SensorID = "nicks-office", //can you believe i have to share my office with http://ntotten.com ?
Temp = temperature,
Humidity = relativeHumidity,
Light = lightPercentage,
DateAdded = DateTime.UtcNow
};
//insert into your Windows Azure Mobile Service and your done!
var json = MobileService.GetTable("SensorReading").Insert(reading);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment