Categories
Activism Code Pete Taylor (shameless self publicity) Social Media Websites

Tweet your Candidate is back!

Following the initial joy and elation at discovering we’ve got yet another chance to express our electoral opinions I’ve updated TweetYourMP.com to now include candidate information for the forthcoming 2017 snap General Election, and I’ve even managed to secure yet another dot com – TweetYourCandidate.com includes the details of over 3,000 candidates standing in the 650 constituencies across the UK.

Fortunately this time around I’ve been able to make use of the very useful candidate data from The Democracy Club which has saved a lot of time and made it possible to turn update the site in a very short space of time.

This time around there’s a new feature to play with: the campaign generator makes it possible to create your own pre-filled twitter campaigns to share.

As an example I created a very simple campaign – posing possibly the easiest question to people vying to be your Member of Parliament:

https://twitter.com/kimondo/status/859686716080357376

As I live in the Vauxhall constituency of former MP Kate Hoey I have had a number of replies:

First to reply was Harini Iyengar for The Women’s Equality Party:

https://twitter.com/Harini_Iyengar/status/859735962213122056

and now without the ringer:

https://twitter.com/Harini_Iyengar/status/859737011439251456

Then Mark Chapman for the Pirate Party:

https://twitter.com/Pirate_Lennon/status/859738317297942528

George Turner for the Lib Dems:

https://twitter.com/georgenturner/status/859738670219309058

and Gulnar Hasnain for the Greens

https://twitter.com/gulnar73/status/859742839361736704

Sadly I’ve yet to receive replies from Kate Hoey (The former Labour MP) nor Dolly Theis who is the Conservative and Unionist Party candidate, although in the case of the latter I did tweet later as my initial candidate list didn’t include her twitter details. UKIP are not running in Vauxhall.

So far a number of campaigns have made use of the tool – which is provided free of charge, as a spare time project.

To ask the same question to your candidates visit TweetYourCandidate.com

Categories
Activism Code Social Media

Send pre-filled tweets using tweetyourmp.com

Rather excitingly my little side project tweetyourmp.com was mentioned by pukka chef Jamie Oliver as part of his campaign for healthy eating:

Big yellow sign
Big yellow sign

After my panic that I might not have enough bandwidth subsided, I thought it might be a good moment to give Tweety our MP a bit of love, so I’ve added the option to pre-fill tweets.

The tweet text is passed across using a custom URL – this can be done as follows:

Pre-filling in the postcode and tweet message:

Make sure you use the URL http://tweetyourmp.com/index.php

The URL needs to be in the format:

http://tweetyourmp.com/index.php?postcode=SW2 2AX&tweetmsg=twitter message&sentvia=@kimondo

the parts being:

http://tweetyourmp.com/index.php

?postcode= the postcode for constituency lookup

&tweetmsg= the twitter message

&sentvia= the twitter handle for the sender (default is @tweet_your_mp)

You can leave out the postcode (or the tweet message!):

http://tweetyourmp.com/index.php?tweetmsg=twitter message&sentvia=@kimondo

Passing values to tweetyourmp.com in this way works with spaces, but safer to encode the message and postcode parts using http://andrewu.co.uk/tools/uriencoder/ to replace characters with %20 for a space.

so the above becomes:

http://tweetyourmp.com/index.php?postcode=SW22AX&tweetmsg=twitter%20message&sentvia=@kimondo

This example generates:

hello @ChukaUmunna your twitter message via @kimondo

as the tweet.

Important note on using hashtags

I had to use a bit of a hack to make it possible to have a pre-filled tweet with a hashtag. As # is used to denote an anchor link when you stick it in a URL the rest of the URL gets ignored by the bit of the code that reads the tweet from it.

To get round this use an asterisk * in place of a hash # – the code then puts the hash back in when it sends the tweet:

http://tweetyourmp.com/index.php?postcode=SW22AX&tweetmsg=twitter%20message%20*hashtag&sentvia=@kimondo

This hashtag example generates

hello @ChukaUmunna your twitter message #hashtag via @kimondo

The salutation is fixed as ‘Hello’ but can be changed – is important not to begin the tweet with the @handle as it reduces its visibility and ‘Hi’ is a bit American sounding hence the hello.

Next on the list is building some sort of Raspberry Pi based tweet totaliser. You can download the (very simple) code that runs Tweet your MP on GitHub – a couple of interesting options are to use the code in a thankyou email after a supporter has completed an action to give it a bit more impact, or to sort through your data and merge in constituency contacts in an email.

Note that some MPs don’t consider twitter an ‘official’ communication format so this is best combined with an email or letter to an MP.

tweetyourmp.com is made possible thanks to the theyworkforyou.com API – this is free for charitable use up to 50,000 queries.

Update: I’ve now added a page that automates this process and builds a bit.ly link with the correct address!

Categories
Arts Code Gadgets Geekery Raspberry Pi

ASCII camera with the Holga 120d

So now I’ve finished my digital Holga project, one of the things I wanted to do was to get a bit creative with it – so here’s my first attempt at an ASCII art generating camera.

Holga 120d ASCII text image
High contrast images work best.

This uses the ASCII art script written by Steven Kay, please visit his blog to find out more – I’ve modified the original script to use the python picamera library – this helps speed up the image resize. There’s also a timestamp added to the text file which uses the same script I wrote about in my previous Holga post.

If you just want to run Steven Kay’s script you’ll need the python imaging tools – install with

sudo apt-get install python-imaging

Here’s my modified script:

'''
ASCII Art maker
Creates an ascii art image from an arbitrary image
Created on 7 Sep 2009

@author: Steven Kay
'''

import time
import picamera
from PIL import Image
import random
from bisect import bisect

# greyscale.. the following strings represent
# 7 tonal ranges, from lighter to darker.
# for a given pixel tonal level, choose a character
# at random from that range.

greyscale = [
            " ",
            " ",
            ".,-",
            "_ivc=!/|\\~",
            "gjez2]/(YL)t[+T7Vf",
            "mdK4ZGbNDXY5P*Q",
            "W8KMA",
            "#%$"
            ]

# using the bisect class to put luminosity values
# in various ranges.
# these are the luminosity cut-off points for each
# of the 7 tonal levels. At the moment, these are 7 bands
# of even width, but they could be changed to boost
# contrast or change gamma, for example.

zonebounds=[36,72,108,144,180,216,252]


#take photo

with picamera.PiCamera() as camera:
                        camera.capture('image.jpg');

# open image and resize
# experiment with aspect ratios according to font


im=Image.open(r"image.jpg")
im=im.resize((160, 75),Image.BILINEAR)
im=im.convert("L") # convert to mono

# now, work our way over the pixels
# build up str

str=""
for y in range(0,im.size[1]):
    for x in range(0,im.size[0]):
        lum=255-im.getpixel((x,y))
        row=bisect(zonebounds,lum)
        possibles=greyscale[row]
        str=str+possibles[random.randint(0,len(possibles)-1)]
    str=str+"\n"

print str

date_string = time.strftime("%Y-%m-%d-%H:%M:%S")

text_file = open('image' + date_string + '.txt', "w")
text_file.write(str)
text_file.close()

There are lots of settings to tweak – the image above was generated by the script – and bear in mind this is designed to be viewed with black text on a white background. Perhaps I’ll see if I can dig out an old dot matrix printer from somewhere.

For a blog of ‘photos’ updated whenever I take them and am in range of WiFi check out:

http://holga120d.blogspot.co.uk/

This emails the ASCII art in HTML format to blogger whenever I take a photo (and the Pi Holga is in range of the internet).

For more about the Digital Holga check out my previous blog posts on the hardware and building the case.

Categories
Code Raspberry Pi

How to find a Raspberry Pi on your network

Here’s a quick tip to finding a Raspberry Pi (and anything else) on your network using the nmap network scanning security tool.

Quite often you might want to run a ‘headless’ Raspberry Pi without a screen or keyboard, using SSH to connect. SSH can be enabled in the config menu when you first boot the Pi. You can then find the IP address of your Pi when you’re initially setting it up using the ifconfig command in the terminal. Normally this works like this – on the Pi you want to connect to, type into the terminal:

ifconfig

Note the value next to “inet addr” – which usually looks like 192.168.1.(a number) – Then from another machine you can SSH to your Pi to allow for remote control

ssh pi@[the ip address of your pi]

This is fine, but most home networks use something called DHCP – ‘dynamic host configuration protocol’ – local IP addresses are temporarily assigned to the computers by your router (the DHCP server). Although these addresses often don’t change, they can. You can assign a static IP address which is something i’ve used in the past, or install a service like no-ip that tracks your Pi’s IP address (and makes it available over the internet as well). You also need to be able to connect a screen to the computer you’re attempting to connect to!

A simpler method is to use a tool called nmap (network map)- there are versions available for windows and mac, and it works from a Raspberry Pi. It’s also free.

For instance, you might have a Raspberry Pi setup on your network with a monitor and keyboard, and you’ve plugged a second Pi in that’s running SSH.

Install nmap with:

sudo apt-get install nmap

and then use the following command:

sudo nmap -sP 192.168.1.*

Returns a list of ips and hostnames – just look for the one called Raspberry Pi – This takes about 30 seconds.

Just like the matrix
Just like the matrix

Nmap does a lot of other things as well – and it’s the program of choice whenever movies attempt to depict computer hacking, or if you want to hack into Matt Damon’s brain.

If you’re looking for a more portable version there’s a (paid for) tool called Scany which is available for the iPhone and iPad or Fing which is free.

 

 

Categories
Code Gadgets Raspberry Pi

Add a Raspberry Pi temperature gauge to your blog

At the moment I have a Raspberry Pi sat in the kitchen at home, running a Ghost blog – you can usually find it a ghostpi.org (BT broadband connection permitting).

As I don’t usually leave computers running 24 hours a day, 7 days a week I was curious as to how warm the Raspberry Pi gets with use, so I’ve found a handy way of keeping track of the temperature of the CPU. Admittedly the blog isn’t driving massive amounts of traffic – it was mentioned on Reddit once which generated a spike of activity, but the plucky little Pi held up very well. There are heat sink kits available for the Pi that add a block of metal – either aluminium or copper to dissipate heat. At the more extreme end of the spectrum someone’s even created a water cooled Pi.

The snowman still isn't getting in the least bit warm
The snowman still isn’t getting in the least bit warm

Realistically, although they look nice, heat sinks are a bit like go faster stripes or fluffy dice – in use the biggest impact on my Raspberry Pi was what time of day it was, and if the sun was shining on the kitchen shelf. Famous last words, perhaps this will get slashdotted and I’ll come home to find a smouldering pile of molten plastic.

If you’re interested in hosting a Ghost blog I’ve posted some instructions here – it is a beta blogging platform based on node.js which launched last year – it generally works well on the Pi, although for slightly complicated reasons logging in takes about 3 minutes (enough time for a cup of tea).

I’ve been using RRDTool to track the temperature of my Pi’s CPU – every 5 minutes this updates a nice little graph of the last 24 hours as a PNG which is then copied to the images directory on my GhostPi.org blog:

This might get cached so click on the image for the latest version

This can then be added to a page on the Ghost blog giving some stats on how hard the Pi is working.

In putting this together I used the information on this blog with a few alterations to get it to work for me.

First install the RRD  (Round Robin Database) tool:

sudo apt-get install rrdtool

 

Then run this script to set up the database. I created a folder in my home/pi directory called ‘scripts’ and then used nano to edit the script.

#!/bin/bash
#
# update .rrd database with CPU temperature
#
# $Id: update_cputemp 275 2013-05-16 05:20:56Z lenik $
cd /home/pi/scripts
# create database if not exists
[ -f cputemp.rrd ] || {
/usr/bin/rrdtool create cputemp.rrd --step 300 \
DS:cputemp:GAUGE:1200:U:U \
RRA:AVERAGE:0.5:1:3200 \
RRA:AVERAGE:0.5:6:3200 \
RRA:AVERAGE:0.5:36:3200 \
RRA:AVERAGE:0.5:144:3200 \
RRA:AVERAGE:0.5:1008:3200 \
RRA:AVERAGE:0.5:4320:3200 \
RRA:AVERAGE:0.5:52560:3200 \
RRA:AVERAGE:0.5:525600:3200
}

 

Run the script with the bash ‘name of your script’ command.

Now create a script which will update the graph: – you might want to edit the line cd /home/pi/scripts to point in the right location. The last line starting cp copies the png file to the content folder on the ghost server. Again you might want to edit that.

#!/bin/bash
#
# update .rrd database with CPU temperature
#
# $Id: update_cputemp 275 2013-05-16 05:20:56Z lenik $
cd /home/pi/scripts
# read the temperature and convert .59234. into .59.234. (degrees celsius)
TEMPERATURE=`cat /sys/class/thermal/thermal_zone0/temp`
TEMPERATURE=`echo -n ${TEMPERATURE:0:2}; echo -n .; echo -n ${TEMPERATURE:2}`
/usr/bin/rrdtool update cputemp.rrd N:$TEMPERATURE
/usr/bin/rrdtool graph cputemp.png DEF:temp=cputemp.rrd:cputemp:AVERAGE LINE2:temp#00FF00
cp /home/pi/scripts/cputemp.png /home/pi/ghost/content/images/

Test this script with bash ‘name of your update script’ – run it a few times and you should see the green line start to grow on the png graph.

Finally because you don’t want to keep having to run the script manually you need to add it to crontab:

crontab -e

 

and then add the line:

*/5 * * * *   ./scripts/CPU_temp.sh

 

the */5 bit means run every 5 minutes, and again you might need to edit the location and name of the script.

RRDtool is quite simple – there are projects out there that use external sensors to track temperatures outside the Pi. Part of me is wondering if running RRDtool a lot and reloading the PNG file will then start increasing the temperature of the CPU in a sort of observer effect feedback loop…

 

Categories
Code Gadgets Geekery

Xtrinsic sensor evaluation board giveaway!

Thanks to the lovely people at Farnell UK I have 4 Xtrinsic sensor evaluation boards to give away. These boards include a stack of sensors (altitude, pressure, magnetometer and accelerometer) attached to a Freescale Freedom Development Platform board which has a multicolour LED and a touch pad.

Out of the box the boards show up as a USB drive when attached to a PC, and it’s possible to load apps to the board – the Farnell kit comes with a script that displays the information from the various sensors via a USB/Serial interface.

At the moment the board instructions are for PC, although there is a Linux driver available.

xtrinsic sensor board
Droids building droids?

There’s potential for lots of really interesting projects with these boards, so here’s how to win one*:

Just come up with an idea for a project using the board – can be anything you like, from the complicated to the simple – and add it as a comment below.

If you want to include a bit of information (or write a blog about your idea) link to it from your comment.

I’ll pick the 4 I like the best and send out the boards. The closing date is the 7th of December 2013 so you have a week to get your thinking caps on.

I’ll feature the ideas – and follow up on how the projects went on in a later blog post.

 *droids not included. I live in the UK but will post anywhere but it might take a while to arrive. Decisions are all final. Boards supplied by Farnell UK who send me nice stuff from time to time.

Update:

The competition has now closed, thank you to everyone who entered, I’ll be sorting through the ideas and contacting you if you’re a winner.

This rather good competition is still open –  http://uk.farnell.com/panasonic-lego-mindstorms if you’re looking for something else to enter.

Categories
Code Gadgets Geekery Raspberry Pi

Build a Raspberry Pi powered LED web counter

Here’s a little project to build an LED web counter for your blog. Proudly(!) display the number of visitors on a retro LED display, using the wordpress stats API – or potentially using any web accessible stats page.

You’ll need a Raspberry Pi (could even be the computer that’s hosting your blog) and a WordPress blog – either hosted yourself and using the Jetpack Stats plugin or on WordPress.com.

For this project I’m using a Python library called beautiful soup which can grab information from a web page – so as well as using this script to display a web counter, you could use it to display any information scraped from any accessible web page.

If you’re not using WordPress you could also do this using google analytics and the Embedded Analytics service, or by using your own counter installed on your website (see ideas below).

The Python script grabs the value from the web, and then sends it to the Pi’s serial port where it is displayed on an LED matrix.

For my project I’m using the Wharfe-Education.com BelleVue kit which fits neatly inside a Ferrero Rocher box and has a nice Back to the Future look about it. For 15 quid it’s a nice easy to solder together kit which features a 6 figure 7 segment LED display.

Wharfe-Education.com BelleVue and Raspberry Pi
Wharfe-Education.com BelleVue and Raspberry Pi

Raspberry Pi to BelleVue serial wiring diagram
Best to attach these with the power off

First make sure the Pi is powered down before attaching anything to the GPIO pins.

To attach the BelleVue to the Pi, you’ll need to attach the TXD (transmit), 5v and GND (ground) pins on the Pi’s GPIO to the inputs on the BelleVue – the right is a diagram for reference: – TXD on the Pi goes to RxD on the BelleVue, 5v on the Pi goes to Vcc and GND to GND.

For reference the diagram on the right shows the top row of GPIO pins with the Pi logo and text on the board the right way up – on the BelleVue it’s the 3 pins on the left hand side as you look at the board, again with the text the correct way up.

When you power on the Pi a sequence of characters will be sent out across the serial port. It is possible to disable this using the instructions found on the Raspberry Pi Spy website here – although they are for the Pi-Lite they equally apply to the BelleVue or any arduino powered LED display.

The Raspberry Leaf provides a handy guide to get the correct pins on the GPIO – or you can use the Adafruit cobbler and some breadboard. The serial port pins are in the same location for all revisions and A and B models of the Pi.

You could also use an arduino with an LED display – here’s an LED Matrix board made by Ciseco, which I’ve written about before:

LED matrix shield Ciseco
LED matrix shield sat on top of an Arduino Duo

or a Pi-Lite for a scrolling ticker board effect. The Pi-Lite just plugs into the GPIO and sits neatly on top of the Pi. I’ve found that the transparent Mod-My-Pi.com case perfectly fits over the Pi-Lite:

Pi-Lite and Raspberry Pi
Pi-Lite and Raspberry Pi

Alternatively if you’re up to the challenge (and want to save some cash) you could make your own – the Pi-Lite, BelleVue and LED matrix boards are all LED modules driven by Arduino based micro controllers and there’s a handy tutorial here which also includes the code you need.

Setup guide

First on the Raspberry Pi we need to install pyserial to make use of the Pi’s serial port:

sudo apt-get install python-serial

Then install the Beautiful Soup library. This allows us to grab information from a web page.

sudo apt-get install python-beautifulsoup

We could use something simpler, but Beautiful Soup is quite a handy way of scraping information from any web page, and it’s an interesting library to learn about.

For WordPress based stats:

Get your API key from https://apikey.wordpress.com – this will require you to log in using your wordpress account.

A quick test is to use the following URL:

http://stats.wordpress.com/csv.php?api_key=yourAPIkey&blog_uri=www.yourblogaddress.com&days=-1&summarize

Replacing yourAPIkey and blog_uri with your values. The final part of the URL defines what data is returned. You should see a plain text message of “views” and a number if everything is working properly. The &days=-1 returns the total number of unique visits to the site – you can replace this with &days=1 for number of views in the last day or &days=30 for number of views in the last 30 days, etcetera.

Once you’re happy with your URL, create a new python script – either on the Pi Desktop or on the command line using

sudo nano webcounterticker.py

and pasting the following python script

Once you’ve saved the script, run it using the:

python webcounterticker.py

Command – you should see your attached LED display list the number of visits to your site. This will loop with the same value until the script is stopped or run again.

Finally – but we don’t want to be constantly typing in the commands to run the script all the time – to get by this we’re going to use cron (short for cronometer – a regular clock that does things at regular intervals). For a bit more info about cron check out this blog from David Singleton.

We can set cron to run our webcounterticker.py program every minute:

sudo crontab -e

Opens your cron table in the nano editor – you just need to add

* * * * * sudo python /home/webcounterticker.py

and then control-O to save and control-X to exit. You might need to adjust the line above depending on where you saved your python script.

A few other ideas:

Once you’ve got your LED display running you might want to think of a few other things to do with it:

  • You can use Embedded analytics to generate a copy of your Google stats to use with the Beautiful Soup library
  • Use your own web counter – e.g. this php script (which I’m currently using on the footer of GhostPi.org)
  • Host a blog on the same Raspberry Pi that is running the web counter
  • Build an Ashes scoreboard to record England’s epic victory over Australia
  • Build a rack of LED counters for Web visits, Twitter followers, Emails sent or other things you want to measure (and show off)
  • Buy a DMC-12 on ebay and turn it into a time machine

As always, corrections and improvements are welcome!

Categories
Code Raspberry Pi Social Media

Trying out the Ghost blogging platform on a Raspberry Pi

Here’s a quick guide to running the ghost blog platform on a $25 Raspberry Pi.

Pi Ghost setup
Here’s my test blog

Ghost is a new piece of blog software, currently under development which was recently funded by a Kickstarter campaign. Ghost is a completely new blog platform which aims to concentrate on writing and has a really nice minimal, instantly updating theme.

Ghost uses node.js (a new one on me) and can run on the Raspberry Pi computer. So I thought I’d put together a few instructions based on my trial and error. You need to be a Kickstarter backer to download the code, although this will be released fairly soon. 

This assumes you’re running the latest raspbian build.  

For a handy reference check out this blog and the RaspberryPi.org forum posts on running Ghost. 

First Install node.js:

sudo wget http://nodejs.org/dist/v0.10.5/node-v0.10.5-linux-arm-pi.tar.gz
cd /usr/local
sudo tar xvzf ~/node-v0.10.5-linux-arm-pi.tar.gz --strip=1
cd node-v0.10.5-linux-arm-pi
node –v

(this should display the version number to test things are working ok)

then install ghost:

mkdir ghost
cd ghost

For the next step  download and install ghost-0.3.0 from the ghost website – at the moment  you need to be a kickstarter backer – log into the Ghost website, and download ghost-0.3.0.zip onto your Pi.

unzip ghost-0.3.0.zip
sudo npm install --production
sudo npm start

(go and make a cup of tea, this takes a while)

Next open a browser on the pi and enter the address:

http://localhost:2368/

and all being well you should see an intro page!

ghostraspberrypi

The built in browsers on the pi are a bit slow for blogging (particularly if you’re accessing it via a VNC connection) so to speed things up you can access your Ghost blog over your local network:

In the /ghost directory edit the config.js file. You’ll need to know your Pi’s ip address – you can get this from running ifconfig – ideally you need to set up your Pi to have a static ip address – 

sudo nano config.js

 replace “host: ‘127.0.0.1’” with “host: ‘<your IP address>'” and “port: ‘2368’” to “port: ’80′”.

and then enter your Pi’s ip address onto another computer on your network – you should now see your Ghost blog!

If found it very occasionally slows down when setting up users, but once I started adding posts and images it worked really smoothly on the Pi. Having a window open with an SSH session is interesting to see the software updating as you edit and create posts on the blog.

First impressions? it’s very minimal, but the lack of distractions makes this feel like a very creative blog platform to use – it’s not going to compete with the likes of wordpress and drupal for building fully fledged CMS websites, but as an alternative to tumblr or blogger it has a lot of potential.

Here's the side by side view
Here’s the side by side view

Ghost’s approach will be to offer the software as a free download for self hosting, or paid accounts via the website (like wordpress).

I’m looking forward to see how this evolves in time, hats off to the Ghost team. 

Update: making your local blog available on the internet:

I’ve been making my ghost test blog available on the internet – this is handy if you want to be able to update your blog from anywhere – although I wouldn’t recommend it for a production website that might get a lot of traffic, as it’s entirely dependent on your home broadband.

This is assuming you have a residential broadband account (I’m using BT broadband). Most home accounts used dynamic IP addresses, assigned by your service provider that change each time you connect to the internet – we’re going to use a service called no-ip.com which uses a program on your Pi to find out it’s address, and update a domain to point to this address. We’ll also need to open a port in the home router to allow connections to the Pi. 

First sign up for an account at noip.com – there is a free option available, or you can opt to pay $15 a year for a service with more features.

Add a host, and choose a hostname from the list of options.

Next choose the DNS-A host option and save. The settings I’ve been using are below.

no-ip configuration for Raspberry Pi

Next, on the Pi download and install the noip software (here are the instructions from RaspberryPihelp.net – check out their page if you want no-ip to run each time you switch on your Pi)

mkdir /home/pi/noip
cd /home/pi/noip
wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
tar vzxf noip-duc-linux.tar.gz
cd noip-2.1.9-1
sudo make

sudo make install
sudo /usr/local/bin/noip2

Whilst installing it will prompt you for your noip.com login details.

Finally you need to open a port in your router to allow traffic through – there is a port forwarding guide for most routers available here – I found that logging in to my router by visiting http://192.168.1.1 in my browser, finding the advanced menu and adding the local fixed IP address of my pi and web forwarding worked for me.

Hopefully if everything is working you should be able to see your Ghost blog in the wide world: my address is

ghostpi.zapto.org

although this is entirely reliant on it being switched on, which depends on the coffee machine in my kitchen needing power or not. 

 

 

Categories
Code Social Media Work stuff

Click to tweet bit.ly link generator

Here’s another super simple widget, for creating links that generate tweets when you click on them.

click to tweet
advanced tweet technology

I use these links a lot in marketing type emails for work and tend to use quick and easy online tools (because I’m lazy), but I’m always slightly nervous about sending links via another website, that might get shutdown or move.

This makes use of the bit.ly API so you can track the number of clicks on your link, and then compare that to the number of tweets sent   – check it out below:

You can download the source on github – feel free to hack about with it. It’s just 3 files (including the CSS). You just need a website that supports PHP which most do, and a bit.ly account.

Edit the settings at the top of the bitlytotweet.php file to include your source (this can be anything), username and API key.  As this script makes use of your own bit.ly account you might want to hide the widget page and not make it public.

Click to tweet and share this page!

Categories
Code Gadgets Geekery Raspberry Pi

Holga 120 D

This is an update to my original Raspberry Pi Holga camera case project.

Earlier this year Holga Direct created a digital version of the Holga – the 120d as an April fool joke – although my version lacks the 73 megapixel sensor and retina back display it does actually exist, can take nice pictures and is fairly easy to build yourself if you’d like to give it a try.

The aim of this is to build a neat case which fits the Raspberry Pi and camera module, and to do a bit of experimenting with the GPIO (General Purpose Input and Output) pins to use them to control various aspects of the camera. Lacking instant feedback and having no idea what you’ve captured until you take it home also fulfils some of the ideas behind retro analogue photography made popular by Lomography. It also looks a bit hipster.

Holga 120 d Raspberry Pi camera
Shutter release and power on the front lens

This is a fully working Digital Holga 120d – it used the case from a broken Holga, unfortunately it doesn’t use the original plastic lens (although I have kept this) as the Pi Camera board has it’s own built in lens, however it is now possible to use screw on lenses and filters.

The case is now finished but I have made a few changes since my last post:

I’ve lost the external USB port as there wasn’t quite enough space inside the case to fit the USB plug – I am now using a nano wifi adapter inside the case – specifically the Edimax EW-7811UN adapter which works well with the Raspberry Pi model A and fits inside the case.

Along the way I’ve added a few extra parts:

  • A 49mm adapter ring on the front lens – it is now possible to add filters – this is a zomei 46-49mm adapter ring (similar to this one) which screwed in to the original Holga plastic lens after using a dremel to sand down the holga lens until it fitted.
  • 3.5mm plug for external camera trigger – this is a stereo headphone socket with 2 wires attached. Am using a mono 3.5mm cable to use as a cable release driver as I think it’s some kind of standard.
  • led indicator (in the viewfinder – which glows red to indicate a picture is being taken )
  • Optoisolator flash circuit – this is an LED attached to an image sensor – the model I’m using is rated to control very high voltages.
  • A 3 position rotary switch – to select between video, still photos and program mode. This is a 12 way switch so i’m only using a few of the contacts. I used a big chunky switch I found on ebay which makes a satisfying click when you turn it – it did fit after a dremel was used to cut a larger hole. I’ve used a tap washer to fill the gap between the switch and the camera case.
Holga 120d Raspberry Pi Camera Case
Here’s the 3/4 view with the big clunky switch. It will switch something eventually.

I’m currently powering this using a (rather big) Anker USB battery – will likely use something smaller in due course but the Anker battery seems to last forever and powers the Pi with the Wifi adapter with no problems at all.

The next step is to build the hardware to connect the various inputs and outputs to the Raspberry Pi. I’ve been experimenting with these using breadboard and hope to solder it all neatly together – with details – for my next project post. Essentially I need to wire 3 switches (shutter, 2 rotary switch positions) and 2 LEDs (indicator, optoisolator) to the GPIO.

Then finally there’s the matter of some software to pull it all together. At the moment I’ve been testing using the rather useful BerryCam iOS app – although it seems ironic to be using a device with it’s own much better built in camera to control the camera of another computer remotely, it’s a useful app to test things with. If you use the instructions in the first bit of my post about using the Pi as an Adblock server you can also set the IP address to be the same each time.

Update: I’ve added the inputs and 2 LED outputs to the GPIO on the Raspberry Pi – check out this post for more details, circuit diagrams and code.

Finally here’s a selfie in the mirror:

BerryCam Holga 120d self portrait
Hello me