Book Image

Intel Galileo Networking Cookbook

By : Marco Schwartz
Book Image

Intel Galileo Networking Cookbook

By: Marco Schwartz

Overview of this book

Arduino is an electronic prototyping platform used by millions of people around the world. Intel Galileo is fully Arduino compatible; hence it combines the high performance of Intel with the simplicity of Arduino Software Development Environment. This makes it the ideal platform to build exciting projects, especially in the field of web-based connected applications and the Internet of Things. The book features several recipes all based on the Intel Galileo board, and that exploit the powerful features of the board. Each chapter explores a given field using the Galileo board. The book is mainly divided in three parts. The first part is all about learning the basics of the Intel Galileo board, but it uses some of the powerful features of the board such as connecting external sensors and complex hardware devices, compared with more basic Arduino boards. Then, the book dives into the topics related to networking and the Internet of Things. You will learn how to run a web server on the board and log data using a cloud-based service. Finally, the book ends with a chapter that aims to build a complete home automation hub using the Galileo board. This chapter uses everything that was learned in the book to make a home automation system using the Galileo board and Arduino.
Table of Contents (10 chapters)
9
Index

Sending data to a cloud device


We are now going to learn how to take measurements from the temperature sensor and the photocell, and send them to the cloud to be logged. They will then be accessible from anywhere, and you will also be able to use them in other applications.

Getting ready

There is nothing extra you need to do for this recipe. We are going to use dweet.io to store data in the cloud, and you can read more about this service at:

http://dweet.io/

Dweet.io is a very nice and easy-to-use cloud service for storing data. You make a request to the service with your data, and their servers store it.

How to do it...

In the project in this recipe, we will take measurements from the sensors, connect to dweet.io, and then send the data to the dweet.io server.

This is the complete code for this recipe:

// Includes
var mraa = require("mraa");
var util = require('util');
var request = require('request');

// Sensor pins
var temp_sensor_pin = new mraa.Aio(0);
temp_sensor_pin.setBit(12);
var light_sensor_pin...