IoT Bytes

Bits and Bytes of IoT

Control Raspberry Pi GPIO Pins with piCore and RPi.GPIO

Pradeep Singh | 2nd Sep 2017


If you have installed piCore on your Raspberry Pi and are looking to control GPIO Pins using the python scripts, you can follow this article. Here, I am using a Raspberry Pi 3 and “” piCore image downloaded from this link – ““.

1. Install Packages:

1.1 Install Python using the following command –

tce-load -wi python3.5.tcz

If you want to use any other Python package use “tce-ab” command to search other “.tcz” files.

1.2 Install Python RPI.GPIO package using the following command –

tce-load -wi python-RPi.GPIO.tcz

2. Prepare the Circuit:

For this example you need, Raspberry Pi 2/3, a LED and a 330 or 220 Ohm Resistor.

Connect LED anode (+) with 330 Ohm (or 220 Ohm) resistor to Pin # 8 on Raspberry Pi 3 (GPIO # 14), and connect LED cathode (-) to Ground Pin # 6. For more details refer to the following picture –


3. Create a Python Script to Blink the LED:

To organize your python scripts create a dedicated directory under “/home/tc” using the following command –

mkdir /home/tc/python_scripts

Create a new Python Script in “python_scripts” directory with the following command –

vi /home/tc/python_scripts/

Copy and Paste following code into “vi” editor window and save the file –

import RPi.GPIO as GPIO
import time

# Configure the PIN # 8
GPIO.setup(8, GPIO.OUT)

# Blink Parameters
blink_interval = .5 #Time interval in Seconds
blink_Count = 10

# Blinker Loop
for i in range(0,blink_Count):
 GPIO.output(8, True)
 GPIO.output(8, False)

# Release Resources

4. Execute the Script to Blink the LED:

Execute the python script using the following command –

sudo python /home/tc/python_scripts/ 

During the execution of this python script, You should see your LED blinking. if not, check the connections on your Raspberry Pi.

5. Make the Script Persistent:

If you reboot the Raspberry Pi, you would lose this python script. If you want to make it persistent, following these steps –

5.1 Use the following command to add the “python_scripts” directory in the list of file/directories that should be backed up by “” script –

sudo echo '/home/tc/python_scripts' >> /opt/.filetool.lst

5.2 (optional Step) If you want to trigger this script on system startup, add it to “” file using the following command –

sudo echo 'sudo python /home/tc/python_scripts/' >> /opt/

5.3 Save the persistent data using the following command – -b

After this step, if you reboot your Raspberry Pi you should not lose the “” script.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: