Donnerstag, 29. Mai 2014

Arduino without IDE

For my pet project I need to upload sketches to Arduino board connected to RaspPI. As usual I have only SSH access to PI and don't want to install a lot of unnecessary packages. So the only one thing you have to install it arduino-mk package:

 $ sudo apt-get install arduino-mk  


To check if it works fine you can copy one of examples:

 $ cp -r /usr/share/arduino/examples/01.Basics/Blink/ ~  
 $ cd Blink  

To find out which device is associated with your Arduino run following command before and after connecting:

 sudo dmesg -c  

Second time you run it you will see something like:

 FTDI USB Serial Device converter now attached to ttyUSB0  

Which means that your arduino is connected as /dev/ttyUSB0. And then create Makefile in project folder:

 $ vim Makefile  

In my case it looks like the following one:

 ARDUINO_DIR            = /usr/share/arduino  
 TARGET                 = Blink  
 ARDUINO_LIBS           =  
 MCU                    = atmega328p  
 F_CPU                  = 16000000  
 ARDUINO_PORT           = /dev/ttyUSB0  
 AVRDUDE_ARD_BAUDRATE   = 57600  
 AVRDUDE_ARD_PROGRAMMER = arduino
 include /usr/share/arduino/Arduino.mk

If you are not sure which MCU to choose, take a look at the file /usr/share/arduino/hardware/arduino/boards.txt.

After that you can run:

 $ make upload  

Which will compile your sketch and upload it onto controller.

Good article about running Arduino from command line you can find here.

Have fun!

Keine Kommentare:

Kommentar veröffentlichen