Project Home‎ > ‎Documentation‎ > ‎Interfaces‎ > ‎


Pytomation currently supports the Arduino Uno specifically and others by modifying the ”Sketch” that is included with the source. Full support of Analog and Digital I/O is included and operational.

Multiple boards can be supported each on a different serial port. Future releases will support cascading of Arduino boards.

This is a driver for the Arduino UNO board used with the included uno.sketch.ino sketch. The UNO board supports digital and analog I/O. The Uno board can be configured to use up 18 digital I/O channels or 12 digital and 6 analog channels or a combination of both.

This driver will re-initialize any of the boards that experience a power on reset or brownout without having to restart Pytomation.

The the I/O channels on the Andunio board are set according to the following command set.

Every command sent to the board is three or four characters in length. There is no terminating CR or NL character.

[Board] [I/O direction] [Pin]
[Board] 	- 'A'
[I/O]		- 'DN<pin>' Configure as Digital Input no internal pullup (default)
		- 'DI<pin>'     "      " Digital Input uses internal pullup
  		- 'DO<pin>'     "      " Digital Output 
  		- 'AI<pin>'     "      " Analog Input
		- 'AO<pin>'     "      " Analog Output
		- 'L<pin>'  Set Digital Output to LOW
	       - 'H<pin>'  Set Digital Output to HIGH
		- '%<pin><value>'  Set Analog Output to value (0 - 255)
[Pin]		- Ascii 'C' to 'T'  C = pin 2, R = pin A3, etc

Examples transmitted to board:

ADIF		Configure pin 5 as digital input with pullup
AAIR		Configure pin A3 as analog input
AHE		Set digital pin 4 HIGH
A%D75		Set analog output to value of 75

Examples received from board: NOTE the end of message (eom) char '.'

AHE.		Digital pin 4 is HIGH
ALE.		Digital pin 4 is LOW
AP89.		Analog pin A1 has value 89

Available pins:

Pins with “~” can be analog output (PWM).

Pins starting with A can be Analog Input or Digital I/O

All pins can be digital except 0 and 1 which are used for the serial port

Pin codes:

02 03 04 05 06 07 08 09 10 11 12 13 A0 A1 A2 A3 A4 A5
C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T
   ~     ~  ~        ~  ~  ~

The board will return a '?' on error.

The board will return a '!' on power up or reset.

To add another board, edit the sketch and change the board ID to another letter and download the revised sketch. The board will blink the LED upon reset to display the board address. One blink for A, two blinks for B, etc.

Using in an Instance

# Set up the interface
uno = Arduino(Serial('/dev/ttyACM0', 9600))

# Set the I/O on the Arduino Uno board uno.setChannel('ADIC') # Pin C (2) set as digital input with pullup uno.setChannel('ADON') # Pin N (13) set as digital output, LED on the UNO board uno.setChannel('AAIO') # Pin O (A0) set as analog input

# A motion detector connected to channel AD
m_stairs = Motion(address='AD', devices=uno, name='Stair Motion')

When using in a device you always use a 2 letter address, BOARD and I/O, for example
"AN" or "AG" which respectively is board A and pin N or board A and pin G
Here is an example used in a Light:

l_livingroom = Light(address='AN', devices=uno, name='Living room')

On an UNO board this is the on board LED tied to pin 13.