Raspberry Pi, Send Me A Letter

The abundance of small networked boards running Linux — like the Raspberry Pi — is a boon for developers. It is easy enough to put a small cheap computer on the network. The fact that Linux has a lot of software is a double-edged sword. On the one hand, it is a good bet that anything you want to do has been done. On the other hand, some of the solutions are a bit large for a tiny embedded system.

Take, for example, e-mail. Historically, Linux hosts operate as mail transfer agents that can send and receive mail for all their users and possibly even relay mail to others. In today’s world, that’s usually overkill, but the capability is there. It is possible to install big mail transfer agents into a Raspberry Pi. The question is: should you?

What Do You Want?

The answer, of course, depends on what you want to do. If you have a dedicated board sending out text and maybe even files using an external mail server (like, say, Gmail), then the answer is no. You don’t need a piece of software listening for incoming connections, sorting through multiple users, and so on.

Luckily, there are some simple solutions if you know how to set up and configure them. The key is to avoid the big mail programs that do everything you don’t need.

Mail Front Ends

Let’s tackle sending mail first. If you try to grab the mailutils package, you’ll see it drags along a lot of stuff including mysql. Keep in mind, none of this will actually send mail. It just gives you some tools to get mail ready to send.

Luckily, the bsd-mailx package has a lot less overhead and will do the job. Look at the man page to see what options you have with mailx; you can do things like attach files, set a subject, and specify addresses.

It is a little difficult to set up for Gmail, though, thanks to Google’s security. You’ll need the certutil tool from the libnss3-tools package. You’ll need to create a certificate store, import Google’s certificate, and then set up a lot of options to mailx. I don’t suggest it. If you insist, though, you can find directions on the Web.

SSMTP

By default, programs like mailx and other Linux mail commands rely on a backend (often sendmail). Not only does that drag around too much overhead, it is also a full mail system, sending and receiving and relaying–overkill for our little Pi computers.

Luckily, SSMTP is available which only sends mail and is relatively lightweight. You need a configuration file to point it to your mail server. For Gmail, it would look like this:

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?
rewriteDomain=yourdomain.com

# The full hostname
hostname=yourhostname
AuthUser=YourGmailUserID
AuthPass=YourGmailPassword
UseTLS=Yes
UseSTARTTLS=YES
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

You can use a mail agent like mailx or you can just use ssmtp directly:

ssmtp someone@somewhere.com

Enter a message on the standard input and end it with a Control+D (standard end of file for Linux).

Google Authentication

There’s only one catch. If you are using Gmail, you’ll find that Google wants you to use stronger authentication. If you are using two-factor (that is, Google Authenticator), this isn’t going to work at all. You’ll need to generate an app password. Even if you aren’t, you will probably need to relax Google’s fear of spammers on your account. You need to turn on the “Access for less secure apps” setting. If you don’t want to do this on your primary e-mail account, considering making an account that you only use for sending data from the Pi.

Sending Files

Depending on the mail software you use, there are a few ways you can attach a file. However, the mpack program makes it very easy:

mpack -a -s 'Data File' datafile.csv me@hackaday.com

The above command will send datafile.csv as an attachment with the subject “Data File.” Pretty simple.

Receiving Mail

What if you want to reverse the process and receive mail on the Pi? There is a program called fetchmail that can grab e-mails from an IMAP or POP3 server. It is possible to make it only read the first unread message and send it to a script or program of your choosing.

You have to build a configuration file (or use the fetchmailconf program to build it). For example, here’s a simple .fetchmailrc file:

poll imap.gmail.com
protocol IMAP
user "user@gmail.com" with password "yourpassword" mda "/home/pi/mailscript.sh"
folder 'INBOX'
fetchlimit 1
keep
ssl

You can leave the “keep” line out if you don’t mind fetchmail deleting the mail after processing. The file should be in your home directory (unless you specify with the -f option) and it needs to not be readable and writable by other users (e.g., chmod 600 .fetchmailrc). According to the fetchmail FAQ, there are some issues with Gmail, so you might want to consider some of the suggestions provided. However, for simple tasks like this, you should be able to work it all out.

In particular, the mailscript.sh file is where you can process the e-mail. You might, for example, look for certain keyword commands and take some action (perhaps replying using ssmtp).

Special Delivery

You might not think of the Raspberry Pi as an e-mail machine. However, the fact that it is a pretty vanilla Linux setup means you can use all sorts of interesting tools meant for bigger computers. You just have to know they exist.

Hackaday Prize Entry: FPGAs For The Raspberry Pi Zero

The Raspberry Pi is the Arduino of 2016, and that means shields, hats, add-ons, and other fun toys that can be plugged right into the GPIO pins of a Pi. For this year’s Hackaday Prize, [Valentin] is combining the Pi with the next age of homebrew computation. He’s developed the Flea Ohm, an FPGA backpack or hat for the Pi Zero.

The Flea Ohm is based on Lattice’s ECP5 FPGA featuring 24k LUTs and 112kB BRAM. That’s enough for some relatively interesting applications, but the real fun comes from the added 32MB or 128MB of SDRAM, a micro SD card slot, USB + PS/2 host port and an LVDS output.

The combination of Raspberry Pis and FPGAs are extremely interesting and seem to be one of the best FPGA learning platforms anyone can imagine. Another Hackaday Prize entry, the ZinqBerry does a similar trick, but instead of a Pi hat, the ZinqBerry drops a Xilinx Zynq with an FPGA and ARM Cortex A9 core onto a board with Ethernet, HDMI, and USB.

If it’s a Flea or a Zinq, the age of FPGA’d Raspberry Pis is quickly approaching, and hopefully we’ll see them as finalists in the Hackaday Prize. You can check out a video of the Flea Ohm below.

Continue reading “Hackaday Prize Entry: FPGAs For The Raspberry Pi Zero”

Oculus Pi

[WayneKeenan] wrote a proof-of-concept virtual reality system that used a Raspberry Pi and an Oculus Rift. It was about a thousand lines of Python and with a battery pack it was even portable. The problem was that the Pi was struggling to create the 3D views.

[Wayne] recently revisited the demo and found that just about everything has gotten better: the Pi 3 is faster, and the Python libraries have become better. He spent some time building a library — VR Zero — and then recreated the original demo in 80 more lines of Python. You can see a video, below.

Continue reading “Oculus Pi”

Lock Up Your Raspberry Pi With Google Authenticator

Raspberry Pi boards (or any of the many similar boards) are handy to leave at odd places to talk to the network and collect data, control things, or do whatever other tasks you need a tiny fanless computer to do. Of course, any time you have a computer on a network, you are inviting hackers (and not our kind of hackers) to break in.

We recently looked at how to tunnel ssh using a reverse proxy via Pagekite so you can connect to a Pi even through firewalls and at dynamic IP addresses. How do you stop a bad guy from trying to log in repeatedly until they have access? This can work on any Linux machine, but for this tutorial I’ll use Raspberry Pi as the example device. In all cases, knowing how to set up adequate ssh security is paramount for anything you drop onto a network.

Continue reading “Lock Up Your Raspberry Pi With Google Authenticator”

Boombox Doorjam Plays Your Theme Song When You Step In The Ring

Although many of us may have had childhood aspirations to be a famous wrestler in the WWE, not very many of us will ever realize those dreams. You can get close, though, if you have your own epic intro music theme that plays anytime you walk into a room. Although it’s not quite the same as entering a wrestling ring, [Matt]’s latest project will have you feeling just as good whenever you enter a room to your own theme song.

The core of the build consists of a boom box with an auxiliary input. The boom box is fed sound via a Raspberry Pi which also serves as the control center for the rest of the project. It runs Node.js and receives commands via websockets from a publicly accessible control server. The Pi is also running Spotify which allows a user to select a theme song, and whenever that user’s iBeacon is within range, the Pi will play that theme song over the stereo.

The project looks like it would be easy to adapt to any other stereo if you’re looking to build your own. Most of the instructions and code you’ll need are available on the project’s website, too. And, if you’re a fan of music playing whenever you open a door of some sort, this unique project is clearly the gold standard. It might even make Stone Cold Steve Austin jealous.

Raspberry Pi Adds A Digital Dash To Your Car

Looking for a way to make your older car more hi-tech? Why not add a fancy digital display? This hack from [Greg Matthews] does just that, using a Raspberry Pi, a OBD-II Consult reader and an LCD screen to create a digital dash that can run alongside (or in front of ) your old-school analog dials.

[Greg’s] hack uses a Raspberry Pi Foundation display, which includes a touch screen, so you don’t need a mouse or other controls. Node.js displays the speed, RPM, and engine temperature (check engine lights and other warnings are planned additions) through a webpage displayed using Chromium. The Node page is pulling info from another program on the Pi which monitors the CAN Consult bus. It would be interesting to adapt this to use with more futuristic displays, maybe something like a pico projector and a 1-way mirror for a heads-up display.

To power the system [Greg] is using a Mausberry power supply which draws power from your car battery, but which also cleanly shuts down the Pi when the ignition is turned off so it won’t drain your battery. When you throw in an eBay sourced OBD-II Consult reader and the Consult Dash software that [Greg] wrote to interpret and display the data from the OBD-II Consult bus, you get a decent digital dash display. Sure, it isn’t a Tesla touchscreen, but at $170, it’s a lot cheaper. Spend more and you can easily move that 60″ from your livingroom out to your hoopty and still use a Raspberry Pi.

What kind of extras would you build into this system? Gamification of your speed? Long-term fuel averaging? Let us know in the comments.

UPDATE – This post originally listed this hack as working from the OBD-II bus. However, this car does not have OBD-II, but instead uses Consult, an older data bus used by Nissan. Apologies for any confusion!

Continue reading “Raspberry Pi Adds A Digital Dash To Your Car”

Hackaday Prize Entry: Raspberry Pi Thermal Imaging

High up on the list of desirable technologies that are edging into the realm of the affordable for the experimenter is the thermal camera. Once the exclusive preserve of those with huge budgets, over the last few years we’ve seen the emergence of cameras that are more affordable, and most recently a selection of thermal camera modules that are definitely within the experimenter’s range. They may not yet have high resolution, but they are a huge improvement on nothing, and they are starting to appear in projects featured on sites like this one.

One such device is the Melexis MLX90621, a 16×4 pixel thermal sensor array in a TO39 can with an I2C interface. It’s hardly an impulse purchase in single quantities and nor is it necessarily the cheapest module available, but its price is low enough for [Alpha Charlie] to experiment with interfacing it to a Raspberry Pi for adding a thermal camera overlay to the pictures from its visible light camera.

The wiring for the module is simplicity itself, and he’s created a couple of pieces of software for it that are available on his GitHub repository. mlxd is a driver daemon for the module, and mixview.py is a Python graphical overlay script that places the thermal array output over the camera output. A run-through of the device and its results can be seen in the video below the break.

Continue reading “Hackaday Prize Entry: Raspberry Pi Thermal Imaging”