JOY-iT Joy PI Experimental and Education Case User Manual
- June 4, 2024
- JOY-It
Table of Contents
- Joy PI Experimental and Education Case
- signal output time.sleep (1) #wait 1 second GPIO.output(BUZZER, GPIO.LOW)
- stop signal output
- !/usr/bin/python import RPI.GPIO as GPIO import time
- import the required librarys
- define buzzer pin
- make buzzer sound
- wait 0.5 seconds
- !/usr/bin/python import RPI.GPIO as GPIO import time
- import necessary libraries
- define pins button_pin = 37 buzzer_pin = 12
- set board mode to GPIO.BOARD GPIO.setmode(GPIO.BOARD)
- setup button_pin as input and buzzer_pin as output GPIO.setup(button_pin,
- set buzzer on GPIO.output(buzzer_pin, GPIO.LOW) else: #button is not pressed,
- !/usr/bin/python import RPI.GPIO as GPIO import time #define relay pin
- !/usr/bin/python import RPI.GPIO as GPIO import time #define sound_pin
- !/usr/bin/python # -- coding: utf-8 -# Author: Matt Hawkins # Author’s Git:
- device is automatically set to power down mode after measurement
- into a decimal number return ((data[1] + (256 * data[0])) / 1.2)
- !/usr/bin/python # -- coding: utf-8 --
- beginning of loop
- !/usr/bin/python # -- coding: utf-8 -#Author : www.modmypi.com #Link:
- declaration of variable #declaration of variable
- waits 0.00001 seconds
- solution is rounded to 2 decimal place
- !/-*u-sDGeriaP/cgsIbnoOLide-CnitT/Dnseipg,ccy:shhotnbwhuoeotilseonfog-
- defivneerwaemnoduentt. of lines and columns from LCD lcd_columns = 16
- set the LCD in the variable LCD lcd = character_lcd.Character_LCD_I2C(i2c,
- turn on the background lcd.backlight = True #issues 2 words with line break
- scroll message from right to left lcd.clear() scroll_msg = “<– Scroll –>”
- change message
- turn on background lightning lcd.backlight = True
- turn off background lightning time.sleep(2.0)
- !/usr/bin/env python # -- coding: utf8 -# # Copyright 2014,2018 Mario Gomez
- Capture SIGINT for cleanup when the script is aborted def
- Hook the SIGINT signal.signal(signal.SIGINT, end_read)
- Create an object of the class MFRC522 MIFAREReader = MFRC522.MFRC522()
- Welcome message print(“Welcome to the MFRC522 data read example”)
- This loop keeps checking for chips. If one is near it will get the UID and
- Scan for cards (status,TagType) =
- If a card is found if status == MIFAREReader.MI_OK:
- Get the UID of the card (status,uid) = MIFAREReader.MFRC522_Anticoll()
- Print UID print(“Card read UID: %s,%s,%s,%s”.format(uid[0], uid[1], uid[2],
- This is the default key for authentication key =
- Authenticate status = MIFAREReader.MFRC522_Auth(MIFAREReader.PICC_AUTHENT1A,
- Check if authenticated if status == MIFAREReader.MI_OK:
- !/usr/bin/env python # -- coding: utf8 -import RPi.GPIO as GPIO import
- function to perform cleanup functions if the script is aborted def
- create an object from the class MFR522 MIFAREReader = MFRC522.MFRC522()
- this loop searches permanently for chips or cards. If one is near, it gets
- SUcht Karten (status,TagType) =
- Wenn Karte gefunden if status == MIFAREReader.MI_OK:
- if UID is found, continue if status == MIFAREReader.MI_OK:
- issues UID in console print (“Card read UID: %s,%s,%s,%s” % (uid[0], uid[1],
- authenticating status =
- [variables of values which should be saved on card data = 99, 11, 55, 66, 44,
- Ensure to stop reading for cards continue_reading = False else: print
- !/usr/bin/python # -- coding: utf-8 -# Author : Original author
- declare pins as output GPIO.setup(self.pin_A,GPIO.OUT)
- !/usr/bin/python # -- coding: utf-8 -# Author : Original author
- wait 0.5 seconds
- wait 0.5 seconds
- !/usr/bin/env python # -- coding: utf-8 -# Copyright (c) 2017-18 Richard
- show Hello World on matrix msg = “Hello World” #show issued text in console
- !/usr/bin/python # -- coding: utf-8 --
- loop which permanently updates the time and shows on the display try:
- display for the hours segment[0] = str(int(hour / 10)) segment[1] = str(hour
- tens # single – figure numerals
- tens # single – figure numerals
- !/usr/bin/env python # -- coding: utf-8 --
- add libraries
- set TOUCH pin 11 (declaration of variables).
- create function setup_gpio
- !/usr/bin/python import time import RPi.GPIO as GPIO #define tilt_pin
- !/usr/bin/python # -- coding: utf-8 -# Author : original author stenobot
- set IDs of the buttons self.buttonIDs =
- define 4 outputs ans set them on high for j in range(len(self.columnPins)):
- initialisation of button matrix buttons = ButtonMatrix() try:
- !/usr/bin/env python3 “””IRModuleExample1, program to practice using the
- Codes listed below are for the # Sparkfun 9 button remote
- set up IR pi pin and IR remote object irPin = 20 ir =
- set up GPIO options and set callback function required
- by the IR remote module (ir.pWidth) GPIO.setwarnings(False)
- uses numbering outside circles
- time.sleep(5) # turn off verbose option and change callback function # to the
- !/usr/bin/python import time import RPi.GPIO as GPIO
- define LED pin led_pin = 37 #set GPIO mode to GPIO.BOARD
- References
- Read User Manual Online (PDF format)
- Download This Manual (PDF format)
Joy PI Experimental and Education Case
Experimental and education case
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
1. TABLE OF CONTENT
1. Table of content 2. General information & saftey instructions 3. Details
4. Commissioning & operation 5. Changing modules and using the GPIOs 6. Usage
of Python and Linux 7. Lessons
1. Lesson : Using the buzzer for warning sounds 2. Lesson : Controlling the
buzzer with key inputs 3. Lesson : How a relay is working and how to control
it 4. Lesson : Sending a vibration signal 5. Lesson : Detecting noises with
the sound sensor 6. Lesson : Detecting brightness with the light sensor 7.
Lesson : Detecting the temperature and the humidity 8. Lesson : Detecting
movements 9. Lesson : Measuring distances with the ultrasonic sensor 10.
Lesson : Controlling the LCD display 11. Lesson : Reading and writing RFID
cards 12. Lesson : Using stepper motors 13. Lesson : Controlling servo motors
14. Lesson : Controlling the 8 x 8 LED matrix 15. Lesson : Controlling the 7
segment display 16. Lesson : Detecting touches 17. Lesson : Detecting tilts
with the tilt sensor 18. Lesson : Using the button matrix 19. Lesson :
Controlling and using the IR sensor 20. Lesson : Own circuits with the
breadboard 21. Lesson : Photographing with the Raspberry Pi camera 8. Other
information 9. Copyright information 10. Support
The login data is: Username : pi Password : 12345
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
2. GENERAL INFORMATION & SAFETY INSTRUCTIONS Dear customer, Thank you very
much for choosing our product. In the following, we will show you what has to
be observed during commissioning and use. Should you encounter any unexpected
problems during use, please feel free to contact us. The following lessons are
designed so that, regardless of how much prior knowledge you already have, you
can complete all lessons without any problems. For the different lessons, you
have to download sample files and run them on the Joy-Pi. How to do this can
also be found in this manual. But these tutorials are only the beginning you
can use your Joy-Pi for a variety of projects. We are looking forward to see
what you will do with our Joy-Pi.
Safety instructions
1. This device is intended for use in dry indoor areas. It must not become
wet or damp! Also do not touch the device with wet hands!
2. The permissible ambient temperature is : 5 – 40 °C 3. Do not expose the
device to direct sunlight, as the Joy-Pi could heat
up by this. 4. If the unit is damaged or has faults, do not longer use it and
contact
our service for further instructions 5. Unplug the power supply from the power
outlet if you are not going
to use it for a longer period of time. 6. Handle this product with care. It
must not contain high exposed to
temperature, humidity or pressure. It may not be short-circuit either.
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
3. DETAILS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 / 15
Raspberry Pi GPIO LED display
Breadboard 16 x 2 LCD module (MCP23008)
Power supply 8 x 8 LED matrix (MAX7219) 7 segment LED display(HT16K33)
Vibration module Light sensor (BH1750)
Buzzer Sound sensor Motion sensor (LH1778) Ultrasonic distance sensor Servo
interfaces
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
16
Stepper motor interface
17
Tilt sensor (SW-200D)
18
Infrared sensor
19
Touch sensor
20
DHT11 temperature and humidity sensor
21
Relay
22
Key matrix
23
Independent keys
24
RFID module (MFRC522)
25
Switch
26
Fan connection
27
Power supply microUSB
4. COMMISSIONING & OPERATION First you must insert your microSD card into the slot provided by the Raspberry Pi. If you do not want to use our image, please read chapter 5.3 and chapter 6.1 to create your own image. Now you can wire the Raspberry Pi to the Joy-Pi. For this purpose plug the AUX adapter into the AUX port and the USB cable into one of the USB ports. Then connect both GPIO bars, one from the Raspberry Pi and one from the Joy-Pi with the supplied cable. With the HDMI cable, please note that you may need to replace the HDMI adapter depending on the Raspberry Pi you are using. For the Raspbbery Pi 4 you need the small micro HDMI adapter, for all older Raspberry Pi models you need the big HDMI adapter. Changing the adapter is done quickly. Pull the plastic lock of the connector carefully downwards to release the HDMI cable, as shown by the arrows in the picture below. Now you can simply pull the cable out of the adapter.
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
Now take the other HDMI adapter and, as in the previous step, carefully pull
the plastic latch of the connector downwards to release the lock. Now you can
plug the HDMI cable into the connector. Make sure that the side of the cable
with the silver contacts, as shown in the picture below, points away from the
adapter.
When the cable is fully inserted into the connector, you can close the lock by
carefully pushing the plastic latch of the connector upwards.
Now you can plug the HDMI cable into your Raspberry Pi and screw the Raspberry
Pi firmly onto the board of the JoyPis. To start the Joy-Pi, all you have to
do is to supply it with power. The power cable which is included, should be
connected on the right side of the board. The Joy-Pi should now start as soon
as you flip the switch on the power cord.
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
You have various possibilities to operate your Joy-Pi. One is via the wireless
keyboard, which can be used in combination with the touch display, or you can
provide a connection to your computer using VNC or SSH.
Wireless keyboard
First, connect the USB stick of the keyboard to one of your USB ports of the
Raspberry Pi. Now you can switch it on at the right side of the keyboard and
with the help of the key combination Fn+RF it will connect to the Joy-Pi. In
order to make the key assignment match the German keyboard layout of the
keyboard, German must be selected as language in the system preferences. To do
this, open the terminal and enter the following command to open the system
settings: sudo raspi-config There you select 4 Localisation Options I1 Change
Locale to select German as language. There is also a touchpad on the keyboard
that you can use to move the cursor. Further functions are described in the
enclosed instructions. The enclosed microUSB cable is intended for charging
the keyboard.
VNC
With the help of the program VNC Viewer, which you can download here. With
this program, you can see the desktop of your Joy-Pi on your computer and you
can operate it completely. To use this function you must first allow a VNC
connection. You enable this in the system settings. To do this, execute the
following command: sudo raspi-config There you activate VNC in 5 Interfacing
Options P3 VNC. Now you can connect to the Raspberry Pi via your network. To
do so, enter the IP address of the Joy-Pi. You can see the IP address of the
Joy-Pi by clicking on the VNC sign in the upper right corner. Now you only
have to login with the login data and then you have fully access from your
computer to your Joy-Pi.
user name : pi password : 12345
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
SSH
SSH is a different connection path than VNC to connect wirelessly to your Joy-
Pi from a PC. You can use for example MobaXTerm, which you can download here.
To be able to establish an SSH connection, you must enable SSH and your Joy-Pi
must be connected to your network. Enable SSH in system preferences 5
Interfacing Options P2 SSH. Open system preferences with: sudo raspi-config
Now click you enter
tohneSIPesasdiodnreisnsManodbatXhTeeursmertonaemstea.bTlihseh
a new connection. There IP address can be dis-
played by clicking on the VNC icon in the upper right corner.
user name : pi password : 12345
You must then enter the password. Attention! It is possible that the keystrokes are not displayed when entering the password. Now, you can see a terminal which can control the Joy-Pi.
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
5. CHANGING MODULES AND USING THE GPIOS
5.1 Change of modules
On the Joy-Pi board there are two switching units with 8 switches each. The switches make it possible to switch between different sensors and modules. Since the Raspberry Pi has only a limited number of GPIO pins, these switches are needed to use more sensors and modules than GPIO pins are available. Using these switches is quite simple and will be needed in some of the following lessons. In the table you can see which switch switches which sensor or module.
Sensors / modules Key matrix
Independent keys Vibration module
Tilt sensor Stepper motor Servo motor
Switching unit Left Left Right Right Right Right
Keys 1 – 8 5 – 8
1 2 3, 4, 5, 6 7, 8
5.2 Usage of GPIOs
In the following we will explain in more detail what GPIO’s are, how they work
and how they are controlled.
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
GPIO stands output).
for:
General
–
purpose
input
/
output
(universal
input
/
GPIO pins do not have a specific purpose. They can be configured as ei-
ther input or output and have a general purpose. This depends on what
you want to achieve.
Example input pin: Button If the button is pressed, the signal will be transferred through the input pin of the Raspberry Pi.
Example output pin: Buzzer A signal will be sent via the output pin of the Raspberry Pi to the buzzer to control it.
If you look on the opened Joy-Pi from the front, the GPIO pins will be on the right side of the Raspberry Pi.
There are 2 possible schemata of the Raspberry Pi GPIO: GPIO – BOARD and GPIO – BCM. The GPIO – BOARD schemata that reference pins via the actual pin number. That means that the pin numbers of the following picture is used.
TChheansncheel.mThaetaseGaPrIeOt-hBeCnMummbeearnssatfhteart
the pins GPIO:
reference
Broadcom
SOC
1
3.3 V DC
2
3
GPIO 2 (SDA1, I2C)
4
5
GPIO 3 (SCL1, I2C)
6
7
GPIO 4
8
9
Ground
10
11
GPIO 17
12
13
GPIO 27
14
15
GPIO 22
16
17
3.3 V
18
19
GPIO 10 (SPI, MOSI)
20
21
GPIO 9 (SPI, MISO)
22
23
GPIO 11 (SPI, CLK)
24
25
Ground
26
27
ID_SD (I2C, EEPROM)
28
29
GPIO 5
30
31
GPIO 6
32
33
GPIO 13
34
35
GPIO 19
36
37
GPIO 26
38
39
Ground
40
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
5 V DC 5 V DC Ground GPIO 14 (TXD0) GPIO 15 (RXD0) GPIO 18 Ground GPIO 23 GPIO 24 Ground GPIO 25 GPIO 8 (SPI) GPIO 7 (SPI) ID_SC Ground GPIO 12 Ground GPIO 16 GPIO 20 GPIO 21
GPIO – BOARD 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
26
27
28 29 30 31 32
33
34
35
36 37 38 39 40
Sensors and modules 3.3 V 5.0 V
I2C, SDA1 (Light sensor, LCD display, 7 segment display) 5.0 V
I2C. SCL1 (Light sensor, LCD display, 7 segment display) Ground
DHT11 sensor TXD0
Ground RXD0 Touch sensor Buzzer Button matrix(ROW1), vibration motor Ground
Button matrix (ROW2), tilt sensor Motion sensor 3.3 V Sonic sensor SPI Ground
SPI Servo2, Button matrix (COL1), left button SPI RFID module Ground LED
matrix ID_SD (I2C, EEPROM (Electrically Erasable Programmable Read – only
Memory)) ID_SC Stepper motor (STEP1), button matrix (ROW3) Ground Stepper
motor (STEP2), button matrix (ROW4) Ultrasonic sensor (Echo) Stepper motor
(STEP3), button matrix(COL4), down button Ground Stepper motor (STEP4), button
matrix (COL3), right button Ultrasonic sensor (TRIG) Servo1, button matrix
(COL2), up button Infrared sensor Ground Relay
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
In our examples, we use the programming language Python to control the GPIO pins. In Python exists a library which is known as RPi.GPIO. This library is necessary to control the pins with Python.
The following example and comments in the code should help you to understand the program.
First, you have to import the required library with the import command.
The variable TOUCH and BUZZER references to the pins of the touch
sensor and the buzzer. Afterwards, you define the connection with
GPIO.setmode(GPIO.BOARD) as the used GPIO schemata. As the next
step, you configurate the earlier set variables with the command
GPIO.setup() as input or rather output. Pin 11 (TOUCH) is set as input and
pin 12 (BUZZER) as output.
The main function queries if a touch has been detected by the touch sen-
Tsohri.sIffutnhcistiiosnthpericnatsset,htehteefxutnTcotiuocnhddoe_tesmctethd
will be executed. and sets the buzzer
HIGH
and one second later LOW again(buzzer will sum one second):
import RPi.GPIO as GPIO import time #import libraries import signal
TOUCH = 11 #declaring variables BUZZER = 12
def setup_gpio(): #definition of inputs and outputs GPIO.setmode(GPIO.BOARD)
GPIO.setup(TOUCH, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(BUZZER,
GPIO.OUT)
def do_smt(channel): #function for the output if touch was dected print(“Touch
detected”) #and output that touch was detected GPIO.output(BUZZER, GPIO.HIGH)
signal output time.sleep (1) #wait 1 second GPIO.output(BUZZER, GPIO.LOW)
stop signal output
def main(): setup_gpio() try: #checking if touch is detected
GPIO.add_event_detect(TOUCH,GPIO.FALLING,callback=do_smt,bouncetime=200)
except KeyboardInterrupt: #CTRL + C exists the script pass finally:
GPIO.cleanup()
if name==_main_
: main()
To learn more about the purpose and usage of GPIO, we recommend that you read the official documentation on that topic of GPIO pins which is written by the Raspberry Pi Foundation. https://www.raspberrypi.org/documentation/usage/gpio/
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
5.3 Software installation for the Joy-Pi
On the included microSD card is a preinstalled operating system already
installed. If you want to rewrite the card, you can do it like described in
the following: First of all, you should download the latest image file for the
Joy-Pi from our website www.joy-pi.net. 1. Download the image file (.zip
format). After
unzipping the file, you get a file that ends with .img. 2. Connect your
microSD card to your computer and format it with
the program SD formatter. A microSD card reader is included in the scope of
delivery. 3. Start the program Win32-Disk-Imager and choose the downloaded
image file. the device which is to be written. 4. Now the card is written with
the operating system and you can insert it into the microSD card slot of the
Raspberry Pi.
5. At the end, you have to edit the image to the size of your SD card.
Therefore, start the Raspberry Pi, open the terminal and enter
sudo raspi-config.
Click After
anorewstoanrtA, dthveasniczeedofOtphteioimnsagaendwailfltbeer
tahdajtuEstxepdatnodyFoiuler sSyDstem.
card.
6. USAGE OF PYTHON AND LINUX
6.1 Download of code examples
This step is optional but it makes it easier to execute scripts without having
to create them individually. On our prepared image for the Joy-Pi all code
examples are already downloaded. So all scripts are already on the desktop.
The scripts which are used in this guide can be downloaded directly from a
package. Therefore, follow the following instructions:
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
1. Open the Terminal. We will need this to perform most of our Python scripts
and to download scripts and expansions.
2. After we have successfully opened the terminal, we need to download the
script archive to the desktop (included on the image) using the following
command
cd Desktop/ wget https://joy-pi.net/wp-content/uploads/2020/09/Joy-Pi.zip 3.
Press Enter on your keyboard. Now you have to unzip the archive: unzip Joy-
Pi.zip 4. Press Enter again on your keyboard and wait until the process
succeeded. 5. With the command cd, you can change to the right folder to be
able
to use the scripts which are placed there: cd Joy-Pi
Attention! Every time you shut down your Joy-Pi, you must repeat these steps
to change the folder.
The login data is: Username : pi Password : 12345
6.2 Installation of the required libraries
If you are not using our prepared image, you can install the required
libraries as follows:
16×2 LCD
For the 16×2 LCD the library Adafruit_CircuitPython_CharLCD from adafruit is
used. Enter the following command into the terminal for the installation: sudo
pip3 install adafruit-circuitpython-charlcd
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
Segment Anzeige
For the segment display the library Adafruit_CircuitPython_HT16K33 from
adafruitis used. Enter the following commands into the terminal for the
installation: sudo apt-get install python3-pip sudo apt-get install
python3-pil sudo pip3 install adafruit-circuitpython-ht16k33
LED-Matrix
For the LED matrix the library luma.led_matrix from rm-hull is used. Enter the
following command into the terminal for the installation: sudo wget
https://github.com/rm-hull/luma.led_matrix/ archive/refs/heads/master.zip Now
extract the downloaded archive: sudo unzip master.zip Now navigate to the
library folder and edit the setup.cfg file with the following commands: cd
luma.led_matrix-master sudo nano setup.cfg Now remove the following line from
the file: ws2812; platform_machine==”armv7l” and platform_system==”Linux” Save
the changes with Ctrl + O and close the file with Ctrl + X. After that you can
install the library with the following command: sudo pip3 install e .
www.joy-it.net Pascalstr. 8 47506 Neukirchen-Vluyn
RFID-MFRC522
For the RFID Module the library MFRC522-python from lucassarcanjo is used.
Furthermore the library SPI-Py from lthiery is required. Enter the following
commands into the terminal for the installation:
sudo git clone https://github.com/lthiery/SPI-Py.git
cd SPI-Py/
sudo python3 setup.py install
sudo git clone –single-branch –branch python3-spi-updates https://
github.com/lucassarcanjo/MFRC522-python.git Note that also the last command
must be entered as just one line.
IR-Sensor
For the IR-Sensor the library IR-Remote-Receiver-Python-Module from owainm713
is used. Enter the following commands into the terminal for the installation:
sudo git clone https://github.com/owainm713/IR-RemoteReceiver-Python-
Module.git You can save the file IRModule.py in your library folder under
“/usr/lib/ python3.7/IRModule.py”. This allows you to run the sample script
from any folder. You can use this command to do this: sudo mv /home/pi/IR-
Remote-Receiver-Python-Module/ IRModule.py /usr/lib/python3.9/IRModule.py
DHT11
For the DHT11 the library DHT11_Python from szazo is used. Enter the following
command into the terminal for the installation:
sudo pip3 install Adafruit_DHT
6.3 Performing Python scripts
After we successfully downloaded our script, we would like to execute it. Open
the terminal again and follow the instructions below to run the script: 1.
Enter the command sudo python3