Category Archives: Python

I2C Library

I2C Library WiringPi includes a library which can make it easier to use the Raspberry Pi’s on-board I2C interface. Not all systems have the I2C development libraries and headers installed, and when you buildwiringPi, it detects this at build time. If you are using these helper functions and you get link errors, it means that wiringPi is not installed with the I2C helper functions. You need to install the I2C development libraries and re-build. Under Raspbian: sudo apt-get install libi2c-dev then

Configuring I2C

Configuring I2C I2C is a very commonly used standard designed to allow one chip to talk to another. So, since the Raspberry Pi can talk I2C we can connect it to a variety of I2C capable chips and modules. Here are some of the Adafruit projects that make use of I2C devices and modules:×2-character-lcd-plus-keypad-for-raspberry-pi   If you are using Occidentalis, then your Pi is ready to go with I2C as far as

Pi with a keypad matrix

 Pi with a keypad matrix Today we will see how to interfacing the Raspberry Pi with a matrix keypad usingRpi-hw library. Matrix keypad interfacing – Video The library provides the class keypad::matrix↱, defined in “rpi-hw/keypad/matrix.hpp”↱, with which it is possible to manage keypads of any size. Its constructor method takes two ordered lists containing the GPIO pins used by the device: keypad::matrix( { COL0, COL1, COL2, … }, // Column pins { ROW0, ROW1, ROW2, … } // Rows pins ) Let’s take

Python RTC, 1307, Script   #!/usr/bin/env python #encoding: utf-8 # Copyright (C) 2013 @XiErCh # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject

List of files, directories in Python

List of files, directories in Python Here I present a short python program that prints the list of all files inside the current directory and subdirectories. It prints filename with relative path to the current directory. import os for root, dirs, files in os.walk(‘./’): for name in files: filename = os.path.join(root, name) print filename You can also print the list of directories only (just print the dirs). Actually I needed this stuff to solve a problem from Google treasure hunt.

Options for listing the files in a directory with Python Options for listing the files in a directory with Python I do a lot of sysadmin-type work with Python so I often need to list the contents of directory on a filesystem. Here are 4 methods I’ve used so far to do that. Let me know if you have any good alternatives. The examples were run on my Ubuntu Karmic machine. OPTION 1 - os.listdir() This is probably the simplest way to list the contents of a directory in Python.

MySQL Python tutorial MySQL Python tutorial This is a Python programming tutorial for the MySQL database. It covers the basics of MySQL programming with Python. It uses the MySQLdb module. The examples were created and tested on Ubuntu Linux. There is a similar PostgreSQL Python tutorial, MySQL Visual Basic tutorial, or MySQL PHP tutorial on ZetCode. If you need to refresh your knowledge of the Python language, there is a fullPython tutorial. You may also consider to look at the MySQL tutorial, too. About MySQL database MySQL

Send Email using Python…

Send Mail Through Gmail with Python by MARK SANBORN on June 30, 2009 Python is a great scripting language for Linux and it is often used to automate tasks or check on overall system health. Discover how to send emails through Gmail with Python. Good system admins get to know scripting languages well and sometimes use them for all kinds of purposes, from scripts that do backups to complex automated tasks. Often times it would be nice to get an email notification

How to quickly make a (sorted) playlist for mplayer How to quickly make a (sorted) playlist for mplayer January 17, 2009 by Shinobu See my update on July 10, 2010, below (making use of the neat “-iregex” option)! Mplayer uses a simple kind of playlist: a text file with the path and name of each file to be played. The path to the new file is relative to the location of the playlist file itself. So, you can do: 1 find -maxdepth 1 -type f -name \*.\* | sort > playlist

Getting Up and Running with MySQL for Python   Getting Up and Running with MySQL for Python   by Albert Lukaszewski, PhD |December 2010 | MySQL Open Source There are, several ways to get MySQL for Python in a place such that your local Python installation can use it. Which one you use will depend as much on your familiarity with your operating system and with Python itself, as it will on which operating system and version of Python you are running. In this article, by Albert Lukaszewski, PhD,

Getting a Python script to run in the background (as a service) on boot Getting a Python script to run in the background (as a service) on boot 16 Replies Share on facebookShare on twitterShare on emailShare on pinterest_shareMore Sharing Services10 For some of my projects I write a simple service in Python and need it to start running in the background when the Raspberry Pi boots. Different Linux distributions use different ways of starting and stopping services (some now use Upstart, some systemd). I am using the “Wheezy” Debian distribution on my Raspberry Pi,

HOWTO: Boot your Raspberry Pi into a fullscreen browser kiosk HOWTO: Boot your Raspberry Pi into a fullscreen browser kiosk It seems there’s some demand for knowledge of setting up a full-screen, browser-based kiosk on the all-singing Raspberry Pi. Here at Watershed we’ve done this, to drive the screens of our digital signage system. Although we complicate matters a bit (we net-boot the pis, which requires a few extra tweaks – see our blog post on net-booting raspberry pis), we thought it’d be useful to document what we achieved: automatically running

Looping video playlist with Omxplayer on the Raspberry Pi

Looping video playlist with Omxplayer on the Raspberry Pi The Raspberry Pi comes with an awesome little video player called Omxplayer that is very capable of playing back full 1080p video perfectly when encoded correctly in H.264/AAC. One problem is the current lack of playlist support in omxplayer, so this post explains how to create a bash script that will permanently loop through and play a directory of videos.   First install omxplayer: sudo apt-get install omxplayer Now create this script named for

Looping videos seamlessly OMXPlayer Looping videos seamlessly OMXPlayer Ellen 16:30 on October 15, 2013 As I looked for different solutions for looping videos on the Raspberry Pi seamlessly I eventually came out with a solution that worked quited good for videos looping with sounds. Looking at the possiblities of using the existing example of hello_video/video.c to loop a video wasn’t an option as sound was not supported and syncing sound was not something I wanted to spend time on. Instead I looked to jbaiter’s OMXPlayer library pyomxplayer build in

Raspberry Pi playing a video in loop Raspberry Pi playing a video in loop May 11, 2013 So there is gonna be an art exibition where i work, its mainly video art, so they will need six projectors showing one piece of video each, and they are all gonna run in loop, all day long. There are several boxes that can play video, and still be cheaper than the mini-mac, but none as cheap as the raspberry pi. So i decided to see if i could

« Older Entries