I needed a way to control the cheerlights that could be useful for friends who didnt have or understand twitter. Whilst to most of us sending the colour or a sentence with a colour included along with the hashtag cheerlights was the norm, I needed to simplify the process.
Firstly obtain an Amazon Dash Button, they are a fiver in uk money, but order the product that the button is for e.g. duracell order batteries, then you get your fiver back making it free.
next was to follow the instructions that come with the dash button, order those batteries (or whatever you chose the dash button to be) then delete the button before re installing it. when you get to the point of choosing your product again just exit and turn off dash button notification as you dont want to be ordering more product everytime the button is pressed.
next was to write the code, I needed (and failed quite a few times to begin with) code that could look for the mac address of the amazon dash button on my network, after several tries and googling each bit of code that gave me errors I found and edited some lines and bingo the hello world message I had been looking for telling me the button had been pressed and the ip address of the router.
I then tried to incorporate a way that this could be tweeted and colour and went for a random message option where I had a dozen ready made sentences with a different colour mentioned in each followed by the hashtag. I ended up using tweepy which is easily installed with a apt-get install python-tweepy and went to an old blog I had about a twitter camera I built for my wedding and hacked away at the code taking all the bits i needed and writing it to just tweet once when code was run and it worked.
Next was to merge both scripts into one and run it, bingo it worked and didnt send tons of messages either which was a main worry.
Future work on this code will be to introduce a way to detect you are not tweeting the colour already in use and also not to tweet a previous colour as twitter doesnt like this.
My code can be found on git hub at github.com/smstext/dashbuttoncheerlights
Showing posts with label pi. Show all posts
Showing posts with label pi. Show all posts
Friday, 27 July 2018
Tuesday, 7 March 2017
Raspberry Pi Wedding Twitter selfie camera
I wanted to do something for my wedding to my wonderful wife that was different. We had already planned a non traditional wedding with lots of different things, but I also wanted something that would be seen as trendy amongst the cool kids.
My daughter told me about a photo booth company but with such a small budget we couldnt afford one then I remembered something similar had been done and after a few googles I found tons of similar ideas but all seem to use Twython and from what I read parts had been depreciated yet I couldnt find the right commands to actually make it work.
So with the latest Raspberry PiZeroW and offical case, old pi camera from another project I began my project. I had to enable ssh and vnc, personally I prefer sshing in to deal with issues but vnc can be better for trouble shooting.
I then had to make a twitter account (@angelapawedding) and set up the api so i could get the access and consumer tokens and set to read write and got to work, even soldering two pins on the back to 3rd and 4th pin in on the top row to attach a two wire pc wire/button reset switch to. I figured this way if kids dropped or pulled it at least it could be reconnected with ease.
here is the code:
-----------------------------------------------------------------------------------
#mypifi feel free to use
#!/usr/bin/env python2.7
import tweepy
import sys
from picamera import PiCamera
from time import sleep
from datetime import datetime
from gpiozero import Button
consumer_key = 'goes here'
consumer_secret = 'goes here'
access_token = 'access token code goes here'
access_token_secret = 'access secret goes here'
button = Button(14)
camera = PiCamera()
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
while True:
button.wait_for_press()
status = "#LobsterWedding"
timestamp = datetime.now().isoformat()
photo_path = '/home/pi/wedding/photo/%s.jpg' % timestamp
sleep(3)
camera.capture(photo_path)
with open(photo_path, 'rb') as photo:
api.update_with_media(photo_path, status=status)
-------------------------------------------------------------------
The status part of the code is what text you want to display with the picture I used a hashtag so it be easy for people to find pictures or even add theirs for the wedding. If you are interested, lobsters are supposedly meant to mate and be loyal to the same partner for life.
photo_path is where the picture is stored in my case its stored in folder called wedding in another folder within called photo. each file saved here is given a unique filename and the program then tweets the latest picture using the twitter api via tweepy.
I saved the file as camera.py and chmod +x the file. Once in place I vnc'd into it opened up a terminal and ran camera.py and then left it.
So throughout the evening guests (and especially the younger ones) had something to do and even my selfie obsessed daughter had a go as you will see below. Guests could look up what had been tweeted by the camera at @angelapawedding or by searching the hashtag #lobsterwedding.
Sure the code could be cleaned up a bit more and more could be done with it, but for a quick project between finalising the final parts of the wedding I thought it was pretty good and was also a good talking point to guests.
If you do find a way of tidying up code then feel free to comment below and I will add it to the blog.
My daughter told me about a photo booth company but with such a small budget we couldnt afford one then I remembered something similar had been done and after a few googles I found tons of similar ideas but all seem to use Twython and from what I read parts had been depreciated yet I couldnt find the right commands to actually make it work.
So with the latest Raspberry PiZeroW and offical case, old pi camera from another project I began my project. I had to enable ssh and vnc, personally I prefer sshing in to deal with issues but vnc can be better for trouble shooting.
I then had to make a twitter account (@angelapawedding) and set up the api so i could get the access and consumer tokens and set to read write and got to work, even soldering two pins on the back to 3rd and 4th pin in on the top row to attach a two wire pc wire/button reset switch to. I figured this way if kids dropped or pulled it at least it could be reconnected with ease.
here is the code:
-----------------------------------------------------------------------------------
#mypifi feel free to use
#!/usr/bin/env python2.7
import tweepy
import sys
from picamera import PiCamera
from time import sleep
from datetime import datetime
from gpiozero import Button
consumer_key = 'goes here'
consumer_secret = 'goes here'
access_token = 'access token code goes here'
access_token_secret = 'access secret goes here'
button = Button(14)
camera = PiCamera()
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
while True:
button.wait_for_press()
status = "#LobsterWedding"
timestamp = datetime.now().isoformat()
photo_path = '/home/pi/wedding/photo/%s.jpg' % timestamp
sleep(3)
camera.capture(photo_path)
with open(photo_path, 'rb') as photo:
api.update_with_media(photo_path, status=status)
-------------------------------------------------------------------
The status part of the code is what text you want to display with the picture I used a hashtag so it be easy for people to find pictures or even add theirs for the wedding. If you are interested, lobsters are supposedly meant to mate and be loyal to the same partner for life.
photo_path is where the picture is stored in my case its stored in folder called wedding in another folder within called photo. each file saved here is given a unique filename and the program then tweets the latest picture using the twitter api via tweepy.
I saved the file as camera.py and chmod +x the file. Once in place I vnc'd into it opened up a terminal and ran camera.py and then left it.
So throughout the evening guests (and especially the younger ones) had something to do and even my selfie obsessed daughter had a go as you will see below. Guests could look up what had been tweeted by the camera at @angelapawedding or by searching the hashtag #lobsterwedding.
Sure the code could be cleaned up a bit more and more could be done with it, but for a quick project between finalising the final parts of the wedding I thought it was pretty good and was also a good talking point to guests.
If you do find a way of tidying up code then feel free to comment below and I will add it to the blog.
Monday, 13 June 2016
Keyes 16x8 led matrix add on board
I bought one of these keys 16x8 led boards a while back but couldnt get it working. Well a lie i couldnt get both screens working.
So tonight whilst looking for something different I found this board and decided to give it another try. On googling i kept finding arduino set ups which wasnt what i wanted and after using git clone https://github.com/rm-hull/max7219.git i searched for projects which used mr hulls code and came across one which pointed me to another github repo.
So here we go:
First enable SPI in sudo raspi-config (look in advanced menu)
next type:
sudo git clone https://github.com/leon-anavi/raspberrypi-matrix-led-max7219
cd raspberrypi-matrix-led-max7219
sudo python setup.py install
There we go. Some good example codes there and after some playing around i managed to get it to display the time.
Sunday, 29 May 2016
Reintroduction to caching
After the passing of my beloved dog Frodo a couple of weeks ago I decided to brush the cobwebs off my basic looking mountain bike that I had been given a while back and decided to take it for a ride and do a few geocaches as a carrot to the donkey to ensure i didnt give up to quick. First thing i noticed was I lost my pen. after trying to sign in with a dirty stick I managed to find a waxy crayon in the puncture repair kit and decided this was my pen for the day.
It was nice to get back into the countryside and felt weird as this was where me and Frodo had come many times, but in recent years we had gone from unlimited miles per walk, to 10, then 6, down to 3 then less than a mile.
I was disappointed to the fact there were not any traditional size caches just tiny boring micros.
I had been for a while playing Ingress another location game but after being caught up in a widespread ban for allegedly breaking TOS which to this date I still dont have a clue but it be something to do with travelling to fast between locations or something stupid to which i have lodged a appeal as reaching level 14 without cheating and playing within the rules feels like an insult. The other option would be to start all over again and work my way back up and with what i know these days it would take long, but still why should I after the way they have treated me in this mass world wide ban sweep that took place last week. Ive heard that those that appeal have a very low chance of having their accounts reinstated so who knows I should hopefully be one of those.
But on a huge positive I thought about my raspberry pi geocaching device. It was made with a pi model b. now thinking about it I could remake it as a wrist band device with a pi zero and a long lead to a battery pack in my bike bag and have a new gps system. maybe i will work on this idea next.
It was nice to get back into the countryside and felt weird as this was where me and Frodo had come many times, but in recent years we had gone from unlimited miles per walk, to 10, then 6, down to 3 then less than a mile.
I was disappointed to the fact there were not any traditional size caches just tiny boring micros.
I had been for a while playing Ingress another location game but after being caught up in a widespread ban for allegedly breaking TOS which to this date I still dont have a clue but it be something to do with travelling to fast between locations or something stupid to which i have lodged a appeal as reaching level 14 without cheating and playing within the rules feels like an insult. The other option would be to start all over again and work my way back up and with what i know these days it would take long, but still why should I after the way they have treated me in this mass world wide ban sweep that took place last week. Ive heard that those that appeal have a very low chance of having their accounts reinstated so who knows I should hopefully be one of those.
But on a huge positive I thought about my raspberry pi geocaching device. It was made with a pi model b. now thinking about it I could remake it as a wrist band device with a pi zero and a long lead to a battery pack in my bike bag and have a new gps system. maybe i will work on this idea next.
Sunday, 24 February 2013
Pideas.co.uk now live
Today pideas went live, its been started up by a student called Ryan Walmsley who kindly gave me a chance to enter my twitter furby project early before the site went live, however i had a few problems in getting it published so waited till the site went live and published it then.
At the moment there are four projects including my own for the raspberry pi, but i have done another write up waiting for moderation before that will be added and have also had ideas for another project thanks to one ive seen already called twitter letterbox.
So if you have a raspberry pi and dont have any ideas of a project to do or you have made tons of projects that you would like to share with other like minded people then pop over to www.pideas.co.uk and sign up. Once signed up you can submit your project for moderation before its published for the world to see.
All thats left to say is tell your friends and family and remember to mention the site in your posts as well as raspberryjam meets.
Monday, 12 November 2012
geocaching pi
Not really been up for much outdoorness recently, might be the time of the year or I can't be bothered to drive for an hour to get to a trail.
However I have started a new project called raspberry pi. It's a £20 quid computer that you need to then buy a lead to you tv (99p) a case (a couple of quid) power pack (couple of quid again) wifi or Ethernet and USB keyboard and mouse (about 7 quid) and a USB powered hub (three quid). Oh an an sd card of minimium 4gb and preferable class 10.
So for under fifty quid it's up and running, I currently have two. One is plugged in with ssh and vnc so I can play and learn from anywhere. The other I interchange the sd cards, one card has xbmc on it and since changing the class 4 card to a class 10 doesn't seem to buffer or drag no more I know have a better way of watching films than with my apple tv.
Ok I've had to start learning Linux and unix and have been lucky to find many of the books on amazon second hand costing a grand total of £2.81 including postage for many books costing ten times what I'm paying for brand new. Yes I've had one dirty book with part of a page ripped out, but 99% of the books have been received like brand new.
My current project is to make a cloud at home to use from anywhere. I did succeed with my first file server and ended up connecting my tb harddrive back to the router and have since started adding all my DVD s to it as my music (200gb) is already loaded on there after going through a spate of buying secondhand CDs for less than a quid including postage and using iTunes to get a better quality with their service and cloud thingy and certainly cheaper than buying the old albums from iTunes.
So what have I planned? Well I'm looking eventually to run one of these devices from the car with mobile data, touchscreen, live maps and live cache status of caches, ambitious? Yes but an interesting project it will be.
However I have started a new project called raspberry pi. It's a £20 quid computer that you need to then buy a lead to you tv (99p) a case (a couple of quid) power pack (couple of quid again) wifi or Ethernet and USB keyboard and mouse (about 7 quid) and a USB powered hub (three quid). Oh an an sd card of minimium 4gb and preferable class 10.
So for under fifty quid it's up and running, I currently have two. One is plugged in with ssh and vnc so I can play and learn from anywhere. The other I interchange the sd cards, one card has xbmc on it and since changing the class 4 card to a class 10 doesn't seem to buffer or drag no more I know have a better way of watching films than with my apple tv.
Ok I've had to start learning Linux and unix and have been lucky to find many of the books on amazon second hand costing a grand total of £2.81 including postage for many books costing ten times what I'm paying for brand new. Yes I've had one dirty book with part of a page ripped out, but 99% of the books have been received like brand new.
My current project is to make a cloud at home to use from anywhere. I did succeed with my first file server and ended up connecting my tb harddrive back to the router and have since started adding all my DVD s to it as my music (200gb) is already loaded on there after going through a spate of buying secondhand CDs for less than a quid including postage and using iTunes to get a better quality with their service and cloud thingy and certainly cheaper than buying the old albums from iTunes.
So what have I planned? Well I'm looking eventually to run one of these devices from the car with mobile data, touchscreen, live maps and live cache status of caches, ambitious? Yes but an interesting project it will be.
Subscribe to:
Posts (Atom)




