That’s the rapid clatter of chopping up Kothu Roti at Amma at the end of our street. You know that tasty spicy food is imminent when you hear that sound. I’m really pleased that Amma’s back under the original management. The other proprietors just didn’t care as much about their food.
Blog
-
Potentially handy Raspberry Pi power source
This looks handy; it’s the Globe Electric 2-Outlet Tap with Surge Protection and 2 USB Chargers (#46082). The USB outlets are rated at 1A. It was $12 at Loblaws. I’ll let you know how it works out for powering the Raspberry Pi.
Update: Yes! It works!
-
python + Arduino + Tk: Toggling an LED
Whoa! This is so old I don’t even know where to start!
- It’s using Python 2, so if it works at all it probably won’t for much longer, and Tkinter is something completely different under Python 3
(grrreat planning there, Python guys …) - pyfirmata is likely ancient history too.
Phil sent me a note last week asking how to turn an LED on or off using Python talking through Firmata to an Arduino. This was harder than it looked.
It turns out the hard part is getting the value from the Tkinter Checkbutton itself. It seems that some widgets don’t return values directly, so you must read the widget’s value with a
get()
method. This appears to work:#!/usr/bin/python # turn an LED on/off with a Tk Checkbutton - scruss 2012/11/13 # Connection: # - small LED connected from D3, through a resistor, to GND import pyfirmata from Tkinter import * # Create a new board, specifying serial port # board = pyfirmata.Arduino('/dev/ttyACM0') # Raspberry Pi board = pyfirmata.Arduino('/dev/tty.usbmodem411') # Mac root = Tk() var = BooleanVar() # set up pins pin3 = board.get_pin('d:3:o') # D3 On/Off Output (LED) def set_led(): # set LED on/off ledval = var.get() print "Toggled", ledval pin3.write(ledval) # now set up GUI b = Checkbutton(root, text = "LED", command = set_led, variable = var) b.pack(anchor = CENTER) root.mainloop()
This is explained quite well here: Tkinter Checkbutton doesn’t change my variable – Stack Overflow. I also learnt a couple of things about my previous programs:
- You don’t really need to set up an Iterator unless you’re reading analogue inputs
- My “clever” cleanup-on-exit code actually made the script hang on Mac OS.
- It’s using Python 2, so if it works at all it probably won’t for much longer, and Tkinter is something completely different under Python 3
-
No … just no.
Instagram filter used: Lo-fi
Photo taken at: Ellis Parking Structure-University of Chicago
-
My American Science & Surplus haul
I went to American Science and Surplus yesterday, and picked up:- a pair of cross lock tweezers
- a small 12V stepper motor
- two P-38 can openers
- a musical box mechanism that plays “For He’s a Jolly Good Fellow“.
-
Pwned by King James V
The Earl of Northumberland had dismissed as mere bragging the expressed intention of the Scottish government to try to do something about the Liddesdale robbers. Like Sim the Laird, he believed the Armstrongs were far too powerful for King James. But he was wrong. The young king had undertaken to “proceed to the sharpe and rygorouse pwnyssching of all transgressioune apone the bordourisâ€, and he now went to work, beginning with a gentle approach.
— from The Steel Bonnets, by George MacDonald Fraser, chapter 27.
Yes, the Scots. We may have been the bunk at spelling, but we’ve been pwning since 1529.
-
Power Cost Monitor signals — for reals!
After doing almost nothing with the Arduino and the elusive Power Cost Monitor signal, I’m finally getting something from it. Matt Colyer’s Power Monitor sketch does all the heavy lifting, for he managed to reverse engineer the protocol. His solution is a rather complex one, involving ethernet shields and Ruby. All I wanted was a simple serial logger, so I cut down Matt’s code, and modified the network output to simple print statements:
== Waiting (38464857ms, 1676 bytes) == == Sending (38467858ms, 1668 bytes) == sample[data]=0000000a sample[data]=0000015a == Waiting (38467863ms, 1676 bytes) == == Received (38592156ms, 1670 bytes) == == Waiting (38592157ms, 1676 bytes) == == Sending (38595158ms, 1668 bytes) == sample[data]=00000000 == Waiting (38595159ms, 1676 bytes) == == Received (38624334ms, 1670 bytes) == == Waiting (38624335ms, 1676 bytes) == == Sending (38627336ms, 1668 bytes) == sample[data]=ffffe746 == Waiting (38627337ms, 1676 bytes) == == Received (38688007ms, 1670 bytes) == == Waiting (38688009ms, 1676 bytes) == == Received (38688045ms, 1670 bytes) == == Waiting (38688046ms, 1676 bytes) == == Sending (38691047ms, 1668 bytes) == sample[data]=00001748 sample[data]=00000008 == Waiting (38691052ms, 1676 bytes) == == Received (38720026ms, 1670 bytes) == == Waiting (38720027ms, 1676 bytes) == == Sending (38723028ms, 1668 bytes) == sample[data]=00000000 == Waiting (38723030ms, 1676 bytes) == == Received (38783686ms, 1670 bytes) == == Waiting (38783687ms, 1676 bytes) == == Sending (38786688ms, 1668 bytes) == sample[data]=00000011 == Waiting (38786689ms, 1676 bytes) == == Received (38815636ms, 1670 bytes) == == Waiting (38815637ms, 1676 bytes) == == Sending (38818638ms, 1668 bytes) == sample[data]=fffff322 == Waiting (38818639ms, 1676 bytes) == == Received (38847547ms, 1670 bytes) == == Waiting (38847548ms, 1676 bytes) == == Sending (38850549ms, 1668 bytes) == sample[data]=00000001 == Waiting (38850550ms, 1676 bytes) == == Received (38879444ms, 1670 bytes) == == Waiting (38879446ms, 1676 bytes) == == Sending (38882445ms, 1668 bytes) == sample[data]=0000374f == Waiting (38882446ms, 1676 bytes) == == Received (38911210ms, 1670 bytes) == == Waiting (38911211ms, 1676 bytes) == == Sending (38914212ms, 1668 bytes) == sample[data]=00000043 == Waiting (38914213ms, 1676 bytes) == == Received (39006981ms, 1670 bytes) == == Waiting (39006982ms, 1676 bytes) == == Sending (39009982ms, 1668 bytes) == sample[data]=00000000 == Waiting (39009983ms, 1676 bytes) == == Received (39038895ms, 1670 bytes) == == Waiting (39038896ms, 1676 bytes) == == Sending (39041897ms, 1668 bytes) == sample[data]=00000001 == Waiting (39041898ms, 1676 bytes) == == Received (39102999ms, 1670 bytes) == == Waiting (39103000ms, 1676 bytes) == == Sending (39106001ms, 1668 bytes) == sample[data]=00000000 == Waiting (39106002ms, 1676 bytes) == == Received (39134880ms, 1670 bytes) == == Waiting (39134881ms, 1676 bytes) == == Sending (39137882ms, 1668 bytes) == sample[data]=00000001 == Waiting (39137883ms, 1676 bytes) ==
Now it’s just a small matter of programming to work out what Matt’s Ruby code does. Ruby always looks to me like two programmers started coding at different ends of the same line, and collided in the middle. I’m hoping there’s enough processing power in the Arduino to do the conversion in the chip, and output useful log data as a serial stream.
More later …