Give Your Raspberry Pi SD Card A Break: Log To RAM

The fragility of SD cards is the weak link in the Raspberry Pi ecosystem. Most of us seem to have at least one Pi tucked away somewhere, running a Magic Mirror, driving security cameras, or even taking care of a media library. But chances are, that Pi is writing lots and lots of log files. Logging is good — it helps when tracking down issues — but uncontrolled logging can lead to problems down the road with the Pi’s SD card.

[Erich Styger] has a neat way to avoid SD card logging issues on Raspberry Pi, he calls it a solution to reduce “thrashing” of the SD card. The problem is that flash memory segments wear out after a fairly low number of erase cycles, and the SD card’s wear-leveling algorithm will eventually cordon off enough of the card to cause file system issues. His “Log2Ram” is a simple Unix shell script that sets up a mount point for logging in RAM rather than on the SD card.

The idea is that any application or service sending log entries to /var/log will actually be writing them to virtual log files, which won’t rack up any activity on the SD card. Every hour, a cron job sweeps the virtual logs out to the SD card, greatly reducing its wear. There’s still a chance to lose logging data before it’s swept to disk, but if you have relatively stable system it’s a small price to pay for the long-term health of a Pi that’s out of sight and out of mind.

One thing we really like about [Erich]’s project is that it’s a great example of shell scripting and Linux admin concepts. If you need more information on such things, check out [Al Williams’] Linux-Fu series. It goes back quite a way, so settle in for some good binge reading.

Conquering The Earth With Cron

The GOES-R series of Earth observation satellites are the latest and greatest NASA has to offer. As you might expect, part of the GOES-R job description is imaging Earth at high-resolution, but they also feature real-time lighting monitoring as well as enhanced solar flare and space weather capabilities. Four of these brand new birds will be helping us keep an eye on our planet’s condition into the 2030s. Not a bad way to spend around 11 billion bucks.

To encourage innovation, NASA is making the images collected by the GOES-R satellites available to the public through a collaboration with Google Cloud Platform. [Ben Nitkin] decided to play around with this data, and came up with an interactive website that let’s you visualize the Earth from the perspective of GOES-R. But don’t let those slick visuals fool you, the site is powered by a couple cron jobs and some static HTML. Just as Sir Tim Berners-Lee intended it.

But it’s not quite as easy as scheduling a wget command; the images GOES-R collects are separated into different wavelengths and need to be combined to create a false-color image. A cron job fires off every five minutes which downloads and merges the raw GOES-R images, and then another cron job starts a Python script that creates WebM time-lapse videos out of the images using ffmpeg. All of the Python scripts and the crontab file are available on GitHub.

Finally, with the images merged and the videos created, the static HTML website is served out to the world courtesy of a quick and dirty Python web server. The site could be served via something more conventional, but [Ben] likes to keep overhead as low as possible.

If you want to take the more direct route, we’ve covered plenty of projects focused on pulling down images from weather satellites; from using old-school “rabbit ears” to decoding the latest Russian Meteor-M N2 downlink.

Continue reading “Conquering The Earth With Cron”

Linux-Fu: Running Commands

One of the things that makes Linux and Unix-like systems both powerful and frustrating is that there are many ways to accomplish any particular goal. Take something simple like running a bunch of commands in sequence as an example. The obvious way is to write a shell script which offers a tremendous amount of flexibility. But what if you just want some set of commands to run? It sounds simple, but there are a lot of ways to issue a sequence of commands ranging from just typing them in, to scheduling them, to monitoring them the way a mainframe computer might monitor batch jobs.

Let’s jump in and take a look at a few ways you can execute sequences from bash (and many other Linux shells). This is cover the cron and at commands along with a batch processing system called task spooler. Like most things in Linux, this isn’t even close to a complete list, but it should give you some ideas on ways to control sequences of execution.

Continue reading “Linux-Fu: Running Commands”

Colorful Clock

A Colorful Clock For Toddlers

[Don] and his wife were looking for a way to teach their two-year old daughter how to tell time. She understood the difference between day and night, but she wasn’t old enough to really comprehend telling the actual time. [Don’s] solution was to simplify the problem by breaking time down into colored chunks representing different tasks or activities. For example, if the clock is yellow that might indicate that it’s time to play. If it’s purple, then it’s time to clean up your room.

[Don] started with a small, battery operated $10 clock from a local retailer. The simple clock had a digital readout with some spare room inside the case for extra components. It was also heavy enough to stay put on the counter or on a shelf. Don opened up the clock and got to work with his Dremel to free up some extra space. He then added a ShiftBrite module as a back light. The ShiftBrite is a high-brightness LED module that is controllable via Serial. This allows [Don] to set the back light to any color he wants.

[Don] already had a Raspberry Pi running his DIY baby monitor, so he opted to just hijack the same device to control the ShiftBrite. [Don] started out using a Hive13 GitHub repo to control the LED, but he found that it wasn’t suitable for this project. He ended up forking the project and altering it. His alterations allow him to set specific colors and then exit the program by typing a single command into the command line.

The color of the ShiftBrite is changed according to a schedule defined in the system’s crontab. [Don] installed Minicron, which provides a nice web interface to make it more pleasant to alter the cron job’s on the system. Now [Don] can easily adjust his daughter’s schedule via web page as needed.

 

Network Enabled Window Air Conditioner

It’s no secret that the central US is feels like a very humid oven right now. [Erik’s] window AC hack might help you out if you’re coping with triple-digit temperatures. He added network connectivity to the unit above but the picture is a bit deceiving. The blue CAT-5 cable that enters the bottom isn’t connecting directly to the network, but extends the up and down button connections for the unit to an external relay board. From there he uses an SNMP board to connect it to the network and uses PHP commands to reset the temperature. The unit has a working range of 66-88 degrees Fahrenheit so he cycles enough button press to reach the maximum or minimum level, then sets the desired temperature (avoiding the need to know what temperature the unit is currently set at).

If you’ve got an AC unit with a remote control you could always use an IR device to patch into the system for similar functionality.