Device Fun

In this chapter, we will move away from generating random data. Instead, we will attach a few sensors to a Particle Photon. The list of sensors you can add is massive but we will add a just few simple sensors. The sensors we will add are low-cost and easy to attach.

First, we will add a temperature and humidity sensor that is very common: the AM2302, a wired version of the DHT22 sensor. It is a bit more expensive than the standard DHT22 sensor but is a bit easier to attach because you do not have to add a resistor. If that does not make sense to you, don't worry about it, it will be covered later.

Besides temperature and humidity, we will also monitor light and motion to have a total of four data points to send. We will have to wrap these data points in a data structure, and we will use JSON. We will see how to handle a JSON payload with multiple values in Particle Cloud and IoT Hub.

Although the Particle Cloud integration with IoT Hub makes it easy to forward events to Azure, you might want to avoid having an extra component in front of IoT Hub. IoT Hub supports several protocols for direct connectivity such as HTTP, AMQP and MQTT. The Particle Cloud integration uses HTTP. On constrained devices (low memory and compute power), MQTT is the recommended protocol. We will see how to use MQTT on the Particle Photon not only to send data to IoT Hub but also to receive data in Chapter 3.

results matching ""

    No results matching ""