The sample URLs in this documentation can optionally be set to your key, which makes them relevant and functional for your device.
If you wish to set your key, enter it in the following form and click 'Set Key'.
Sending instructions and retrieving values from your online Teleduino device is acheived by interacting with the Teleduino API.
Requests can be submitted to the API using either GET or POST, and the returned result can be in either JSON (default), JSONP or serialised PHP.
For the examples provided in this document, the GET method will be used.
The request URL will depend on which proxy server your device is connected to.
For the examples provided in this document, the request URL will be https://us01.proxy.teleduino.org/api/1.0/2560.php.
All returned data packets consist of three parameters at the top level. They are:
Parameter | Datatype | Description |
---|---|---|
status | Integer | The status code of the API response. These are matched as close as possible to HTTP status codes. |
message | Text | A simple message explaining the status code. |
response | Array | The resulting data packet response from the Teleduino. |
When a response is received back from the device (status = 200), the response array will consist of three parameters. They are:
Parameter | Datatype | Description |
---|---|---|
result | Integer | Whether or not the request was successful. Possible values are 1 or 0. |
time | Float | The time (in seconds) that the request took to complete. |
values | Array | The returned value(s). Will remain as an empty array if no values are returned. |
The analog pins on the Arduino can also be used as digital pins. To keep things simple when using the Teleduino, the analog pin numbering is different to the native Arduino.
The following table shows the pin value to be used for addressing the analog pins:
Arduino Pin | Teleduino Pin |
---|---|
A0 | 54 |
A1 | 55 |
A2 | 56 |
A3 | 57 |
A4 | 58 |
A5 | 59 |
A6 | 60 |
A7 | 61 |
A8 | 62 |
A9 | 63 |
A10 | 64 |
A11 | 65 |
A12 | 66 |
A13 | 67 |
A14 | 68 |
A15 | 69 |
There are some parameter values that are used regardless of which method is being called.
These common parameter values are represented by a single character and are explained in the following table:
Parameter | Datatype | Required? | Default | Description |
---|---|---|---|---|
k | String | Yes | The unique API key for the device. | |
r | String | Yes | The method being requested. | |
o | String | No | json | The output format. Possible values are json, jsonp or php. |
p | String | No | TeleduinoReturn | When the selected output format is jsonp, this sets the callback function name. |
s | Integer | No | 1 | Whether or not to set the HTTP status header. Possible values are 1 or 0. |
The following definitions expain in detail the methods available via the API.
Select from the list to view to a specific definition:
Resets the device.
Returns the firmware version of the device.
Parameter | Datatype | Description |
---|---|---|
String | Firmware version of the device. |
Sets the digital pin to be used for the status LED.
Parameter | Datatype | Description |
---|---|---|
pin | Integer | Digital pin. Possible values are 0 - 69. |
Sends a flash sequence to the status LED.
Parameter | Datatype | Description |
---|---|---|
count | Integer | Flash count to be sequenced. If flash sequence time exceeds 5 seconds then timeout may occur. Possible values are 0 - 255. |
Returns the amount of free memory available on the device.
Parameter | Datatype | Description |
---|---|---|
Integer | Free memory available, in bytes. |
Pings the device, resulting in a quick flash of the status LED.
Returns the uptime of the device.
Parameter | Datatype | Description |
---|---|---|
Integer | Uptime in milliseconds. |
Loads preset values from EEPROM. This is the same as what occurs when the device starts.
Sets the digital mode for a pin.
Parameter | Datatype | Description |
---|---|---|
pin | Integer | Digital pin. Possible values are 0 - 69. |
mode | Integer | Mode. Possible values are 0 (input) or 1 (output). |
Sets the output on a digital pin.
Parameter | Datatype | Description |
---|---|---|
pin | Integer | Digital pin. Possible values are 0 - 69. |
output | Integer | Output. Possible values are 0 (low), 1 (high) or 2 (toggle). |
expire_time | Integer | Optional expire time (in milliseconds) for output. 0 means no expiry. Possible values are 0 - 16777215. |
save | Integer | Optionally save the output as a preset (2560-0.1.2 and above). Can only be set if expire_time is 0. Possible values are 0 (don't save) or 1 (save). |
Sets the duty cycle of a PWM pin.
Parameter | Datatype | Description |
---|---|---|
pin | Integer | PWM pin. Possible values are 2 - 13, 44 - 46. |
output | Integer | Output. Possible values are 0 (low) - 255 (high). |
Returns the input state of a digital pin.
Parameter | Datatype | Description |
---|---|---|
pin | Integer | Digital pin. Possible values are 0 - 69. |
Parameter | Datatype | Description |
---|---|---|
Integer | Input state of digital pin. Possible values are 0 (low) or 1 (high). |
Returns the input value of an analog pin.
Parameter | Datatype | Description |
---|---|---|
pin | Integer | Analog pin. Possible values are 54 - 69. |
Parameter | Datatype | Description |
---|---|---|
Integer | Input value of analog pin. Possible values are 0 (low) - 1023 (high). |
Returns the input values of all the digital and analog pins.
Parameter | Datatype | Description |
---|---|---|
Integer | Input values of pins. The first 54 elements of the array are the digital inputs with possible values of 0 (low) and 1 (high). The remainder values are the analog outputs with possible values of 0 (low) - 1023 (high). |
Sets the outputs of one or more digital pins.
Parameter | Datatype | Description |
---|---|---|
outputs | Integer | An array of outputs. Possible values are 0 (low), 1 (high) or 2 (toggle). |
expire_times | Integer | Optional array of expire times (in milliseconds) for output. 0 means no expiry. Possible values are 0 - 16777215. |
offset | Integer |
Optional array offset. Defaults to 0. When 0: output[0] = pin 0, output[1] = pin 1 When 5: output[0] = pin 5, output[1] = pin 6 etc |
Defines a cascade of up to 32 shift registers.
Parameter | Datatype | Description |
---|---|---|
shift_register | Integer | The shift register cascade we are defining. Possible values are 0 - 3. |
clock_pin | Integer | The digital pin which is connected to the shift register clock pin. Possible values are 0 - 69. |
data_pin | Integer | The digital pin which is connected to the shift register data pin. Possible values are 0 - 69. |
latch_pin | Integer | The digital pin which is connected to the shift register latch pin. Possible values are 0 - 69. |
enable_pin | Integer | Optional. The digital pin which is used to enable the shift register. Possible values are 0 - 69. |
Sets the output values for a shift register cascade.
Parameter | Datatype | Description |
---|---|---|
shift_register | Integer | The shift register cascade we are setting. Possible values are 0 - 3. |
outputs | Integer | An array of integers. Each element of the array represents a shift register (up to 32). Possible values per element are 0 - 255. |
Merges new output values with any existing values.
Parameter | Datatype | Description |
---|---|---|
shift_register | Integer | The shift register cascade we are setting. Possible values are 0 - 3. |
action | Integer | Action to apply to affected outputs. Possible values are 0 (low), 1 (high) or 2 (toggle). |
expire_time | Integer | Expire time in milliseconds. Once expired the action reverses itself. Set to 0 to never expire. Possible values are 0 - 16777215. |
outputs | Integer | An array of integers. Each element of the array represents a shift register (up to 32). Possible values per element are 0 - 255. |
Returns the output values for a shift register cascade.
Parameter | Datatype | Description |
---|---|---|
shift_register | Integer | The shift register cascade we are setting. Possible values are 0 - 3. |
Parameter | Datatype | Description |
---|---|---|
Integer | Output values of shift registers. Each element in the array represents a shift register in the cascade (32 in total). Possible values are 0 - 255. |
Defines a serial port for use.
Parameter | Datatype | Description |
---|---|---|
port | Integer | The port we are defining. Possible values are 0 - 3. |
baud | Integer | The baud rate of the port. Possible values are per element are 300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600 or 115200. |
Write data to the serial port.
Parameter | Datatype | Description |
---|---|---|
port | Integer | The port we are writing to. Possible values are 0 - 3. |
bytes | Text | Text to send to the serial port. Maximum length is 254 bytes. |
Read data from the serial port.
Parameter | Datatype | Description |
---|---|---|
port | Integer | The port we are reading from. Possible values are 0 - 3. |
byte_count | Integer | Maximum number of bytes to read from the serial port. Possible values are 0 - 255. |
Parameter | Datatype | Description |
---|---|---|
Text | String of bytes read from the serial port. |
Flushes the serial port buffer.
Parameter | Datatype | Description |
---|---|---|
port | Integer | The port we are defining. Possible values are 0 - 3. |
Defines the instance of a servo.
Parameter | Datatype | Description |
---|---|---|
servo | Integer | Servo instance. Possible values are 0 - 47. |
pin | Integer | Digital pin. Possible values are 0 - 69. |
Sets the position of a servo.
Parameter | Datatype | Description |
---|---|---|
servo | Integer | Servo instance. Possible values are 0 - 47. |
position | Integer | Position to set the servo to. Possible values are 0 - 180. |
Resets the EEPROM.
Parameter | Datatype | Description |
---|---|---|
quarter | Integer | Which quarter of the EEPROM to reset. Possible values are 0 - 3. |
Write data to the EEPROM.
Parameter | Datatype | Description |
---|---|---|
offset | Integer | Starting position of the EEPROM to write to. |
bytes | Text | Text to write to the EEPROM. Maximum length is 253 bytes. |
Read data from the EEPROM.
Parameter | Datatype | Description |
---|---|---|
offset | Integer | Starting position of the EEPROM to read from. |
byte_count | Integer | Number of bytes to read from the EEPROM. Possible values are 0 - 255. |
Parameter | Datatype | Description |
---|---|---|
Text | String of bytes read from the EEPROM. |
Starts the Wire interface.
Write data to the Wire (TWI/I2C) bus.
Parameter | Datatype | Description |
---|---|---|
address | Integer | The 7 bit address of the device to write to. Possible values are 1 - 127. |
bytes | Text | Text to write to the Wire (TWI/I2C) bus. Maximum length is 32 bytes. |
Parameter | Datatype | Description |
---|---|---|
Integer | The response from the Wire (TWI/I2C) bus. 0 - success 1 - data too long to fit in transmit buffer 2 - received NACK on transmit of address 3 - received NACK on transmit of data 4 - other error |
Request data from the Wire (TWI/I2C) bus.
Parameter | Datatype | Description |
---|---|---|
address | Integer | The 7 bit address of the device to write to. Possible values are 1 - 127. |
byte_count | Integer | Number of bytes being requested. Possible values are 1 - 32. |
Parameter | Datatype | Description |
---|---|---|
Text | String of bytes returned from the Wire (TWI/I2C) bus. |