上QQ阅读APP看书,第一时间看更新
Application-level protocols – HTTP
In this section, we will try to build a simple IoT application for sending data from a DHT-12 temperature and humidity sensor to a receiver device, using a Raspberry Pi hub and the HTTP protocol:
Data flow from a DHT-12 sensor to a receiver
Offering a variety of usage options, HTTP is one of most popular protocols on the web. Every time you open a website or run a mobile application, it is most likely the HTTP protocol you are using.
In the following table, you can find a more detailed description of the protocol to understand whether it is suitable for your needs:
Key Value
Open source Yes
OSI layer Application
Data types Text, HTML, script, style, font, JSON, XML, stream, binary
Limitations Not suitable for large amounts of binary data
Possible operations Send/receive data
Latency Low
Usage On-demand requests
Security Yes
Compression Yes
For building the application, we will need the following.
Required software:
- Node.js 6+ (https://nodejs.org/en/download/)
- The request package (https://www.npmjs.com/package/request)
- The rpi-dht-sensor package (https://www.npmjs.com/package/rpi-dht-sensor)
- Docker (https://docs.docker.com/engine/installation/)
Required hardware:
- Raspberry Pi 3 (model B)
- A power adapter (2A/5V)
- A microSD card (8 GB+) and an SD adapter
- A DHT-12 temperature and humidity sensor module
- A breadboard and a set of dupont cables
- An Ethernet cable for a wired network connection