Well first of all happy new year to all! … Today marks the start of a new journey for me, I quit my last job in September last year, I needed a change something new, over the last three months I’ve been gathering all the tools to upcycle old objects, make old new again etc. I’ll hopefully get chance to start incorporating bigger projects in the vblog and you lot will see my mini workshop! Still have a lot of work to do, I’ll write another blog when I have some free time. Once again happy new year and have fun hacking!
Hey you guys!! So a quick catch up, new tools installed in the garage ready for the new year, awaiting some blasting medium for my cabinet and I can finally get started. The reddit arduino / pi project is finished including checksums and far less glitchy code. I made some really stupid mistakes the first time round but it’s all a learning process. I’d kinda hoped I could just grab the checksum code, copy, paste and be done but I must have spent maybe 20-30 hours debugging, refining and analysing.
Next on the agenda is the clock I’ve been working on having issues loosing time have done a fair amount of reading on the module im using and think i’ve tracked down what the issue is, we shall see though, when I get some time to sit down and start coding.
Love my workshop at the moment too still needs some more work but it’s nice walking in to a tidy place to work with plenty of space. That said there’s still a hand glider hanging up in there which I’m thinking I probably need to get rid of b/c of space … yet its never been out of the bag since I bought it.
Anyway I’m waffling, have a great Christmas and new year etc. I shall see you on the other side. Hack all the things, drink all the tea, eat all the mince pies, read all the manuals, scan all the frequencies, log all the voltages and be safe!!
Quick blog, had a nice weekend relaxing, I’m going to be busy over the next few weeks starting up a new business so videos, projects and code will be a little thin on the ground. I’ll try my best to keep you up to date with progress and hopefully everything will tie in together nicely. BBS hakologists.
Over the last three weeks I’ve been playing with various breakout boards, microcontrollers and embedded linux. I’ve been trying to take time to learn how the technology works and how best to combine them to teach and produce something useful, different and entertaining. So this project initially started out when I was playing with the RTLSDR dongle, I thought it might be cool to display the messages as they got demodulated on a separate device that was dedicated to grabbing POCSAG messages, I slapped it all together, then when my son was over the other weekend we decided to modify the code to grab the top 25 articles from a given subreddit.
Eventually when I get time ill put together a video tutorial on setting this all up but in the meantime here are the notes …
You will need:
1 x Raspberry Pi model B.
1 x Wifi dongle or ethernet cable.
1 x Arduino deumilinove.
1 x USB lead (for serial communication with the arduino)
1 x USB lead (to power the RPi)
1 x USB Charger
1 x LED Matrix 8×8 x4 (I used the horizontal style layout)
So how does it work?
Its pretty simple really, the raspberry pi runs a small python script that grabs the top 25 articles from a predefined subreddit using the api (most of reddits api can be accessed just by post fixing .json to a lot of their URLS the data structures are also well documented and available on github.) The script strips out any weird characters as the JSON is returned in utf-8 format. A string is built containing the articles rank, total amount of upvotes and the article title. If the string is over 300 characters it gets trimmed and “…” appended to the end. The script creates a serial connection to the arduino (the device is usually addressable using /dev/ttyUSB0) The string is then sent to the arduino over serial. When the arduino receives a new string it displays it to the LED matrix after having scrolled any current messages.
What’s the python code?
Install and configure raspbian in the normal way. Before running the script make sure you have internet access otherwise the python script will fail when it trys to communicate with reddit. (todo: add better error handling.)
Python code – http://pastebin.com/shXyry5C
Copy the code in to a file called reddit.py to your home directory.
Edit the file so it points to the correct serial device.
If you’re unsure about the arduino serial port run
sudo ls /dev
Look for something like …
Edit the line in reddit.py where the serial communication is initialised ensure it matches the port for the arduino.
ser = serial.Serial('/dev/ttyUSB0','57600')
Save the file using …
Make sure the file has execute permissions by issuing the following command …
chmod +x reddit.py
You can test the script by running it from the command line using the following command (*this needs to be run with superuser privs to access the serial port) …
sudo python reddit.py
Once you’re happy with the way the script is running you can make it autoboot with the pi by using the following command …
sudo crontab -e
If you are prompted which editor to use and are unsure use nano (option 2)
At the bottom of the file add the following line …
@reboot /local/bin/python /home/user/reddit.py
Save the file by pressing
Reboot and test your script is autoloading.
To display the messages on the matrix you’ll need to flash your arduino with a little code …
Wiring the arduino …
To connect the arduino to the matrix you will need to ensure you have the correct SPI pins as they differ between arduino boards the ones on the deumilinove are pins A4 and A5, A4 SDA and A5 SCL, you will also need to attach the CS (chip select) pin to pin number 13 on the arduino and also connect VCC to 5v and GND to GND on the arduino.
A4 to SDA
A5 to SCL
13 to CS
5v to VCC
GND to GND
(todo : will post a pic when i get time)
What’s the arduino code?
Arduino code – http://pastebin.com/pvkM2DUK
Copy and paste the arduino code in to your arduino IDE, you’ll also need to grab the md_max29xx library from git hub. (Download the zip file and unzip the files to your arduino IDE library folder usually /Documents/arduino-x.x.xx/libraries) This library is used to drive the LED matrix. Once you’ve installed the library you’ll have to specify how many matrices you are using in the arduino code. (How many LED matrix panels you will be displaying to my board had 4 8×8 LED panels.) Here’s the important bit though depending on what/where/who you bought your led matrix board from you might find you’ll have to edit way the arduino draws to the matrix otherwise you could be in for some very interesting results. This can be done in the md_max29xx lib folder. There are a few variables that define the matrix rotation and draw direction IE. right to left, left to right, top to bottom etc. You will need to play with these variables until you get the right combination for your matrix.
NB. When initially getting this running use the example grapicstest to make sure the leds are drawing as expected then flash the arduino reddit serial code once you have the library configured correctly.
Now all the hard work’s done
Once you’ve installed the library, edited the arduino code, updated the variables for the draw direction and successfully flashed the code, plug the arduino in to the raspberry pi and boot. There should be enough of a delay in the script to ensure the RPI has connected to your network before it makes its initial request.
If you have the arduino setup correctly you should see scrolling text on the matrix. “Waiting for serial data!” after a short while the rpi should connect and start displaying articles from reddit.
Still yet to build an enclosure or decided how / where im going to use this yet but i’ve had fun making it. Initially getting the libraries setup and running correctly was by far the most frustrating part of this project writing / editing the code was pretty straight forward. There’s plenty of scope for improvement / modification too, if I get time I was thinking I’d get it to cycle multiple subreddits, but for the time being I’ve spent enough hours on this project.
NB. The original code running on the arduino was limited to 25 characters I’ve modified this to allow for messages up to 300 characters in length (the size of an article title from reddit) Since doing so some of the serial messages appear to glitch intermittently. I’ve been checking the code for errors but haven’t managed to pinpoint the problem yet. As far as I can tell the python code runs fine but there might be a problem when the arduino is receiving the serial messages. Possible solutions maybe change the baud rate and send the data slower or add a checksum. (*As suggested by advancednewbie) Example code an library for implementing a checksum. https://github.com/AdvancedNewbie/serialChecksum
IF YOU HAVE ANY QUESTIONS REGARDING THIS PROJECT PLEASE PUT THEM IN THE COMMENTS ON THE YOUTUBE VBLOG EPISODE AT THE TOP OF THIS POST.
Had a nice early night last night. Woke up spark awake at 5.30 and couldn’t get back to sleep. So decided to make some breakfast have a brew. Loads to do, as you lot may know we’ve had some pretty bad storms in the UK recently and the weather has been particularly crap for this reason I’m avoiding sorting my garage out till it cheers up a little. I’ve got loads of little micro controller projects on the go just trying to condense what I’m learning into some useful videos / code. I’ll probably write up all the notes for the RPi reddit project later on today too with photo’s etc. Right peace BBL
Well hakology need to record a VBLOG later had some new tech arrive, nothing too special, a new microcontroller (the smallest one yet), some adapters and a couple of transistors I need for an RF amplifier I’m looking at building. Need to go and get cleaned up though before I get messy, starting to grow one of those linux admin beards.
Managed to get the arduino mini programmed using another arduino. Having issues trying to get the two boards working in unison the display draws, but I can’t seem to get the time from the RTC.
Up bright and early this morning covered almost head to toe in fibre glass insulation. Rearranging the loft to start putting some temporary flooring up there. Also want to reposition my discone and dig through some of the old tech. I was thinking about trying to pull my old acorn electron down and making a short vblog on it see if I could power it up etc … 1985 vintage … 26 year old capacitors hmmmm ? 🙂
Six hours later and I’ve used all the floor boards I have. Still a long way to go but its a start. Completely knackered going to have a rest and contemplate my next job.
Woke up very late today but respectively I had a very late night last night, tweaking the rpi/reddit/python/arduino project. Im having issues with serial communication somewhere there’s a few bits / bytes being lost? It very irregular and after a little bit of debugging I think its either the serial message get out of sync and missed part of the message or the arduino is rejecting certain characters. The reddit API JSON comes utf-8 encoded and needs converting to ASCII before I send it to the arduino, I’m processing the string to remove and replace irregular characters, I’m going to try changing the baud rate later see if this has an impact.
RE. Wardriving idk if it was where I had the GPS dongle positioned in the car but the GPS co-ords I converted to KML where ALL OVER THE PLACE so maybe its down to kismet and the –use-nmea-gps option this is the only thing I’ve really changed since I last went out. (Regardless of GPS I still managed to get some good data.)
The LED matrix project is looking very slick now, apart from the serial message issues I’m pretty darn happy with it.
Managed to get my keyboard in the post this morning on its way back to the manufacturer for the second time, think I’ve mentioned this before but, really hope they get it right this time (I’ve even requested they send me a different model this time round.) *fingers crossed*
Chores done thinking about doing a vblog assembling a small FM transmitter I purchased from ebay. Will try and get the next main hakology video done first though.
Im only rendering the sdr# video! … still dont have the perfect solution for screen capture but its done now … the audio is terrible near the start next time will record on another device as noise supression appears to be playing hell with my laptop capture, meh, its done now time to move on and not make that mistake in future.
Todays VBLOG I made an FM transmitter from a small kit I purchased on ebay. Just rendering the video and preparing to upload it. This by far was the most enjoyable vblog I’ve done so far may be more to come like it.
Time to get busy NO MATTER WHAT. Had a great weekend spent with my son and family, we even did a little coding using the reddit API. Sunday was cool too, I managed to grab some bargains from a few second hand sales, nothing exciting or tech related, just a few books on survival/bushcraft/scouting. Today im going to attempt to record the SDR# video as the last time I forgot to hit record! (*not quite I forgot to hit record but that’s another story/rant), I’m also ready to go war driving so that might be a thing in a few hours. Had some more breakout / dev boards turn up in the post but not the one I’m waiting for, lol, its always the way.
Nothing ever goes as planned, I went for a little war drive earlier after having installed kismet, gpsd-clients and gpsd. Recently I reinstalled debian with lxde and I couldn’t figure out, or seem to kill the gpsd process to set my gps as the default device (/dev/ttyUSB0), no matter what I did couldn’t get kismet to detect the dongle in gpsd or even find the configuration file. I decided to run kismet with the –use–nmea option BUT this was a lot less reliable in kismet than what gpsd usually is. Then my netbook went to sleep as I havent figured out the power saving settings in lxde yet. (I’ve been using lxde less than a week) I pulled over to restart my scan but accidentally chose the wrong wireless device when I restarted kismet, so all in all a complete mess. That said I’m working on a little script to load everything at once correctly so this won’t happen again. I really newb’d out tonight, If at first you don’t succeed try harder.
sudo kismet -c wlan1 -use-nmea-gps /dev/ttyUSB0 -gps-reconnect true
DO NOT USE THIS FOR GPS IT SUCKS … I had the most sketchy log files using this syntax to call kismet. Might have been the way I had the dongle positioned but I think its the way netxmltokml process the file when its been generated using that switch.
Good afternoon, just getting warmed up. Going to try and record the SDR# video today and start re-writing that matrix driver. Had a productive evening last night posted the new VBLOG and mini intro video for the VBLOG channel. Now the fun begins with windows screen capture at least I won’t have to mess with the file format, but from experience I’m going to be recording in chunks as there’s nothing more frustrating getting to the end of recording a long tutorial and finding out the screen capture failed to save.
Too much shit being talked today … I’m avoiding social media. *reaches for a datasheet*
Good afternoon hakologists, I’ve finally got the LED matrix ‘working’ I’ve managed to find one library that draws correctly to the screen, with a little bit of effort I think I could rewrite it for multiple matrices. Today I’m going to get a quick vblog together then later tonight hopefully record the SDR# video. Then we’ll take a look at multimon-ng and demodulating pager messages.
Need to send a massive shout out to gir, for sending hakology 2 RPi Zeros from the US as I couldnt get any at a reasonable price anywhere in the UK. Ridiculous considering they are made less than 50/60 miles from my house.
Family stuff over, vblog recorded, introduction video for vblog channel recorded, vblog rendering, time to get the kettle on and make a brew, thinking I might have a look at an old netgear router I have, see if I can connect using those new USB2UART boards. If I’m feeling really productive I might even get the sdr# video done.