Raspberry Pi Zero W for new Projects
By EricMesa
- 5 minutes read - 930 wordsThe next project I wanted to work on was to see if maybe my environment monitoring might be slightly more reliable with a Raspberry Pi than with an Arduino. So I wanted to do some comparisons. For my bathroom IoT project, I am using:
- Arduinio MKR Wif i 1010 - $32.10
- Arduino MKR ENV Shield - $34.40
- 5V 2.5A power supply - $7.50
That’s a total of $74 before taxes and shipping. To get the same measurements on the Pi platform I went with:
- Raspberry Pi Zero W (with headers attached) - $14
- 8 GB memory card - $9.95
- 5V 2.5A power supply - $7.50
- Pimoroni Environmental Monitor Hat - $34.95
That’s a total of $66.4 before taxes and shipping. In a way, that’s pretty incredible because the Raspberry Pi kicks the Arduino’s pants off when it comes to computing power specs. Also, the Pimoroni Env Hat has a screen to display whatever you want - on the product page it shows a graph of the data being measured. It also has a button. It’s also basically the same size:
Raspberry Pi Zero W size comparison with Arduino MKR Wifi 1010Raspberry Pi Zero W size comparison with Arduino MKR Wifi 1010
In fact, this whole endeavor has really made me think a lot about how to decide which boards to use for various projects. On the one hand, the Raspberry Pi (any version or revision) is going to be easiest to program and debug. On the programming end, you can use pretty much any programming language you are familiar with - from Python to Rust to Go. On the debugging end, you can plug it into a monitor via HDMI. You can SSH into it (as long as it’s connected to Wifi). If you’ve designed your project to do so, you can check log files. It’s got a lot more RAM and it’s got as much storage space as you want to add via an SD card. Arduino, on the other hand, needs to be programmed in its C variant. (Although Adafruit’s boards - and many others - can run Circuit Python) For debugging, I had to add on a breadboard with some LEDs so I could tell what was going on. Because sometimes plugging it into a laptop to debug is either impractical (vs using SSH with a Raspberry Pi) or sometimes changes enough about what’s going on to mask the issue. And, as you can see above, when you’re looking at a Raspberry Pi Zero or Zero W, you’re looking at the same footprint (that is to say that they take up the same space in your project)
Raspberry Pi Zero W
Of course, there are reasons people use Arduinos and Adafruit Feathers (and other boards). For starters, while debugging is easier with a Raspberry Pi (it’s running a whole freakin’ Linux disto), it’s also harder with a Raspberry Pi (because it’s running a whole freakin’ Linux distro!). To give an example, I bought a Raspberry Pi 4 for my daughter to use as a jukebox running Mopidy. After doing an update of the system, something changed in the libraries and the way they handled outputs that made it stop working. It was a week of work to try and figure out what went wrong. (And I wouldn’t have figured it out without help on the Mopidy forums) By contrast, an Arduino is (to simplify a bit) ONLY running your code. With the exception of firmware upgrades for various chips, there’s nothing to update. If you code works now, it will always work unless you change something about your code. Speaking of always working - that brings me to one of the reasons I wanted to write this post; sometimes the Raspberry Pi can be quite fragile. I didn’t have a 5V 2.5A power supply available (the minimum recommended by the Raspberry Pi foundation). So I used a 5V 2A charger. When I did a shutdown, it needed a little more power and so the card became corrupted and I had to reflash it. At least, I was able to switch to Raspbian Lite which dumps you straight to the console. No need to waste space and RAM on an OS desktop if it’s going to just be measuring environmental data. Back to reasons you might use an Arduino, Feather, etc - they’re generally referred to as prototype boards. Because they’re so simple, if you end up using them to build something useful, you can then use that to get a single board printed with exactly the chips and connections you’re using from the Arduino board - and that’s a pretty powerful preposition. Also, generally speaking, a power outage is not going to screw up your program as it can cause corruption on Raspberry Pi from not shutting down correctly.
Going forward, I’m not 100% sure what I’m going to choose, but I imagine it will depend on a variety of features. Do I need it to survive power failures? Is it a one-off or something I might want to duplicate? Do I want to challenge myself with C(ish) code or just do something easy with Python? How much money do I have for my build? And do I care about needing to update libraries to keep my network safe?
I don’t get as many comments on my posts nowadays - partly because the internet culture has shifted to commenting on Reddit, Facebook, Hackaday, etc, but if you are a fellow maker, I’d love to hear your decision-making process when trying to select a board for a project.