Uploading sketches via 6pin FTDI header
To connect your Canique MK1/MK2 to your computer via USB you need an FTDI Breakout Board that runs with 3.3V
(the voltage is important since the radio of the MK1/MK2 will be damaged if you connect 5V to its FTDI header).
Please note that genuine FTDI chips (FT232RL) cost about 4-5 USD (the chip alone) in low quantities. If you buy an FTDI Breakout Board for under 5 USD, the probability is high that it is using a non genuine chip. The consequence could be that you might have driver issues with these boards. In this case the FTDI breakout board would not be recognized by your computer.
Connect your FTDI Breakout Board to the 6 pin FTDI header of your Canique MK1/MK2 which is located on the left side (when looking from top). Please pay attention that the pins must match - DTR pin of your Breakout Board must be connected to DTR pin of your MK1/MK2 etc.
Please note that genuine FTDI chips (FT232RL) cost about 4-5 USD (the chip alone) in low quantities. If you buy an FTDI Breakout Board for under 5 USD, the probability is high that it is using a non genuine chip. The consequence could be that you might have driver issues with these boards. In this case the FTDI breakout board would not be recognized by your computer.
Connect your FTDI Breakout Board to the 6 pin FTDI header of your Canique MK1/MK2 which is located on the left side (when looking from top). Please pay attention that the pins must match - DTR pin of your Breakout Board must be connected to DTR pin of your MK1/MK2 etc.
Setting up Arduino IDE for Canique MK1/MK2
- First you need to install Arduino IDE 1.6.4 or later - if you have not done so yet, please download Arduino IDE and install the software.
- Start Arduino IDE, go to File › Preferences and add the following URLs (comma-separated) in the field "Additional Boards Manager URLs" (this option does not appear in Arduino IDEs < 1.6.4):
https://resources.canique.com/ide/package_canique_index.json
https://downloads.arduino.cc/packages/package_avr_3.6.0_index.json - Go to Tools › Board › Boards Manager and enter "Canique" into the search field. You should see the Canique MK1 as an entry. Click on the entry and click "Install".
- Next search for "Avr" in the search field. You should see Arduino AVR Boards as an entry. Update it to the latest version (currently 1.6.207 as of 28th Nov 2018). This step is necessary to be able to burn bootloaders and also necessary to support Atmega328PB devices.
- Select the new board under Tools › Board › Canique MK1. It is most probably the last entry.
If you are an expert you can select which speed your sketch shall be compiled for under Tools › CPU Speed. If you select the entries which contain "Boot@2MHz" you need equipment to burn a bootloader. The entries except the first 2 are meant for situations where you want to set the clock speed of the board to a lower value because you want to run the board with a lower voltage than 3.3V. - Now you're ready to go: you can upload sketches to your MK1/MK2 pressing the Upload button.
Burning a bootloader or uploading sketches via SPI
This section is only for advanced users...
Your MK1/MK2 ships with a DualOptiboot Bootloader onboard. This bootloader gives you the ability to
You need
Your MK1/MK2 ships with a DualOptiboot Bootloader onboard. This bootloader gives you the ability to
- upload sketches via FTDI (see first section of this page)
- upload sketches via transceiver (over the air) - for this to work you need to upload a sketch that receives packets and writes them to the onboard flash memory (if installed) in a specific format
You need
- an Arduino Uno
- a 4 channel logic level converter
- First we have to setup the Arduino Uno to serve as a programmer.
- Open the Arduino IDE and open the ArduinoISP sketch by selecting from the menu File › Examples/Sketches › Arduino ISP › ArduinoISP
- Select from Tools › Board › Arduino/Genuino Uno
- Select from Tools › Programmer › Arduino as ISP
- Connect your Arduino Uno per USB
- Select from Tools › Port the port to which your Arduino Uno is connected
- Click Upload
- After the upload is completed disconnect your Arduino Uno from the USB port
-
Next we need to connect the Arduino Uno to the Canique MK1/MK2 - in this section called MKx.
We do not connect the datalines directly because the Arduino Uno uses 5V data lines while the Canique MKx uses 3.3V. That's where the logic level converter comes into play.
We'll call the logic level converter LLC. HV stands for High Voltage (5V), and LV stands for Low Voltage (3.3V).
Establish the following connections using jumper wires:- Uno Pin D13 to LLC HV4, MKx D13 to LLC LV4
- Uno Pin D12 to LLC HV3, MKx D13 to LLC LV3
- Uno Pin D11 to LLC HV2, MKx D11 to LLC LV2
- Uno 3.3V via a resistor (e.g. 10K) to MKx D10 (this is necessary if your MKx has a radio device onboard)
- Uno Pin D10 to LLC HV1, MKx RST to LLC LV1
- Uno 3.3V to LLC LV
- Uno 5V to LLC HV
- Uno GND to LLC GND
- Uno 3.3V to MKx 3.3V
- Uno GND to MKx GND
-
Finally we can program the MKx or even burn a bootloader on the MKx.
Connect your Arduino Uno per USB.
To burn a bootloader, select Tools › Burn bootloader.
To upload a sketch to your MKx, select Sketch › Upload with Programmer (beware: If you select Upload instead, you will upload the sketch onto your Arduino Uno which you probably don't want)
MK1/MK2 special Pins
RFM69 Interrupt: Pin D2
4 Mbit Flash Memory Slave Select: Pin D8
On Board LED: Pin D9
RFM69 Slave Select: Pin D10
MK1/MK2 Fuse Settings (with Arduino IDE "CPU Speed" menu set to "Run@16MHz, Boot@16MHz, BOD@2.7V")
Low Fuses: 0xDE
High Fuses: 0xD4
Extended Fuses: 0xFD
Note that the settings are configured in such a way that your EEPROM does not get wiped when you upload a new sketch.
Flash Memory Library
To use the optional onboard flash memory, you can use this SPIFlash library. The example sketch works out of the box.
RFM69 Library
To use the optional onboard RFM69 transceiver, you can use the LowPowerLab RFM69 library. A good alternative is the RadioHead library with the RH_RF69 driver.
Note that the RadioHead library is programmed in a cleaner way - it is object oriented. Please also note that the RadioHead library allows you to reduce the transmit power of RFM69HW (high power) transceivers down to -2 dBm.
The LowPowerLab library, though, only supports reducing the transmit power down to 5 dBm. Thus, by using the RadioHead library, you are able to send weaker signals if needed (to preserve battery power) which is an important advantage.