This is only a preview of the January 2023 issue of Silicon Chip. You can view 39 of the 112 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "Q Meter":
Items relevant to "Raspberry Pi Pico W BackPack":
Items relevant to "Active Subwoofer, Part 1":
Items relevant to "Noughts & Crosses game using just two modules":
Items relevant to "Noughts & Crosses Machine, Pt1":
Purchase a printed copy of this issue for $11.50. |
Raspberry Pi Pico W
BackPack
Our Raspberry Pi Pico BackPack from
March 2022 has a powerful dualcore 32-bit processor, 480 × 320 pixel
colour touchscreen, onboard real-time
clock, SD card socket, stereo audio
output and infrared receiver. Now, for
only about $5 more, it has WiFi too!
Project by Tim Blythman
M
icrocontrollers have become so
easy to use, cheap and accessible for hobbyists, while chips like
the ESP8266 have made it simple to
use WiFi.
The Raspberry Pi Foundation’s Pico
W is an inexpensive, well-documented
32-bit microcontroller board with WiFi
that is well-suited to being used with
the LCD BackPack.
We reviewed the Pico W in the
November 2022 issue and found that
it was mostly interchangeable with the
Pico (siliconchip.au/Article/15547)
but with added WiFi support. So it
was only natural for us to update the
Pico BackPack to include WiFi support using the Pico W. As it turns out,
that was not hard to do.
From launch, the Pico supported
the MicroPython and C languages
(using the Raspberry Pi Foundation’s
Features and Specifications
∎ Includes a 3.5in LCD touch panel
and a dual-core microcontroller
with WiFi.
∎ Also includes all the features of
the original Pico BackPack.
∎ We provide software demos and
examples for the Arduino IDE, C
SDK and MicroPython.
∎ Our sample code demonstrates
practical uses of HTTP, UDP and
NTP.
50
Silicon Chip
Raspberry Pi is a trademark of the Raspberry Pi Foundation
C software development kit). Arduino support in the form of the Arduino Pico board profile came soon after.
The Raspberry Pi Foundation has
made many inexpensive single-board
computers and microcontroller boards
available to the masses, even amid
continuing electronics component
shortages.
The Pi Pico series are simple but
well-thought-out boards and are attractively priced for what they offer.
BackPack hardware
We considered whether it was
worthwhile to update the Pico BackPack PCB to complement the Pico W,
but ultimately, we decided not to make
any significant changes.
The thing is that the Pico BackPack
crams a lot of features into a small area
corresponding to the size of the matching LCD touch panel.
To add any features would likely
mean removing some of the existing
features, which we didn’t want to do.
The Pico BackPack has a row of I/O
pins to make external connections, so
it’s easy enough to connect different
hardware if necessary.
Thankfully, we’d already established that the Pico W didn’t ‘break’
any existing functionality of the Pico
BackPack. So the BackPack PCB
remains the same for the Pico W,
although we will recommend a minor
Australia's electronics magazine
assembly variation to enhance the
WiFi capability.
The Pico W BackPack
The only substantial difference
between the Pico BackPack and the
Pico W BackPack is the replacement
of the Pico module with a Pico W. All
the pins on the Pico W are labelled the
same as those on the Pico, so none of
the signals or I/O pin breakouts need
to change.
Still, as we noted in our review of
the Pico W, both the BackPack PCB
and LCD touch panel have large solid
copper areas that could impede WiFi
signal propagation.
Therefore, we recommend that
the Pico W is mounted slightly away
from the BackPack PCB to provide
better clearance for its onboard WiFi
antenna. We used header strips to provide this spacing.
You could also use low-profile
socket headers and short pin headers if
you wish to make the Pico W pluggable.
We tried this and found it worked well,
although it was fiddly to assemble.
Circuit details
Fig.1 shows the circuit diagram for
the Pico W BackPack. It is identical to
the original Pico BackPack, with the
Pico replaced by a Pico W.
IRRX1 at top left allows the Pico W
to receive IR signals on its GP22 digital
siliconchip.com.au
Fig.1: the Pico W BackPack circuit is almost
identical to the Pico BackPack. It includes an
IR receiver, microSD card, real-time clock,
audio output and LCD touch panel. A 20-way
header provides access to power and spare I/O
pins for adding more features. The 1kW resistor
at IRRX1’s output is not needed in most cases.
input. The LCD touch panel connects
to power and the SPI bus at the top,
as does the microSD card socket at
upper right.
The two transistors on the right control the power to the LED backlight on
the LCD touch panel. Below this, a
DS3231 real-time clock and calendar
IC connects to the I2C bus.
siliconchip.com.au
Finally, the components at the
bottom, including the op amps, can
deliver line-level audio at CON3.
They connect to pins on the Pico W
that generate pulse-width modulated
(PWM) signals to provide synthesised
analog voltages.
For more details and specifics about
how the various features work on the
Australia's electronics magazine
Pico BackPack PCB, refer to the article from March 2022 (siliconchip.au/
Article/15236). The original software
to interface to the BackPack hardware
was also explained in that article.
Construction
While that March 2022 article has
more detail on assembling the PCB
January 2023 51
removable. We figure it’s inexpensive
enough that you are better off saving
the effort and just soldering it.
Software with WiFi support
The release of the Pico W has
allowed us to update the Pico BackPack
with WiFi. It’s a powerful combination that we think
will be the basis of some diverse and interesting projects. We’re
providing several practical WiFi demos to make it easy to pick up and use.
and fitting it to the LCD touch panel,
experienced constructors should have
no trouble using the overlay in Fig.2 to
assemble the PCB. If you refer to that
earlier article, the PCB construction is
no different until you get to the Pico
W module.
Most IR receivers will not need
the 1kW resistor; in fact, it will interfere with their weak internal pullup.
Hence, it has been omitted from the
overlay and is not seen in our photos. Don’t forget the cell holder on the
reverse of the PCB if you are fitting the
real-time clock IC.
Lines separate the various sections
of the board on the silkscreen. That
helps you to omit some components
if you wish to reclaim some I/O pins
by not using those features.
As we mentioned earlier, the Pico W
should be spaced away from the main
BackPack PCB and also kept clear of
the LCD above. Thus, we have added
two 20-way pin header strips to the
parts list. Solder these to the BackPack PCB, with the plastic carrier sitting above. Then solder the Pico W to
the top of the pin headers. The plastic
carrier separates the Pico W from the
BackPack PCB.
Our photos show how the Pico W
is spaced above the BackPack PCB by
a small distance.
The other option requires low-
profile (5mm) header sockets too.
Altronics Cat P5398 can be used but
you will need two lengths, cutting
them down to 20 pins each.
52
Silicon Chip
The fiddly part is fitting the pin
headers to the Pico W, as this requires
removing the metal pins from their
plastic carrier to minimise the height.
Although the plastic carrier is only
2.5mm high, it’s enough to cause the
Pico W to foul the LCD, so it must be
removed.
After pulling the pins out of the
plastic carrier, insert them individually into the socket header entries. You
can then place Pico W over the pins
and solder them to it. Depending on
the length of the pins, they might also
need to be trimmed so that the pins do
not foul the LCD screen.
The only advantage of that more
fiddly approach is that the Pico W is
Of course, we need some sample
code that uses WiFi to show off the
Pico W’s new feature. Since PicoMite
BASIC will not support the Pico W’s
WiFi (as noted in the November review
article), our software samples do not
include PicoMite BASIC.
Existing PicoMite BASIC programs
should work fine on the Pico W, with
the minor exception that the Pico W’s
onboard LED is driven differently, so
it can’t be controlled as it would be
on a Pico.
We have updated the Arduino, C
SDK and MicroPython examples to
add WiFi features. As we noted in
our review of the Pico W, a document
called “Connecting to the Internet with
Raspberry Pi Pico W” explains how to
do this with the C SDK and MicroPython. But that guide is quite basic; our
sample code does much more.
Since the updated demos are based
on the earlier versions we made for
the original Pico BackPack, we recommend reading the original Pico
BackPack article for information on
the original features.
One of the great features of the Pico
and the Pico W is the bootloader which
implements a virtual flash drive,
allowing software to be uploaded by
simply copying a file to the virtual
drive.
The bootloader is in mask ROM in
the RP2040 microcontroller that runs
the Pico and Pico W. This makes it
Fig.2: the lines on the overlay delineate the components that provide the
different features of the Pico W BackPack. There is also a cell holder on the
rear of the PCB, used by the real-time clock IC to keep time when power
is not otherwise available. The Pico W is spaced above the main PCB to
improve the performance of its WiFi antenna.
Australia's electronics magazine
siliconchip.com.au
practically impossible to ‘brick’ the
Pico or Pico W as the bootloader cannot be overwritten.
Bootloader mode is entered by holding down the BOOTSEL button on the
Pico or Pico W while powering up or
resetting the chip. Since the BackPack
provides a reset button, you can start
the bootloader by pressing and holding BOOTSEL while pressing S1 on
the BackPack.
Software images for the Pico and
Pico W use the UF2 file type, which is
a binary format, unlike the text-based
HEX files used for other chips like PIC
microcontrollers. If you are simply
interested in seeing what the Pico W
BackPack is capable of doing, all you
need to do is copy the respective UF2
file to it after putting the Pico W into
bootloader mode.
We’ll go into a bit more detail about
the workings of the software later in
this article.
To simplify entering the WiFi credentials, you can set them using the
virtual serial port. You will need a
serial terminal program, such as Tera
Term, minicom or the Arduino Serial
Monitor, to communicate with the
Pico W.
You might notice that the demo .uf2
files are larger than the Pico examples
due to the extra libraries needed to
communicate with the WiFi chip. The
WiFi chip also needs a 300kB binary
‘blob’ to work, which is bundled into
the firmware images.
Arduino coding
The team that created the Arduino-
Pico port for the Arduino IDE has
done a good job of aligning the Pico
W’s WiFi API (application programming interface) to that used by other
WiFi boards, such as those based on
the ESP8266 and ESP32 processors.
Indeed, it is based heavily on that of
the ESP8266.
You might remember the D1 Mini
BackPack from the October 2020 issue
(siliconchip.au/Article/14599). It uses
an ESP8266-based D1 Mini module
to drive an LCD touch panel and has
many features in common with the
Pico W BackPack.
We’re using version 2.5.2 of the
Arduino-Pico board profile, although
versions as old as 2.30 should support the Pico W. You can find more
information about the board profile
at https://github.com/earlephilhower/
arduino-pico
siliconchip.com.au
Parts List – Pico W BackPack
1 double-sided PCB coded 07101221, 99 x 55mm
1 Raspberry Pi Pico W Module (MOD1) [Altronics, Core, Digi-Key, Little Bird]
1 3.5in LCD touchscreen [Silicon Chip Shop Cat SC5062]
1 14-pin, 2.54mm pitch socket header (for LCD panel)
3 20-pin, 2.54mm pitch pin header (CON2 & to mount Pico W)
2 20-pin low-profile (5mm tall) 2.54mm pitch socket headers (optional)
2 2-pin, 2.54mm pitch pin headers with jumper shunts (JP1, JP2)
1 6mm x 6mm tactile switch (S1)
8 M3 x 6mm panhead machine screws
4 M3 x 12mm tapped spacers
Semiconductors
1 IRLML2244TRPBF/SSM3J372R P-channel Mosfet, SOT-23 (Q1)
1 2N7002 N-channel Mosfet, SOT-23 (Q2)
Resistors (all M3216/1206, 1%, ⅛W)
1 10kW
1 1kW
Optional Components
SD card
1 SMD microSD card socket (CON1) [Altronics P5717]
1 10μF 10V X7R SMD ceramic capacitor, M3216/1206 size
1 100nF 10V X7R SMD ceramic capacitor, M3216/1206 size
Real time clock/calendar
1 surface-mounting CR2032 cell holder (BAT1) [BAT-HLD-001]
1 DS3231 or DS3231M in SOIC-16 (wide) or SOIC-8 package (IC1)
1 100nF 10V X7R SMD ceramic capacitor, M3216/1206 size
2 4.7kW 1% ⅛W M3216/1206 size
IR receiver
1 3-pin infrared receiver (IRRX1) [Jaycar ZD1952]
1 10μF 10V X5R SMD ceramic capacitor, M3216/1206 size
1 1kW 1% ⅛W resistor M3216/1206 size (see text)
1 470W 1% ⅛W resistor M3216/1206 size
1 100W 1% ⅛W resistor M3216/1206 size
Stereo audio
1 MCP6272(T)-E/SN, MCP6002(T)-I/SN or -E/SN dual op amp, SOIC-8 (IC2)
1 3-pin, 2.54mm pitch pin header (CON3)
2 1nF 25V X7R SMD ceramic capacitors, M3216/1206 size
2 100nF 10V X7R SMD ceramic capacitors, M3216/1206 size
2 10uF 10V X5R SMD ceramic capacitors, M3216/1206 size
4 100kW 1% ⅛W resistor M3216/1206 size
2 47kW 1% ⅛W resistor M3216/1206 size
2 22kW 1% ⅛W resistor M3216/1206 size
2 10kW 1% ⅛W resistor M3216/1206 size
2 100W 1% ⅛W resistor M3216/1206 size
As well as adding WiFi support,
we’ve updated the Arduino sample
code to include an infrared receiver
decoding library. In our original Pico
BackPack article, we mentioned that
we expected the IRRemote library to
be ported to the Pico (and Pico W),
which has now happened.
You can find that library online at
https://github.com/Arduino-Irremote/
Arduino-Irremote or it can be installed
by searching for “irremote” in the
Arduino Library Manager. We have
also included a copy of the version
Australia's electronics magazine
we’ve used in the software bundle.
Screen 1 shows the BackPack running our updated Arduino Pico W
sample. We have added some text to
the LCD panel to show the status of
the WiFi hardware.
Setting up the WiFi
Since using the Pico W in a meaningful way requires that it connect to a
WiFi network, we have added a configuration menu on the virtual serial port.
We did it that way, rather than using
the touchscreen, because it’s easier to
January 2023 53
► Screen 1: the Arduino demo for
the Pico W has the most features,
primarily due to the excellent library
support the Arduino community
offers. Apart from the new WiFi
features, there is now also support for
the IR receiver.
►
Screen 2 (right): all the demos include a menu system that can be accessed from a serial terminal program.
This is to simplify entering the WiFi credentials needed for the demo to work. The Arduino output is shown here.
enter WiFi credentials via a computer
rather than an on-screen keyboard.
Screen 2 shows the menu that is
presented over the serial port by the
Arduino software. Items are selected
by typing the number and pressing the
Enter key. Items 2 and 3 will prompt
for the SSID name and password, also
followed by Enter.
This demo can scan for WiFi networks and connect by name and password. It can also connect to a website
over HTTP to retrieve data from the
internet. In this case, we use ip-api.
com to get some location text to display, along with a timezone offset for
that location.
This isn’t perfect and would probably be fooled by a VPN (virtual private
network), but it will usually give the
correct timezone. We think it is a simple and effective way of demonstrating
the use of HTTP on the Pico W.
We also use NTP (network time protocol) to provide the current time in
UTC, adjusted by the timezone offset
to provide accurate local time. This
can then be saved to the RTC IC on
the BackPack.
To do all this, you would use menu
items 2, 3 and 4 to connect to a WiFi
network, followed by 8 to get the offset
and 7 to set the RTC. You can set the
offset manually using item 6 if item 8
does not work.
The IRRemote library is also used to
capture and decode IR signals, as displayed in the line beginning “NEC” in
Screen 1. This indicates that an NEC
54
Silicon Chip
code was last received and shows
that code.
Code differences
The Arduino code for the updated
Pico W Backpack differs from the earlier Pico BackPack example only in the
main sketch file, plus the requirement
to have the IRRemote library installed.
It uses other library files that are part
of the Arduino-Pico board profile,
including those needed for WiFi.
Those who have worked with modules based on the ESP8266 or ESP32
will be familiar with how WiFi works
under the Arduino IDE; the Pico W
is similar. Three library includes are
used to implement the WiFi features:
#include <WiFi.h>
#include <WiFiUdp.h>
#include <HTTPClient.h>
NTP requires the UDP protocol for
communication, hence its inclusion.
Fetching web pages uses HTTP. Scanning for networks is done by running
a single line of code, as is connecting
to a network:
WiFi.scanNetworks();
WiFi.begin(ssidname,ssidpass);
These calls are blocking (ie, the program doesn’t proceed until the action
is completed), and the latter can take
up to ten seconds to run. So they may
not suit all applications. The C SDK
gives better access to the low-level
commands and might be more suited
if blocking calls are not desired.
Australia's electronics magazine
It is possible to use function calls
from the C SDK in the Arduino IDE,
but we preferred to keep the Arduino
code consistent with the Arduino way
of doing things.
NTP is implemented as a background routine that simply needs to be
started and then quietly synchronises
in the background. Fetching a website
using HTTP can be done in a few lines:
http.begin(wificlient,URL);
httpCode=http.GET();
Serial.print(“Return code:”);
Serial.println(httpCode);
if(httpCode == 200)
{
Serial.println(
http.getString() );
}
We got around some of the longer
blocking sections by using the second
processor core to do some tasks in the
background without interrupting the
main program flow. These can be seen
in the setup1() and loop1() functions.
At the time of writing, we have not
seen an official Arduino board profile for the Pico W, so we were unable
to try this out as we did for the Pico.
But the Arduino-Pico board profile
appears to be updated regularly and
works well; we have no hesitation in
recommending it.
Using it with the C SDK
Screen 3 shows the LCD panel of
the BackPack loaded with the C SDK
(software development kit) demo. It
siliconchip.com.au
as it gets updated in time. This means
that the main program is not blocked
from other operations while network
activity occurs.
Using HTTP requires several callback functions to be set, meaning that
using the C SDK can seem a bit more
complicated than using the Arduino
IDE. Still, if you have the patience to
set up and delve into the C SDK, we
recommend trying it, especially if you
need to get the most performance from
your Pico W BackPack.
MicroPython
Screen 3: the C SDK demo runs fast, with good access to low-level functions.
Support for protocols like NTP and HTTP is very good once you get it working.
includes similar elements to the Arduino example, although the C SDK does
not have library support for the IR
receiver or RTC chip.
There is an RTC feature in the Pico
W (and Pico) that can be used by C
SDK, but it doesn’t provide the battery backup timekeeping feature that
chips like the DS3231 have. It needs
the time to be set each time Pico W is
reset. Since the Pico W uses a crystal
oscillator, it should be pretty accurate
once it has been set.
The C SDK performs similar tasks to
the Arduino demo, using a WiFi connection and NTP to update the RTC.
Location and timezone data are also
fetched from ip-api.com using HTTP.
Several library files are needed
for WiFi support. The first file is
required to interface with the Infineon
CYW43439 chip that provides the
WiFi interface, while the others provide library support for HTTP and
NTP:
Pi computer, we ran it on a Windows
PC using the pico-setup tool that can
be found at https://github.com/ndabas/
pico-setup-windows
This resulted in many minor
glitches, especially as some of the
commands are subtly different. If you
have a Raspberry Pi computer handy,
you might find it more straightforward
to program the Pico W via the C SDK.
Just as for the original Pico BackPack demos, the C SDK software runs
very fast and some lower-level functions allow more control than we could
easily achieve with the Arduino IDE.
In most cases, the serial port menu is
used to start an action, such as starting
a network scan or connecting to a WiFi
network. These do not return immediately like the Arduino equivalents.
Instead, the main program monitors
the status of variables like the Pico W’s
IP address and displays information
The MicroPython version available
for the Pico W at the time of writing is
tagged as ‘unstable’, although we did
not have any issues using it. We have
included a copy of this version with
our software bundle.
Note that there are different MicroPython UF2 files for the Pico and Pico
W. Be sure to use the correct version.
Our MicroPython demo has much
the same features as the C SDK demo,
as shown in Screen 4. We haven’t
made any changes to the two library
files (from the original Pico BackPack
demo); only the “main.py” file has
been updated.
Like the Arduino IDE, several libraries must be imported to provide WiFi
functionality:
import network
import urequests
import ntptime
We noted that the original Micro
Python software was barely fast
enough to be useful. The addition of
the WiFi features does make interacting with the LCD touch panel quite
slow. Still, we expect most people
would not try to cram in all the features that we have.
Like the Arduino code, many
#include “pico/cyw43_arch.h”
#include
“lwip/apps/http_client.h”
#include “lwip/apps/sntp.h”
To properly use the C SDK with the
Pico W, we had to make a few changes
to the CmakeLists.txt file, especially in
the target_link_libraries and add_definitions sections. Look at our sample
project to see what to do before creating your own projects.
While the C SDK is primarily
intended to be used on a Raspberry
siliconchip.com.au
This shows the spacing needed to give clearance for the Pico W’s WiFi antenna.
Short pin headers are the simplest way to achieve this while also keeping clear
of the LCD touch panel, which is mounted above.
Australia's electronics magazine
January 2023 55
it uses a compiled rather than interpreted language.
The C SDK was a bit more tricky to
work with, but the results are fast and
responsive. It also gave us much better
access to low-level operations.
Bluetooth will be a nice feature to
have when it arrives, but as it stands,
the Pico W is very useful at its current price and works very well with
the BackPack hardware.
Now that we have WiFi working
well with the C SDK, we think the Pico
W will be a good choice for future projects needing WiFi. The Arduino IDE
will be a handy option when we want
to quickly interface with hardware,
especially if it needs library support.
Availability
Screen 4: the MicroPython demo has similar capabilities to that of the C SDK.
It’s possible to use the drawing feature of the demo, but it is not very responsive.
MicroPython routines are blocking
and may not return for many seconds.
The features available are much
the same as the C SDK, with options
to scan for networks and set the SSID
name and password. You can connect,
disconnect and make an HTTP request
to retrieve data.
Is there Bluetooth support?
Since the Infineon CYW43439
WiFi chip has support for Bluetooth,
many people have been left wondering whether the Pico W will be able
to use Bluetooth.
At the time of writing, it appears
that is not the case. Instead, we are
simply left with the tantalising statement from the folks at the Raspberry
Pi Foundation that it “may be enabled
in the future”.
Summary
Our demo code does many things
you might typically do with a WiFi-
capable microcontroller: connect to a
network, make HTTP requests to fetch
data from websites and use NTP to set
the time.
The Arduino IDE (using Arduino-
Pico) and MicroPython made this very
easy. We found the Arduino IDE more
attractive as it has better library support, and the code runs quicker since
At the time of writing, the Pico W
was available from:
∎ Altronics (Z6424)
siliconchip.au/link/abi5
∎ Digi-Key Electronics (SC0918)
siliconchip.au/link/abgw
∎ Core Electronics (CSE08703)
siliconchip.au/link/abgx
∎ Little Bird Electronics (SC0918)
siliconchip.au/link/abhj
Other retailers we expect might
stock the Pico W when it becomes
available in volume include element14
SC
and Mouser.
SC6625 Kit ($85 + P&P)
includes all parts in the parts list
except the socket headers and DS3231
IC (the DS3231 is available separately
– SC5103 or SC5779).
U Cable Tester
S
B
Test just about any USB cable!
USB-A (2.0/3.2) USB-B (2.0/3.2)
USB-C Mini-B Micro-B (2.0/3.2)
Reports faults with individual cable
ends, short circuits, open circuits,
voltage drops and cable resistance etc
November & December 2021 issue
siliconchip.com.au/Series/374
DIY kit for $110
SC5966 – siliconchip.com.au/Shop/20/5966
Everything included except the case and batteries. Postage is $10 within Australia, see our website for overseas & express post rates
56
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
|