Portable temperature, humidity and pressure sensor using a Raspberry Pi Pico W

Components for this Raspberry Pi project

Hi everyone. It’s been a little while! I’ve been horribly busy with various things, including work, so it’s been difficult to keep up with blogging. I have been posting Pi stuff over on Twitter/X (how I hate that new name!) so if you follow me there, you’ll see I’m still active in the community.

The project

Today, I’d like to show you a project I put together over the weekend of 19th-20th August 2023. I decided I wanted to create a temperature sensor, but a portable, battery-powered one.

The components

I went shopping in the Pimoroni sale and bought the following components:

I chose the LiPo Amigo Pro because I wanted the functionality of it being able to charge and supply power to the Pico at the same time. It means I have the choice between plugging it in or leaving it portable.

Putting it together… Bit by bit…

With the compilation of components laid out, I mentally worked out what I wanted to do.

First of all, I knew that I would need to create a kind of “sandwich” with the Display Pack, the Pico Proto and the Pico W. It was therefore vitally important to work out what to solder, and in what order.

The first thing to do was to put it together “dry” and make sure it would all work together, and that I had the Proto on the right way up! Then, I soldered the BME sensor to the Pico Proto.

As you can see in my slightly-blurred photos (!), I bridged between the 3v3 pin and a vertical rail. This was just in case I needed to add anything else that needed power. As it turned out, I didn’t need this after all, but I’m glad I did anyway. As you can see, the wire wrap split when I soldered it, so I used a pair of tweezers to close it again. Not totally successful, but again, a good idea. You’ll see that I used pins 8 and 9 on the Pico for the I2C connections of the BME. In the event, this was a mistake because the Pico Display Pack uses one of the pins for the RGB LED. Never mind!

I dry-assembled it again and realised that if I used the standard pin headers in the project, because of the soldering of the pins through everything, I’d come up a little short. So, I dug out some extended headers from my parts box and soldered those to the Pico instead.

This gave me enough length to go through the Pico Proto and into the Pico Display Pack with solder in between. I did have to trim all the pins to length, though. I took about half a centimetre off of each pin with a pair of side cutters.

I had looked up which pins I needed to solder the JST lead wires to – VSYS and GND. This sends the battery power directly into the Pico, which can take between 1.8V and 5.5V. The battery pack has a nominal voltage of 3.7V, so that’s bang in the middle. The Pico takes care of converting that into the appropriate voltage for its components. I soldered the wires to the Proto board as well and then set about assembling the sandwich again.

As you can see, there is a fair amount of space for the wires. I think this was before I snipped the pins down to size. The finished article has less space, but not so little as to squash the wires or ground anything out.

I then realised that by doing that, it was impossible to tell if the Pico was working or not because I hadn’t programmed it to do anything! I quickly knocked up an LED blink script in MicroPython using the Pimoroni firmware for the Pico W. To my delight, as you can see above if you look closely, the LED started blinking when powered from the battery. Marvellous! I also added a sensor read-and-print. To my dismay, the sensor failed to initialise! 🙁 After an inspection using a multimeter, I worked out that everything was wired correctly. So what was the problem? It turns out there was a tiny sliver of wire between SDA and SCL on the Proto. I took a big breath and blew, and off it went into the distance. I ran the script again and it worked!

I programmed the full code at this point, but more on that later.

The final thing to do was to assemble everything into a nice, near package. Out came the trusty glue gun. First of all, I glued the LiPo Amigo Pro to the bottom of the battery with the USB-C port on the end. Then, I glued everything else together as you can see below:

And, yes, I did clear the glue strands off afterwards!

The code

First things first: Thank you to whoever at Pimoroni (and I think it was Phil “Gadgetoid” Howard) who did the code for the Pico Display Pack and the BME280 sensor library. I stood heavily on the existing code, and I don’t mind admitting that!

I programmed reading the BME280 sensor then fed the readings into the graphing function, slightly adapted to cope with the multiple sets of data. I also coded in a button handler so that I could switch between temperature, humidity and pressure. You can see the results in the demo video below.

The actual code can be found on GitHub. You’ll see it’s quite simple, but I’m new to MicroPython (I usually use CircuitPython) and it’s all I could manage. You see from the demo video that the graphing of the humidity and pressure isn’t quite right – it’s a maths problem and I haven’t got time to fix it at the moment. If you fancy giving me a hand, leave a comment or a pull request on GitHub! 🙂

Update – 22nd August 2023 – Have used this excellent tutorial from Core Electronics in Australia to use MQTT message publishing and Adafruit IO to create pretty graphs out of the data feeds as you can see below! The code on GitHub is up-to-date. You just need to populate your own secrets.py file! Give me a shout if you get stuck with that bit!

Demo video

Here’s a quick video I shot showing the different graphs so you can see the issues I had.


That’s all, folks! I enjoyed doing this project – it gave me something to do on a boring Saturday and Sunday morning. Further work is to hook up the Pico W to an IoT service (or even via MQTT to a local broker!) so I can remotely see the readings, but that’s a project for another day!

6 comments for “Portable temperature, humidity and pressure sensor using a Raspberry Pi Pico W

  1. Michael,
    Instead of Twitter/X – also Facebook, and WhatsApp, but do use Signal – ) which we will never use any more. Do you not have an Internet Site for your excellent material?

  2. Hi, nice project. One question, my experience is, that the BME 280 is very heat sensitive. How did you calibrate it. I did a similar stuff with a adafruit feather and I had to connect the BME 280 with cables in a distance of 15 cm from the electronic stuff away to get reasonable values (tem).
    My thx

    • Oh really? I wondered why it was a bit on the high side. The answer is: I haven’t calibrated it, but I probably should!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.