Raspberry Pi Blog

This is the official Raspberry Pi blog for news and updates from the Raspberry Pi Foundation, education initiatives, community projects and more!

Pulling shower thoughts from Reddit for a Raspberry Pi e-paper display

The Reddit users among you may already be aware of the Shower Thoughts subreddit. For those of you who aren’t, Shower Thoughts is where people go to post the random epiphanies they’ve had about life, the universe, and everything. For example:

YouTuber ACROBOTIC is a fan of the Shower Thoughts subreddit. So much so that they decided to program their Raspberry Pi to update an e-paper HAT with the subreddit’s top posts from the last hour.

Raspberry Pi 4 Scrape JSON Data w/ Python And Display It On e-Paper | reddit /r/showerthoughts

$2 for PCB prototype (any color): https://jlcpcb.com/ ========== * Your support helps me post videos more frequently: https://www.patreon.com/acrobotic https://www.paypal.me/acrobotic https://buymeacoff.ee/acrobotic BTC: 1ZpLvgETofMuzCaKoq5XJZKSwe5UNkwLM ========== * Find me on: https://twitter.com/acrobotic https://facebook.com/acrobotic https://instagram.com/acrobotic ========== * Parts & supplies: https://acrobotic.com/shop https://amazon.com/shops/acrobotic ========== In another video we setup a Raspberry Pi to control an e-Paper/e-Ink HAT and running demo code.

For their build, they used a three-colour e-paper display, but you can use any e-paper add-on for Raspberry Pi to recreate the project. They also used Raspberry Pi 4, but again, this project will work with other models — even Raspberry Pi Zero W.

ACROBOTIC created an image to frame the Shower Thoughts posts, which they uploaded to their Raspberry Pi as a .bmp file. They altered prewritten code for using the e-paper display to display this frame image and the various posts.

Adding .json to the URL of the appropriate Shower Thoughts page allows access to the posts in JSON format. Then a request can be set up to pull the data from this URL.

ACROBOTIC goes into far more detail in their video, and it’s a great resource if you’re looking to try out working with JSON files or to learn how to pull data from Reddit.

Find more projects using e-paper displays for you to recreate in our handy guide.

5 Comments

Raspberry Pi Sense HAT impact recorder for your car

Let the accelerometer and gyroscope of your Raspberry Pi Sense HAT measure and record impact sustained in a car collision.

Raspberry Pi Sense HAT

The Raspberry Pi Sense HAT was originally designed for the European Astro Pi Challenge, inviting schoolchildren to code their own experiments for two Raspberry Pi units currently orbiting the Earth upon the International Space Station.

The Sense HAT is kitted out with an 8×8 RGB LED matrix and a five-button joystick, and it houses an array of useful sensors, including an accelerometer and gyroscope.

And it’s these two sensors that Instructables user Ashu_d has used for their Impact Recorder for Vehicles.

Impact Recorder for Vehicles

“Impact Recorder is designed to record impact sustained to a vehicle while driving or stationary,” Ashu_d explains. Alongside the Raspberry Pi and Sense HAT, the build also uses a Raspberry Pi Camera Module to record footage, saving video and/or picture files to the SD card for you to examine after a collision. “The impacts are stored in the database in the form of readings as well as video/picture.”

By following Ashu_d’s Instructables tutorial, you’re essentially building yourself a black box for your car, recording impact data as the Sense HAT records outside the standard parameters of your daily commute.

“Upon impact, remote users can be verified in real time,” they continue, “and remote users can then watch the saved video or take remote access to the Pi Camera Module and watch events accordingly.”

Ashu_d goes into great detail on how to use Node-RED and MQTT to complete the project, how you can view video in real time using VLC, and how each element works to create the final build over at Instructables.

1 Comment

Playing Snake on a Raspberry Pi word clock

I have a soft spot for Raspberry Pi word clocks. True, they may not be as helpful as your standard clock face if you need to tell the time super quickly, but at least they’re easier to read than this binary clock built by engineerish.

“But Alex,” I hear you cry, “word clocks are so done. We’re over them. They’re so 2018. What’s so special about a word clock that you feel it to be worthy of a blog post?”

And the answer, dear reader, is Snake, the best gosh darn game to ever grace the screen of a mobile phone, ever — sorry, Candy Crush.

If you’re looking to build a word clock using your Raspberry Pi, here’s a great tutorial from Benedikt Künzel. And, if you’re looking to upgrade said word clock to another level and introduce it to Snake, well, actually, there isn’t a tutorial for that, yet, but there’s a whole conversation going on about it on Reddit, so you should check that out.

There is, however, a tutorial for coding your own game of Snake Slug on the Raspberry Pi Sense HAT here. So give that a whirl!

Until tomorrow, fair reader, adieu.

No Comments

Rather lovely Raspberry Pi time lapses

Having just sat and watched this gorgeous time lapse of a Finnish lake, we thought it would be nice to finish off the working week with a collection of lovely Raspberry Pi Camera Module time lapses.

Summer over a Finnish lake

Summer time lapse over a Finnish lake.

Time lapse over a Finnish lake from July 2019. Shot with a DIY all-weather HDR time-lapse camera built from ZWO ASI 224MC and Raspberry Pi 3. The camera was built to function as an all-sky camera for recording the night sky year round but since in July the stars were not visible in Finland I decided to test it aimed horizontally over a lake and was positively surprised about the results.

Time-lapse over a Finnish lake from July 2019. Shot with a DIY all-weather HDR time-lapse camera built from ZWO ASI 224MC and Raspberry Pi 3.

Six days of cress growth

Cress Seeds Growing Raspberry Pi Time Lapse Video

Filmed over 6 days using a Raspberry Pi Zero W and Raspberry Pi Camera. Once photo taken every 5 minutes and then played back at 24 fps. I removed the night time photos and then the images were stitched together using the ‘Stop Motion’ app on an iPhone.

Filmed over 6 days using a Raspberry Pi Zero W and Raspberry Pi Camera. Once photo taken every 5 minutes and then played back at 24 fps.

Growing salad

Salad Growth | Timelapse | Raspberry Pi Camera | PiMeetsPlants

Timelapse about salad growth. Period of Picture Making: 03-04 to 02-05-2016 Camera has shot 2087 pictures in a distance of 20 minutes. Camera: Raspberry Pi Camera Module Music: Valesco – Stay With Me: http://soundcloud.com/valesco_official/stay-with-me Valesco on Soundcloud: http://soundcloud.com/valesco_official My Links: Website: https://pimeetsplants.com Twitter: https://twitter.com/PiMeetsPlants Google+: https://plus.google.com/+Pimeetsplants

I think I have a thing for time-lapse videos of plant growth. They’re just so friggin’ cool!

Skyline time lapse

Skyline Timelapse: Day to Night l SainSmart FOV160° Raspberry Pi Camera

More info : https://www.sainsmart.com/products/wide-angle-fov160-5-megapixel-camera-module-for-raspberry-pi FOLLOW US Twitter: https://twitter.com/Sain_Smart Facebook: https://www.facebook.com/SainSmart/ Instagram: https://www.instagram.com/sainsmart/

A time lapse of slime

PHYSARUM MACHINE

Summer Project 2018 – Computational Arts MA, Goldsmiths University London. Time-lapse footage of Physarum Polycephalum captured with Raspberry Pi and IR camera, slit-scan program in Open Frameworks.

Summer Project 2018 – Computational Arts MA, Goldsmiths University London. Time-lapse footage of Physarum Polycephalum captured with Raspberry Pi and IR camera, slit-scan program in Open Frameworks.

Setting up the Raspberry Pi Store, Cambridge

Setting up the Raspberry Pi Shop, Cambridge

Given that we had access to a bunch of Raspberry Pis, we thought that we should use some of them to get some timelapse footage of the shop being set up. Read more about the Raspberry Pi shop on our blog: http://rpf.io/ytstoreblog

We couldn’t help ourselves. When the time came to set up the Raspberry Pi retail store in Cambridge, we just had to install a time-lapse camera in the corner.

Technically…

While this time lapse wasn’t taken with a Raspberry Pi Camera Module, the slider moving the camera was controlled using Raspberry Pi. That counts, right?

The Burren

The Burren is a karst landscape region in north-west Co. Clare in Ireland. It is one of the largest karst regions in Europe. I have been photographing The Burren over the last 5 years, and recently got into time lapse photography. The Burren was an obvious place for me to do this first video.

The Burren is a karst landscape region in north-west Co. Clare in Ireland. It is one of the largest karst regions in Europe. I have been photographing The Burren over the last 5 years, and recently got into time-lapse photography. The Burren was an obvious place for me to do this first video.

Your turn

Want to set up your own Raspberry Pi time-lapse camera? Our handy guide shows you how.

Do you have a time-lapse video you’d like to share with us? Then please post your link in the comments below.

15 Comments

Create your own arcade-style continue screen | Wireframe #19

Raspberry Pi’s Rik Cross shows you how to create game states, and rules for moving between them.

Ninja Gaiden’s dramatic continue screen. Who would be cruel enough to walk away?

The continue screen, while much less common now, was a staple feature of arcade games, providing an opportunity (for a small fee) to reanimate the game’s hero and to pick up where they left off.

Continue Screens

Games such as Tecmo’s Ninja Gaiden coin-op (known in some regions as Shadow Warriors) added jeopardy to their continue screen, in an effort to convince us to part with our money.

Often, a continue screen is one of many screens that a player may find themselves on; other possibilities being a title screen or an instruction screen. I’ll show you how you can add multiple screens to a game in a structured way, avoiding a tangle of if…else statements and variables.

A simple way of addressing this problem is to create separate update and draw functions for each of these screens, and then switch between these functions as required. Functions are ‘first-class citizens’ of the Python language, which means that they can be stored and manipulated just like any other object, such as numbers, text, and class instances. They can be stored in variables and other data types such as lists and dictionaries, and passed as parameters to (or returned from) other functions.

the continue screen of SNK’s Fantasy

SNK’s Fantasy, released in 1981, was the first arcade game to feature a continue screen.

We can take advantage of the first-class nature of Python functions by storing the functions for the current screen in variables, and then calling them in the main update() and draw() functions. In the following example, notice the difference between storing a function in a variable (by using the function name without parentheses) and calling the function (by including parentheses).

[Ed. comment: We have to use an image here because WordPress doesn’t seem to allow code indentation. We know that’s annoying because you can’t copy and paste the code, so if you know a better solution, please leave us a comment.]

The example code above calls currentupdatefunction() and currentdrawfunction(), which each store a reference to separate update() and draw() functions for the continue screen. These continue screen functions could then also include logic for changing which function is called, by updating the function reference stored in currentupdatefunction and currentdrawfunction.

This way of structuring code can be taken a step further by making use of state machines. In a state machine, a system can be in one of a (finite) number of predefined states, and rules determine the conditions under which a system can transition from one state into another.

Rules define conditions that need to be satisfied in order to move between states.

A state machine (in this case a very simplified version) can be implemented by first creating a core State() class. Each game state has its own update() and draw() methods, and a rules dictionary containing state:rule pairs – references to other state objects linked to functions for testing game conditions. As an example, the continuescreen state has two rules:

  • Transition to the gamescreen state if the SPACE key is pressed;
  • Transition to the titlescreen state if the frame timer reaches 10.

This is pulled together with a StateMachine() class, which keeps track of the current state. The state machine calls the update() and draw() methods for the current state, and checks the rules for transitioning between states. Each rule in the current state’s rules list is executed, with the state machine updating the reference to its current state if the rule function returns True. I’ve also added a frame counter that is incremented by the state machine’s update() function each time it is run. While not a necessary part of the state machine, it does allow the continue screen to count down from 10, and could have a number of other uses, such as for animating sprites.

Something else to point out is the use of lambda functions when adding rules to states. Lambda functions are small, single-expression anonymous functions that return the result of evaluating its expression when called. Lambda functions have been used in this example simply to make the code a little more concise, as there’s no benefit to naming the functions passed to addrule().

State machines have lots of other potential uses, including the modelling of player states. It’s also possible to extend the state machine in this example by adding onenter() and onexit() functions that can be called when transitioning between states.

Here’s Rik’s code, which gets a simple continue screen up and running in Python. To get it working on your system, you’ll need to install Pygame Zero. And to download the full code, visit our Github repository here.

Get your copy of Wireframe issue 19

You can read more features like this one in Wireframe issue 19, available now at Tesco, WHSmith, and all good independent UK newsagents.

Or you can buy Wireframe directly from Raspberry Pi Press — delivery is available worldwide. And if you’d like a handy digital version of the magazine, you can also download issue 19 for free in PDF format.

Make sure to follow Wireframe on Twitter and Facebook for updates and exclusive offers and giveaways. Subscribe on the Wireframe website to save up to 49% compared to newsstand pricing!

4 Comments

Build Demolition Man’s verbal morality ticketing machine

In the 1993 action movie Demolition Man, Sylvester Stallone stars as a 1990s cop transported to the near-future. Technology plays a central role in the film, often bemusing the lead character. In a memorable scene, he is repeatedly punished by a ticketing machine for using bad language (a violation of the verbal morality statute).

In the future of Demolition Man, an always-listening government machine detects every banned word and issues a fine in the form of a receipt from a wall-mounted printer. This tutorial shows you how to build your own version using Raspberry Pi, the Google Voice API, and a thermal printer. Not only can it replicate detecting banned words, but it also doubles as a handy voice-to-paper stenographer (if you want a more serious use).

Prepare the hardware

We built a full ‘boxed’ project, but you can keep it simple if you wish. Your Raspberry Pi needs a method for listening, speaking, and printing. The easiest solution is to use USB for all three.

After prototyping using Raspberry Pi 4 and various USB devices, we settled on Raspberry Pi Zero W with a small USB mic and Pimoroni Speaker pHAT to save space. A Pico HAT Hacker allowed the connection of both the printer and Speaker pHAT, as they don’t share GPIO pins. This bit of space-saving means we could install the full assembly inside the 3D-printed case along with the printer.

Connect the printer

To issue our receipts we used a thermal printer, the kind found in supermarket tills. This particular model is surprisingly versatile, handling text and graphics.

It takes standard 2.25-inch (57mm) receipt paper, available in rolls of 15 metres. When printing, it does draw a lot of current, so we advise using a separate power supply. Do not attempt to power it from your Raspberry Pi. You may need to fit a barrel connector and source a 5V/1.5A power supply. The printer uses a UART/TTL serial connection, which neatly fits on to the GPIO. Although the printer’s connection is listed as being 5V, it is in fact 3.3V, so it can be directly connected to the ground, TX, and RX pins (physical pins 6, 8, 10) on the GPIO.

Install and configure Raspbian

Get yourself a copy of Raspbian Buster Lite and burn it to a microSD card using a tool like Etcher. You can use the full version of Buster if you wish. Perform the usual steps of getting a wireless connection and then updating to the latest version using sudo apt update && sudo apt -y upgrade. From a command prompt, run sudo raspi-config and go to ‘Interfacing options’, then ‘Enable serial’. When asked if you would like the login shell to be accessible, respond ‘No’. To the next question, ‘Would you like the serial port hardware to be enabled?’, reply ‘Yes’. Now reboot your Raspberry Pi.

Test the printer

Make sure the printer is up and running. Double-check you’ve connected the header to the GPIO correctly and power up the printer. The LED on the printer should flash every few seconds. Load in the paper and make sure it’s feeding correctly. We can talk to the printer directly, but the Python ‘thermalprinter‘ library makes coding for it so much easier. To install the library:

sudo apt install python3-pip
pip3 install thermalprinter

Create a file called printer.py and enter in the code in the relevant listing. Run the code using:

python3 printer.py

If you got a nice welcoming message, your printer is all set to go.

Test the microphone

Once your microphone is connected to Raspberry Pi, check the settings by running:

alsamixer

This utility configures your various sound devices. Press F4 to enter ‘capture’ mode (microphones), then press F6 and select your device from the list. Make sure the microphone is not muted (M key) and the levels are high, but not in the red zone.

Back at the command line, run this command:

arecord -l

This shows a list of available recording devices, one of which will be your microphone. Make a note of the card number and subdevice number.

To make a test recording, enter:

arecord --device=hw:1,0 --format S16_LE --rate 44100 -c1 test.wav

If your card and subdevice numbers were not ‘0,1’, you’ll need to change the device parameter in the above command.

Say a few words, then use CTRL+C to stop recording. Check the playback with:

aplay test.wav

Choose your STT provider

STT means speech to text and refers to the code that can take an audio recording and return recognised speech as plain text. Many solutions are available and can be used in this project. For the greatest accuracy, we’re going to use Google Voice API. Rather than doing the complex processing locally, a compressed version of the sound file is uploaded to Google Cloud and the text returned. However, this does mean Google gets a copy of everything ‘heard’ by the project. If this isn’t for you, take a look at Jasper, an open-source alternative that supports local processing.

Create your Google project

To use the Google Cloud API, you’ll need a Google account. Log in to the API Console at console.developers.google.com. We need to create a project here. Next to ‘Google APIs’, click the drop-down menu, then ‘New Project’. Give it a name. You’ll be prompted to enable APIs for the project. Click the link, then search for ‘speech’. Click on ‘Cloud Speech-to-Text API’, then ‘Enable’. At this point you may be prompted for billing information. Don’t worry, you can have up to 60 minutes of audio transcribed for free each month.

Get your credentials

Once the Speech API is enabled, the screen will refresh and you’ll be prompted to create credentials. This is the info our code needs to be granted access to the speech-to-text API. Click on ‘Create Credentials’ and on the next screen select ‘Cloud Speech-to-text API’. You’re asked if you’re planning to use the Compute Engine; select ‘no’. Now create a ‘service account’. Give it a different name from the one used earlier, change the role to ‘Project Owner’, leave the type of file as ‘JSON’, and click ‘Continue’. A file will be downloaded to your computer; transfer this to your Raspberry Pi.

Test Google recognition

When you’re happy with the recording levels, record a short piece of speech and save it as test.wav. We’ll send this to Google and check our access to the API is working. Install the Google Speech-To-Text Python library:

sudo apt install python3-pyaudio
pip3 install google-cloud-speech

Now set an environment variable that the libraries will use to locate your credentials JSON:

export GOOGLE_APPLICATION_CREDENTIALS="/home/pi/[FILE_NAME].json"

(Don’t forget to replace [FILE_NAME] with the actual name of the JSON file).

Using a text editor, create a file called speech_to_text.py and enter the code from the relevant listing. Then run it:

python3 speech_to_text.py

If everything is working correctly, you’ll get a text transcript back within a few seconds.

Live transcription

Amazingly, Google’s speech-to-text service can also support streaming recognition, so rather than capture-then-process, the audio can be sent as a stream, and a HTTP stream of the recognised text comes back. When there is a pause in the speech, the results are finalised, so then we can send the results to the printer. If all the code you’ve entered so far is running correctly, all you need to do is download the stenographer.py script and start it using:

python3 stenographer.py

You are limited on how long you can record for, but this could be coupled with a ‘push to talk’ button so you can make notes using only your voice!

Banned word game

Back to Demolition Man. We need to make an alarm sound, so install a speaker (a passive one that connects to the 3.5mm jack is ideal; we used a Pimoroni Speaker pHAT). Download the banned.py code and edit it in your favourite text editor. At the top is a list of words. You can change this to anything you like (but don’t offend anyone!). In our list, the system is listening for a few mild naughty words. In the event anyone mentions one, a buzzer will sound and a fine will be printed.

Make up your list and start the game by running:

python3 banned.py

Now try one of your banned words.

Package it up

Whatever you decide to use this project for, why not finish it up with a 3D-printed case so you package up the printer and Raspberry Pi with the recording and playback devices and create a portable unit? Ideal for pranking friends or taking notes on the move!

See if you can invent any other games using voice recognition, or investigate the graphics capability of the printer. Add a Raspberry Pi Camera Module for retro black and white photos. Combine it with facial recognition to print out an ID badge just using someone’s face. Over to you.

The MagPi magazine issue 84

This project was created by PJ Evans for The MagPi magazine issue 84, available now online, from your local newsagents, or as a free download from The MagPi magazine website.

7 Comments

Raspberry Pi internet kill switch

Control the internet in your home with this handy Raspberry Pi Zero W internet kill switch.

Internet Kill Switch!

It’s every teenager’s worst nightmare… no WIFI! I built a standalone wireless Internet Kill Switch that lets me turn the Internet off whenever I want. A Raspberry Pi Zero W monitors the switch and sends an alert via SSH over WIFI to my firewall where another script watches for the alert and turns the external interface off or on.

Internet in my home wasn’t really a thing until I was in my late teens, and even then, there wasn’t that much online fun to be had. Not like there is now, with social media and online gaming and the YouTubes.

If I’d had access to the internet of today in my teens, I’m pretty sure I’d have never been off the thing. And that’s where a button like this would have been a godsend for my mother.

Shared by Nick Donaldson on his YouTube account, the Internet Kill Switch is a Raspberry Pi Zero W–powered emergency button that turns off all internet access in the house — perfect for keeping online activities to a reasonable level. Nick explains:

It’s every teenager’s worst nightmare… no WiFi! I built a standalone wireless Internet Kill Switch that lets me turn the internet off whenever I want. A Raspberry Pi Zero W monitors the switch and sends an alert via SSH over WiFi to my firewall, where another script watches for the alert and turns the external interface off or on. I have challenged the boys to hack it…

The Raspberry Pi Zero W sits snug within the button casing and is powered by a battery. And so that the battery can be continuously recharged, the device sits on a wireless charging pad. Hence, the button is juiced up and ready to go at any time.

I can pick it up, walk around at any time, threaten the teenagers, and shut down the internet whenever I want, hahaha!

While internet service providers are starting to roll out smartphone apps that offer similar functionality, we like the physicality of this button.

Great job, Nick! Please don’t turn off our internet.

14 Comments

Take a virtual reality tour of the Raspberry Pi Store

Some months back, we received an email from Rob Chinery, explaining that he’d created a virtual reality (VR) tour of the Raspberry Pi Store, Cambridge.

When I heard about the new Raspberry Pi store in Cambridge, I was immediately impressed by the design and aesthetic of the store. I thought it would be a great project to add to my portfolio, so I put together a quick virtual experience based around the store.

Here’s a video for those without VR headsets:

Raspberry Pi Store VR Tour With Narration

A narrated VR tour of the Raspberry Pi Store in Cambridge, U.K.

Cool, right?

Based in New York, Rob hadn’t visited the store at the time and created the walk-through using images and video content that he’d found online.

I had to rely on a few press images from the opening to make the model (which did make things a bit difficult). One of the reasons I decided to build the app is to allow us Pi fans on other continents to virtually experience the store.

Since our initial communications in April, Rob has now managed to visit the store in the flesh, as he explained on Reddit.

Rob has built the tour specifically for mobile VR platforms, and it is available for free on Oculus Go and Gear VR. You can also view it via Testflight on Android and iOS using a cardboard viewer. You can try the Raspberry Pi Store VR tour here. And, if you’re in need of a mobile VR experience for your architectural projects, Rob’s your guy!

In the words of Liz, colour us impressed.

6 Comments

Raspberry Pi Zero white noise night light

Many members of the Raspberry Pi team have small children. As such, many members of the Raspberry Pi team are constantly tired and walking around like zombies — loving, productive zombies humming Baby Shark while scrubbing food stains off their clothing.

Whenever a Raspberry Pi project appears on social media that aids parents do the simple things in life — such as getting sleep or finding time to eat, breathe, shower, etc. — it’s an instant hit around the office.

White noise night light for unrelenting children

This is why, while setting up my desk this morning, I heard an “Oooo, white noise nightlight!” cheer from behind me and turned to find Liz checking out this new project from Instructables maker Cary Ciavolella.

This is a project I made for my 1-year-old for Christmas. Honestly, though, it was a sanity present for me and my wife. It’s a white noise machine that can play multiple different sounds selected through a web interface, and also incorporates lights that change color based on the time (red lights mean be in bed, yellow mean you can play in your room, and green means it’s ok to come out). Since my son is too young to tell time, a color-based night light seemed like a really good idea.

As Cary has kindly provided all the code for the project, it’s a fairly easy build to replicate at home and looks like it’ll do the trick.

The device uses a Raspberry Pi Zero W, Blinkt, and Speaker pHAT from Pimoroni, and a handful of wires. Building it requires some basic soldering skills. If you’re unsure about your soldering skills, our handy video guide is all you need to get started.

How to solder your Raspberry Pi header pins

Learn the basics of how to solder components together, and the safety precautions you need to take.

The white noise files are selectable via a flask webserver hosted on the Raspberry Pi that parents can control via their smart device. Cary’s write-up for the project is so wonderfully detailed that any parent looking to build their own device can easily replace the white noise files with any MP3s of their choice.

Here’s the Instructables tutorial to help you get started on your own.

Remix your own

What’s so wonderful about this project is that it’s a great example of a build that is easily hackable to fit your own requirements. If you don’t have a child, it’s still a great notification device for your day-to-day routine, or a nice tool to remind a relative to take medication based on a colour system. There’s so much you can do using Cary’s build as the bare bones, which is why we think it’s awesome, and you should too.

3 Comments

IT’S SO HOT OVER HERE. WE’RE MELTING. SEND HELP.

[Today’s temperatures are set to reach a whopping 38ºC/101ºF degrees in the UK, and none of us know what to do with ourselves. This doesn’t happen here and we have nothing prepared: we live in a society devoid of air conditioning, and we’re are unable to comprehend weather conditions more friendly than a slight chill and drizzle.

I can’t handle it. I have desk fan, but it’s in a cupboard somewhere, covered in dust and sadness. My local corner shop is already out of ice pops and ice cube trays. And anyway, I believe the tarmac on the road outside my house has melted and will suck down anything that dares step or drive on it.

I think I’m melting too. I feel sloshy, and, while I’m not 100% sure this is scientifically possible, I believe I may be partly barbequed. If someone presented me at a restaurant, I would probably be described as medium rare.

So yes, it’s hot. Very hot. It only makes sense that we share a Raspberry Pi project that fits with this theme: here’s an article from the latest issue of The MagPi magazine, out today, that shows you how Ishmael Vargas built his own smart fan for his home in hot and humid Chicago.

It’s a very clever idea, and one we wish we’d thought up ourselves before today’s sudden heatwave/opening of the Hell Mouth.

Enjoy — Alex]

When you need to keep your home cool during the summer months, a smart window fan could be just the thing.

Summer days, and nights, can be uncomfortably hot and humid in the Chicago area. As the sun goes down, the outside temperature drops, but homes may remain hot. This is where a window fan comes in useful, blowing cooler air into the house. Last summer, Ishmael Vargas was using a small window fan upstairs and, after turning it on in the afternoon, he found he had to get up in the middle of the night to turn it off. “That is when I thought there must be a better way to control this fan,” he recalls, “and I started putting this project together.”

Viewable via VNC on a smartphone, the program window features temperature data and control buttons.

As he was already using a DHT22 temperature and humidity sensor for another project, he opted to use that, connected to a Raspberry Pi Zero running a Python program, to monitor the room temperature. This is then compared with the external temperature; if the latter is cooler, the window fan is turned on via a smart WiFi power plug (TP-Link HS100) — a much simpler method than wiring the fan up to a relay.

Weather report

To keep things simple, Ishmael opted to source the outdoor temperature from Weather.com (The Weather Channel) using the pywapi Python library, rather than wiring up an external sensor. “The temperature provided by Weather.com as compared to the temperature in my car could differ by one or two degrees. This is close enough for this project,” he explains. “In other parts of the world or rural areas where they do not have as many weather stations, an outdoor sensor might be required.”

A smart WiFi socket is used to turn the window fan on and off.

One issue he discovered was that in the early morning, the fan could end up blowing warm air into the house. “Depending on the size of the fan, the size of the room, and the house materials, the inside temperature might never be as cool as outside,” he says. “For example, if the temperature outside is 65 °F (18°C), the temperature inside might only drop to 67 °F (19.5°C) through the night. As the temperature outside starts to climb, you want to keep the fan off.” This resulted in him adding an ‘inhibit’ mode to turn the fan off at 6am.

Remote control

Rather than having the fan program run automatically on bootup, Ishmael opted to start and control it manually via an Android smartphone. The latter runs the VNC Viewer app, enabling remote access to Raspberry Pi’s desktop, on which there is a shortcut to start the fan application; this then displays a Pygame window with temperature information and control buttons.

The DHT22 sensor is connected to power, ground, and GPIO 4 pins on a Raspberry Pi Zero — a 10kΩ resistor is recommended.

“The fan application has two buttons to change the [desired temperature] set-point up or down,” reveals Ishmael. “Also, the button on the upper right is to close the application and return to the desktop.” His aim is to have more than one project running on his Raspberry Pi, and have a desktop shortcut for each application.

While the original project used a single fan, he has since modified it to add another. “I have been reading that two fans are required for best performance,” he says. “One to blow in and another to blow out.”

This certainly is a cool project, in more than one way. If you’d like to have a go at building a similar system, you can read Ishmael’s Hackster guide and check out his GitHub repo for the code.

You should read The MagPi magazine

The latest edition of The MagPi magazine is out today, packed full of Raspberry Pi goodness. If you’re new to The MagPi magazine, welcome! As with all publications produced by Raspberry Pi Press, today’s new issue is available as a free download on The MagPi website, as well as in physical form from your local newsagent, the Raspberry Pi Store in Cambridge, or the Raspberry Pi Press online store.

Subscribers to The MagPi magazine get discounts and free stuff, and anyone purchasing any of our publications with actual currency will help fund the production of the magazine as well as the charitable work of the Raspberry Pi Foundation.

23 Comments