[GUIDE] ODROID meets Arduino

Moderators: odroid, mdrjr

[GUIDE] ODROID meets Arduino

Unread postby odroid » Sun Oct 20, 2013 6:32 pm

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/Arduino_Shield#Arduino_LCD.26KeyPad_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 18814 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
odroid
Site Admin
 
Posts: 21875
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: [GUIDE] ODROID meets Arduino

Unread postby sert00 » Mon Oct 21, 2013 12:35 am

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
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

Re: [GUIDE] ODROID meets Arduino

Unread postby streetboy » Mon Oct 21, 2013 3:17 pm

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
streetboy
 
Posts: 184
Joined: Tue Feb 26, 2013 6:43 pm
languages_spoken: english
ODROIDs: ODROID-X,U2,XU3-Lite
C1, XU4

Re: [GUIDE] ODROID meets Arduino

Unread postby odroid » Wed Oct 23, 2013 7:21 pm

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
odroid
Site Admin
 
Posts: 21875
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: [GUIDE] ODROID meets Arduino

Unread postby sert00 » Thu Oct 24, 2013 3:07 am

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
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

Re: [GUIDE] ODROID meets Arduino

Unread postby streetboy » Thu Oct 24, 2013 10:51 am

$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. :(
User avatar
streetboy
 
Posts: 184
Joined: Tue Feb 26, 2013 6:43 pm
languages_spoken: english
ODROIDs: ODROID-X,U2,XU3-Lite
C1, XU4

Re: [GUIDE] ODROID meets Arduino

Unread postby mdrjr » Thu Oct 24, 2013 11:08 am

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: 11576
Joined: Fri Feb 22, 2013 11:34 pm
Location: Brazil
languages_spoken: english, portuguese
ODROIDs: -

Re: [GUIDE] ODROID meets Arduino

Unread postby mdrjr » Thu Oct 24, 2013 11:22 am

For clarifications..

at 16Mhz.. you'll get 1Mbit/s over serial.
http://www.atmel.com/Images/doc8161.pdf
Page 203 ;)
mdrjr
Site Admin
 
Posts: 11576
Joined: Fri Feb 22, 2013 11:34 pm
Location: Brazil
languages_spoken: english, portuguese
ODROIDs: -

Re: [GUIDE] ODROID meets Arduino

Unread postby odroid » Thu Oct 24, 2013 11:33 am

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
odroid
Site Admin
 
Posts: 21875
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: [GUIDE] ODROID meets Arduino

Unread postby streetboy » Thu Oct 24, 2013 3:42 pm

Thanks mdrjr and odroid,
I think 1~2Mbps bandwidth is enough for most project. ;)
User avatar
streetboy
 
Posts: 184
Joined: Tue Feb 26, 2013 6:43 pm
languages_spoken: english
ODROIDs: ODROID-X,U2,XU3-Lite
C1, XU4

Re: [GUIDE] ODROID meets Arduino

Unread postby odroid » Mon Nov 04, 2013 3:41 pm

We've added the Qt app as well as Android app.
http://odroid.com/dokuwiki/doku.php?id=en:odroidoduinoone

dht11.png
dht11.png (13.72 KiB) Viewed 18621 times
User avatar
odroid
Site Admin
 
Posts: 21875
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: [GUIDE] ODROID meets Arduino

Unread postby streetboy » Mon Nov 04, 2013 10:13 pm

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
streetboy
 
Posts: 184
Joined: Tue Feb 26, 2013 6:43 pm
languages_spoken: english
ODROIDs: ODROID-X,U2,XU3-Lite
C1, XU4

Re: [GUIDE] ODROID meets Arduino

Unread postby odroid » Fri Dec 06, 2013 12:15 pm

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 18295 times
User avatar
odroid
Site Admin
 
Posts: 21875
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: [GUIDE] ODROID meets Arduino

Unread postby ilham » Thu Jan 02, 2014 12:29 am

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.
ilham
 
Posts: 23
Joined: Mon Oct 28, 2013 6:35 pm
languages_spoken: English, Turkish
ODROIDs: XU

Re: [GUIDE] ODROID meets Arduino

Unread postby odroid » Thu Jan 02, 2014 12:12 pm

Yes, it is a 4.7K resistor.
2mm x 1.2mm(2012) size tiny chip resistor.
User avatar
odroid
Site Admin
 
Posts: 21875
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: [GUIDE] ODROID meets Arduino

Unread postby Pingu » Wed Jan 22, 2014 3:02 pm

@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
Pingu
 
Posts: 28
Joined: Sun Oct 27, 2013 11:09 pm
Location: Germany
languages_spoken: english, german
ODROIDs: U2, C1, VU

Re: [GUIDE] ODROID meets Arduino

Unread postby odroid » Wed Jan 22, 2014 7:11 pm

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
odroid
Site Admin
 
Posts: 21875
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: [GUIDE] ODROID meets Arduino

Unread postby Pingu » Thu Jan 23, 2014 8:11 am

I think each version has slightly different path.

Yes, you're right.

I'm using 1.0.1
User avatar
Pingu
 
Posts: 28
Joined: Sun Oct 27, 2013 11:09 pm
Location: Germany
languages_spoken: english, german
ODROIDs: U2, C1, VU

Re: [GUIDE] ODROID meets Arduino

Unread postby BeebBenjamin » Wed Jan 29, 2014 9:48 pm

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.
BeebBenjamin
 
Posts: 7
Joined: Wed Jan 29, 2014 9:31 pm
languages_spoken: english
ODROIDs: Odroid-U2

Re: [GUIDE] ODROID meets Arduino

Unread postby linuxgnuru » Sun Apr 17, 2016 4:29 pm

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?
linuxgnuru
 
Posts: 26
Joined: Fri Jun 27, 2014 9:01 pm
languages_spoken: english,swahili
ODROIDs: XU4, C2, vu7+

Re: [GUIDE] ODROID meets Arduino

Unread postby odroid » Sun Apr 17, 2016 4:33 pm

Refer this link or search forum with "arduino ide".
viewtopic.php?f=52&t=9377
User avatar
odroid
Site Admin
 
Posts: 21875
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID


Return to ODUINO One

Who is online

Users browsing this forum: No registered users and 1 guest