O'Reilly logo

Mastering Internet of Things by Peter Waher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Publishing sensor data

Now that we have a live connection, we're ready to publish sampled sensor data. We will first need some member variables. These will store last values, last-published values, and the timestamps of last-published values:

private double? lastLight = null; 
private bool? lastMotion = null; 
private double? lastPublishedLight = null; 
private bool? lastPublishedMotion = null; 
private DateTimelastLightPublishTime = DateTime.MinValue; 
private DateTimelastMotionPublishTime = DateTime.MinValue; 

From our sampling and event methods where we receive and calculate our most recent sensor data, we call two new methods: PublishLight() and PublishMotion(). To illustrate different ways of publishing data, these two methods will publish ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required