Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Internet of Things

You're reading from   Mastering Internet of Things Design and create your own IoT applications using Raspberry Pi 3

Arrow left icon
Product type Paperback
Published in Mar 2018
Publisher Packt
ISBN-13 9781788397483
Length 410 pages
Edition 1st Edition
Concepts
Arrow right icon
Author (1):
Arrow left icon
Peter Waher Peter Waher
Author Profile Icon Peter Waher
Peter Waher
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Preparing Our First Raspberry Pi Project 2. Creating a Sensor to Measure Ambient Light FREE CHAPTER 3. Creating an Actuator for Controlling Illumination 4. Publishing Information Using MQTT 5. Publishing Data Using HTTP 6. Creating Web Pages for Your Devices 7. Communicating More Efficiently Using CoAP 8. Interoperability 9. Social Interaction with Your Devices Using XMPP 10. The Controller 11. Product Life Cycle 12. Concentrators and Bridges 13. Using an Internet of Things Service Platform 14. IoT Harmonization 15. Security for the Internet of Things 16. Privacy 17. Other Books You May Enjoy

Storing measured data

We are now ready to store our measured data. We use the lastMinute field defined earlier to know when we pass into a new minute. We use that opportunity to store the most recent value, together with the basic statistics we've calculated:

if (!this.lastMinute.HasValue) 
   this.lastMinute = Timestamp.Minute; 
else if (this.lastMinute.Value != Timestamp.Minute) 
{ 
   this.lastMinute = Timestamp.Minute; 

We begin by creating an instance of the LastMinute class defined earlier:

LastMinute Rec = new LastMinute() 
{ 
   Timestamp = Timestamp, 
   Light = Light, 
   Motion= D8, 
   MinLight = this.minLight, 
   MinLightAt = this.minLightAt, 
   MaxLight = this.maxLight, 
   MaxLightAt = this.maxLightAt 
}; 

Storing this object is very easy. The call is asynchronous and can be executed in parallel, if desired. We choose to wait for it to complete, since we...

You have been reading a chapter from
Mastering Internet of Things
Published in: Mar 2018
Publisher: Packt
ISBN-13: 9781788397483
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime