Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / IoT

Procedure to Autostart the Arduino Sketch on Edison

0.00/5 (No votes)
20 Jan 2016CPOL1 min read 10.5K  
Procedure to Autostart the Arduino Sketch on Edison

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.

Running Arduino sketch at System Start-Up

There are many ways to do this, but on Edison I found that the easiest way is using the /etc/init.d directory. There are many references out there for why and how this works, a good one can be found here. If this is your first time using init.d for start-up scripts, you’re going to have to first create the directory else skip to Step 2:

Step 1

root@edison:~# mkdir /etc/init.d

Now lets switch into that directory,

Step 2

root@edison:~# cd /etc/init.d

Next, we’re going to create a bash script in this folder that contains our boot commands. In this case, we’re automating the Arduino sketch to run at startup.

In any case, open your favorite text editor and create the script automateSketch.sh:

root@edison:/etc/init.d# vi automateSketch.sh

Add the following contents into the script.

Bash
#!/bin/sh
	exec /sketch/sketch.elf /dev/ttyGS0 /dev/ttyGS0

Really, it’s just the two commands and we landed on at the end of our tutorial.

Now we can make the script executable by changing the permissions with chmod.

root@edison:/etc/init.d# chmod +x /etc/init.d/automateSketch.sh
	root@edison:/etc/init.d# chmod +x automateSketch.sh

Now, to make sure this script is executed every time linux boots, issue the following command and wait for the return shown below

root@edison:/etc/init.d# update-rc.d automateSketch.sh defaults
	Adding system startup for /etc/init.d/automateSketch.sh

Well!!, We are done! we can see if it Worked!

root@edison:/etc# reboot

Now you can see if the Arduino sketch auto starts.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)