Home › Evil Mad Scientist Forums › Clock Kits › Alpha Clock Five and serial in Python from a Raspberry Pi
- This topic has 4 replies, 2 voices, and was last updated 11 years, 9 months ago by rolf.
-
AuthorPosts
-
February 27, 2013 at 8:36 pm #20197rolfParticipant
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()February 27, 2013 at 9:06 pm #21208Windell OskayKeymasterIf 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:(via raspberry pi forum: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=32&t=6832 )Explicitly disable the RTS as follows:myport=serial.Serial(‘/dev/ttyUSB0’,19200, rtscts=1)Please let me know if that fixes it!February 28, 2013 at 5:40 pm #21209rolfParticipantI 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…February 28, 2013 at 5:45 pm #21210Windell OskayKeymasterOkay, so there must be something still screwy about the Pi’s USB driver. Good to know for future reference, at least.
March 26, 2013 at 6:53 pm #21211rolfParticipantI 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… -
AuthorPosts
- You must be logged in to reply to this topic.