Use Arduino MKR Shields With Raspberry Pi

by Zihatec in Circuits > Raspberry Pi

1310 Views, 0 Favorites, 0 Comments

Use Arduino MKR Shields With Raspberry Pi

IMG_20200531_210022_893.jpg
IMG_20200521_210014_558.jpg
PiMKRHAT_1.jpg

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.

Tools and Materials

asx00011_iso.jpg
PiMKRHAT_4.jpg

Materials:

Tools:

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

Assembly

PiMKRHAT_3.jpg

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

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.

Raspbian

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

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

Testing I2C Interface

i2c.jpg

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


Install Additional Libraries

sudo apt install python-pip
sudo pip install veml6075

Test Your Work

IMG_20200516_175901.jpg

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.