Reader small image

You're reading from  Full Stack Web Development with Raspberry Pi 3

Product typeBook
Published inAug 2017
Reading LevelExpert
PublisherPackt
ISBN-139781788295895
Edition1st Edition
Languages
Right arrow
Author (1)
Soham Kamani
Soham Kamani
author image
Soham Kamani

Soham Kamani is a full-stack developer who has extensive experience in the JavaScript ecosystem. He works as a consultant, developing end-to-end web-based solutions for clients around the world. He is an open source enthusiast and an avid blogger. He has worked on many frameworks and technologies such as React, Angular, Node, Express, Sails, SQLite, Postgres, and MySQL, and he has worked on many projects in the IoT space using Arduino and Raspberry Pi systems.
Read more about Soham Kamani

Right arrow

Understanding how our node process takes readings

In order to integrate our sensor reading code into our server, first. let's understand what is happening under the hood whenever we execute the node script that takes our sensor readings. Let's review the snippet of code that actually called for the sensor readings:

    /*
Section A
*/
sensor.read(11, 4, function(err, temperature, humidity) {
/*
Section B
*/
//After reading the sensor, we get the temperature
and humidity readings
if (!err) {
//If there is no error, log the readings to the
console
console.log('temp: ' + temperature.toFixed(1) +
'°C, ' +
'humidity: ' + humidity.toFixed(1) + '%'

)
}
});
/*
Section C
*/

Immediately, we can see that the...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Full Stack Web Development with Raspberry Pi 3
Published in: Aug 2017Publisher: PacktISBN-13: 9781788295895

Author (1)

author image
Soham Kamani

Soham Kamani is a full-stack developer who has extensive experience in the JavaScript ecosystem. He works as a consultant, developing end-to-end web-based solutions for clients around the world. He is an open source enthusiast and an avid blogger. He has worked on many frameworks and technologies such as React, Angular, Node, Express, Sails, SQLite, Postgres, and MySQL, and he has worked on many projects in the IoT space using Arduino and Raspberry Pi systems.
Read more about Soham Kamani