Category Archives: Raspberry Pi

Raspberry Pi + Thermal Printer


I’m looking at doing some experimentation with thermal printing, using the same type of device that prints point-of-sale receipts. I found the Adafruit tutorials to be a little incomplete, so here’s how I got my printer up and running.

  1. Download the full version of Raspbian Jessie (Lite will not work).
  2. Open the terminal and type   tar xzvf /path/to/your/file/ (the file is too big to unzip by double-clicking in OSX).
  3. Use ApplePi-Baker to transfer the .img to an SD card (I couldn’t get the official terminal method to work).
  4. Boot up the Pi and follow these instructions.
  5. Connect the printer to a 5V power source. I could only get it to work with a 10A supply, which is rated far above the 2A that the Adafruit tutorial calls for. You can test the printer by holding down the button near the power LED and then turning on the power.
  6. Wire up the printer data lines to the Pi’s GPIO pins. If you use a Pi rev1 like I did, you want pins 6, 8, and 10. Note that the RX and TX lines cross between the Pi and the printer.
  7. If you get a permissions error at the end of the Adafruit tutorial, open the terminal and type  sudo usermod -a -G lpadmin pi (source).
  8. Finish up with these steps for network printing (optional).


RPi web cam baby monitor


Aah – the summer arrives, so now I can actually finish/document some work that languished during the academic year. Have a look at this project over on Github and build your own! This fork of the popular RPi_Web_Cam_Interface adds support for night vision via IR LED ring (including auto shutoff so you’re not blasting your tot with IR all night).

Adding IR LEDs to an RPi Noir Cam (WIP)

A little research online seems to indicate the potential for IR LEDs to damage eyesight. Perhaps this is the tinfoil hat squad talking, but I don’t want to take chances with my kid’s eyesight. Thus, we need to wire/program the pi so that it only flips the IR array on during active recording.

A little poking around revealed that the status of the camera (“ready” or “halted”) is held at /var/www/status_mjpeg.txt . I created a simple python script in the same directory called

Lastly, edit /etc/rc.local  with nano to include  python /var/www/  somewhere before exit 0 . That will cause the script to run on startup.

Next up: connect pin 7 to a transistor so that it can control an IR array!


Raspberry Pi Baby Monitor

Today I got down to business on a new Raspberry Pi project. I started with the following parts:

  1. RPi 2B (w/ 8G NOOBS)
  2. USB wifi dongle
  3. RPi Noir camera board
  4. Monitor, keyboard and mouse (just for setup)

Following a clean install* I set up my RPi to enable SSH and the camera. If your RPi system software is already installed, you can reach these features by entering raspi-config  in the Terminal. I also got the wifi dongle talking to my network. Camera installation is really simple. See this link to make sure you get the ribbon cable polarity right.

Now we install RPi-Cam-Web-Interface. The documentation is a little hard to follow, so here’s a condensed version:

  1. sudo apt-get install lsb-release
  2. lsb_release -a
  3. Confirm OS code name is “Jessie”
  4. git clone
  5. cd RPi_Cam_Web_Interface
  6. chmod u+x *.sh
  7. Enter the IP address of the RPi into a browser from another computer on your network. You should get a page full of options and a live image from the camera.

Ok! Next time I’ll talk about adding UV LEDs.

*After one unsuccessful run at this project, I ran into problems trying to reinstall NOOBS from the RPi boot screen. You’re supposed to be able to do this by holding shift, but I couldn’t get it to work (even after trying all the voodoo like rapidly pressing both shift keys in alternating fashion). I wound up downloading a fresh copy of NOOBS and copying it to the SD after wiping it with the OSX disk utility. Everything worked perfectly after that.

Sponsored by Element14!

The_element14_company_logoThe good folks at Element14 got in touch after they read some of the Raspberry Pi tutorials on this website. They offered to send me some parts for a project, so I decided to start with a networked baby monitor. I’ll post progress as I go!

CTA bus tracking clock prototype complete

CTA bus tracking clock prototype

This is my first complex Raspberry Pi project.  The guts are working great:  plug the device in and it automatically boots up and starts checking arrival times at my favorite stop.  Planned improvements include a Flask-based web interface for selecting bus routes and a nicer case.

Hardening a headless RPi to run an infinite script

Though a Raspberry Pi can act like a conventional desktop computer, my RPi projects are generally “headless”, in that no monitor, keyboard or mouse are present.  This means that we must “harden” the system settings and code to be self-starting and fault-tolerant.  Here are the steps I took to ensure that my CTA bus tracker could run indefinitely without user input.

  1. Set the default user “pi” to automatically log in on power up.
  2. Follow these instructions to daemonize your script.  This allows it to run as a service, which is easier to monitor and restart.
  3. Install and configure Monit to resurrect the daemon if it dies.  A script can die/exit unexpectedly if it encounters an unhandled error.  It’s good practice to take care of these errors within the script itself, but I kept getting occasional script exits despite my best efforts.  Here’s a nice little python tutorial about exceptions.
  4. sudo nano /etc/kbd/config and search for BLANK_TIME=30 and POWERDOWN_TIME=30.  Change both values to zero (meaning never).  This prevents the Pi from falling asleep.

Update:  I’ve been chasing bugs for a month, and I’ve finally got 24 hours of up time according to Monit.  I think the problem had to do with the python requests module.  I added a timeout to each URL request, allowing the loop to continue even if the CTA server is acting up.

Update 2:  It also looks like the API will start bouncing requests once you hit a certain number in 24 hours from the same IP.

SSH Between OSX and Raspberry Pi

Use SSH so you can operate your Pi in “headless” mode:  no monitor, keyboard or mouse required.  Adafruit has covered this at length, but here are my personal notes on one page.

From RPi

  1. Connect RPi to modem via Ethernet cable.  Connect a keyboard, mouse and monitor too.
  2. Power on the RPi.
  3. If it’s your first time booting, you can search through the setup menu to enable SSH.
  4. If you’ve already booted up before, open up the Terminal application and type sudo raspi-config
  5. SSH > Enable

From OSX

  1. Connect your computer to the same network (wired or wireless).
  2. Determine the IP address of your RPi.  Steps will vary based on your modem.  If I type the IP address on the side of my modem into a web browser, I can find an option to list all device IPs that are currently connected.  Here’s another method that I haven’t tested.
  3. Open the OSX terminal (Applications > Utilities).  Be aware that you can do some major file/systems damage if you’re not careful.
  4. Type  ssh [device IP] -l [device name] .  Replace the bracketed text and delete the brackets.  The RPi is named “pi” by default.
  5. When prompted, enter the RPi password.  It’s “raspberry” by default.  You won’t see any cursor activity as you type – this really confused me the first time around.

CTA Bus Tracker

Let’s make a custom “clock” that constantly checks and updates the arrival times for the bus outside my house.  You’ll need to apply for a CTA API key to make this work.  I’ve run my clock for about 12 hours total, will update if I find reliability issues.


  1. Raspberry Pi
  2. Pi power supply
  3. Wifi dongle
  4. 7-segment LED “backpack”


Wiring (Backpack to Pi Rev2).  If you look at the Pi with the SD card facing up, you’ll see GPIO pin #1 marked at upper right as “P1”.

  1. D >> SDA
  2. C >> SCL
  3. + >> 5v
  4. – >> GND
  5. IO >> 3.3v

Now follow this tutorial to get all your libraries in place.  Once everything is wired/updated, try entering the following 3 commands into the terminal:


If that works then you’re ready for the last step.  Download this python script on Github.  Follow these instructions to get your Pi to automatically run the script on startup.  Enjoy!  Will update soon with pictures/CAD files of the finished housing.

Useful Pi terminal commands


  • sudo reboot
  • sudo shutdown -h now


  • ssh [yourip] -l pi replace bracketed text with the Pi’s IP address


  • mv one.txt two.txt  changes the name of one.txt to two.txt
  • cp /home/pi/one.txt /home  move one.txt from pi directory to home directory


  • sudo raspi-config  pick option 4 to set timezone