Create an access point with the Raspberry Pi Pico W, serve a web-page and flash the on-board LED

Following various examples, I’ve created a MicroPython script that does the following:

  • Create an access point on the Raspberry Pi Pico W.
  • Create a web server.
  • Serve a simple page on that web server.
  • Toggle/flash the on-board LED when that page is loaded/refreshed.

TL;DR – see the code here

Download MicroPython and install it

First of all, you’ll need to download the latest MicroPython UF2. The one I’m using is v1.19.1-108-g474c47d59 (2022-07-08) .uf2 from this page. I found out via the Raspberry Pi forums that there was something broken on versions earlier than the 07-05 one – check out the thread here.

Next, you will need to put the Pico into bootloader mode and then drag the UF2 file to the external device that comes up.

Initial access point

Use Thonny to program the initial code:

import socket
import network

ssid = "PicoW"
password = "123456789"

ap = network.WLAN(network.AP_IF)
ap.config(essid=ssid, password=password) 
ap.active(True)

while ap.active == False:
  pass

print("Access point active")
print(ap.ifconfig())

Despite setting the SSID, to start with I got a generic wi-fi name starting with “PICO”. In order to get PicoW working, I had to power cycle the Pico (rather than just CTRL-D and run again). This is behaviour described here on the RP forums.

I tried connecting to it using my mobile and success – I could connect to the access point, but had no Internet (as expected, obviously).

Serving a web page

Now, I want to serve a web page of some kind from the Pico W, otherwise it’s pretty useless. What’s the point in having an access point that does nothing?

I found this MicroPython library called tinyweb which is like Flask, but for MicroPython instead of full-blown Python. This I can use to establish “routes” which will deliver specific content via the web browser.

tinyweb requires, as it says in the README, the logging library. I had to scratch around to find that, so here it is.

I uploaded the tinyweb folder and the logging.py file to the PicoW and added

import tinyweb

at the top of the code. This ran correctly, so I then looked at the tinyweb documentation for how to create a web server.

I added some more code (which you can see on my own GitHub repo – WordPress is doing VERY weird things if I paste it in here!)

I connected to the AP again using my phone, turned off mobile data to make sure it didn’t try and serve content from the Internet, and then accessed http://192.168.4.1/ (which had been printed to the REPL which I could see because I was using Thonny).

To my surprise, I got Hello world! on the browser. Yay! It works!

Flash the onboard LED

I added the definition of the onboard LED:

led = Pin("LED", Pin.OUT)

and set the / path of the tinyweb web server to toggle it on and off.

Now, when I refresh the Hello World page, the LED goes on and off. Wonderful!

See the code on GitHub.

Raspberry Pi Pico W launched – build your Internet of Things projects much easier!

Image from Raspberry Pi

Raspberry Pi has today launched the Raspberry Pi Pico W (see the official announcement here).

This uses the same RP2040 chip as the regular Pico but has wi-fi built into it! This is going to get eaten up by the Internet of Things crowd and, at $6 (£6 ish), it is incredibly good value for money!

You can buy a Pico W from Pimoroni and of course from The Pi Hut and there are other resellers out there too.

Pimoroni have got ahead of the game (as usual) by developing several Pico-with-wireless boards and add-ons. My favourite is the Inventor 2040 W which has motor drivers, audio and breakouts (as well as wi-fi) onboard. Good job, folks! There are also other sensor/IoT based boards in the works and the e-ink boards are already available. Best place to go is the New Products page.

You can read a review of the Pico W by Les Pounder here and there’s a new issue of The MagPi out covering the launch. If you’re on Twitter, other coverage will come out over the day, I’m sure.

Opinion

£6? That’s ridiculous for an IoT platform with the kind of support and quality that Raspberry Pi puts out. The RP2040 is a great chip and the 2MB of onboard memory is just enough for most uses, although 4MB wouldn’t have gone amiss (I appreciate it wouldn’t have been £6 then, but I can wish!) Go and buy one if you need the wi-fi connectivity or a cheap Bluetooth device (when the software catches up). Well done, Raspberry Pi – this one is going to go like hotcakes!

Raspberry Pi Zero 2 W launched! More processor power in a small package!

Raspberry Pi Zero 2 close-up, front side

Fans of the Raspberry Pi Zero can today get excited about a new Raspberry Pi product – the Raspberry Pi Zero 2 W.

TL;DR – it’s got the Pi 3B processor, 512MB of RAM and is a lot speedier than the original Zero/Zero W.

New processor

The big headline improvement to the Zero is that the Pi Zero 2 W uses the same processor as the Raspberry Pi 3.

In technical terms, RP3A0 is a SiP that combines the BCM2710A1 die used in BCM2837A1 – which was used in the Raspberry Pi 3 – and a 4Gbit Micron LPDDR2 die along with the decoupling capacitors required to smooth the core supply voltage.

Raspberry Pi Zero 2 - chip package

The new Zero 2 chip is a quad-core, 64-bit processor, a massive increase in processor power over the original Zero/Zero W which uses the single core Raspberry Pi 1 processor. The processor is only set to 1 GHz to avoid overheating issues, but could be overclocked to 1.4 GHz (the same as the Pi 3B) with adequate heat dissipation. I’m sure someone will come out with a case that will allow you to do just that!

Same memory size, new package

Also on-board is 512MB of RAM. This has been packed into a new “substrate package” developed by Raspberry Pi to allow it to work with the new processor, making it their second home-grown silicon package (after the Raspberry Pi Pico).

The Pi Zero 2 W has WiFi onboard, but this time it is packaged into a “can” which means the whole Pi Zero 2 is conformance-tested, making it much easier to develop full products with the Zero 2 W embedded. As you can see from the image above, because the silicon package was developed by Raspberry Pi, you get the Pi logo on top, which is nice.

The board comes without a 40-pin header (so blame me for the soldering below!).

Raspberry Pi Zero 2 close up, reverse

Same form-factor

The form-factor of the Pi Zero 2 W is the same, although some components have moved so cases that expect components not to move (like the Pimoroni PiBow) might not fit properly. My usual choice for the Zero (the £6 “Premium Raspberry Pi Zero Case” from The Pi Hut) housed the new board nicely, however, because it allows for flexibility of components.

I was also happy to see the continued inclusion of the Zero-sized camera connector. This is still a very fragile connector, although necessary because of the board size.

Existing models

It’s expected that the original Pi Zero and Pi Zero W will still be available to purchase for the near future.

Cost and getting the board

The baseline price of the Raspberry Pi Zero 2 W is $15 (because they source the parts in dollars, in case you didn’t know!). That works out to just over £13 in the UK. They are limited to one-per-customer, as per usual with the Zero. This stops eBay scammers grabbing them all and makes things fairer, although this may be frustrating for some people, also as per usual with the Zero.

For those buying in the UK:

For those buying in the EU:

For those buying in North America:

For those buying in the Rest of the World

(I will add other resellers as I pick up their website addresses).

Extras

In practice

When I used the Pi Zero 2 W, I first of all did a full update/upgrade. Once that was done, it took less than 30 seconds to boot up into the desktop. Impressive considering the amount of memory on-board. Web browsing felt sluggish (because of the lack of memory), but I’m told that the Zero 2 isn’t really built for that (although it would do it at a push – I managed to post to the Raspberry Pi Forums from it without much bother!). I tested out the GPIO pins, including an I2C and SPI test and everything “just worked”.

I do wish that the Pi Zero 2 had 1GB, but maybe that would make it “too capable” and eat into the usage and sales of the Pi 4.

Bottom line: A very nice little board and is well worth the extra cost.

Other opinions and blog posts

As usual, I’ll pick up other coverage and link to it as the day progresses. Check back later for links to more opinions!

Review of the Cytron Technologies Maker Pi RP2040 – a motor controller board at the start of your robotics journey

Last in my mailbag of Cytron Technologies goodies, this is the Maker Pi RP2040. It has clearly been designed to get you going with your robotics journey and to give you the ability to add all sorts of inputs and outputs into a project, centered around the new RP2040 microcontroller chip from Raspberry Pi.

TL;DR – great for beginners, plenty of inputs and outputs, easy to power. Another winner from Cytron.

What’s in the box?

You get the Maker Pi RP2040 board and also 4 Grove-to-female-header cables, some rubber feet and, handily, a small Phillips screwdriver – that saved me digging my own screwdriver out, and it’s a nice something for the newbies who don’t have a collection of tools.

What can the board do?

Let’s first of all look at your input/output options:

  • 7 x Grove sockets – you can plug in any compatible Grove modules, or you can use the four included cables to hook up any generic sensors, outputs, inputs, whatever you like!
  • 2 x DC motor outputs – allowing you to drive 2 motor outputs forwards and backwards independently at up to 1A per channel (1.5A peak). Also on-board are four test buttons that allow you to get your motors moving and check they work without any programming.
  • 4 x servo motor outputs – for fine motor control.
  • 1 x piezo buzzer – so you can play beeps and other sounds (this can be disabled completely by an on-board switch).
  • 2 x Neopixel-style user-controllable RGB LEDs.
  • A collection of low-power LEDs in-line with all the input/output ports so that you know what has been activated (and who doesn’t like blinkies?)
  • 2 x user-defined buttons – perhaps you can use these to put your robot into different modes…?
  • A Run/reset button and a Boot button.

If you want to take a look at the Datasheet, you can find it here.

Let’s talk about power

In terms of powering the board and the motors, you have three options:

  1. Supply power through the microUSB socket (very handy when you’re testing things out and programming at the same time).
  2. Supply power via a single-cell 3.7V LiPo battery. (The microUSB input will charge your LiPo as well, with overcharge and undercharge protection built-in).
  3. Supply power via the screw terminals between 3.6V and 6V (the max is equivalent to 4 x non-rechargeable AA batteries, but you can, of course, use rechargeable ones instead).

All the power is handily isolated by an on-board power switch so if you just need to shut the thing off, one click and you’re done.

Having a play

I hooked up two 6V DC motors to the board using the screw terminals (thanks again for the screwdriver!) then used the test buttons to make them run. Excitingly, it “just worked”. I then used the pre-loaded demo script to automatically “turn the robot on the spot” (which it would have done had I not elevated the wheels before I hit the button!). You can see a short demo video of it working below:

 

I also hooked up a servo and used the demo script to turn it back and forth. These are small steps, but vital ones, as it proves that everything works and you’re ready to embark on your future exploits.

Speaking of which, Cytron have provided a GitHub repository to help you, full of demo scripts for both CircuitPython (which is pre-installed) and MicroPython.

You can see the code for the pre-loaded demo here. As you can see, for DC motors you simply use the pwmio library to define the motors and then trigger them. For servos, they are using Adafruit’s adafruit_motor/servo library. Normally, I’d criticise them for not building their own library, except a) why re-invent the wheel? and b) they’re using CircuitPython for this anyway, and Adafruit invented that!

What did I think?

I think this is an excellent board for beginners. With the ability to hook motors up, provide power and then just click a button to test the motors out, you get the instant gratification that both kids and adults love. Programming the RP2040 is easy (especially using CircuitPython) and if you added on, say, a Cytron line following sensor (which might be a bit “cable-y” using the Grove sockets, admittedly), it’s clear to see how you could create a line following robot, as an example, quite simply.

The only caveat I really have with the board is that, because it’s all very centred around the 7 Grove sockets, there’s no direct access to the GPIO ports. Sometimes, you just want to hook something up without needing a special cable to do it. Now, they obviously provide 4 of these “special cables” to enable you to do that, which is very handy, but having (even unpopulated) headers for the pins might’ve made things even more flexible. Of course, the board is 85mm x 60mm (approx), and that small size is very attractive. There are always trade-offs, though, in any product, and it doesn’t stop me recommending it, it’s just something to be aware of.

The three power options are very flexible, and it’s good to see a LiPo port on there, even if beginners probably shouldn’t use them to start with. Adding the charging circuitry in, though? Very good move from Cytron, there.

I do keep mentioning that it is for beginners. Well, at 1A per channel, it’s not going to blow anyone away in terms of sheer power. Having said that, as a trade-off, you can run 6 motors independently, so one shouldn’t complain! They have a lovely range of other motor controller boards able to provide more grunt, so there is a clear path to change your method later when you get more advanced.

Overall, it’s a solid 9/10, I think, and a great use of the RP2040 chip.

Another winner from Cytron – highly recommended.

For another take on the same board, I suggest having a look at Les Pounder’s review over at Tom’s Hardware.

Where can I get it?

In Malaysia and surrounding countries, go directly to the Cytron website where the board is available for $9.90.

In the UK, I recommend The Pi Hut where it is listed at £9, but I notice they are currently out of stock. There is a notification email list, though.

In the USA, I suggest Adafruit who I believe are getting stock in very soon and selling for $12.50.

Other resellers are listed on the Cytron page near the bottom, above the reviews.

Review of the Maker Pi Pico from Cytron Technologies – a Raspberry Pi Pico project board worth your time

Also in my review box from Cytron (along with yesterday’s Edu:Bit) was a Maker Pi Pico. This is a board that houses a Raspberry Pi Pico and measures approximately 95mm x 70mm. The version I’ve got is the ordinary Maker Pi Pico, but there is also a Maker Pi Pico Base which just has a slot for a Pico that you may already own.

The idea of this board is to make it simpler to add components onto a project, but still keep it to a manageable size.

TL;DR – a great add-on home for your Raspberry Pi Pico at a great price. Find out where to buy it at the bottom of the post!

Features

It has the following features:

  • 6 Grove-compatible sockets for adding on inputs and outputs via Grove cables.
  • An SD card slot (so you can read and write files).
  • A 3.5mm audio output jack and a (fairly loud) buzzer for playing simple sounds (and, thank God, a small switch to disable the buzzer!).
  • Low-power LEDs on every pin so you can see what’s happening, input and output-wise.
  • A socket for an ESP-01 wi-fi module.
  • 3 user-defined buttons.
  • A RUN (reset) button.
  • A single Neopixel-style RGB LED.
  • A header that breaks out the debug pins and also allows you to wire up your own RUN/reset button.
  • All the Pico pins broken out as pin headers.

That’s quite a list, I think you’ll agree. They also provide lots of demo scripts to use when trying it out, so the software is “there”, too. These scripts come in both CircuitPython and MicroPython flavours, although the board is pre-loaded with CircuitPython. This is a wise choice – CP does give you a much easier way to develop – just drop the files on the “drive” that you get when the Pico is plugged in and away you go.

Initial impressions

What I liked about it most initially was that they have been very smart in deciding which pins to break out as Grove sockets. They have chosen lots of I2C but also chosen to break out two of the Pico’s analog pins as a Grove socket. Handy, because that means you can use Grove modules like a potentiometer. It’s an attractive board, too, in its purple colour and everything is well-labelled and well-engineered.

Experiments

Cytron were kind enough to send me a Grove OLED module and a Grove potentiometer module too, so I had a play with one of their demo scripts that shows the value of the pot on the OLED.

As you can see, the board also comes with a nifty pin reference card – very handy for looking up what pin does what quickly.

I did try and get the SD card reading and writing, but for some reason it didn’t recognise my card. I suspect this is just something to do with the card I was using, so I’ll try a different one at a later date.

The buzzer is certainly loud – the pre-loaded demo code plays the Mario theme immediately upon boot. Fortunately (and I can’t stress this enough), they’ve been good enough to provide a shut-off button for the buzzer! The audio jack is a nice touch for higher fidelity sound playing.

The three user-defined buttons, which are linked to GPIO pins 20, 21 and 22, are satisfyingly clicky and the Neopixel-like RGB LED is appropriately blinky. 🙂

Experiments in Wi-Fi

Cytron also sent over a cheap ESP-01 module which allows you to connect the Maker Pi Pico to the Internet. There is a socket on-board (bottom-right) for the module. They were good enough to give me some support in getting it going and I was soon able to ping an IP address by providing wi-fi credentials in a supplied template “secrets” file.

Quick instructions: The demo scripts are on their GitHub here. I renamed simpletest.py to code.py, uploaded that and the lib folder to the Pico then altered secrets.py to give it my own credentials.

Overall

I had a very satisfying experience with this product, overall. The SD card issue I’m sure waseither down to the card, or the way it was formatted, so I will see about that later on. Price-wise, the board is very competitive. On the Cytron site, it’s $9.90 including the Pico. Elsewhere, it can be found on The Pi Hut’s site for £11.50 with the Pico, or £8 for the Base version. It is also available from Kitronik (just the Base version) and you can find other international resellers on the Cytron page, at the bottom.

It’s a great board at an attractive price and it gives you really great options for getting going with the Pico if you don’t want to use jumper cables on the Pico’s pins (although that option is still available to you!). Great features, great price, great idea. What’s not to like?!

Review of the Cytron Technologies Edu:Bit STEM and Coding kit

SC Lim of Cytron Technologies was kind enough to send me a review sample of their Edu:Bit, which is based around the micro:bit. Originally a successfully-funded Kickstarter, the Edu:Bit is, primarily, a large, red circuit board which houses a micro:bit and various sensors, a motor controller and some other bits and pieces. The joy in this kit, however, is not so much the technology but is instead the great printed educational material that comes with the kit.

TL;DR – If you want to get into physical computing using the micro:bit, this kit is superb. See the bottom of the post for retailers.

The packaging

You know I like a good bit of packaging, and here it is!

The Edu:Bit comes in a sturdy box containing the physical book, additional cardboard “props”, the Edu:Bit circuit board itself plus other components including a servo motor, a DC motor and a load of Grove plug-in connectors. The plastic housing inside is strong enough that it will keep all the hardware safe for quite a while.

The hardware

The PCB that is the actual Edu:Bit is large at 16cm x 12cm, but that does make it kid-friendly. Everything is well labelled, as you can see. The micro:bit (which comes with the kit) is a version 2 and slots in the top. Cleverly, there is a cut-out behind the micro:bit giving access to the physical on-board reset button. The supplied cable has a USB plug that goes into your computer on one end and then a microUSB plug for programming the micro:bit and a barrel jack to power the Edu:Bit board and (primarily, I suspect) any motors that you may use. You can see the input sensors and outputs in the picture above. Sensibly, they have replicated the A and B buttons from the micro:bit into two big-capped buttons on the bottom right. This puts everything “together” at the bottom of the Edu:Bit. Of particular note is the sound output board bottom left which has an audio jack output which can be switched to using the INT/EXT switch. This really is an excellently-conceived kit – with all those inputs and outputs, you’ve got everything for a group of students (whether home or school-based) to explore the wonderful world of physical computing.

The bits and pieces are all programmable using the usual MakeCode block interface, so that’s wonderfully familiar if you’ve used a micro:bit before and a great way to start with visual programming.

Just as an aside: the sensors can all be broken off to be used with the Grove cables. I didn’t, because I want to keep it intact, but it’s a great way to allow you to take the pieces and put them inside something else, for instance a 3D printed case.

The additional components

Together with the main Edu:Bit, there is a servo motor, a DC motor, some Grove connector cables and some servo-compatible plastic pieces.

The prize of the package – the printed book!

I know I’m prone to gushing with praise occasionally, but in this instance the book that comes with the Edu:Bit is truly worthy of that praise. First of all, the book is the ideal thickness to be not-overwhelming for kids, but it’s no 10-page pamphlet. As you can see above, this has a proper spine, is about 6mm thick and is 126 pages long! It’s also, thank goodness, full colour which means that the appeal to kids continues inside…

The instructions are clear, with just enough help for a visual programming novice (which, as it turns out, is good because I’m *still* a bit clueless when it comes to visual stuff! 🙂 )

Obviously, it takes you through using all of the components on the Edu:Bit – and there is plenty of learning material here. My particular favourite chapter is the music chapter which gives you enough music theory knowledge to make up simple tunes using the on-board speaker (or audio jack) as an output. I was particularly impressed with the extra pages that challenge the reader to carry out a programming task without giving them much help apart from hints as to the way forward. Very good, because it means you have different challenges for different levels of skills, which is great for the classroom, for example. There’s a bonus chapter on using the radio functionality of the micro:bit to communicate with a second micro:bit that I really liked, too.

Reassuringly, the content has been tested by a 7-year old, as the book proudly proclaims!

As well as the book, you also get some cardboard components which are used throughout:

As you can see, there’s a Twister board and there’s also Snakes and Ladders – all great examples of the gamification of the learning, which is very encouraging and, obviously, aimed at children.

Conclusion

This really is a first-class box of fun for youngsters who want to take the leap into physical computing.

From the retail packaging to what is contained inside, Cytron have just got everything right.

I cannot recommend this kit enough – the amount of learning available is amazing, and it’s so well-produced.

Sorry to be so gushing but… No, I’m not really – good job, folks. Cytron Technologies has a winner.

Buying the Edu:Bit

Please note: some of the retailers do not supply the micro:bit with the Edu:Bit, so just keep an eye out for that.

If you’re in the USA, try RobotShop for the Edu:Bit or DigiKey.

In the UK, you can find the Edu:Bit at the following outlets: The Pi Hut, Kitronik and the UK arm of RobotShop.

If you’re in the Far East, you can find the Edu:Bit on the Cytron Technologies website.