Create your Arduino (2 / 2)

Next and last step in the creation of your own Arduino using Raspberry Pi. After a post on the creation of the Arduino, now here's how to program it from the Raspberry.

Arduino Raspberry PiNow that your Arduino is ready to be programmed, we will see how to configure the Raspberry Pi to use it.

You will first need the Arduino environment on the Raspberry Pi. As I use it with SSH (without local X Server also), we will also install what command line tools.

Thereafter I went from a newly installed distribution and up to date

  1. Install the Arduino environment
    apt-get install arduino arduino-mk
  2. Download version Raspberry avrdude tool that will enable to make the upload of your programs
    cd /tmp
    dpkg -i avrdude_5.10-4_armhf.deb
  3. You can connect the Raspberry to your Arduino with the SPI interface. I have disconnected the LED. Here is the installation. For not to overload the image, I did put the wires only for the SPI connection :
    Create Arduino Raspberry Pi
  4. Now you can test the connection between the two through the tool avrdude :
    Create Arduino Raspberry PiFor me to not get the error, I have to keep the Reset button pressed for the execution of the command :
    Create Arduino Raspberry Pi
  5. Now, create a directory for your program
    mkdir ardtest
    cd ardtest
  6. Create a file Makefile with the following content :
    ARDUINO_DIR = /usr/share/arduino
    BOARD_TAG = uno
    ARDUINO_PORT = /dev/ttyAMA0
    include /usr/share/arduino/
  7. Create a file blink.ino with the following content :
    int led = 13;
    void setup() { 
    pinMode(led, OUTPUT); 
    void loop() {
     digitalWrite(led, HIGH);
     digitalWrite(led, LOW);

    The program will flash the LED with 400ms delay.

  8. Compile the program
  9. Upload the program. Don't forget to hold the reset button.
    make upload
    Create Arduino Raspberry Pi
  10. Release the button
  11. Disconnect the Arduino. I disconnect just wire 3.3V without turning off the Raspberry. I do not know if it's good to make or not but it works.
  12. Disconnect the 4 wires related to the SPI
  13. Reconnect the LED on pin D13 (or the one that you have configured in your program)
  14. Turn on the Arduino. Your LED should now blink quickly.

This is for a method that works. The disadvantages are :

  • Keep the button pressed ! Not very convenient because you have to be close to the Arduino !
  • Connect wires SPI for each load. Is it possible to use the RX pins / TX dedicated ?
  • The compilation is slow on Raspberry Pi. There, not much to do …


I now use this system to create small wireless sensors. The following steps are therefore communication to Raspberry Pi with 433Mz modules or NRF24L01 and power module for maximum autonomy.

If you have any ideas of use of this kind of mounting, feel free to share them in the comments !

You may also like...