control GPIO over USB



  • Hi there,

    absolute noob question here, but I'd like to control the GPIO through USB. I couldn't find straightforward documentation. Could someone point me to the right direction?

    Background

    (not immediately relevant for the question, though)

    • I'd like to use this library to talk with a coffee machine.

    I already managed to make this work, using fast-gpio and exposing this over REST. But now, I'd like to go one step further and try to talk directly with it.
    I work on OSX

    thanks!



  • Good question for simplifying it by not having to write all the logic on the board. I'd just use an arduino then. But if you wanted to you could write a python script to talk over serial USB. I'm trying to do USB from host to talk to an Arduino to control WS2812b LEDs. Seems tough.


  • administrators

    @cecemel Sounds like a cool project!

    I'm a little unclear about the overall setup of your project, so let me know if I misunderstood anything.

    Computer -> Omega
    You don't really need a library to talk to the Omega over USB, you can access the Omega via serial: https://wiki.onion.io/Tutorials/Connecting-to-Omega-via-Serial-Terminal
    If you don't want a serial terminal open, you can probably use the library you linked above to just send single commands (I've never tried it though).

    But you don't necessarily need a computer to send the Omega instructions. Which brings me to my next point...

    Omega -> Coffee Machine via USB
    The Omega can actually completely replace the need to use your computer since it has it's own USB host. As @Joseph-Sammarco mentioned, you can use Python to perform all of the serial communication

    To install Python and the required PySerial Library:

    opkg update
    opkg install python-light python-pyserial
    

    PySerial has a treasure trove of documentation: https://pythonhosted.org/pyserial/
    But I think you will most likely be interested in something along the lines of this first example.

    Let me know if this helps and how it goes!



  • Hi there,

    thanks for all the responses! It helped.
    At hindsight, controlling the GPIO over Serial interface was indeed quite trivial.

    Here's the script I made in Processing (unlikely whether this is going to help someone in the future, but anyway...): script

    The python library was equally helpful. There is a great SO example, which almost works out of the box, after correcting for baudrate and removing the parity, stopbits and bytesize parameters.


  • administrators

    @cecemel glad to hear you figured it all out. make sure to post photos or a video of the final result, we would love to see it!



  • Well, it's actually quite dull to look at. You know, click a button, coffee machine turns on (girlfriend was NOT impressed šŸ™‚
    However, since I am neither a CS nor an engineer and thus a complete electronics noob, I might make an howto on my github, for people like me, which kinda could make it useful.



  • @Joseph-Sammarco are you trying to do OMEGA -> USB -> ARDUINO? Cause I got that working with php and I added a wireless module on there for a wireless network of sensors.... I was thinking of writing a tutorial on how to accomplish this...if you need let me know. Cheers


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.