V2_00_step_01.rst 6.10 KiB

STEP n°1 : Raspberry Pi configuration

PART A: OS installation

Required components Quantity
Raspberry Pi 4 Model B 1
Micro SD 32 Go 1
HDMI Cable 1
Computer mouse 1
Computer Keyboard 1

The first step is to start up the Raspberry Pi board, including installation of an OS (operating system). For this step, the installation instructions are well described on the Raspberry website

  1. Watch the vidéo how to set up your raspberry Pi.
  2. The authors recommend installing the latest stable and complete version of Raspberry Pi OS (Previously called Raspbian) by using Raspberry Pi Imager.
  3. or you can visit this website <https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up>.

Note

All the development tests were performed on Raspberry Pi 3 Model B, we used the following version of Raspbian:

alternate text

Warning

Once the OS has been installed, 1-wire, spi and GPIO remote option must be deactivated and I2C option must be activated via the Raspbian GUI settings menu. Failure to carry out this task may cause damage to the relay shield cards during measurements.

3. When the relays are connected to the GPIO, make sure that all the GPIOs are in the low position when the raspberry starts up. If not, the relays will activate unexpectedly. To ensure that the GPIOs are in Low position, you will need to modify the /boot/config.txt file.

Run the terminal, and write

cd /boot/
  1. Open config.txt with GNU nano editor
sudo nano config.txt
  1. At the end of the file write :
gpio=8=op,dl
gpio=7=op,dl
  1. Press Ctrl +O to save the modifications and press enter
  2. Press Ctrl +x to escap and return to the terminal
  3. Close the terminal

PART B: Virtual Environnement and packages

A virtual environment is a way to have multiple, parallel instances of the Python interpreter, each with different package sets and different configurations. Each virtual environment contains a discrete copy of the Python interpreter, including copies of its support utilities. It also protects your system in case of problems with the packages.

All dependencies are specified in requirements.txt

Note

All instructions below should be typed in the terminal

It is first necessary to ensure that the libatlas-base-dev library is installed:

sudo apt-get install libatlas-base-dev

We strongly recommend users to create a virtual environment to run the code and installed all required dependencies. It can be done either in a directory gathering all virtual environments used on the computer or within the ohmpy directory.

Create the virtual environment:

python3 -m venv ohmpy

Activate it using the following command:

source ohmpy/bin/activate

Install packages within the virtual environment. Installing the following package should be sufficient to meet dependencies:

export CFLAGS=-fcommon
    sudo pip install RPi.GPIO adafruit-blinka numpy pandas adafruit-circuitpython-ads1x15 adafruit-circuitpython-tca9548a adafruit-circuitpython-mcp230xx gpiozero

Check that requirements are met using

pip list

You should run you code within the virtual environment to leave the virtual environment simply type:

deactivate

PART C: Activate virtual environnement on Thonny (Python IDE) (on Rapberry Pi)

If you decided to use a virtual environment, it is necessary to setup Thonny Python IDE the first time you use it.

1- Run the Thonny Python IDE software, Click on raspebrry acces menu > programming> Thonny pythonIDE

2- Thonny's interface opens, Python runs on the Root (Python 3.7.3 (/usr/bin/python3))

alternate text

3-Click on Run>select interpreter, a new window opens click on interpret

alternate text

4-On the new open windows select alternative Pyhton3 or virtual environnement

alternate text

5- New buttons appeared, selected "locate another python executable "

6- A new window opens, find the folder where there is the python 3 file in the virtual environment folder previously created /home/pi/ohmpi/bin/python3.

7- In the known interpreter tab the path of the virtual environnementshould appear

alternate text

8- Close the window by clicking on ok.

9- Close thonny to save modifications