An Introduction to Using the Embedded-Pi with the Raspberry Pi
- Overview
- System Configuration
- Bill of Materials
- Set of Instructions
- More Details
- Using the Embedded-Pi
- Trouble Shooting
- Appendix A - The Embedded Pi
- Appendix B - The Software
- Appendix C - The Arduino TinkerKit Sensor Shield
- Terminology
- About this Document
Overview
This Project is about introducing the use of the Embedded Pi (E-Pi) to extend the functionality of the Raspberry Pi (R-Pi). The Embedded Pi provides an R-Pi with an interface to Arduino Shields without the use of an Arduino device. In this set of instructions the R-Pi/E-Pi combination is used to drive a TinkerKit Sensor Shield with a set of sensors/actuators:
- LED actuator - to switch an LED on and off;
- Button sensor - to sense the state of a button/switch;
- Tilt sensor - to sense when an object is being tilted;
- Relay actuator - to use a low power device to control the on/off state of a high power device.
The key learning objectives of this project are for an intermediate/novice developer to learn:
- How to use a combination of the R-Pi, E-Pi and Sensor Shield to control a set of sensors and actuators;
- How to write Python software that is used to control/detect the state of the sensors/actuators.
The associated Bill of Materials describes the set of components, hardware and software, required to complete this project. When complete, the system will look as shown in the Figure below. There is a signifiant amount of information about the Embedded Pi available on the Element14 Community Embedded Pi web-site.
The completed system. |
---|
1. System Configuration
The system configuration is shown in Figure 1.1. The basic configuration is:
- R-Pi (Model A/B) - this project can make use of either Model. Network connectivity is required to install the necessary software updates and the Embedded Pi demonstration software. A USB2 hub is recommended to enable more than two USB devices to be linked to the R-Pi (the R-Pi has two USB ports). It is assumed that the keyboard and mouse are linked via the USB Hub and, if required, the WiPi. The monitor can be linked either via the HDMI interface or the yellow RCA phono connector for composite video output. In this project a PiView connector is used to enable a monitor with a VGA connector to be connected to the R-Pi via the HDMI interface;
- Embedded Pi (E-Pi) - the E-Pi provides an interface platform to the R-Pi, Arduino and the 32-bit embedded ARM processor. For this set of instructions the E-Pi is used as a bridge between the R-Pi and Arduino Shields. This interface is physically achieved using the GPIO connectors on the R-Pi and E-Pi. The software interface is achieved using the RPi.GPIO and WiringPi modules. The Embedded Pi User Manual (Revision 1.0 published in May 2013 by CooCox) is available at: Embedded Pi User Manual. This is required reading. Details on the CooCox development environment, this is not used in this project, are available Here;
- TinkerKit Sensor Shield - this allows TinkerKit sensors and actuators to be connected directly to an Arduino or E-Pi without the use of a breadboard. The Sensor Shield has 12 standard TinkerKit 3-pin connectors. The 6 labelled 'I0' to 'I5' are the Analog Inputs and the 6 labelled 'O0' to 'O5' are the Analog Outputs (these can be driven using PWM capable outputs or can be configured as digital inputs). In this set of instructions only the 'O0' to 'O5' pins are used. Further information is available at TinkerKit Sensor Shield;
- Sensor Shield Sensors and Actuators - in this set of instructions the LED and Relay actuators and the Button and Tilt sensors modules fromTinkerKit are used (they are plugged into the 'O0' to 'O5' pins on the Sensor Shield). The use of sensor and actuators being used together is also demonstrated.
Figure 1.1 System Configuration. |
---|
When the complete system is built it will have various forms as shown in Figure 1.2. The views shown in Figure 1.2 are for LED modules (a), Button modules (b), Tilt module (c) and Relay module(d).
Figure 1.2 The completed system. | |
---|---|
(a) Demonstrating LED modules. |
(b) Demonstrating Button modules. |
(c) Demonstrating the Tilt module. | (d) Demonstrating the Relay module. |
2. Bill of Materials
2.1 System Configuration
The architecture is based upon the use of an R-Pi, an E-Pi, a TinkerKit Sensor Shield and a set of sensors and actuators. The configuration is shown in Figure 2.1 and the key to the alphanumeric labels is provided in Tables 2.1 and 2.2.
Figure 2.1 System configuration for the bill of materials |
---|
The associated bill of materials for the system shown in Figure 2.1 is listed in Table 2.1.
Table 2.1 - the Bill of Materials.
ID | Part | Comment | Qty | Order Code |
---|---|---|---|---|
1(a) | R-Pi Model A | Either Model can be used (includes 4GB SD Card). Use a Multicomp enclosure to protect the R-Pi base. | 1 | R-Pi Model AR-Pi Model A |
1(b) | R-Pi Model B | Use a Multicomp enclosure to protect the R-Pi base. Can include the use of a Cat 5 Ethernet cable. | 1 | R-Pi Model BR-Pi Model B |
1(c) | R-Pi Enclosure | Multicomp enclosure to protect the R-Pi base. | 1 | R-Pi EnclosureR-Pi Enclosure |
1(d) | SD Card | Storage medium (8GB) for the R-Pi (with NOOBS pre-installed). | 1 | SD CardSD Card |
2 | Embedded Pi | The external board, connected to the the R-Pi (using the GPIO interface), that provides the link to TinkerKit Sensor Shield. Optional 12V DC External Power Supply for the E-Pi. | 1 | Embedded PiEmbedded Pi External 12V DC Power SupplyExternal 12V DC Power Supply |
3 | Keyboard | Include a USB cable. Get as part of an Accessory Bundle (see 4 below). | 1 |
Accessory BundleAccessory Bundle |
4 | Mouse | Include a USB cable. Get as part of an Accessory Bundle (see 3 above). | 1 | |
5 | WiPi | Wireless access via USB. Required to provide network access if a R-Pi Model A is used. | 1 | WiPiWiPi |
6 | PiView | HDMI/VGA adapter to provide connection to a non-HDMI enabled monitor. | 1 | PiViewPiView |
7 | Monitor | A suitable colour monitor (VGA or HDMI connectivity recommended). | 1 | N/A |
8 | USB2 Hub | Includes the power supply and USB2 cables. | 1 | USB2 HubUSB2 Hub |
9 | Power Supply | R-Pi power supply with 5V/1A output. Micro USB connector. | 1 | Power SupplyPower Supply |
10 | Power Supply | USB2 power supply (5V/1A with 2.1mm x 5.5mm Barrel Plug connector). Included with the USB2 Hub (see 8 above). | 1 | N/A |
11 | TinkerKit Sensor Shield | Arduino Sensor Shield Base Kit (including a set of sensors/actuator). | 1 | TinkerKit Sensor Shield Base KitTinkerKit Sensor Shield Base Kit |
12 | TinkerKit Sensor/Actuator Modules | Set of sensor/actuator modules for use with the Sensor Shield (in particular LED, Button, Tilt and Relay). | 1 | (As above) |
2.2 Hardware Configuration
The hardware connectivity is detailed in Table 2.2.
Table 2.2 - The hardware connectivity.
ID | Connector | Connection | Comment |
---|---|---|---|
A | VGA (PiView) | Monitor/R-Pi | Part of the Monitor cable to the R-Pi. |
B | HDMI (PiView) | R-Pi/Monitor | Part of the Monitor cable to the R-Pi. |
C | Power Cable | R-Pi Micro USB/Mains | Power supply for the R-Pi. |
D | GPIO | R-Pi/E-Pi | The GPIO flat-flex cable (female-to-female). |
E | Power Cable | USB2 Hub/Mouse + Keyboard | Power for the USB2 hub - the hub supports seven ports. |
F | USB Cable | USB2 Hub/Mouse + Keyboard | USB cable connection for the Mouse and Keyboard. |
G | USB Insert | R-Pi/WiPi | The WiPi will be plugged directly into the USB2 hub. |
H | USB Cable | USB2 Hub/R-Pi | USB cable to connect the USB hub to the R-Pi. The R-Pi can also draw power using this cable. |
I | Header Pins | E-Pi/Sensor Shield | Sensor Shield underside pins inserted directly into E-Pi Arduino form factor compatible interface pins. |
J | 3-Pin Wires | Sensor Shield/Sensor and Actuator Modules | Connect each sensor/actuator module to the Sensor Shield 'O0' to 'O5' 3-pin sockets. Wiring supplied as part of the TinkerKit Sensor Shield Base Kit. |
K | Cat 5 Ethernet Cable | R-Pi (Model B)/Network Hub | Ethernet-based network access. |
2.3 Software Configuration
The software required to support this project that must be installed on the R-Pi is:
- R-Pi Operating System (Raspbian) - this is installed using the NOOBS that comes pre-installed on the R-Pi SD cards. If NOOBS is not preinstalled it is available at Downloads;
- Integrated Development Environment - IDLE with Python 2.x support (normally installed as part of Raspbian).
3. Set of Instructions
The set of instructions for using the E-Pi are:
- Configure the R-Pi system in preparation for the connection of the E-Pi and usage of the demonstration software i.e. the monitor, USB2 Hub, keyboard and mouse and the network connection (using either a WiPi for wireless access or using the wired Ethernet port). If the WiPi is to be used then insert the WiPi into one of the USB ports on the R-Pi - see More Detail;
- The next step is to connect together the R-Pi, E-Pi and the Sensor Shield. A demonstration of this is shown in Video 1. The R-Pi and E-Pi are connected via the GPIO interfaces using the flat-flex cable (supplied as part of the E-Pi kit). It is important to ensure that the two GPIO interfaces are connected correctly and so use the red edge on the flat-flex cable to confirm the correct alignment of the interfaces. The Sensor Shield is placed on top of the E-Pi and connected using the set of pins on the underside of the Sensor Shield and the outer set of sockets on the E-Pi Arduino Form-Factor Compatible interfaces. Set the E-Pi power bus voltage to 3.3V (using Jumper JP1). Finally the E-Pi must be configured for the R-Pi mode by making sure that only the Jumper JP3 ('R') is present of the JP3 ('R') and and JP4 ('S') pair - see More Detail;
- To use the LED modules take the 3-pin twisted wires cable that were supplied with the TinkerKit Sensor Shield Base Kit and connect the LED modules to the orange sockets (Analog output) on the Sensor Shield. Download the Python software program 'epi-leds-rgv1p0p0.py' from the Element14 GitHub repository and run it using the LXApplication. A demonstration of this software is shown in Video 2 - see More Detail;
- To use the Button modules take the 3-pin twisted wires cable that were supplied with the TinkerKit Sensor Shield Base Kit and connect the Button modules to the orange sockets (Analog output) on the Sensor Shield. Download the Python software program 'epi-buttons-rgv1p0p0.py' from the Element14 GitHub repository and run it using the LXApplication. A demonstration of this software is shown in Video 3 - see More Detail;
- To demonstrate the use of the Tilt Switch module connect it and one of the LED modules to the orange sockets (Analog Output) on Sensor Shield using the 3-pin twisted wires cables. Note that the Tilt Switch should be connected to the orange socket 'O0' and the LED to orange socket 'O1'. Download the Python software program 'epi-tilt-rgv1p0p0.py' from the Element14 GitHub repository and run it using the LXApplication. While the software is running vary the orientation of the Tilt Switch and observe the brightness of the LED (it should be possible to turn the LED 'on' and 'off' by varying the orientation of the Tilt Switch). A demonstration of this software is shown in Video 4 - see More Detail;
- To demonstrate the use of the Relay module connect it and a Button module to the Sensor Shield (via the orange sockets 'O3' and 'O2' respectively) using two 3-pin twisted wires cables. The Relay is used to control current flow through a separate circuit and for this demonstration a small red LED is wired to the Relay such that the LED is 'off' under normal operation. The power to the red LED is drawn from convenient 3.3V and ground pins on the E-Pi via the Power Socket on the Arduino Form-Factor Compatible Interface on the Sensor Shield. The demonstration involves the Button being pressed to close the Relay and thus light the red LED. When the Button is pressed again, the Relay is opened and the LED turned 'off'. Download the Python software program 'epi-relay-rgv1p0p0.py' from the Element14 GitHub repository and run it using the LXApplication. A demonstration of this software is shown in Video 5 - see More Detail.
4. More Details
4.1 Configure the R-Pi System
The layout of the R-Pi (Model B) is shown in Figure 4.1. Once the various cables have been connected to the R-Pi, the configuration is as shown in Figure 4.2 (the alphanumeric annotations refer to the identifier entries in Tables 2.1 and 2.2). The latest versions of the Raspbian operating system can be installed using the instructions in Appendix B1.1.
4.2 Connecting the R-Pi, E-Pi and Sensor Shield
Once the R-Pi has been configured, the next step is to connect the E-Pi and Sensor Shield in preparation for using the various sensor and actuator modules. The E-Pi is connected to the R-Pi using the GPIO flat-flex cable as shown in Figure 4.3 (note the positioning of the red edge of the flat-flex cable with respect to the orientation of the R-Pi and E-Pi).
Figure 4.3 - R-Pi and E-Pi connection. |
---|
The Sensor Shield is inserted into the outer set of pins on the E-Pi i.e. the Arduino Form-Factor Compatible Interface (see Appendix A): this connection is shown in Figure 4.4 (Figure 4.4d showing the use of the outer set of pins). The GPIO pins on the underside of the E-Pi are used to connect to the R-Pi as shown in Figure 4.4a.
Figure 4.4 - E-Pi and Sensor Shield connection. | |
---|---|
(a) | (b) |
(c) | (d) |
When all three devices are connected, the layout is as shown in Figure 4.5. Note that in Figure 4.5 the JP3 ('S') jumper has been removed to prepare the E-Pi to operate in R-Pi mode (see Appendix A for more details on the JP3).
Figure 4.5 - The connected R-Pi, E-Pi and Sensor Shield. |
---|
See Video 1 for a demonstration of how to connect the R-Pi, E-Pi and Sensor Shield.
4.3 Demonstrating the Sensor Shield LED Actuator Module
The LED modules are connected to the Analog Output (orange) sockets on the Sensor Shield using the 3-pin wires. The green LED on the module board will be lit when the E-Pi/Sensor Shield is powered. The Sensor Shield can support up to six LED modules all of which are controlled independent of each other. See Figure 4.6 for the connection of the demonstrator. The order of the LEDs connected to the Sensor Shield is not important because the software drives all of the output sockets.
Figure 4.6 - Connecting the LEDs to the R-Pi, E-Pi and Sensor Shield. | |
---|---|
(a) LED module connection. |
(b) Full configuration. |
Once the hardware has been configured the demonstration software should be used. Download the Python software program 'epi-leds-rgv1p0p0.py' from the Element14 GitHub repository - see Appendix B. To run the software use the LXApplication and type the following instruction:
sudo python epi-leds-rgv1p0p0.py
Now follow the instructions printed on the terminal. This program will now switch the LEDS on and off in a number of predefined sequences. A commentary on the activity of the program is printed on the terminal display. This program can be changed to reflect any personal preferences on the control of the LEDs. See Video 2 for a demonstration of the operation of this software.
4.4 Demonstrating the Sensor Shield Button Sensor Module
The Button modules are connected to the Analog Output (orange) sockets on the Sensor Shield using the 3-pin wires. The green LED on the module board will be lit when the E-Pi/Sensor Shield is powered. The Sensor Shield can support up to six Button modules all of which are controlled independent of each other. See Figure 4.7 for the connection of the demonstrator. The actual orange sockets used to connect to the Sensor Shield is not important because the software monitors all of the output sockets.
Figure 4.7 - Connecting the Buttons to the R-Pi, E-Pi and Sensor Shield. | |
---|---|
(a) Button module connection. |
(b) Full configuration. |
Once the hardware has been configured the demonstration software should be used. Download the Python software program 'epi-buttons-rgv1p0p0.py' from the Element14 GitHub repository - see Appendix B. To run the software use the LXApplication and type the following instruction:
sudo python epi-buttons-rgv1p0p0.py
Now follow the instructions printed on the terminal. This program will now monitor the state of the buttons and display this state on the terminal window. A commentary on the activity of the program is printed on the terminal display. This program can be changed to reflect any personal preferences on the control of the buttons. See Video 3 for a demonstration of the operation of this software.
4.5 Demonstrating the Sensor Shield Tilt Sensor Module
In this demonstration the Tilt Switch is used to drive the state of an LED i.e. when the Tilt switch is upright the LED is 'on' otherwise the LED is 'off'. The Tilt Switch and LED modules are connected to the Analog Output (orange) sockets on the Sensor Shield using the 3-pin wires. The green LED on the module board will be lit when the E-Pi/Sensor Shield is powered. See Figure 4.8 for the connection of the demonstrator. It is important to connect the LED and Tilt Switch to the correct orange sockets otherwise the software will not work correctly (unless it is also modified to reflect the different sockets connections). The software assumes that the Tilt Switch is connected using socket 'O1' and the LED using socket 'O0'.
Figure 4.8 - Connecting theTilt Switch to the R-Pi, E-Pi and Sensor Shield. | |
---|---|
(a) Tilt switch connection. |
(b) Full configuration. |
Once the hardware has been configured the demonstration software should be used. Download the Python software program 'epi-tilt-rgv1p0p0.py' from the Element14 GitHub repository - see Appendix B. To run the software use the LXApplication and type the following instruction:
sudo python epi-tilt-rgv1p0p0.py
Now follow the instructions printed on the terminal. While the demonstration software is running vary the orientation of the Tilt Switch and watch the corresponding change in state of the LED module and the logging on the terminal. A commentary on the activity of the program is printed on the terminal display. This program can be changed to reflect any personal preferences on the use of the Tilt Switch. See Video 4 for a demonstration of the operation of this software.
4.6 Demonstrating the Sensor Shield Relay Actuator Module
In this demonstration the state of the Relay module is controlled using a Button module. The Relay and Button modules are connected to the Analog Output (orange) sockets on the Sensor Shield using the 3-pin wires. See Figure 4.9 for the connection of the demonstrator. It is important to connect the Relay and Button modules to the correct orange sockets otherwise the software will not work correctly (unless it is also modified to reflect the different sockets connections). The software assumes that the Relay is connected using socket 'O3' and the Button using socket 'O2'. The small red LED, see Figure 4.9a, is connected to the power pins on the E-Pi Power port .e. one of the GND pins and the 3.3V pin. The aim is to show that when the Relay is closed the current can flow through the red LED and thus show that the relay has changed state. The drop-down resistor (approx 180 Ohm) is used to ensure that the voltage drop across the LED is not more than 2.2V (the connection to the E-Pi is configured to supply a voltage of 3.3V). The red LED is wired to the 'NO' port on the Relay and so the circuit is normally open.
Figure 4.9 - Connecting the Relay module to the R-Pi/E-Pi/Sensor Shield. | |
---|---|
(a) Relay module connection. | (b) Full configuration. |
Once the hardware has been configured the demonstration software should be used. Download the Python software program 'epi-relay-rgv1p0p0.py' from the Element14 GitHub repository - see Appendix B. To run the software use the LXApplication and type the following instruction:
sudo python epi-relay-rgv1p0p0.py
Now follow the instructions printed on the terminal. The state of the Relay is changed by pressing the Button. At the start, the Relay is open (the small red LED is also off) and when the Button is pressed the Relay is closed (the red LED is now turned on). If the Button is pressed again then the Relay opened (the red LED is now off). Note that there is an audible click every time the state of the Relay is changed. A commentary on the activity of the program is printed on the terminal display. This program can be changed to reflect any personal preferences on the use of the Relay module. See Video 5 for a demonstration of the operation of this software.
5. Using the Embedded-Pi
All of the videos below are available in medium resolution (a) and high resolution (b) - the high resolution will require at least a 3.5Mbps broadband data rate to view in streamed mode.
5.1 Configuring the Hardware
A video, 8 minutes long, demonstrating the wiring together of the R-Pi, E-Pi and Sensor Shield is shown in Video 1.
Video 1 - Wiring the R-Pi, E-Pi and Sensor Shield. | |
---|---|
(a) High resolution. |
(b) Medium Resolution. |
5.2 Demonstrating the Embedded Pi with Sensor Shield LED
A video, 4 minutes long, demonstrating the use of the R-Pi, E-Pi and Sensor Shield to control LEDs is shown in Video 2.
Video 2 - Demonstrating the R-Pi, E-Pi and Sensor Shield to drive a set of LEDs. | |
---|---|
(a) High resolution. |
(b) Medium Resolution. |
5.3 Demonstrating Embedded Pi with Sensor Shield Buttons
A video, 4 minutes long, demonstrating the use of the R-Pi, E-Pi and Sensor Shield to sense the state of Buttons is shown in Video 3.
Video 3 - Demonstrating the R-Pi, E-Pi and Sensor Shield to sense the state of buttons. | |
---|---|
(a) High resolution. |
(b) Medium Resolution. |
5.4 Demonstrating Embedded Pi with Sensor Shield Tilt Sensor
A video, 2 minutes long, demonstrating the use of the R-Pi, E-Pi and Sensor Shield to sense the state of a Tilt Switch and to use an LED to show that state is shown in Video 4.
Video 4 - Demonstrating the R-Pi, E-Pi and Sensor Shield to sense the state of a Tilt Sensor. | |
---|---|
(a) High resolution. |
(b) Medium Resolution. |
5.5 Demonstrating Embedded Pi with Sensor Shield Relay Actuator
A video, 3 minutes long, demonstrating the use of the R-Pi, E-Pi and Sensor Shield to change the state of a Relay actuator using a Button/switch is shown in Video 5.
Video 1 - Demonstrating the R-Pi, E-Pi and Sensor Shield to control the state of a Relay actuator. | |
---|---|
(a) High resolution. |
(b) Medium Resolution. |
6. Trouble Shooting
Problem 1 | When using the Tilt Switch demonstration software the state of the LED does not change when the Tilt switch is moved. |
Solution | Check that both the Tilt Switch and LED modules are connected to the correct sockets on the Sensor Shield i.e. 'O1' and 'O0' respectively. The demonstration software assumes that it is those two sockets that are used. If different sockets are to be used then edit the Tilt Switch demonstration software. |
Problem 2 | When using the Relay demonstration software the state of the Relay does not change, there is no audible click and the red LED does not change, when the Button is pressed. |
Solution | Check that both the Relay and Button modules are connected to the correct sockets on the Sensor Shield i.e. 'O3' and 'O2' respectively. The demonstration software assumes that it is those two sockets that are used. If different sockets are to be used then edit the Relay demonstration software. |
Problem 3 | When using the relay software the state of the small red LED is inconsistent with the expected state i.e. when the Relay is open the LED is 'on'. |
Solution | The small LED has been connected to the wrong ports on the Relay module. The demonstration expects the red LED to be connected to the 'COM' and 'NO' ports and in your case it is connected to the 'COM' and 'NC' ports. The 'NC' port, normally closed, means that the Relay is closed unless a voltage has been applied and so the red LED will be on. |
Problem 4 | When using the demonstration software the results are not as expected but repeatable i.e. the unexpected results are repeated each time the software is used. |
Solution | Make sure that the Sensor Shield is correctly plugged into the E-Pi and make sure that the E-Pi and R-Pi are correctly connected using the GPIO flat-flex cable. The Sensor Shield must be plugged into the outer sets of sockets on the E-Pi i.e. the Arduino Form-Factor Compatible Interface sockets. In the case of the GPIO flat-flex cable make sure the red edge cable is correctly aligned on the E-Pi and R-Pi devices. |
Appendix A - The Embedded Pi
The layout of the E-Pi is shown in Figures A1.1 and A1.2. The E-Pi is supplied with the GPIO flat-flex cable (see Figure A1.3) and the plastic stands (see Figure A1.1c): the latter should be inserted into the E-Pi so that the underside is not damaged when the E-Pi is being used. The TinkerKit Sensor Shield is connected using the two outer sockets labelled as the Arduino Form-Factor Compatible Interface. The GPIO interface is one of the male set of pins on the underside (see Figure A1.1b). The other set of pins on the underside are the debug interface that enables the internal operation of the E-Pi to be observed using a set of test software (see the CooCox Embedded Pi User Manual for more details - this interface is not used in this set of instructions). The GPIO ports are directly mapped to the Analogue Output/Digital Input pins that are part of the Arduino Form-Factor Compatible Interface. The details of the various GPIO pin numbers and relationships between the Arduino Form-Factor and the R-PI are defined in Table 3.7 in the Embedded Pi User Manual.
Figure A1.1 - E-Pi board layout. | |
---|---|
(a) Top view. |
(b) Underside view. |
The use of the three jumpers JP1, JP2 and JP3 is summarised in Table A1.1.
Table A1.1 - Use of the Jumpers of the E-Pi.
Jumper ID | Function | Description |
---|---|---|
JP1 | Bus Power Selection | Jumper across bottom two pins for Power Bus Output 3.3V (as shown in Figure A1.1a). |
Jumper across top two pins for Power Bus Output 5V | ||
JP3 ('R') | R-Pi Bus Enablement | Together these two jumpers provide three modes of operation:
|
JP4 ('S') | STM32 Bus Enablement |
The various side images of the E-Pi are shown in Figure A1.2. In these image both the 'R' and 'S' jumpers are present and the voltage is set to 3.3V. To set the E-Pi for R-Pi mode the 'S' jumper must be removed.
Figure A1.2 - Side views of the E-Pi. | |
---|---|
(a) | (b) |
(c) | (d) |
The R-Pi and E-Pi are connected using the GPIO interface and the flat-flex cable supplied with the E-Pi. The GPIO cable is connected as shown in Figure A1.3 i.e. the red edge is at the top such that the dimple on the actual connector (dimple cannot be seen in Figure A1.3) faces into the rest of the R-Pi.
Figure A1.3 - The GPIO cable used to connect the E-Pi to the R-Pi. |
---|
|
Appendix B - The Software
B1 System Software
To ensure that you have the latest version of the operating system and the Python development environment then working in the LXTerminal application type the following instructions:
sudo apt-get update
sudo apt-get install python-get python-pip
This will download and install the latest versions of the software.
B2 The Embedded Pi/Sensor Shield Python Demonstration Software
The demonstration Python software written for this project is available in the Element14 GitHub at: https://github.com/element14/pi_project/tree/master/EmbeddedPi_Introduction. A clone of this software should be established using an appropriate software versioning application. The clone can be established at: https://github.com/element14/pi_project.git. The software files are:
- epi-leds-rgv1p0p0.py - to demonstrate the use of the TinkerKit LED actuator. This drives six LEDs connected to the 'O0' to 'O5' sockets on the Sensor Shield;
- epi-buttons-rgv1p0p0.py - to demonstrate the use of the TinkerKit Button sensor. This monitors the state of any Buttons connected to the 'O0' to 'O5' sockets on the Sensor Shield;
- epi-tilt-rgv1p0p0.py - to demonstrate the use of the TinkerKit Tilt sensor with the TinkerKit LED actuator. This uses the 'O0' and 'O1' sockets on the Sensor Shield for the connection of the Tilt Switch and LED modules;
- epi-relay-rgv1p0p0.py - to demonstrate the use of the TinkerKit Relay actuator with the TinkerKit Button sensor. This uses the 'O2' to 'O3' sockets on the Sensor Shield for the connection of the Button and Relay modules.
The software requires that the RPi.GPIO Python module is installed (RPi.GPIO is installed in all Raspbian operating system from Sept 2012 onwards). The demonstration software is written in Python 2.7. The use of the RPi.GPIO module means that root access is required to run the software and so when using the LXTerminal, type the following to run one of the programs:
sudo python <<program name>>
As each program runs it uses the display to provide the corresponding activity report, prompt for user input and to display the associated sensor/actuator input/output.
NOTE: This demonstration software does not need software downloaded and running on the Embedded Pi host processor itself. The E-Pi is used as a hardware connection conduit to the Sensor Shield with the E-Pi operating in R-Pi mode.
Appendix C - The Arduino Tinker Kit Sensor Shield
The layout of the TinkerKit Sensor Shield is shown in Figure C1.1. Figure C1.1a shows the top view and C1.1b the underside view. A Sensor Shield is just one of many Arduino Shields that are available. The Sensor Shield has two types of connector:
- Arduino form factor compatible interface pins - these pins are use to connect the Sensor Shield to the Arduino/E-Pi and to allow other Arduino Shields to be stacked. In this set of instructions the Sensor Shield will be plugged directly into the E-Pi using the pins on the underside of the Sensor Shield. Only one Sensor Shield is to be used. It should be noted that if more than one Arduino Shield is used in a stack, there is no way to differentiate between those boards using the Arduino form factor compatible interface pins;
- Device/module sockets - the sockets used by the array of sensors and actuators that are available. There are four sets of sockets available:-
- Analog Output/Digital Input Sockets - the set of 3-pin sockets that are used to provide analog output/digital input to the E-Pi/R-Pi. These sockets are labelled 'O0' to 'O5'. This set of instructions makes extensive use of these sockets because they can be directly controlled using the GPIO interface on the R-Pi/E-Pi. When using the GPIO interface, these six sockets can be used to provide a variety of digital inputs and digital outputs and so the appropriate sensor/actuator modules can be controlled. In Analog Output mode the socket behaves as a Pulse Width Modulation (PMW) interface
- Analog Input Sockets - the set of 3-pin sockets that are used to provide analogue input to the E-Pi/R-Pi. These sockets are labelled 'I0' to 'I5'. This set of instructions does not make use of these sockets
- Serial Socket - this 4-pin socket provides a serial interface. This interface is only available under some configurations. This set of instructions does not make use of this socket
- TWI Socket - this 4-pin socket allows communication with any device supporting the I2C protocol. This set of instructions does not make use of this socket.
When the Sensor Shield is correctly connected and powered, through the E-Pi, then the 'Power LED' will be lit.
Figure C1.1 - Layout of the Tinker Kit Sensor Shield. | |
---|---|
(a) Top view of Sensor Shield. | (b) Underside view of Sensor Shield. |
(c) Side view of Sensor Shield. | (d) Side view of Sensor Shield. |
(e) Side view of Sensor Shield. |
(f) Side view of Sensor Shield. |
The connections between the R-Pi/E-Pi/Sensor Shield are via a set of GPIO/Arduino Form Factor pins. There are a number of ways in which these pins are labelled and used and these relationships are summarised in Table C1.1. From an end-to-end respective the key label relationship is that between the held Output Port number (column one) and the R-Pi GPIO pin (column four). This provides the relationship between the device connected to the Sensor Shield (using the Output Port number) and the GPIO pin used within the corresponding Python software hosted on the R-Pi. In Table C1.1 the two middle columns show the relationship to the standard Arduino pin numbering and the E-Pi pin numbering.
Table C1.1 - Sensor Shield Output Ports to E-Pi to R-Pi to Arduino Pin number mappings.
Sensor Shield Analog Output Port | Arduino Pin Number | E-Pi Pin Remap / R-Pi Pin ID | R-Pi GPIO Pin ID / R-Pi GPIO Pin Name |
---|---|---|---|
O0 | 11 | D11 / 19 | 19 / GPIO10 |
O1 | 10 | D10 / 24 | 24 / GPIO08 |
O2 | 9 | D09 / 07 | 07 / GPIO04 |
O3 | 6 | D06 / 16 | 16 / GPIO23 |
O4 | 5 | D05 / 15 | 15 / GPIO22 |
O5 | 3 | D03 / 12 | 12 / GPIO18 |
The four sensor and actuator modules that are used in this set of instructions are shown in Figure C1.2. Each of these modules is connected to the Sensor Shield using the 3-wire connectors (see Figure 1.2).
Figure C1.2 - The set of Sensor Shield sensors and actuators used in this project. | |||
---|---|---|---|
(a) Red LED (Large) actuator |
(b) Button sensor |
(c) Tilt switch sensor |
(d) Relay actuator |
The capabilities of the modules shown in Figure C1.2 are:
- LED actuator - the brightness can be controlled by outputting a value of '0' to '-1023' to the LED. In digital mode the LED is on (1023) or off (0);
- Button sensor - detects when the circular cap is pressed. The module outputs a 5V when the button is pressed and 0V when released. When using the Sensor Shield a value of '1023' is detected when the button is pressed and '0' when released;
- Tilt sensor - when upright the sensor sends an analogue value of '0' and when tilted a value of '1023'. When using the Sensor Shield as a digital input on the 'O0' to 'O5' ports with the GPIO interface, the corresponding digital values are '0' and '1';
- Relay actuator - a device that is used to enable a low power device to electrically switch/control the state of a high power device. The module provides three connections labeled COM, NC and NO. NC stands for "NORMALLY CLOSED". This means that when the relay has no signal (LOW or 0V), the connected circuit wil be active; conversely, if you apply 5V or pull the pin HIGH, it will turn the connected circuit off. NO stands for "NORMALLY OPEN", and functions in the opposite way; when you apply 5V the circuit turns on, and at 0V the circuit turns off.
Terminology
Actuators | These are devices that provide output control i.e. relay control, LED brightness, motors, etc. |
Arduino Shield | These are devices that can be plugged into the Arduino PCB to extend its functionality. The Arduino has a standard Shield connector configuration that provides access to the digital and analogue features of an Arduino. For this set of instructions the TinkerKit Sensor Shield is used but the Embedded Pi can support any of the wide range of Arduino Shields that are available. |
Button Sensor | This is the TInkerKit push button device. It detects when the circular cap is pressed. The module outputs a 5V when the button is pressed and 0V when released. When using the Sensor Shield a value of '1023' is detected when the button is pressed and '0' when released. A green LED signals that the module is powered and a yellow LED indicates when the button is being pressed. This has the standard TinkerKit 3-pin connector. Further information is available at TinkerKit Button. |
Embedded-Pi | The E-Pi provides an interface platform to the R-Pi, Arduino and the 32-bit embedded ARM processor. For this set of instructions the E-Pi is used as a bridge between the R-Pi and Arduino Shields. This interface is physically achieved using the GPIO connectors on the R-Pi and E-Pi. The software interface is achieved using the RPi.GPIO and WiringPi modules. |
GPIO | The General Purpose Input/Output interface is used to connect the E-Pi to the R-Pi. The GPIO can be driven in several ways depending on what is required and the nature of the software that is driving the interface. In the case of Python-based software the GPIO interface can be driven using the RPi.GPIO and WiringPi packages. |
HDMI | High Definition Multimedia Interface. This is one of the interfaces to the monitor. The PiView is connected to this interface. |
I2C | Inter-Integrated Circuit. This is one of the interfaces modes available on the R-Pi and the Sensor Shield. |
IDLE | Integrated Development Environment for Python. It is completely written in Python and the Tkinter Graphical User Interface (GUI) toolkit (wrapper functions for Tcl/Tk). This is the development environment used for producing the software in this project. |
LED Actuator | This is the TinkerKit device with an LED: a variety of colours and sizes are available. The brightness can be controlled by outputting a value of '0' to '-1023' to the LED. This has the standard TinkerKit 3-pin connector. Further information is available at TinkerKit LED. |
NOOBS | New Out Of Box Software. NOOBS is used to install the appropriate version of Operating System (O/S) onto the R-Pi SD card. The Raspbian O/S is used for this project. In many cases, NOOBS is now pre-installed on SD cards that are sold for use with the R-Pi. The latest version of NOOBS is available from the Raspberry Pi Foundation downloads. |
Python | The software in this project is written using Python 2. IDLE is used to support the development of the Python code. |
Raspberry Pi | The R-Pi is the single board computer at the heart of this project. This project will work on both Model A and B versions. |
Relay Actuator | This is the TinkerKit device that is used to enables a low power device to electrically switch/control the state of a high power device. The module provides three connections labeled COM, NC and NO. NC stands for "NORMALLY CLOSED". This means that when the relay has no signal (LOW or 0V), the connected circuit wil be active; conversely, if you apply 5V or pull the pin HIGH, it will turn the connected circuit off. NO stands for "NORMALLY OPEN", and functions in the opposite way; when you apply 5V the circuit turns on, and at 0V the circuit turns off. Relays can replace a manual switch. Remove the switch and connect its wires to COM and NO. When the relay is activated the circuit is closed and current can flow to the device you are controlling. This module can switch 250V/10A devices and the yellow LED indicates when the relay is active. It is recommended that only experts/electricians operate on circuits powered by more than 24V. This has the standard TinkerKit 3-pin connector. Further information is available at TinkerKit Relay. |
SD | Secure Digital (SD) is a non-volatile memory card format for use in portable devices. This is the storage medium for the R-Pi. |
Sensors | These are devices that provide sensory input i.e. temperature, movement (including tilt), touch, etc. |
Sensor Shield | The TinkerKit Sensor Shield allows TinkerKit sensors and actuators to be connected directly to an Arduino or E-Pi without the use of a breadboard. The Sensor Shield has 12 standard TinkerKit 3-pin connectors. The 6 labelled 'I0' to 'I5' are the Analog Inputs, the 6 labelled 'O0' to 'O5' are the Analog Outputs (these can be driven using PWM capable outputs or can be configured as digital inputs). The Sensor Shield also has a 4-pin TWI Socket (this supports the I2C protocol) and a 4-pin Serial Socket. Further information is available at TinkerKit Sensor Shield. |
Tilt Sensor | This is the TinkerKit device that is used to indicate when something has been tilted (a ball bearing contained in the sensor is used to provide the tilt detection). When upright the sensor sends an analogue value of '0' and when tilted a value of '1023'. When using the Sensor Shield as a digital input on the 'O0' to 'O5' ports with the GPIO interface, the corresponding digital values are '0' and '1'. This has the standard TinkerKit 3-pin connector. Further information is available at: TinkerKit Tilt |
USB | Universal Serial Bus. |
VGA | A Video Graphics Array (VGA) connector is a three-row 15-pin DE-15 connector. The 15-pin VGA connector is found on many video cards, computer monitors, and high definition television sets. In this project a PiView was used to connect the VGA monitor to the HDMI on the R-Pi. |
About this Document
Authors | Colin Smythe (Dunelm Services Limited) | |
Date | 7th April, 2014 | |
Version | 1.0 | |
Copyright | Premier Farnell | |
License | GPLv3+ |