Alpha Clock Five and serial in Python from a Raspberry Pi

Home Evil Mad Scientist Forums Clock Kits Alpha Clock Five and serial in Python from a Raspberry Pi

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #20197
    rolf
    Participant

    I am attempting to send serial data to an Alpha Clock Five from a Python script running on a Raspberry Pi. I have version 1 hardware, but I have updated it first to stock version 2 firmware and now GPS with the AdaFruit GPS module. I will admit that I am new to Python programming. I was able to use the same cable to upgrade the firmware and run the Processing demos from a Windows PC. The code I have written in Python so far is below. The code runs and the clock resets with no change in brightness…

    #!/usr/bin/python
    #
    # Rolf Mikkelson. 27-FEB-2013
    #
    import serial
    header = chr(0xFF)
    # print “header = “, header
    myport=serial.Serial(‘/dev/ttyUSB0’,19200)
    tosend=”B00111234567″
    # print tosend
    myport.write(header)
    myport.write(tosend)
    myport.close()

    #21208
    Windell Oskay
    Keymaster

    If it is resetting, then somehow you must be triggering the Auto-Reset feature, that we use in programming.  So, you need to disable the RTS# line on the FTDI interface.

    The solution, I believe, is found here: 
    Explicitly disable the RTS as follows:
    myport=serial.Serial(‘/dev/ttyUSB0’,19200, rtscts=1)

     


    Please let me know if that fixes it!
    #21209
    rolf
    Participant

    I double checked, and my previous attempts were using the EvilMadScientist USB to TTL cable, which has a six pin connector on the TTL end. I tried the Python with rtscts=1, rtscts=True, rtscts=False. Same result on all, clock just resets.

    I switched to the AdaFruit cable https://www.adafruit.com/products/954 that has only four pins on the TTL side, and each pin is a separate female pin. I did not connect power, just ground, TX, and RX. Works great now…
    #21210
    Windell Oskay
    Keymaster

    Okay, so there must be something still screwy about the Pi’s USB driver.  Good to know for future reference, at least. 

    #21211
    rolf
    Participant

    I have done a bit of programming in Python on a Raspberry Pi for sending data to an Alpha Clock Five. My clock has firmware version 2 with the GPS extensions, so if you have a different firmware, you might need to make changes. Please let me know if you find it useful, comments, corrections, etc…


    Files in the above compressed archive:

    AlphaClockFiveSerial.py – Library module, imported into each of the other files. If you just run it, all variables are displayed.

    brightness – expects a command line parameter of an integer between 1 and 11.

    reset – set all parameters back to somewhat sane defaults and sets the mode back to display time.

    scroll – expects a quoted string of any length, a delay between updates, and a number of times to loop (between 1 and 99)
    bedtime – I plan to add this to crontab to run at 8:15 PM to tell my three year old it is time for bed…
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.