Experiment no. 3

  • E3.1 Name:


  • Raspberry Pi - GPIO extensions


  • E3.2 General presentation, purpose.


  • The laboratory experiment aims to explore the possibilities of creating digital extensions for the RPi platform using the Python language as a development environment according to the presentation in the course at Massachusettts Institute of Technology, required to be completed. The possibilities of using GPIO and ways to create active digital extensions are explored. At the end of the experiment, detailed information will be available on how to create Python scripts for input/output ports and how to create power switches with optotriacs, MOSFET transistors or relays. The concepts of Unix process and Unix boot are exemplified. Users a1 -a20 can enable GPIO after assigning this right as follows:
    >sudo adduser ai gpio




    br
  • E3.3 Resources:

  • Raspberry Pi zero2 W platform, RGB LED extension, optotriac extension, MOSFET transistor extension, relay module.
    br


    Documentation:

    1. MIT Python Course
    2. Python reference card
    3. Solid state relay model MP240D4


  • E3.4 Example program source:

  • Python - example1

    Python - example2


    Python script to activate red LED
    Python script to activate blue LED
    Python script to activate green LED
    Video sequence

    Python script to activate motor with "m" key
    Video sequence

    Python script for activating the motor with the K button
    Video sequence


  • E3.5 How to run/follow the experiment:

  • Raspberry Pi development platforms are equipped with a connector to which they are arranged signals coming from the central module represented in the figure below:

    The processors on the Rpi systems are powered with a voltage of 3.7V, the logic levels at the output of the GPIO ports are the following:
    Using a breadboard, the 3 LEDs are connected to the Rpi according to the diagram:



    The proper functioning of the prototype programs related to the 3 LEDs is monitored. The LEDs can be used for commands using optocouplers, respectively they can activate photoreceptors that allow the creation of power switches by using triac-type systems.
    The use of light as an active element eliminates and ensures a galvanic isolation between the Rpi and the power part powered at 220/380V. The lab experiment contains a power extension for the Rpi made with the MP240D4 module and is represented in the following figure:



    Connecting to the Rpi aims to activate an AC motor or a general-purpose socket for 220V consumers. The prototype program for activating an AC motor is called motor.py. The creation of Rpi extensions for controlling DC consumers, common for cars, can be done using MOSFET or bipolar transistors according to the representation below:




    The launch of the prototype programs is done as follows:

    >python blue.py
  • E3.6 Proposed problems:


  • 1. Create a program that allows you to view the signals generated at the GPIO with an oscilloscope.
    2. Using an optocoupler type moc3052 and a triac type BT139 , make an extension for Rpi to activate a 220V AC consumer;


    3. Make a Python script that will activate a laser/photodiode connected to the GPIO;
    4. Make a Python script that will allow you to change the intensity of the light emitted by the LED;
    5. Make a Python script that will activate a power LED powered at 12V usable for data transmissions in Li-Fi networks.


  • E3.7 The experiment can be extended for:

  • - Development of Cyber ​​Physical System ;
    - Creation of actuators for Internet of Things ;
    - Development of active modules for APACHE servers ;
    - Control of digital actuators from very long distances;



  • E3.8 Documentary references:

  • © 2010-2026 - Embedded Advanced Computer