Getting Started Raspberry Pi GPIO
The Open Automation Software platform has a built in communication driver for General Purpose Input / Output when deployed on a Raspberry Pi 4. Tags can be defined to read or write to GPIO pins.
The following steps can be used to setup communications with the GPIO pins.
Download and install OAS onto Raspberry Pi 4 device. View the Raspberry Pi Installation guide for an easy to following video instructions or use the Linux Installation guide for step by step instructions to use the simple install script.
Setup access to gpiomem for the user account the OASEngine is running under. The default is oasuser.
This is achieved by adding a rules file to etc/udev/rules.d/.
Log in to the root account and change directory to etc/udev/rules.d/.
ssh ubuntu@<ip address of Raspberry Pi> cd /etc/udev/rules.d/
Create a file oas-gpio.rules with an editor with the following contents, then save the file.
SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c 'chown -R root:oasuser /dev/gpiomem && chmod -R 660 /dev/gpiomem'"
To create and edit the file you can use nano.
sudo nano oas-gpio.rules
Reboot the system.
From a Windows system start Configure OAS application from the program group Open Automation Software.
Enter the IP Address of the Raspberry Pi device and click Select.
Note: Optionally select the Live Data Cloud node if you are hosting data from the Raspberry Pi over the Internet with a standard Internet connection.
Select ADD GROUP to add the group GPIO and click OK. The group name can be anything you like, in this example it will be GPIO.
With the GPIO group selected click on ADD TAG to a tag with the name Pin 5. The tag name can be anything you desire. In this example we are assigning to GPIO Pin 5 so we will name it Pin 5.
Change the Data Type of the tag to Boolean.
Change Data Source Tag property to GPIO.
Set the Pin Mode to one of the following.
Input: Read Only – Configures the GPIO pin in floating mode, with high impedance.
InputPullDown: Read Only – Configures the GPIO pin as high impedance with a pull-down resistor to ground.
InputPullUp: Read Only – Configures the GPIO pin as high impedance with a pull-up resistor to the voltage charge connection (VCC).
Output: Write Only – Configures the GPIO pin in strong drive mode, with low impedance.
Note: A pin cannot be set to both Input and Output. Inputs are read only. Outputs are write only.
When defining the pin as an input set the desired Polling Rate for the update speed.
Select Apply Changes to activate the pin communications.
To define multiple tags use the CSV Export and CSV Import on the toolbar in the upper right together with Microsoft Excel.
Select the Save button on the toolbar at the top.
Optionally create a directory on the Raspberry Pi and specify a file name to save to and select SAVE.
Under Configure – Options set the Default Tag Configuration File so when the device restarts the tag file will automatically be loaded.