You connected Arduino to the Internet using Ethernet and WiFi respectively. This chapter looks at two protocols used for sending and receiving data. A protocol is an agreed-upon structured format that is used for network communication. It defines what should be sent and received and what actions should be taken.
At the end of this chapter, you will be able to:
- Understand the basics of the HTTP protocol
- Send an HTTP request to the server
- Understand the basics of the MQTT protocol
- Publish and subscribe to an MQTT broker
The web uses Hyper Text Transfer Protocol (HTTP) as its underlying protocol. HTTP supports multiple methods of data transmission, but in this project you are going to write code for the two more popular methods, GET and POST . The GET and POST methods do the same job and their code is very similar, but there is a slight variation in their request formats. GET has a limit on how much data it can transmit compared to POST , which has no such limitations. POST is also considered safer compared to GET . Based on your requirements, you can decide which one works better for you
In this chapter, you learned about HTTP and MQTT, two very important, popular, and lightweight communication protocols used in IoT applications. These protocols are device agnostic, so they can be used for communication with any type of device or server. You will use both these protocols extensively in the next chapters.