Skip to content
This repository has been archived by the owner on Mar 28, 2020. It is now read-only.

Pymata3 Usage Notes

Alan Yorinks edited this page Apr 3, 2018 · 18 revisions

When instantiating pymata3, the arduino_wait parameter is set to a default value of 2 seconds. This value specifies the amount of time needed to allow the Arduino to complete a reset cycle. Make sure that this value is set to match the reset needs of your Arduino board type.

Here are some typical reset wait times by board type:

Board Type Seconds
Uno 2 (default)
Leonardo 0
Teensy 5

For other board types, you may need to experiment with this value.

When retrieving input data, it is preferrable to use a callback method instead of polling for the data value. An example can be found here.

When using the pymata3 API and wish to include a sleep in your application, use the pymata3 sleep method instead of time.sleep(). So if your pymata3 instance is called 'board', and you want to sleep for 1 second, you would call board.sleep(1)

If your code calls a blocking method or function, you may need to convert that code to an asyncio future. Look at the source code for the read method of pymata_serial to see how to create a non-blocking future from a blocking call.

Examples:

###Connection Errors:

If you are seeing this message:

Do you have Arduino connectivity and do you have a Firmata sketch uploaded to the board?

You may need to use the com_port parameter to explicitly state the com port in use.