HackerBox 0087: Picow

by HackerBoxes in Circuits > Raspberry Pi

14894 Views, 23 Favorites, 0 Comments

HackerBox 0087: Picow

HB0087 Whole Box.png

Welcome to HackerBox 0087 presented in cooperation with Digi-Key Electronics. Configure programming environments for the Raspberry Pi Pico W microcontroller module. Assemble the HackerBox Exclusive Pico Weather Kit. Set up a display driver library for use with the kit's 2.8 inch, 320x240 pixel, full-color LCD module. Leverage the kit's BME280 sensor to measure relative humidity, barometric pressure, and ambient temperature. Display the measurements along with weather-related XBM graphic icons. Using the new wireless features of the Pico W, connect over Wi-Fi to OpenWeather servers to obtain localized weather data via JSON objects. Understand options for additional weather sensors. Assemble the exclusive HDMI Breakout Kit. Wire the HDMI Breakout Kit to the Raspberry Pi Pico W and generate digital video output signals using the Pico's awesome PIO (Programable I/O) functionality.

HackerBox is the original monthly subscription box for electronics, computer technology, and hacker culture. Each HackerBox is a discovery box, which means all members await and enjoy a new surprise each month. Tech, toys, knowledge, and fun. It's like having a hacker convention, your birthday, and the first day of school - every month - right in your mailbox.

There is a wealth of information for current and prospective members in the HackerBoxes FAQ. Almost all of the non-technical support emails that we receive are already answered there, so we'd really appreciate it if you can take a few minutes to read the FAQ.

Supplies

This Instructable contains information for getting started with HackerBox 0087. The full box contents are listed on the product page for HackerBox 0087 where the box is also available for purchase while supplies last. If you would like to automatically receive a HackerBox like this right in your mailbox each month, you can subscribe at HackerBoxes.com and join the party. Subscribers save at least $15 every month and get each new HackerBox shipped immediately off of the production line.

A soldering iron, solder, and basic assembly tools are generally needed to work on the monthly HackerBox. A computer for running software tools is also required. Have a look at the HackerBox Workshops for basic tools and a wide array of introductory activities and experiments.

The most import thing you will need is a sense of adventure, hacker spirit, patience, and curiosity. Building and experimenting with electronics, while very rewarding, can be tricky, challenging, and even frustrating at times. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from this hobby. Take each step slowly, mind the details, and don't be afraid to ask for help.

WEAR SAFETY GLASSES WHEN SOLDERING, WHEN TRIMMING WIRE LEADS, OR WHEN CUTTING, DRILLING, ETC.

Raspberry Pi Pico W

picow DKE.png

The Raspberry Pi Pico W (a.k.a. picow) is a low-cost, high-performance microcontroller module based on the Raspberry Pi RP2040 microcontroller chip and the Infineon CYW43439 2.4GHz wireless chip.

The RP2040 microcontroller features a dual-core Arm Cortex M0+ processor, flexible clock running up to 133 MHz, 264KB of SRAM, 2MB of on-board flash memory, and a USB 1.1 port operable in both device and host modes.

The CYW43439 wireless chip is connected via SPI to the RP2040. The 2.4GHz onboard antenna is licensed from ABRACON (formerly ProAnt). The CYW43439 chip provides both 802.11 wireless (Wi-Fi) and Bluetooth. Bluetooth was not supported with the initial release of the Pico W, but support is starting to come available as of early 2023.

Thank You Digi-Key Electronics!

We've been shopping Digi-Key whenever we need Raspberry Pi Picos or Raspberry Pi Pico Ws. Even in the face of chip shortage madness, Digi-Key has Picos in stock by the thousands along with countless other components.

Programming the Raspberry Pi Pico W

Programming Picow.png

BEFORE SODLERING

Prior to soldering anything to the Pico W module, be sure to power it up and perform a quick experiment to validate at least one simple program running on the microcontroller.

When the Pico W is first plugged into your computer, it will not display any lights or other indictors. However, a new mass storage device (basically a flash drive) will appear. It will have the name RPI-RP2. If it does not appear, unplug the USB cable, hold down the BOOTSEL button and plug the USB cable back in before releasing the button. You can execute this BOOTSEL procedure anytime to force the Pico into a receptive state for (re)programming.

The RPI-RP2 mass storage can accept a UF2 file. Just copy/paste or drag the file onto the storage device. Once you drop it in, the Pico will automatically reset and run the deposited program.

UF2 stands for USB Flashing Format. The associated bootloader allows embedded devices to be programmed using a simple USB mass storage class (removable drive) interface. The bootloader is also compatible with BOSSA (Basic Open Source SAM-BA Application), which is used by the Arduino IDE.

CONFIGURE THE ARDUINO IDE

Install the Arduino IDE software and setup the Raspberry Pi Pico Arduino core as outlined here.

In the Arduino IDE, select: Tools > Board > Raspberry Pi RP2040 Boards > Raspberry Pi Pico W

Open File > Examples > Basics > Blink

Execute the BOOTSEL procedure if necessary (unplug the USB cable, hold down the BOOTSEL button, and plug the USB cable back in before releasing the button)

Hit the arrow icon to compiler the sketch and upload it to the Pico W.

The Pico W's green LED will start blinking once the code is uploaded and starts running.

DroneBot Workshop has a very nice Pico W Arduino Tutorial that is definitely worth a look.

OTHER PROGRAMMING OPTIONS

CircuitPython

MicroPython

C/C++ SDK


Pico Weather Kit

Weather Kit.png

HackerBox Pico Weather PCB

The custom PCB provides interconnection between a Pico W microcontroller module, an LCD TFT Display, a BME280 sensor module (for pressure, temperature, and humidity), and some additional optional sensors that can be added on later.

The schematic diagram for the PCB is attached as a PDF.

Resistors First

Begin assembly of the Pico Weather Kit by placing two 1K resistors (marked "1001") at locations R1 and R2 on the back side of the PCB. Resistors are not polarized, so they can be oriented either way.

Notice that there are 11 other surface mount landing pads on the rear of the PCB. We can ignore those for now.

Three Tactile Momentary Buttons

Solder these on the front side of the PCB at the locations labeled RUN, SW1, and SW2.

BME280 Sensor Module

The BME280 (datasheet) is a tiny sensor capable of measuring relative humidity, barometric pressure, and ambient temperature. The sensor was especially developed for mobile applications and wearables where size and low power consumption are key design parameters. The unit combines high linearity and high accuracy sensors and is perfectly feasible for low current consumption, long-term stability and high EMC robustness. The humidity sensor offers an extremely fast response time and therefore supports performance requirements for emerging applications such as context awareness, and high accuracy over a wide temperature range.

The BME280 sensor is provided in the HackerBox as a GY-BME280 Module. Notice that the landing pad for the module can accept the provided GY-BME280 module using the pins on the left side or the optional SparkFun SEN-13676 (available from Digi-Key) using the pins on the right side. Only one of the sensor modules time can be installed on the Pico Weather PCB at one time. Both module types are based on the same BME280 sensor.

Male Pin Headers

Snap the first 40 pin male header right at its midpoint to form two 20 pin headers. If you have already tested the module and verified at least one example program, solder the two 20 pin headers onto the Pico W microcontroller module.

Snap 4 pins from the second 40 pin male header. We will use this with the TFT Display Module.

Snap 10 pins from the second 40 pin male header. Set that aside for use with the HDMI Breakout Kit in a later step.

LCD TFT Display Module

The display module measures 2.8 inches with 320x240 pixel resolution, and is based on the ILI9341 display chip. Using the 14 factory-populated header pins along with the four additional header pins, mount and solder the display module onto the Weather PCB. The provided display module does not include a touch sensor even though the red PCB of the display module has traces and header pins to support the touch functionality.

Raspberry Pi Pico W Mounting Options

For a low-profile finished project, the Pico W module can be soldered directly to the Pico Weather PCB. Alternatively, the two 20 pin "short" female headers can be soldered to the Pico Weather PCB providing a pluggable socket for the Raspberry Pi Pico W module.

Configure the Display Driver

Carefully follow these steps to install and configure the TFT_eSPI Library for operating the LCD TFT display from the Pico W on the HackerBox Pico Weather Kit...

  • From Tools > Manage Libraries, search for TFT_eSPI
  • Install the TFT_eSPI Library from Bodmer
  • Find the folder where Arduino Libraries are installed and the folder for TFT_eSPI
  • Locate and open the file User_Setup_Select.h in a text editor
  • Comment out the line with #include User_Setup.h (default)
  • On the next like paste in: #include <User_Setups/HackerBox_Weather_Pi.h>
  • Save the User_Setup_Select.h file with those two changes in place
  • Download the attached header file and copy it into the User_Setups folder
  • Open File > Examples > TFT_eSPI > 320x240 > Cellular_Automata
  • Compile and Upload

Any of the examples in that 320x140 folder should work as well.

Display BME280 Sensor Readings

Display BME280 Readings.png

In the Arduino IDE, use Tools > Manage Libraries to search for, and install the library "Bme280" by Eduard Malokhvii.

Grab both files attached here and place them in the same folder.

The bitmaps.h file contains weather related icons in the X BitMap (XBM) format. You can use this online utility to create your own custom XBM images.

Compile and upload BME280icons.ino to the Pico W (or even a Pico-non-W). Since this demo only uses the BME280 sensor for display data, it does not require Wi-Fi network access.

Connecting to OpenWeather Over Wi-Fi

Open Weather.png

Next, using the magic of the interwebs, we can add a screen displaying outdoor weather information about out location, or even multiple screens for various locations of interest.

OpenWeatherMap is an online service that provides global weather data via API. The data including current weather, forecasts, nowcasts, and historical weather data for any geographical location. They utilize a convolutional machine learning weather model leveraging meteorological broadcast services, data from airport weather stations, ground radar stations, weather satellites, remote sensing satellites, METAR, and automated weather stations. Google chose OpenWeatherMap as a weather data provider and has published documentation on how to use OpenWeather data to display weather conditions on Google Maps.

You can create a free account with OpenWeatherMap. From the API tab on the site, copy your API key. We will use this key when making JSON (JavaScript Object Notation) data requests from within the sketch.

Grab the OpenWeather.ino sketch attached here. The bitmaps.h header is the same one used in the last example. It will need to be copied into the same folder with this sketch as well.

Two points before compiling the new sketch...

Use Tools > Manage Libraries to search for, and install, the library Arduino_JSON by Arduino.

Customize these five lines inside the sketch:

const char* ssid = "xxxxxxx";
const char* password = "xxxx";
String my_Api_Key = "xxxxxxxxxxxxxx";
String my_city = "Atlanta"; //specify your city
String my_country_code = "US"; //specify your country code

The JSON operations in this sketch are adapted from this project by Jean-Luc Aufranc (CNXSoft).

Adding More Sensors

Additional Sensors.png

The HackerBox Pico Weather PCB was designed to support even more weather sensors than those provided in the initial kit. Obviously these are optional, but if you want to extend your weather station, you can get what you need from Digi-Key Electronics using the links below.

Lightning Sensor

AS3935 - Lightning Sensor Board

The header pins for the lightning sensor are wired to SPI1, which is shared with the SD Card. The specific pins can be seen on the schematic as:

GPIO08 - SPI1_MISO
GPIO11 - SPI1_MOSI
GPIO10 - SPI1_SCK
GPIO12 - LGHTNG_CS
GPIO13 - LGHTNG_INT

Rain, Wind Speed, and Wind Direction Sensors

SparkFun Weather Meter Kit

SparkFun provides an online guide to assembling the Weather Meter Kit.

The Cup Anemometer (wind speed sensor) operates as a switch. The contact will close (causing GPIO28 to go from high to low) once per second when the wind speed is 1.492 mph (2.4 km/h). An interrupt handler routine could be used to keep a count of how frequently the contact closes. Wind speed can be derived from that rate.

The Tipping Bucket Rain Gauge also operates as a switch. For every 0.011 inch (0.2794 mm) of rainfall, the contact will close (causing GPIO26 to go from high to low). Again, an interrupt handler routine may be useful to keep a count of contact closures. Rainfall can be derived from that count.

The Wind Vane (direction sensor) uses eight switches and eight different values of resistors. Two neighboring switches can be closed when the vane is near the midpoint betwixt, so there are actually 16 different resistances that can be measured. The 16 resistances are listed in the table found in the datasheet. The resistance to be sensed forms a voltage divider (against 3.3V) with the 10K resistor located at R5. The divider output can be captured at GPIO27.

Connecting the Weather Meter Kit to the Pico Weather PCB requires some additional components:

The interface circuitry on the Pico Weather PCB are derived from the SparkFun MicroMod Weather Carrier Board.

SD Card

The SD Card slot on the back side of the TFT display id not used in this project and has not been fully tested. However, it should work as expected. It is wired to SPI1, which is shared with the lightning sensor. The specific pins can be seen on the schematic as:

GPIO08 - SPI1_MISO
GPIO11 - SPI1_MOSI
GPIO10 - SPI1_SCK
GPIO09 - SD_CS

HDMI Breakout Kit

HDMI Kit.png

Start assembling the HDMI Breakout Kit by soldering the eight 270 Ohm Resistors (marked "2700"). Resistors are not polarized, so they can be oriented either way.

HDMI Right-Angle Through-Hole Socket

The 19 pins on this connector are very thin and bend so easily that you should start by assuming they are bent. Using a thin instrument like a dental pick, needle, or mechanical pencil tip, very carefully nudge any bent pins until they are all standing straight up in regimental formation.

Once the pins are straight, the connector should drop easily into place on the PCB. If it gives resistance, do not push as this will just bend/crush the tiny pins. Instead, lift it off and repeat with the straightening. Eventually it will drop right into place. From there, it is actually much easier to solder than it looks. Thanks to the pin spacing, through holes, and the solder mask on the PCB, the solder seems to wick into place right where it belongs. Of course, you should still be careful to keep an eye out for solder bridges.

Header Pins

Remember the 10 pin header section that we snapped from the 40 pin header earlier? Do the needful.

HDMI Video From Raspberry Pi Pico

HDMI with Pico.png

Using a solderless breadboard and some jumper wires, connect the Raspberry Pi Pico (W or not) to the HDMI Breakout as shown. Here are the pin specifics:

HDMI     PicoW GPIO
D2+      16
D2-      17
D1+      18
D1-      19
D0+      12
D0-      13
CK+      14
CK-      15
GND      GND

The 5V pin is usually not needed.

Download this zip file from PiCockpit.

Under each app folder in the zip file you'll find a compiled UF2 file that can simply be dropped onto the Pico's "RPI-RP2" mass storage. Connect the HDMI port to a TV/Monitor and given the UF2s a shot.

More information and the original source code can be found in this repository. The code can be compiled using the C/C++ SDK.

Solderless or SolderFul?

After prototyping a project on a Solderless Breadboard, you can easily make it permanent and durable using a Digi-Key SolderFul Breadboard just like the one included in your HackerBox!

Hack the Planet

outro.png

We hope you are enjoying this month's HackerBox adventure into electronics, computer technology, and hacker culture. Reach out and share your success in the comments below or other social media. Also, remember that you can email support@hackerboxes.com anytime if you have a question or need some help.

What's Next? Join the party and live the HackLife. Get a cool box of hackable gear delivered right to your mailbox each month and enjoy a generous member discount. Surf over to HackerBoxes.com right now to sign up for your monthly HackerBox subscription.

Please consider sharing this free Instructable with others who may be interested in learning about these subjects. We really appreciate your support and "word of mouth advertising" is the most powerful marketing!