Introduction: Use Arduino MKR Shields With Raspberry Pi

Our PiMKRHAT is an adaptor HAT to use Arduino MKR boards and shields together with the Raspberry Pi. Different Arduino MKR Shields can be used via our HAT as extension for the Raspberry Pi. I want to show in this small project how to use the Arduino MKR ENV shield with a Raspberry Pi under Python.

Step 1: Tools and Materials

Materials:

Tools:

  • Soldering iron
  • solder wire
  • side cutter
  • bending tool

Step 2: Assembly

The PiMKRHAT comes as kit. You have to assemble it first. Please follow the attached assembly instruction

Step 3: Jumper Setting

Please set for the Arduino MKR ENV shield only the 5V and 3, 3V Jumper on the Power jumper bank. Leave all other jumpers open.

Step 4: Raspbian

Please download the latest Raspbian OS for the Raspberry Pi and copy it to an SD card via Pi imager or Win32diskimager.

Step 5: Configuring I2C

The sensors on the MKR ENV shield are using I2C communication. You have to install some libraries first via the bash:

sudo apt-get install -y python-smbus 
sudo apt-get install -y i2c-tools

Now you have to enable the I2C interface:

sudo raspi-config 
--> 5 Interfacing Options 
--> P5 I2C--> YES
sudo reboot

Step 6: Testing I2C Interface

Now it's time to test the I2C interface:

sudo i2cdetect -y 1

This shows that three I2C addresses are in use – 0x10, 0x5c and 0x5f


Step 7: Install Additional Libraries

sudo apt install python-pip
sudo pip install veml6075

Step 8: Test Your Work

3 little Python programs are available on Github to test the UV radiation, temperature & humidity and pressure sensor of the MKR ENV shield:

  • HTS221.py -temperature and humidity
  • LPS22HB.py - pressure
  • VEML6075.py - UV radiation

The analogue light sensor requires an analogue input and can not be used with the Raspberry Pi.

Arduino Contest 2020

Participated in the
Arduino Contest 2020