DyIO + Jython = <3

Posted by Eric Stein - February 6, 2011 CE @ 03:57:33 UTC
I've been working on and off (mostly off) on a project of mine for home monitoring called Ramirez. I need temperature and switch sensing ability. I'd tried a few things here and there with Arduino, etc, but that always meant writing my own communications protocol over the serial bus and I never got the enthusiasm up to get anywhere with it. The project I'm building needs the data to get to a full scale computer, not an embedded board, so I needed something that would let me do that easily.

I heard a few weeks ago from my friends at Neuron Robotics that their digital/analog I/O breakout kit called the DyIO was finally available! I remember a good ways back when they were designing this while we were still in school. It always seemed like a great idea, and I jumped on the chance to buy one. Before getting it Kevin gave me a few tips - including that it was possible to get it going with python code using Jython.

I started hacking on getting it to work with Jython tonight. I had a few issues trying to translate the Java examples to Python. However, Kevin was able to both fix a small bug I found in the Neuron Robotics Development Kit and help me get a small proof of concept running.

Proof of Concept


I haven't got the correct thermistors in from DigiKey yet, so I'm starting out with a simple digital in. In this example, I have plugged a switch into channel 0 on the DyIO module (pins are S and -) and connected the module to my Ubuntu laptop using USB.
eastein@numenor:~/dev/ramirez/mcore/plug$ cat jdyio.py
#!/usr/bin/env jython

import sys, time

sys.path.append('/home/eastein/nr-sdk/nrsdk-0.3.7.a-jar-with-dependencies.jar')

from com.neuronrobotics.sdk.dyio import DyIO
from com.neuronrobotics.sdk.dyio.peripherals import DigitalInputChannel
from com.neuronrobotics.sdk.serial import SerialConnection

if __name__ == '__main__' :
        dyio = DyIO(SerialConnection("/dev/ttyACM0"))
        dyio.connect()
        dig = DigitalInputChannel(dyio.getChannel(0))

        while True :
                print dig.isHigh()
                time.sleep(.25)
eastein@numenor:~/dev/ramirez/mcore/plug$ ./jdyio.py
RXTX Warning:  Removing stale lock file. /var/lock/LCK..ttyACM0
0
0
0
1
1
0
1
1
1
1
1
1
1
1
1
eastein@numenor:~/dev/ramirez/mcore/plug$

Where To?


Now that I've got a quick connection to the DyIO proofed, I'll be working more on the sensor history and eventing systems within Ramirez. Soon: madness such as text alerts when my fridge temperature goes out of normal parameters for too long or my front door opens when I'm not home.
Last Edited February 6, 2011 CE @ 04:00:59 UTC

Comments

Phidget
#5240 - Bill Mania, April 21, 2011 CE @ 20:14:10 UTC
If you haven't also already looked at Phidget devices, you should. USB interfaces and very robust Python modules.

Post a Comment

Name
Email (not published, I won't spam you)
URL (optional)
Title
Comment
singular of trees?
Worth Saying
Valid XHTML, CSS, RSS | 2ms | Copyright 2004-2024 Eric Stein