chebe: (AsciiC)
This is a fun one. I was playing with my Explorer pHAT and noticed that every time I Ctrl-C'd out of a script I'd get a message;

Broadcast message from root@raspberrypi (somewhere):

BCM 4 held low, system shutdown in 5 minutes


Broadcast message from root@raspberrypi:

The system is going down for power-off!


And yes, the pi would turn off. Every single time.

I don't know why the Explorer pHAT seems to pull BCM 4 low upon exit, when none of my other pHATs do. But I do know why that was triggering a shutdown.

I had also installed (though not in use) the Zero LiPo SHIM and the OnOff SHIM. They both install the clean-shutdown library that does just what it says, shuts down your pi when BCM 4 is held low.

It installs the cleanshutd service, but it didn't respond to my attempts to stop it, so I had to disable it.

In /boot/config.txt add;
disable_cleanshutd=1
Save, exit, reboot. Then you can play around with your Explorer pHAT in peace.
chebe: (Candles)
The Ikea Trådfri lights look very interesting. While not cheap, they are much more affordable than other wireless 'smart' lighting. They don't do RGB colours (yet), but you can control the colour temperature; ordinary neutral soft yellow, a warm orange, or a bright white. You can also dim the lights, and of course, turn them on and off. They don't do too much, but what they do they do well, and there don't appear to be any major security holes. But most interestingly, they use ZigBee, and seem to be built on top of a lot of open source stuff. Which means, there are already tools to play with them.

First thing you're going to need to do is get some Trådfri lights. They do have a starter kit, but I wanted the smaller E14 bulbs so I built my own (for not much extra). You'll need the Gateway hub, a control device (remote control definitely works, I don't know about using the dimming set, or motion sensor instead), at least one bulb, and have a lamp/socket to put it in.



Supplies; gateway, remote control, two E14 bulbs, and two lamp shades
Photo by chebegeek



The Gateway has a companion app to set everything up. You pair the app (your phone) to the Gateway, then you pair the Remote Control to the Gateway. Then you add the bulbs (pairing through the Remote Control) one by one. The app lets you arrange the bulbs into separate groups, or lump them all into one if you prefer. Once all that is done, it's time to build your own control interface.

Mostly I followed this excellent tutorial from the lovely Pimoroni crew.

sudo apt-get install build-essential autoconf automake libtool
(Or on Fedora;
sudo dnf install build autoconf automake libtool)

git clone --recursive https://github.com/obgm/libcoap.git
cd libcoap
git checkout dtls
git submodule update --init --recursive
./autogen.sh
./configure --disable-documentation --disable-shared
make
sudo make install


You're going to need the Gateway IP address. You can log into the router, or scan the network. The Pimoroni tutorial found their's at 192.168.0.10. I found mine at 192.168.0.20, so it probably jumps in steps of 10 until it finds an empty slot.
There is a Security Code on the base of your Gateway, you'll need to make a note of it.

The endpoint protocol is coaps:// and the port is :5684, followed by 15001 to control bulbs individually, or 15004 to control as a group.

A good way to start is by sending info requests to both endpoints;
coap-client -m get -u "Client_identity" -k "your_security_code" "coaps://192.168.0.20:5684/15001"
You'll get back an array of devices;
[65536,65537,65538]
It's a bit predictable. The first number is your remote control, the next two are bulbs, in the order you paired them.

coap-client -m get -u "Client_identity" -k "your_security_code" "coaps://192.168.0.20:5684/15004"
Also gives you back an array, but with the group ids, which seem much less predictable. (You can also find the group ids in the app.)

You can append the ids to the requests to get more information about each. Helpfully, there is an English description (i.e. "TRADFRI remote control", "TRADFRI bulb...", etc) returned in each.

The bulbs have a field "3311" with detailed state information. You can set parts of this to control the lights with -m put commands, e.g.;
coap-client -m put -u "Client_identity" -k "your_security_code" -e '{ "3311": [{ "5850": 0 }] }' "coaps://192.168.0.20:5684/15001/65537"
"5850" controls on/off and takes 0 or 1.
"5851" controls brightness, and takes values between 0 and 255.
"5709" and "5710" seem to work together to control the colour temperature. Valid values can be found by using the Remote Control, and then querying the state. The three main ones seem to be;
-e '{ "3311": [{ "5709":24933, "5710":24691 }] }' for bright white,
-e '{ "3311": [{ "5709":33137, "5710":27211 }] }' for warm orange,
-e '{ "3311": [{ "5709":30138, "5710":26909 }] }' for neutral yellow.


But this is all from the terminal. There is a nice python wrapper (with come convenience calls) if you want to start calling it from python, which is helpful if you want to start using python libraries for interfacing with hardware on your Raspberry Pi Zero W. But you'll find all of that in the tutorial.

There's also so much beautiful info in the thread that started all this. Have fun!



Ikea Trådfri lights controlled from Raspberry Pi Zero W
Photo by chebegeek

Print+ DIY Headphones

2017-Aug-14, Monday 01:41 pm
chebe: (Purple - DanceLikeNooneisWatching)
On 13 October 2015 I backed a crowd-funding campaign for DIY headphones. The plan being, they send you the electronic bits, and the fabric bits, and you 3D print the form (from designs they would provide). Seemed pretty sweet to me. And to many other people, because the next day it was successfully funded.

Around 9 May 2017 the electronics and squishy bits arrived. They were still tweaking the 3D design files, but it didn't matter much as I'd lost my access to 3D printers. They said they would be partnering up with 3D Hubs to help out people in my situation, so I scoped out some prices. They went from hundreds of euro, to thousands. I didn't order any. Shortly thereafter Print+ opened their own store selling printed parts for only €35. Much better! I ordered as soon as I could on 30 May. There was more of a delay, as I think they actually started doing the printing themselves. They sent me an apology, a discount code, and I got a shipment notice 26 July. They finally arrived last week, 10 August.

13 October 2015 to 10 August 2017. But, I now have some nifty headphones.

Assembly details )

The fit is tight to the head, which I actually appreciate as there is less loss of sound. They're incredibly light-weight, and definitely possess an unique look. They also sound damned good, especially for the price tag.



Print+ Headphones (design #1) in PolyMatte Grey and purple
Photo by chebegeek

(no subject)

2017-Apr-17, Monday 12:33 pm
chebe: (DearDiary)
Aaaaaaand done! My LJ is wiped down, all images moved. After 13 years, 1 month, 1 day. So please let me know if you stumble across any deadlinks.

LovelaceSpace

2017-Apr-14, Friday 10:54 pm
chebe: (Purple - DanceLikeNooneisWatching)
Ahem. Hi. Yes, I'm still around. (Only four more years of posts to go through and relocate the images, and I'll be LJ free!) I was at MakerFaireUK a couple of weeks ago, helping some of the tog guys at their stand. It's always a great trip, to catch up with people from other spaces. (And this time I even got to drool over a laser cutter I really, really want.) But things were a bit different this time, I was wearing a different hoodie. This year I was representing for LovelaceSpace.

A while back I made a post about why I needed to leave tog. In the meantime, as I whined to anyone who would listen, people started making suggestions, and dropping hints. This coalesced into something. Something truly wonderful. A working group, of passionate, hard-working, truly kick-ass humans, to set up an intersectional feminist lgbtq+ inclusive secular space, for hackers, makers, educators, and feminists, in Dublin, Ireland. It's a massive undertaking, we know we're unlikely to get everything right, but we really, keenly, want to try.

Our first event was last month. A cross-stich event, held in a very congenial pub. We'd expected maybe 20 people, 30 people tops. Turnout was more like 65-75. Some people even dropped in just to pick up kits. We could barely cope with the volume. At the busiest we had taken over more than half the pub!

We can't take all the credit. The event was a charity fundraiser, a rather popular one, and it was just before International Women's Day, and the protests that were planned to coincide. We raised €360, which bowled us over. The money went to ARC, an organisation challenging the restrictive abortion laws in Ireland. They are just one of many groups campaigning for change, to Repeal the 8th Amendment.

Our event idea was simple, take the symbols of these organisations, this iconography of the movement, and create cross-stitch patterns that people could turn into pins/badges/anything they wanted. We just didn't realise it'd be so popular! We had people from the other ends of the country asking us to run the workshop down there too. We had people in England wanting in. The solidarity, the love, in these communities, is so strong, so raw. Especially coming from a mostly techie background, it was a surprise for me. It was beautiful.

Well, our next event is somewhat similar, but completely different. The Science Gallery have a 'Humans Need Not Apply' exhibition on at the moment. They have an AI, Hoopla, that designs embroidery patterns. They've asked us to run a workshop to show people how to turn these designs into actual physical objects. This event is free, but also much smaller. It should be fun.

From the organisational side, we have another meeting tomorrow. We're working on finalising our Code of Conduct, planning even more events, and trying to get our documentation in place so we can become a legal structure. And then, find a physical space so we can house this amazing community 24/7.

It's hard work. For a group of people who are already over-worked. But the need for this kind of space, the passion and dedication of the people we interact with. It's a tonic against so much going wrong all around us. It is my primary source of hope right now.
chebe: (VintageMoon)
You know what's super annoying? Not knowing the ip-address of the server you're trying to access. I could scan the network and find the right machine. But, I'm lazy. And, the server knows its own ip, it should simply tell me.

This is something I believed my Pirate Radio could manage. When the pHAT BEAT bonnet gets installed it sets itself up with a daemon in /usr/bin. Technically I installed it twice (once for spotipy as well). I don't know if the code differs, but as I installed vlc-radio last, that's the code I will play with.

Think it through. I've just booted up the server. The volume and power buttons do very necessary jobs, so we'll leave them alone. The fast-forward and rewind buttons start playing a station/cycle through stations. Very useful if you can't be bothered finding the ip-address. That leaves Play/Pause, which doesn't do anything until a station has started streaming. And if I have access to the web interface, well I can do that very job there. That's it, I'm sacrificing Play/Pause!

In the end I simply replaced line#204 with a call out to my script;
myip.read_ip()
(making sure to import it at the top of the file. Let's hear it for the wonders of Open Source!)

What script you ask? A simple one, to parse the wlan0 ip from ifconfig, and then a call to text-to-speech to actually read it out loud to me.

You'll probably need to install the text-to-speech stuff;
sudo pip install pyttsx
sudo apt-get install espeak


Then save this as a file named myip.py (or whatever) into /usr/bin

#!/usr/bin/env python

import os, pyttsx, time

def read_ip():
f = os.popen('ifconfig wlan0 | grep "inet\ addr" | cut -d: -f2 | cut -d" " -f1')
your_ip=f.read()

engine=pyttsx.init()
engine.say(your_ip)
engine.runAndWait()

time.sleep(3)
print your_ip

if __name__ == '__main__':
read_ip()


And sure, give it a reboot to make sure the changes are picked up.

Now, when I press play the Pirate Radio reads out its ip-address to me! So handy.
(Note; if you press play with monitor and OTG cable attached, it'll probably crash and reboot. So don't do that.)

Pimoroni Pirate Radio

2017-Mar-26, Sunday 10:44 pm
chebe: (Purple - DanceLikeNooneisWatching)
Hardware
Order the Raspberry Pi Zero W Pirate Radio (get it?) kit.
Assemble. Making sure you put the headers on the correct way around *cough*.

Software
Download the NOOBS installer. Extract archive. Copy contents to microSD card of 8GB+.
Put microSD card in Pi, supply power to boot. (You will need a monitor (micro HDMI), OTG micro-USB adapter to plug in keyboard and mouse.)
When boots into installer connect to wifi. (Have the details handy, you'll need them again later.)
From the network install list select Raspbian Jessie Lite.
Lite boots into console only (you can do away with the mouse now). Default login deatils are; pi/raspberry. You'll need to edit a config file to connect back to wifi;
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
And add;
network={
ssid="YOURSSID"
psk="YOURPASSWORD"
}

Once online, install all your favourites (*cough* vim *cough*). Now is also a good time to set up the Pi as you want it. For instance, change the hostname;
sudo hostnamectl set-hostname new_host_name
You'll also need to update the hosts file;
sudo vim /etc/hosts
And update the line that says;
127.0.0.1 raspberrypi

You can test the speaker with;
aplay /usr/share/sounds/alsa/Front_Center.wav

Spotipy
Okay, so far so good. But, it's supposed to be a radio yeah? Do you have Spotify Premium? Then you can hook it up, with a convenient one-line installer;
curl https://get.pimoroni.com/spotipy | bash
It will install a whole load of things (details here), asking for your input (including Spotify login details), and then reboot.

From another device you can access the web interface at http://192.168.0.2:6680/iris/ (run ifconfig on the Pi and take the ip address from the wlan0 interface). You'll need to go to the Settings tab and Authorize your Spotify account. Ta-da, that's it, rock out.

(But, it seems the installer doesn't actually remember your Spotify details properly, so open /etc/mopidy/mopidy.conf, down the bottom check that the [spotify] section contains your username and password. It had forgotten my username and mangled my password, so definitely check.)

(Also, your session will timeout regularly, just log back in, no worries.)

VLC
But, I was not content with just Spotify. I wanted actual internet radio. So I installed the vlc-radio as well.
Again, just one line installer;
curl https://get.pimoroni.com/vlcradio | bash
You can access the web interface at http://192.168.0.2:8080 (default login details; blank username/raspberry).
If you want to queue up your own internet radio stations save them as playlist.m3u, and scp over to /home/pi/.config/vlc/. Then reboot.

(SSH server is off by default, you can turn it on through sudo raspi-config, more details here.)

Other than warning you that the default volume is very high, that's it. Enjoy!

Open Theremin V3

2017-Feb-26, Sunday 06:24 pm
chebe: (OnTheVergeOfSomethingWonderful)
Gather:
- active/powered speakers with a 3.5mm stereo audio jack (bonus points if the power plug is grounded)
- camera tripod
- Arduino Uno, from wherever it has been gathering dust (and USB/power cable)

Acquire:
- Open Theremin Arduino Shield
- 1m of aluminium round tube; 6mm external thickness, 1mm wall thickness, 4mm internal diameter, from your local hardware shop

Do:
- Cut tube in half, and bend (or get bent) each half into the shape described in the diagram
- Solder shield together. (The button and LEDs are surface mounted. I scorched a leg pad of the yellow LED, so no blinky yellow for me.)
- Program Uno
- Plug all the bits together. The whole lot should be grounded, but both my speakers, and the Arduino, are powered over USB, and I could not find an earthed USB-converter plug. So, at the moment, they are plugged into my laptop, which is plugged into the mains. (There is a ground pad on the shield that I should hook up in future.)
- Power up, leave to warm up, trigger auto-calibration
- Make ALL THE NOISE



Theremin!
Photo by chebegeek



- Start band

(no subject)

2017-Jan-18, Wednesday 04:17 pm
chebe: (Default)
You may have noticed a lack of updates. That's mainly because finding, and updating, all the image links in my blog takes a very, very long time. Did you realise I've had this blog nearly eight years? I certainly didn't.

In other news, I'm falling down the Quantified Self rabbit hole. I'd like to have a blog to reflect it. So that's another project on the backburner.
chebe: (OlympusCamera)
You are Good People, right? You just want to get what's yours (albeit in the laziest way possible), right? You don't want to misuse any tools to cause any damage, right? Okay, great, listen up.

A while back I came up with some cmd line calls using wget to back up my LJ Scrapbook. This method stopped working as LJ restructured Scrapbook a few times. Me, I kept using them as free image hosting. But, for some reason, I've been remotivated to get a backup.

They use Flash. Flash does not play nice with, well, anything. So I am left with the not so elegant brute-force approach.

Log in to LJ. Go to your Scrapbook, view a photo, click on the little share icon. Grab your $usernumber.
Format:
http://ic.pics.livejournal.com/$username/$usernumber/$photonumber/$photonumber_original.jpg
Have a look at your newest upload, note the $photonumber.

While logged in, export your cookies.txt (see previous post, basically find plugin for your browser).
Plug $username, $usernumber, and a number greater than the $photonumber into $maxphotonumber.

Run script.

#!/bin/bash
username=your_user_name
usernumber=your_user_number
maxphotonumber=your_max_number
for (( c=0; c<=$maxphotonumber; c++))
do
wget --load-cookies cookies.txt -erobots=off -nd -np -r http://ic.pics.livejournal.com/$username/$usernumber/$c/"$c"_original.jpg
done


The script simply checks every single number between zero and your maximum number. If there exists an image, it will save it, with the same name. It only checks for the _original images. It saves everything in the one directory. It is not optimised, but it should get everything. Most of the flags aren't needed. But I think they show well just how much patience I lost with this whole thing.

*edit* About 14 hours to get over 1,000 pictures in a 280,000 number range.

*edit2* If you get a few unopenable files, try different format extensions.
Page generated 2017-Aug-23, Wednesday 01:59 pm
Powered by Dreamwidth Studios