Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Complete Sensor Guide
      • Engineering Deep Dives
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Tech Terms
    • Webinars & Digital Events
  • Resources
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • White Papers
  • Guest Post Guidelines
  • Advertisers
    • Advertise
    • PR Submissions
    • Eblast Submissions
  • Subscribe

Autorun Python Script on BeagleBone Black Boot (Part 14/15)

By Ashish Vara August 23, 2016

You already know how to run python script from command terminal as explained in the previous tutorial How to make first python program in BBB. When you execute python script from SSH command prompt, you need to make BBB connection with PC because you are accessing the BBB through SSH connection. If you wish to run python script on BBB without connecting it with PC, an external power is needed to be supplied.

You can run python script when you power up BBB without any command prompt or command. This job is done by Crontab.

Make Simple LED blinking program

Let’s run LED blinking program on boot up of Beaglebone black.

Required Tools:

  • Beaglebone Black
  • LED
  • 330 Ω Resistor
  • BreadboardFemale to Female connectors

Setup of Software environment

Install the latest python version in BBB as explained in tutorial How to make first python program with Beaglebone Black. Install the adafruit python-GPIO library named adafruit_BBIO.

Working

It is a simple learning tutorial of Beaglebone black. Here I connected two LEDs with GPIO pins of Beaglebone black. When script is running, both  the LEDs are switched ON and OFF for one second. After this execution  for five times, the pin status and configuration are clear.

Description

Let’s first prepare the circuit connection. Take a breadboard and provide VCC and ground from BBB to breadboard line. Connect Supply 3.3 V from pin number 3 of header P9 and ground from pin number 2 of header P8. Connect the negative terminal of both LEDs with ground and the positive  one with 330 Ohm resistor. Connect another end of both resistors with pin number 8 and 9 of header P8. Provide the supply to Beaglebone black by connecting it with PC through USB cable. Now your circuit is prepared.

Prototype of BeagleBone Black Boot

Fig. 1: Prototype of BeagleBone Black Boot

Image showing Autorun of Python Script on BeagleBone Black Boot

Fig. 2: Image showing Autorun of Python Script on BeagleBone Black Boot

Open the command terminal and access Beaglebone black through SSH as explained in getting started with Beaglebone black. Create a new file using touch command with .py (i.e. led.py) extension. Open the file with any text editor (i.e. nano, vim etc.) and write a code in python language.

Automatic Running Script on Boot

Crontab is a task management tool which is built-in into Debian. We can add the new Cron Job at which a Python script will run at boot.

Follow these steps to run python script on boot up of BBB:

Step1: Connect with internet and power up BBB.  Access   BBB with SSH through PC.

Step2: Install the crontab from debian repository by following command line:

sudo apt-get install crontab

Screenshot of Linux Console Installing Crontab

Fig. 3: Screenshot of Linux Console Installing Crontab

Step3: Open the crontab and edit for run on boot. Enter the following instruction to open crontab editing file:

crontab –e

Screenshot of Linux Console Editing Crontab

Fig. 4: Screenshot of Linux Console Editing Crontab

Step4: Scroll down and add the following line to run led.py on boot of BBB:

@reboot sudo  python /root/python_program/led.py &

Screenshot of Python Script Written in Nano Editor on Linux Console

Fig. 5: Screenshot of Python Script Written in Nano Editor on Linux Console

Here, /root/python_program/led.py is pathname of file where led.py is located. Don’t forget to add & for run the process in background at the end of line. Save the file and exit from it.

Step5: If you want to see suddenly, reboot the system:

reboot

Wait for some time to reboot. After reboot, the led.py script automatically runs on boot and  the LED starts blinking.

Step6: If you don’t want to reboot then remove the USB cable and attach it again. After booting, led.py will run automatically.

Project Source Code

###

# Led blinking Tutorial 
# developed By Ashish vara
# Engineersgarage
 
import Adafruit_BBIO.GPIO as GPIO
 
LED1 = "P8_8"
LED2 = "P8_9"
 
 
GPIO.setup(LED1,GPIO.OUT)
GPIO.setup(LED2,GPIO.OUT)
 
 
from time import sleep
 
for i in range(0,5):
 
        GPIO.output(LED1, GPIO.HIGH)
        GPIO.output(LED2, GPIO.HIGH)
 
        sleep(1)
 
        GPIO.output(LED1, GPIO.LOW)
        GPIO.output(LED2, GPIO.LOW)
 
        sleep(1)
 
GPIO.cleanup() 

###

 


Project Video


Filed Under: BeagleBone, Electronic Projects
Tagged With: beaglebone black
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

Log in to leave a comment:

Lost your password?

Don't have an account? Register here

Submit a Guest Post

submit a guest post

EE TECH TOOLBOX

“ee
Tech Toolbox: Wide Bandgap Semiconductors
Moving from silicon to GaN or SiC feels like a whole new ballgame, doesn’t it? It isn’t just about faster switching; it’s about managing the layout parasitics and thermal realities that come with that speed. This month’s Tech Toolbox features a curated eBook that tackles these design hurdles head-on.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS feed: EDABOARD.com Discussions. EDABOARD.com Discussions.

  • 7555 with no discharge resistor for monostable operation?
  • I have an Acer Aspire 5 A515-54G-53H6 issue with mother board
  • PCB not properly made
  • Flyback converter working incorrectly
  • Improve Equipment Efficiency

RSS feed: Electro-Tech-Online.com Discussions Electro-Tech-Online.com Discussions

  • Electronics and PIC Programming Assembler Update
  • Getting rid of old magazines
  • PIC code for 2.42" I2C OLED Display?
  • Getting Back Into Electronics
  • Best way to check charge and discharge many mixed batteries?

Featured Tutorials

LoRa and LoRaWAN: A Complete Guide to Wireless Communication

  • Best practices for securing LoRa networks
    Best practices for securing LoRa networks
  • Understanding LoRa architecture: nodes, gateways, and servers
    Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
    Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
    How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
    How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices
    How communication works between two LoRa end-node devices
More Tutorials >

Recent Articles

  • Silanna launches matched chipset for multi-channel LiDAR
  • Renesas launches browser-based embedded development hub
  • Diodes targets EV charging current sensing
  • Tria Technologies launches software kit for embedded systems
  • Nexperia adds 18 V to 200 V GaN FETs

EE ENGINEERING TRAINING DAYS

engineering
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2026 Arrowfly LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of Arrowfly
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Complete Sensor Guide
      • Engineering Deep Dives
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Tech Terms
    • Webinars & Digital Events
  • Resources
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • White Papers
  • Guest Post Guidelines
  • Advertisers
    • Advertise
    • PR Submissions
    • Eblast Submissions
  • Subscribe