[GUIDE] ODROID meets Arduino

Post Reply
User avatar
odroid
Site Admin
Posts: 41084
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3194 times
Been thanked: 1753 times
Contact:

[GUIDE] ODROID meets Arduino

Post by odroid »

Some people asked us the compatibility of Arduino with ODROID Linux.
So we bought an Arduino board and a few accessories to test it.

To enjoy the development of Arduino with ODROID, I prepared below items.

Hardware
1. ODROID-X2 or X or U2 or XU (PSU, SD or eMMC, HDMI monitor/cable, Keyboard/Mouse)
2. Arduino Uno R3 ( http://arduino.cc/en/Main/ArduinoBoardUno ) + USB Cable
3. LCD + Keypad shield board ( http://www.dfrobot.com/wiki/index.php/A ... Pad_Shield )
4. DHT11 Humidity and Thermometer sensor ( http://www.adafruit.com/products/386 ). I should solder a few wires and a resistor.

Software
1. Ubuntu 13.04 with Kernel 3.8
2. Oracle JDK8 for ARM-HardFloat ( http://forum.odroid.com/viewtopic.php?f=52&t=204 )
I used robroyhall's "Lubuntu 13.04 Whisper" OS image because it has the Oracle JDK pre-installed. Yes, I'm lazy. ;)

Boot your ODROID and plug the Arduino Uno board via USB cable.
And you can see the device node of Arduino serial port.

Code: Select all

odroid@odroid:~$ ls /dev/ttyACM0 
/dev/ttyACM0
Sometimes it can be /dev/ttyACM1 !

Install the Arduino IDE (Sketch).

Code: Select all

sudo apt-get update
sudo apt-get install arduino
Note that Ubuntu PPA has Arduino IDE Ver 1.0.3.

Run the Arduino IDE and configure the Serial port to upload the compiled code to Arduino board.
arduino_port2.png
I made a simple test code.

Code: Select all

#include <LiquidCrystal.h>
#include <dht.h>
 
/*******************************************************
 
This program will test the LCD panel, the buttons
and the Humidity/Temperature sensor

Version : 0.1
Date : 20-Oct-2013

By Hardkernel
 
********************************************************/

// for Digital Humidity and Temperature sensor (DHT11)
dht DHT;
#define DHT11_PIN 3

// Global variables
unsigned long elapsed_time;
 
// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
 
// define some values used by the panel and buttons
int lcd_key     = 0;
int adc_key_in  = 0;
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5
 
// read the buttons
int read_LCD_buttons()
{
 adc_key_in = analogRead(0);      // read the value from the sensor 
 // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
 // we add approx 50 to those values and check to see if we are close
 if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
 if (adc_key_in < 50)   return btnRIGHT;  
 if (adc_key_in < 195)  return btnUP; 
 if (adc_key_in < 380)  return btnDOWN; 
 if (adc_key_in < 555)  return btnLEFT; 
 if (adc_key_in < 790)  return btnSELECT;   
 
 return btnNONE;  // when all others fail, return this...
}
 
void setup()
{
     // initialize serial communication at 115200 bits per second:
     Serial.begin(115200);  
     lcd.begin(16, 2);              // start the LCD library
     lcd.setCursor(0,0);
     lcd.print(" Hello, ODUINO! "); // print a simple message
     //         1234567890123456 
     delay(1500); // Splash for 1.5 second

     Serial.println("ODUINO TEST PROGRAM ");
     Serial.println();
     Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
     
     elapsed_time = millis()/1000; // Returns the number of milliseconds since the Arduino board began running the current program.
    
}
  
void loop()
{
     lcd.setCursor(0,1);            // move to the begining of the second line     
     lcd.print("KEY :");     
     
     lcd.setCursor(6,1);            // move to the begining of the second line
     lcd_key = read_LCD_buttons();  // read the buttons
     
     switch (lcd_key)               // depending on which button was pushed, we perform an action
     {
       case btnRIGHT:
         {
         lcd.print("RIGHT ");
         Serial.println("RIGHT ");
         break;
         }
       case btnLEFT:
         {
         lcd.print("LEFT   ");
         Serial.println("LEFT ");     
         break;
         }
       case btnUP:
         {
         lcd.print("UP    ");
         Serial.println("UP ");     
         break;
         }
       case btnDOWN:
         {
         lcd.print("DOWN  ");
         Serial.println("DOWN ");     
         break;
         }
       case btnSELECT:
         {
         lcd.print("SELECT");
         Serial.println("SELECT ");     
         break;
         }
         case btnNONE:
         {
         lcd.print("NONE  ");
         break;
         }
     }
    
    // Read & Display the humidity / temperature data every 1 second (approx.)
     if(elapsed_time != millis()/1000)
     {
            elapsed_time = millis()/1000;
            Serial.print("DHT11, \t");
            int chk = DHT.read11(DHT11_PIN);
            switch (chk)
            {
              case DHTLIB_OK:  
                          Serial.print("OK,\t"); 
                          break;
              case DHTLIB_ERROR_CHECKSUM: 
                          Serial.print("Checksum error,\t"); 
                          break;
              case DHTLIB_ERROR_TIMEOUT: 
                          Serial.print("Time out error,\t"); 
                          break;
              default: 
                          Serial.print("Unknown error,\t"); 
                          break;
            }
            // DISPLAY DATA
            Serial.print(DHT.humidity,0);
            Serial.print(",\t");
            Serial.println(DHT.temperature,0);
            
            lcd.setCursor(0,0);            // move cursor to second line "1" and 9 spaces over
            lcd.print("HUMI:");
            lcd.print((int)(DHT.humidity));
            lcd.print("%");
            lcd.print(" TEM:");
            lcd.print((int)(DHT.temperature));
            lcd.print("C");
     }
     delay(50); // delay 50 msec.
}
To compile this test code, you must install the library of DHT sensor.
Download dht.cpp and dht.h from below link and copy them into "/home/odroid/sketchbook/libraries/dht".
http://playground.arduino.cc/Main/DHTLib
I should restart the Arduino IDE after copying to use the library.

If you run the test code on the Arduino,
- Read the DHT sensor and show the Humidity and Temperature on LCD
- Read the keypad and show the pressed keypad
- Send the data to ODROID via Serial port (USB)
SerialMonitor.png
SerialMonitor.png (23.56 KiB) Viewed 67314 times
DHT11 uses one-wire communication and I connected it to the digital Pin#3 of Arduino.
Also note that I also added a 4.7K~5Kohm pull-up resistor on that pin.
Image

See photo : Connections are (V)oltage, (S)ignal, (G)round
Image

NOTE: Needs 4.7K to 10K pullup resistor from +5 to Signal pin

- Full range of calibration, in-line digital output;
- Humidity measuring range: 20% ~ 9 0% RH (0-50 ? temperature compensation)
- Temperature measuring range: 0 ~ +50 ?C ;
- Humidity measuring accuracy: 5.0% RH
- Temperature measurement accuracy: 2.0 C
- Response time: <5S ;
- Low power consumption

ODROID meets Arduino :o
s_20131020_173223.jpg
s_20131020_173251.jpg
s_20131020_184542.jpg
s_20131020_184658.jpg

We will make an example code with the Qt library to show the Humidity and Temperature graphically on ODROID.
I will also try the Android platform as well as Linux platform.
Stay tuned !

User avatar
sert00
Posts: 745
Joined: Sun Feb 24, 2013 12:26 am
languages_spoken: english,italian
ODROIDs: ODROID-U2*2__ODROID-U3__ODROID-XU-E__ODROID-XU-Ebeta__ODROID-C1__ODROID-XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by sert00 »

Good approach Odroid!
I have the same setup,running from February on a Usb port free in my bedroom.
Same board,same LCD keypad shield,same sensor,apart i use DHT22 and not 11 because 11 is less accurate having a T range of 2°C where 22 has +- 0.5°C.
To ALL--if you already have a shield similar to this,pay attention on the fact not all Keypad shields are the same internally.What change is the buttons assignements,some has and use one pin for every buttons,others instead only a pin and in the code you can know which pin is pressed because give different impedance being in series in between.
I'm very interested in the future qt\graphical design for read this on odroids.I used a similar approach time ago,did by a guy in Qt,and on my linux host i can see temperatures and pressure in a nice qt interface,all of that connected on internet and loaded via Pachube to read that data remotely.Was amazing!
Many thanks for this 3ad Odroid! :D
2x Odroid-U2
2x Odroid-XU-E
Odroid-U3
Odroid-C1+
Odroid-XU4
Lcd touch panel 10.1"
....and many of the goodies available....

User avatar
streetboy
Posts: 196
Joined: Tue Feb 26, 2013 6:43 pm
languages_spoken: english
ODROIDs: ODROID-X,U2,XU3-Lite
C1, XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by streetboy »

This is a very useful article even I'm using the USB-IO board based on Microchip's PIC MCU.
I like to make a servo motor driven motion controller with a few sensors.

HK's USB-IO vs. Arduino Uno.
The USB-IO is much cheaper than Arduino.
If you consider to make your own device in high volume, the USB-IO is better choice.
Microchip also supports many various example codes.

But if you make a few devices like DIY stuff and familiar with Arduino development, the Arduino is the best solution.
Tons of examples, various shields, books for beginners.... you can buy it locally without relatively expensive shipping cost from Korea.
Processing language on Arduino is very fun and productive.

I hope Hardkernel also sells their own Arduino compatible board at lower cost in near future.

User avatar
odroid
Site Admin
Posts: 41084
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3194 times
Been thanked: 1753 times
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by odroid »

streetboy wrote: I hope Hardkernel also sells their own Arduino compatible board at lower cost in near future.
We are heavilly considering to sell the Arduino Uno + LCD_Key_Shield + DHT11(assembled) + USB cable at $25.
But those are not the original one. They are clone(100% compatible) and manufactured by our partner in China.
The price will be about $50 if you like the orignal one.

When we complete a few applications for Linux and Android, we will start to sell it.
I think it will be available in middle of November. :D

User avatar
sert00
Posts: 745
Joined: Sun Feb 24, 2013 12:26 am
languages_spoken: english,italian
ODROIDs: ODROID-U2*2__ODROID-U3__ODROID-XU-E__ODROID-XU-Ebeta__ODROID-C1__ODROID-XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by sert00 »

Wow it will be great to have some apps for android to interface odroid and arduino!
Please take a look also on connect arduino via internet by odroid or its ethernet shield(10 dollars the clone chinese)and have possibility to exchange datas over internet\web pages via qt.
it would be awesome!
2x Odroid-U2
2x Odroid-XU-E
Odroid-U3
Odroid-C1+
Odroid-XU4
Lcd touch panel 10.1"
....and many of the goodies available....

User avatar
streetboy
Posts: 196
Joined: Tue Feb 26, 2013 6:43 pm
languages_spoken: english
ODROIDs: ODROID-X,U2,XU3-Lite
C1, XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by streetboy »

$25 seems to be very attractive.

My major concern is the maximum speed between ODROID and Arduino.
Is it 115200? or any possibility of 1M ~ 2Mbps?

When I used HK's USB IO, I could get about 2~3Mbps.
But if the Arduino can do only 0.1Mbps of communication... it is not suitable for my project. :(

mdrjr
Site Admin
Posts: 11852
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Has thanked: 2 times
Been thanked: 77 times
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by mdrjr »

Not sure if Arduino can do that..
May have to check if it isn't a limitation of the Atmel chip..
I've seen uarts going up to 4mbits/s so far..
So, it may be a limitation of the atmel chip.

mdrjr
Site Admin
Posts: 11852
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Has thanked: 2 times
Been thanked: 77 times
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by mdrjr »

For clarifications..

at 16Mhz.. you'll get 1Mbit/s over serial.
http://www.atmel.com/Images/doc8161.pdf
Page 203 ;)

User avatar
odroid
Site Admin
Posts: 41084
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3194 times
Been thanked: 1753 times
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by odroid »

I've just tested 2Mbit/s with the double speed mode. ;)

In the Arduino sketch, I just set "Serial.begin(2000000)".

Because the Arduino serial monitor supports only 115200bps max, I should use the minicom.
In the settings of Baud-rate in the minicom, I pressed a few of 'A' and 'B' to see the 2Mbps in the minicom memu.

Anyway, it works very well with 2Mbps.

User avatar
streetboy
Posts: 196
Joined: Tue Feb 26, 2013 6:43 pm
languages_spoken: english
ODROIDs: ODROID-X,U2,XU3-Lite
C1, XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by streetboy »

Thanks mdrjr and odroid,
I think 1~2Mbps bandwidth is enough for most project. ;)

User avatar
odroid
Site Admin
Posts: 41084
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3194 times
Been thanked: 1753 times
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by odroid »

We've added the Qt app as well as Android app.
http://odroid.com/dokuwiki/doku.php?id= ... doduinoone
dht11.png
dht11.png (13.72 KiB) Viewed 67113 times

User avatar
streetboy
Posts: 196
Joined: Tue Feb 26, 2013 6:43 pm
languages_spoken: english
ODROIDs: ODROID-X,U2,XU3-Lite
C1, XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by streetboy »

Awesome!
I love the Qt app source code and Android source code.
It is really helpful and useful for my projects.

One simple question !
When I installed the Arduino IDE into ODROID-U2, apt-get installed the OpenJDK automatically.
It seems to be obviously slower than the Oracle JDK.
Can I uninstall the OpenJDK and run the Arduino IDE with only Oracle's JDK?

User avatar
odroid
Site Admin
Posts: 41084
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3194 times
Been thanked: 1753 times
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by odroid »

Firmata is a generic protocol for communicating with microcontrollers from software on a host computer. It is intended to work with any host computer software package. Right now there is a matching object in a number of languages. It is easy to add objects for other software to use this protocol. Basically, this firmware establishes a protocol for talking to the Arduino from the host software. The aim is to allow people to completely control the Arduino from software on the host computer.
http://firmata.org/wiki/Main_Page


Install firmata into your Arduino board.
Run Arduino IDE Sketch.
Use File -> Open -> Examples > Library-Firmata > StandardFirmata
Build it and upload !

Compile the firmata test program on your ODROID.

1. Install the wxwidget libraries.

Code: Select all

$ sudo apt-get update
$ sudo apt-get install wx2.8-headers libwxgtk2.8-0 libwxgtk2.8-dev
2. Downlaod the firmata test program source code and uncompress

Code: Select all

$ wget http://www.pjrc.com/teensy/firmata_test/firmata_test_OSL.tgz
$ tar xvfz firmata_test_OSL.tgz
$ cd firmata_test_OSL
3. Compile

Code: Select all

$ make
4. Run

Code: Select all

$ ./firmata_test
Select the "dev/ttyACM0" in the Firmata Test program menu.
You can see below screen and you can access the IO ports on Arduino from ODROID.
firmata.png
firmata.png (50.02 KiB) Viewed 66786 times

ilham
Posts: 23
Joined: Mon Oct 28, 2013 6:35 pm
languages_spoken: English, Turkish
ODROIDs: XU
Has thanked: 0
Been thanked: 0
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by ilham »

Is that little thing on picture 4 that sort of "connects" the +5 to signal, a pull-up resistor?
I'am very beginner in electronics :)
Last edited by ilham on Mon Jun 23, 2014 9:06 pm, edited 1 time in total.

User avatar
odroid
Site Admin
Posts: 41084
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3194 times
Been thanked: 1753 times
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by odroid »

Yes, it is a 4.7K resistor.
2mm x 1.2mm(2012) size tiny chip resistor.

User avatar
Pingu
Posts: 28
Joined: Sun Oct 27, 2013 11:09 pm
languages_spoken: english, german
ODROIDs: U2, C1, VU
Location: Germany
Has thanked: 0
Been thanked: 0
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by Pingu »

@odroid
odroid wrote: Use File -> Open -> Examples > Library-Firmata > StandardFirmata
In my Arduino SDK it's: File -> Examples -> Firmata -> StadardFirmata

Could you check this and edit your post, just to prevent any confusion.
Thanks.

User avatar
odroid
Site Admin
Posts: 41084
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3194 times
Been thanked: 1753 times
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by odroid »

The exact path is "libraries -> Firmata -> examples -> StandardFirmata" on the Arudino IDE 1.0.5.
What's the version you tried?

I think each version has slightly different path.

User avatar
Pingu
Posts: 28
Joined: Sun Oct 27, 2013 11:09 pm
languages_spoken: english, german
ODROIDs: U2, C1, VU
Location: Germany
Has thanked: 0
Been thanked: 0
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by Pingu »

I think each version has slightly different path.
Yes, you're right.

I'm using 1.0.1

BeebBenjamin
Posts: 7
Joined: Wed Jan 29, 2014 9:31 pm
languages_spoken: english
ODROIDs: Odroid-U2
Has thanked: 0
Been thanked: 0
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by BeebBenjamin »

Hey! Great guide. I only use my Odroid for arudino projects now, it's all you need! I'll be posting the details of my 3D laser scanner when it's complete, developed in python on odroid making use of an arduino uno with an adafruit motor driver shield version 1.

linuxgnuru
Posts: 26
Joined: Fri Jun 27, 2014 9:01 pm
languages_spoken: english,swahili
ODROIDs: XU4, C2, vu7+
Has thanked: 0
Been thanked: 0
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by linuxgnuru »

I realize it's been over a year since the last post, but I have a XU4 and would love to use the latest Arduino IDE (1.6.8) and I'm wondering if it's even worth trying to get it running via compiling from source code or not or is there a deb package already out there that I'm unaware of?

User avatar
odroid
Site Admin
Posts: 41084
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3194 times
Been thanked: 1753 times
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by odroid »

Refer this link or search forum with "arduino ide".
http://forum.odroid.com/viewtopic.php?f=52&t=9377

Dominic86
Posts: 41
Joined: Thu Jan 03, 2019 7:49 pm
languages_spoken: Italian, english
ODROIDs: ODROID-XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by Dominic86 »

Sorry if this is an old discussion, but is the XU4 compatible with Arduino?
I understood that you speak about Linux, but is it possible to read sensor and map them directly also in Android for passing values to a third-part app?

User avatar
odroid
Site Admin
Posts: 41084
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3194 times
Been thanked: 1753 times
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by odroid »

@Dominic86,
Look at the bottom area in this wiki page.
https://wiki.odroid.com/old_product/etc/odroidoduinoone

User avatar
tony.hong
Posts: 136
Joined: Tue Jun 04, 2019 1:49 pm
languages_spoken: korean
ODROIDs: All
Location: korea
Has thanked: 32 times
Been thanked: 40 times
Contact:

Re: [GUIDE] ODROID meets Arduino

Post by tony.hong »

Arduino for Odroid -> Oduino !!!

If you have Odroid-C1, C2, N2, XU4 or ..., Try Oduino.

viewtopic.php?f=180&t=37713
These users thanked the author tony.hong for the post:
Luke.go (Thu Mar 05, 2020 11:39 am)

Post Reply

Return to “ODUINO One”

Who is online

Users browsing this forum: No registered users and 1 guest