Hands On Embedded Linux with BeagleBone Black

  • 1,854 views
Uploaded on

Slide from my talk at Linux Day 2013 in Avellino (Italy). Getting started with BeagleBone Black and Python library by Adafruit

Slide from my talk at Linux Day 2013 in Avellino (Italy). Getting started with BeagleBone Black and Python library by Adafruit

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,854
On Slideshare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
110
Comments
0
Likes
4

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. HANDS ON EMBEDDED LINUX WITH BEAGLEBONE BLACK Daniele Costarella Ex Carcere Borbonico (Avellino) – October 25th, 2013
  • 2. October 25th, 2013 Linux Day 2013 2 What is BeagleBone Black? BeagleBone Black is a $45 MSRP community-supported development platform for developers and hobbysts. Boot Linux in under 10 seconds and get started on development in less than 5 minutes with just a single USB cable.
  • 3. October 25th, 2013 Hardware Processor: AM335x 1GHz ARM® Cortex-A8 •  512MB DD3 RAM •  2GB 8-bit eMMC on-board flash storage •  3D graphics accelerator Connectivity •  USB client for power and communications •  USB host •  Ethernet •  HDMI •  2x46 pin headers Software Compatibility •  Ångström Linux •  Android •  Cloud9 IDE on Node.js w/ BoneScript Library and more… Linux Day 2013 3
  • 4. October 25th, 2013 Linux Day 2013 4 Embedded Linux for Makers •  Embedded Linux System blur the definition between computer and device •  Powerful tools in the hands of “regular” people, not just those who design electronics for a living •  More powerful and capable than a “simple” microcontroller like ATMEGA 328 (Arduino) •  Perfect for those projects too complex to be executed on a MCU
  • 5. October 25th, 2013 Linux Day 2013 5 Advantages? Built-in networking Remote access Timekeeping Multitasking Linux software Filesystem Size USB Community
  • 6. October 25th, 2013 Linux Day 2013 BeagleBone Black: Ready to use 6
  • 7. October 25th, 2013 Browsing Your BeagleBone •  Firstly, just test that the connection is active by trying to connect to the BBB with a browser. •  Connect to the URL http://192.168.7.2 •  You should see a helful introductory web page served by the BeagleBoard itself Linux Day 2013 7
  • 8. October 25th, 2013 Linux Day 2013 Go with SSH •  On Linux or Mac simply open a terminal window and type the following command: ssh 192.168.7.2 –l root 8
  • 9. October 25th, 2013 Using Python Using GPIO, PWM and more with Python! Available functionality: •  7 Analog pins •  65 Digital Pins at 3.3V •  2xI2C •  2xSPI •  2x CAN Bus •  4 Timers •  4x UART •  8x PWM •  A/D Converter Linux Day 2013 9
  • 10. October 25th, 2013 Expansion Headers Each digital I/O pin has 8 different modes that can be selected, including GPIO Linux Day 2013 10
  • 11. October 25th, 2013 Linux Day 2013 Install Adafruit_BBIO Commands needed to install the library. Access via SSH and execute (on Angstrom Linux): opkg update && opkg install python-pip python-setuptools python-smbus pip install Adafruit_BBIO You can test your installation simply trying to load one of the modules: import Adafruit_BBIO.GPIO as GPIO; print GPIO #you should see this or similar: <module 'Adafruit_BBIO.GPIO' from '/usr/local/lib/python2.7/dist-packages/ Adafruit_BBIO/GPIO.so'> 11
  • 12. October 25th, 2013 Linux Day 2013 12 Using the library Open a Python console and import the library. Example: import Adafruit_BBIO.GPIO as GPIO You can access the channels by either referencing the pin “key” or the name. import Adafruit_BBIO.GPIO as GPIO GPIO.setup("P8_10", GPIO.OUT) GPIO.output("P8_10", GPIO.HIGH) GPIO.setup("P8_14", GPIO.IN) if GPIO.input("P8_14"): print("HIGH") else: print("LOW")
  • 13. October 25th, 2013 LED blinking: wiring Positive to pin 10 and negative to GND Linux Day 2013 13
  • 14. October 25th, 2013 Linux Day 2013 LED blinking: writing the program Back to the Linux/Mac prompt and create the executable file # nano blink.py Write the simple program: import Adafruit_BBIO.GPIO as GPIO import time GPIO.setup("P8_10", GPIO.OUT) while True: GPIO.output("P8_10", GPIO.HIGH) time.sleep(0.5) GPIO.output("P8_10", GPIO.LOW) time.sleep(0.5) 14
  • 15. October 25th, 2013 Linux Day 2013 LED blinking: writing the program …and execute it # python blink.py Easy! 15
  • 16. October 25th, 2013 Linux Day 2013 Measuring Temperature: wiring 16
  • 17. October 25th, 2013 Linux Day 2013 Measuring Temperature …and write the program # nano temperature.py Write the simple program: import Adafruit_BBIO.ADC as ADC import time sensor_pin = 'P9_40' ADC.setup() while True: reading = ADC.read(sensor_pin) millivolts = reading * 1800 # 1.8V reference = 1800 mV temp_c = (millivolts - 500) / 10 temp_f = (temp_c * 9/5) + 32 print('mv=%d C=%d F=%d' % (millivolts, temp_c, temp_f)) time.sleep(1) 17
  • 18. October 25th, 2013 Using a Push Button Energy Harvesting Demoboard 18
  • 19. October 25th, 2013 Writing the code …and write the program # nano button.py Write the simple program: import Adafruit_BBIO.GPIO as GPIO import time GPIO.setup("P8_12", GPIO.IN) old_switch_state = 0 while True: new_switch_state = GPIO.input("P8_12") if new_switch_state == 1 and old_switch_state == 0 : print('Do not press this button again!') time.sleep(0.1) old_switch_state = new_switch_state Linux Day 2013 19
  • 20. October 25th, 2013 Fade Effect with PWM: wiring Linux Day 2013 20
  • 21. October 25th, 2013 PWM? Linux Day 2013 21
  • 22. October 25th, 2013 Fade Effect with PWM: code …and write the program # nano led_fade.py import Adafruit_BBIO.PWM as PWM import time led_pin = "P9_14" PWM.start(led_pin, 0) while True: for i in range(0, 100): PWM.set_duty_cycle(led_pin, i) time.sleep(0.05) for i in range(0, 100): PWM.set_duty_cycle(led_pin, 100-i) time.sleep(0.05) Linux Day 2013 22
  • 23. DEMO
  • 24. October 25th, 2013 Linux Day 2013 Recommended readings Getting Started with BeagleBone Black Make By Matt Richardson Building Embedded Linux System O’Reilly By Karim Yaghmour, Jon Masters, Gilad Ben Yassef, and Philippe Gerum Embedded Linux System Design and Development By P. Raghavan, A. Lad, S. Neelakandan, Auerbach 24
  • 25. October 25th, 2013 Linux Day 2013 Thank you @dcostarella danielecostarella.com 25