element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Single-Board Computers
  • Products
  • Dev Tools
  • Single-Board Computers
  • More
  • Cancel
Single-Board Computers
Blog ADC on the Odroid
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Single-Board Computers to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: mconners
  • Date Created: 23 Dec 2014 6:27 PM Date Created
  • Views 1953 views
  • Likes 3 likes
  • Comments 8 comments
  • wiringpi
  • single_board_computer
  • odroid
Related
Recommended

ADC on the Odroid

mconners
mconners
23 Dec 2014

One of the biggest features that the ODROID-C1 (odroid, from now on) has that is different than the Raspberry Pi B+ is the ADC. This is a welcome addition and will allow you to interface with analog sensors in a very simple way.

 

I figured I would use a photocell since I just finished doing a photocell blog project for the B+, so everything was in place.

 

The first thing I did was log into my odroid, and from my home directory type the following commands:

 

git clone https://github.com/hardkernel/wiringPi
cd wiringPi/
./build

 

This built and installed the wiringPi library on my odroid.

 

Next I opened my favorite code editor (not really, but I installed a pretty cool ide from the Lubuntu Software Store, CodeLite) and entered the following code:

 

#include <stdio.h>
#include <time.h>

#include <wiringPi.h>

#define PORT_ADC1   0 


int main (int argc, char *argv[])
{
    static int timer = 0 ;
  int adcValue;

    wiringPiSetup();

    for(;;)    {

        if (millis () < timer)  continue ;

        timer = millis() + 100;

        adcValue = analogRead(PORT_ADC1);

       printf("Value read is %d\n", adcValue);
    }

    return 0 ;
}

 

I attached the code below.

 

time to hook up the circuit:

 

I connected pin 1 of the Odroid to the + power rail on my breadboard

Pin 6 to the - Power rail

straddled a 1K resistor (any value will work) from the - rail to row 10

straddled a photocell over the channel in the middl on row 10

connected a jumper from the power rail to row 10 on the right side of the channel

connected a jumper from pin 40 of the odroid to row 10 of the bread board right between the photocell and the resistor

 

see the image below:

 

image

 

then I typed:

gcc -o photoSensor photoSensor.c -lwiringPi -lpthread

 

and finally:

 

sudo ./photoSensor

 

this gave me an ouput as follows:

 

 

image

 

That was with me waving my hand all above the sensor.

 

This is what the finished product looked like:

 

image

 

This wasn't intended to be a sophisticated project of any kind, just a quick example of how to use the ADC and the wiringPi libraries on the ODROID-C1.

Attachments:
photoSensor.c.zip
  • Sign in to reply

Top Comments

  • mconners
    mconners over 9 years ago in reply to Former Member +2
    I haven't really done any heavy duty programming of the ADC on the Odroid, but there are a couple of forum posts here : ODROID Forum • View topic - Streaming ADC samples without gaps & low jitter ODROID…
  • mconners
    mconners over 10 years ago in reply to johnbeetem +1
    Hey, John, yes it's definitely possible to access those devices as a normal user if the permissions are properly setup. The easiest might be to execute something in the rc or init files during system startup…
  • mconners
    mconners over 10 years ago in reply to johnbeetem +1
    Also, just to answer the question more, I know you got a variety of answers on another post in the file /etc/rc.local you can put a line like chmod 666 /dev/foo and that will be executed on boot that will…
  • mconners
    mconners over 9 years ago in reply to Former Member

    I haven't really done any heavy duty programming of the ADC on the Odroid, but there are a couple of forum posts here :

     

    ODROID Forum • View topic - Streaming ADC samples without gaps & low jitter

    ODROID Forum • View topic - A/D inputs

     

    You may be able to find more info there.

     

    Mike

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 9 years ago

    Hi Michael,

     

    Thanks for the adc example.

    I am new to odroid programming.

    What is the default sampling rate of adc?

    How do i decrease the sampling rate to 256Hz.

    Any help on this is highly appreciable.

    Thanks and Regards,

    sairam

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • clem57
    clem57 over 10 years ago

    I need to move from the Pi for this reason. How about the PSoC 5?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mconners
    mconners over 10 years ago in reply to johnbeetem

    Also, just to answer the question more, I know you got a variety of answers on another post

     

    in the file

     

    /etc/rc.local

     

    you can put a line like

    chmod 666 /dev/foo

     

    and that will be executed on boot

    that will open your device up to users

     

    Mike

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • johnbeetem
    johnbeetem over 10 years ago in reply to mconners

    I

    Michael Conners wrote:

     

    Hey, John, yes it's definitely possible to access those devices as a normal user if the permissions are properly setup. The easiest might be to execute something in the rc or init files during system startup. Either give group or user permissions. I don't show it in the blogs just to keep them simple. I know you are a unix guy but if you have any issues, ask.

     

    Mike

    Thank you for the quick reply.  I'm glad to hear it's possible, and even sounds pretty easy.

     

    For the record, I'm a GNU user and user-space developer, but not a Linux kernel guy.  I first used unix on a shared PDP-11/45 with 256KB of core memory, and let the lab staff deal with system issues.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube