Sending MQTT messages to a broker
Let's now start to dive into the world of IoT. As every device that has a connection to the internet—or at least to some network—can be considered an IoT device, the project in this section can be considered an IoT project. The Arduino Nano 33 IoT has a u-blox NINA-W102
chip on board that is capable of Wi-Fi communication. We can communicate with this chip using the SPI interface. As a driver for the NINA chip already exists, we don't have to implement one ourselves.
So, our plan is to send data through SPI to the NINA chip, which then sends the data through the network to an MQTT broker. The following diagram illustrates the process:
Although the driver functionality is wrapped in a package, some boilerplate code is still needed to start using the Wi-Fi chip. So, let's wrap it inside a new package.
Implementing the Wi-Fi package
We are going...