What you’ll learn

  • Build an IoT Stack on Pico W in C++
  • Connect Pico-W to Wifi service
  • Connect Pico-W to an MQTT Broker (port 1883)
  • Publish messages in MQTT on a topic
  • Subscribe to a MQTT Topic and handle incoming messages


The Internet of Things (IoT) allows us to put small devices around our environment to measure and control. The Raspberry PI Pico-W is an excellent platform for developing such IoT devices, connecting over WIFI and MQTT protocol.

In this course, we explore how to code C++ for a Pico-W  IoT device using the FreeRTOS coreMQTT-Agent library version v1.1.0. We take the approach of building an IoT framework for all the devices we want to build. With the ability to connect, publish and subscribe to messages. To operate we also need an MQTT broker and the course talks through the use of Eclipse Mosquitto as a locally installed broker on a Raspberry PI, or using Flespi as a cloud-hosted broker.

The course covers:

  1. Establishing WIFI connectivity in station mode to an access point or router
  2. Building TCPIP socket transport for MQTT protocol
  3. Publishing messages
  4. Subscribing and taking action on messages

Simple circuits to turn on and off an external LED using a local switch connected to the Pico-W are used to test the concepts.

The course assumes knowledge of C++. Though each example walks through the functionality, the course will not talk about the syntax of C++. FreeRTOS Kernel is used to support concurrent tasks for managing the MQTT protocol and an understanding of FreeRTOS Kernel is assumed. I have another course on FreeRTOS Kernel for the Raspberry PI Pico to cover this.

The course assumes you can compile and deploy C++ code to the Pico using the Raspberry PI Pico SDK. My other course “Introduction to C Development Environment for Raspberry PICO” teaches these skills.

Test scrips to interact with the device are written in Python. Some basic Python knowledge would be helpful.

Full captions are provided for the course and are not auto-generated.

Link description