Pages

Thursday 24 January 2013

... and USB switching!

I got a USB relay board; 8 relays on the board for £19.99, which looks to me to be a pretty good price. But when it arrived, it came with no documentation. Zero. Not even an invoice! So I went back to the Ebay page, and downloaded the zip file I found there. But that's for Windows, and I want to use it on a Linux Raspberry Pi. So I emailed the vendor, who informed me that it said clearly on the page that it was for VB (Visual Basic) only (I can't see that on the page). And he gave me a URL that he thought might help.

But by then, I'd done a bit of googling, and I found a page that looked relevant. The picture was pretty much what I had, and he had a download on offer. I downloaded, unzipped, did apt-get install libusb-1.0-0.dev compiled his C program and looked at what I had. "hidwrite 0x12bf 0xff03 85" did nothing. Huh.

So I ran lsusb, and the Pi wasn't seeing the device.

So I changed the power supply (in my experience, admittedly only a month or so, nearly all Pi problems turn out to be power). And lsusb showed Bus 001 Device 008: ID 12bf:ff03 which is exactly what I was looking for. So I ran hidwrite again, and this time, I heard the relays clicking, I saw the LEDs light up to show which ones were on, and a multimeter confirmed that it was all worked.

Hurrah!

2 comments:

  1. Picked up same thing .. now trying to figure out how to use python to write instead of c .. some interesting stuff in here .. http://code.activestate.com/recipes/576834-interrogating-linux-devusbhiddev0-in-python/

    Now wondering how to send the on/off commands in python instead.

    Then, onto the big, bad job of controlling my boiler with an RPi.

    ReplyDelete
    Replies
    1. Actually, I compiled the hidwrite and can happily call it from php. Am now actively switching lots of relays on and off ... :)

      Delete