Converting from the Arduino Uno to the Adafruit Pro Trinket
As this project continues to develope, it is time to begin looking to add a more practical means of implementing these systems into the environment in a small and user-friendly package. The problem? The Arduino Uno is an excellent prototyping microcontroller, its easy to work with, has several built in functions with many pins ready to be used, however, this ease of use and functionality comes at the cost of a bulky, power hungry microcontroller that likely can do much more then you need it to. The solution? The Adafruit (3 Volt) Pro Trinket.
The Adafruit Pro trinket is a tiny microcontroller that packs a punch!
Remapping Pin-outs
One of the biggest challenges with swapping the Pro Trinket for the Uno is the difference in board configurations and pin allocations. The blog post “Getting Started with the nRF08001 Bluetooth LE chip” lays out how the pins and wiring of the nRF08001 is set up for the Arduino uno. In this post we will be exploring how to do it for the Pro Trinket. Below is a diagram of the Pro Trinkets Pin outs as well as breakdown of the pin allocation.
- RX – also known as Digital #0, this is the hardware serial input pin. This is used when programming with an FTDI cable but is available when using the native USB to program
- TX – also known as Digital #1, this is the hardware serial output pin. This is used when programming with an FTDI cable but is available when using the native USB to program
- Digital 3 – Also known as external interrupt #1. This pin can also be used as a PWM output pin using analogWrite() (This is the most significant difference between the Uno and the Pro-Trinket and requires manual changes to sketches in order to work)
- Digital 4 – Nothing particularly special about this GPIO pin
- Digital 5 – this pin can also be used as a PWM output pin using analogWrite()
- Digital 6 – this pin can also be used as a PWM output pin using analogWrite()
- Digital 8 – Nothing particularly special about this GPIO pin
- Digital 9 – this pin can also be used as a PWM output pin using analogWrite() It’s also good for driving servos because its a high-speed PWM output
- Digital 10 – this pin can also be used as a PWM output pin using analogWrite() It’s also good for driving servos because its a high-speed PWM output
- Digital 11 – Also known as the SPI MOSI pin. this pin can also be used as a PWM output pin using analogWrite()
- Digital 12 – Also known as the SPI MISO pin
- Digital 13 – Also known as the SPI CLOCK pin. This is also connected to the red #13 LED!
- Analog 0 – also known as Digital 14, this pin can be a digital I/O pin or an analog input pin
- Analog 1 – also known as Digital 15, this pin can be a digital I/O pin or an analog input pin
- Analog 2 – also known as Digital 16, this pin can be a digital I/O pin or an analog input pin
- Analog 3 – also known as Digital 17, this pin can be a digital I/O pin or an analog input pin
- Analog 4 – also known as Digital 18, this pin can be a digital I/O pin or an analog input pin. It’s also the I2C SDA pin
- Analog 5 – also known as Digital 19, this pin can be a digital I/O pin or an analog input pin. It’s also the I2C SCL pin
Conclusions about the switch
The only changes you may have to consider when adapting Arduino sketches are:
- Pins #2 and #7 are not available *
- The onboard 3.3V or 5V regulator can provide 150mA output, not 800mA out, this is due to power saving functionality designed into the Pro Trinket, which is ideal for this project
- You cannot plug shields directly into the Pro Trinket
- There is no Serial-to-USB chip onboard. This is to keep the Pro Trinket small and inexpensive, you can use any FTDI cable to connect to the FTDI port for a Serial connection
- The 3V Pro Trinket runs at 12MHz not 16MHz so its a bit slower, but with the advantage of significantly less power draw, extending battery life significantly
- The bootloader on the Pro Trinket use 4KB of FLASH so the maximum sketch size is 28,672 bytes, more than enough space for almost all applications. The bootloader does not affect RAM usage.
- And most importantly that all sketches that use pin 2 as the interrupt must be switched to pin 3.
Writing a script to bring it all together
This week I have also begin sketching the new data transmission protocol that will be used across the Internet of Ag project. After getting communication between the Pro Trinket and BLE module set up and the demo functioning it was time to start a new script from the ground up. This week I was able to begin drafting out the basic logic, and looking over example codes of the protocol and will contiune working on a sketch next week.
– Tom DeBell, Beginning Researcher Support Program researcher