Summary
The Raspberry Pi Pico W introduces onboard single-band 2.4GHz wireless interfaces (802.11n) through the Infineon CYW43439, making it ideal for custom IoT and home automation applications. Google Cloud Platform (GCP) provides various services to cater to IoT requirements, including Google Assistant, Smart Home and Nest Devices. In today's world, the IoT permeates nearly every aspect of daily life. However, many available solutions are hindered by vendor lock-in and lack transparency regarding user data collection. In this paper, we aim to explore the development of a low-cost custom solution with minimal effort. We will utilize the Raspberry Pi Pico W, part of the Raspberry Pi Pico family, and add onboard single- band 2.4GHz wireless interfaces (802.11n) using the Infineon CYW43439, which retains Pico’s form factor while adding essential wireless features, including:
- Wireless (802.11n), the single band (2.4 GHz)
- WPA3
- Wi-Fi soft access point supports up to four clients
- MicroPython, CircuitPython and C/C++ SDK (software development kits) supported
- In-build support by Mu and Thonny IDEs for Python-based development
Its high processing power, lower power consumption, cost-effectiveness, small form factor and Wi-Fi/Bluetooth support often make it an ideal candidate for creating custom IoT and home automation solutions.
IoT is a collection of physical objects with sensors, processing ability, software and other technologies that connect and exchange data with other devices and systems over the Internet. By 2025, 80 billion IoT devices will be connected to the internet.
Types of IoT
Name | Primary usage | Examples |
Consumer IoT | Home users |
- Voice assistance, - Home automation |
Commercial IoT | Transport, healthcare, etc. |
- Smart parking - Fleet tracking - Wearable biometrics, etc. |
Industrial IoT | Industrial applications |
- Digital control systems - Smart factory - Smart agriculture and industrial big data |
Military IoT | Military field |
- Surveillance using smart robots and drones - Wearable biometrics - Smart inventory management, etc. |
Infrastructure IoT | Smart cities |
- Infrastructure sensors - Crowd management - Event management - Disaster management, etc. |
Most common examples of IoT devices
- Home security
- Smart TVs
- Connected car
- Garmin DriveSmart
- Rove R2-4K Dash Cam
- Activity trackers
- Industrial security and safety
- Security cameras
- AR glasses
- Motion detection
- Smart speakers
- Google Home
- Amazon Echo
- Smart bulbs
- Philips Hue White and Color Ambiance
- Smartwatches
- Smart locks
GCP and IoT
GCP supplies many services that can be used to handle IoT needs, such as:
Offering | Use cases |
Google Assistant Smart Home | Home automation |
Nest Device Access | Home automation |
Firebase | Mobile, home automation, AI |
PubSub | IoT |
BigQuery | IoT, AI |
Edge TPU | IoT, AI |
Google IoT | IoT, AI |
Firebase
Firebase offers various features, including a real-time database, authentication, cloud messaging, storage, hosting, test lab and analytics, that can be harnessed to devise custom IoT solutions. We are going to use authentication and the real-time database features for this documentation. We will use the [micropython-firebase-real-time] package for both authentication and real-time-database API access.
Thonny IDE can be used to install it on Pi Pico W, using the following method:
- Click on "Shell"
-
Enter the following Python commands on the shell to install the firebase_realtime package.
Wi-Fi connectivity
There are many ways data can be shared by a microcontroller, such as short-range (Wi-Fi, Bluetooth) or long-range (LoRa, DASH7).
The primary advantage of the Raspberry Pi Pico W is its ability to connect to nearby Wi-Fi/Bluetooth-enabled devices for sending/receiving data and instructions.
We can create a similar method, as shown below, to connect to a nearby Wi-Fi network:
In the above example, the do_connect function needs to be provided with an SSID and its respective password for the Wi-Fi network.
Architect diagram
As discussed above, Raspberry Pi Pico W can connect to Firebase using REST API. It is also capable of interfacing with I/O devices such as robots, lights, bulbs and other appliances for home/industrial automation and sensors, including those for temperature, sound, light, video, weather, weight and others, for data collection.
In our solution, we can regulate devices or collect data from sensors using Raspberry Pi Pico W and manage them using the Firebase real-time database data.
In the above example, we are doing three main things:
- Connecting to Wi-Fi network
- Authenticating the user
- Interacting (put, patch, get, delete) with Firebase Realtime database.
Details of Wi-Fi Network and Firebase authentications are stored in the ‘data/firebase.json’ file.
Sensors
A sensor is a device that produces an output signal in response to a physical phenomenon. Most sensors can transmit data to general-purpose microcontrollers for processing and storage. They can also send data to remote storage facilities such as Firebase, BigQuery and other IoT solutions.
Board types of sensors available:
- Particle sensors
- Position sensors
- Pressure sensors
- Proximity sensors
- Radiation sensors
- Photoelectric sensors
- Temperature sensors
- Vision and imaging sensors
Raspberry Pi Pico W provides multiple pins that can be used to connect to and communicate with these sensors. Below is the pin diagram:
We will use a simple photoelectric sensor (5mm LDR or Light Dependent Resistor) whose resistance changes with the amount of light exposed.
We can create a circuit as shown below, connecting our sensor across pins (ADC0, ADC1)
Now let's integrate sensor code in the earlier code
In the above example, we are collecting two sensor parameters for a device:
- Temperature
- Relative illumination value as in resistance value by LDR
Similarly, we can connect multiple sensors to the same microcontroller and obtain sensor values, which can be stored on the GCP firebase.
References
- https://pypi.org/project/micropython-firebase-realtime/
- https://www.raspberrypi.com/
- https://firebase.google.com/docs/reference
- https://www.electronicshub.org/different-types-sensors/
- https://www.electronicshub.org/arduino-tilt-sensor/
- https://www.forbes.com/sites/michaelkanellos/2016/03/03/152000-smart-devices-every-minute-in-2025-idc-outlines-the-future-of-smart-things/?sh=7d4ebad4b63e