Updated on | #pi, #raspberry, #rtc | 3 User comments

ARPI600 Expansion Board for Raspberry Pi - Arduino shields

The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It has the ability to interact with the outside world, and has been used in a wide array of digital maker projects, from music machines and parent detectors to weather stations and tweeting birdhouses with infra-red cameras. Arduino is a massive ecosystem, if there's a way for the Raspberry Pi General Purpose Input Output (GPIO) interface to adapt to Arduino pinouts, it is possible to use the Pi together with vast Arduino shields and hardware/software resources. The ARPI600 is just intended for this. The ARPI600 also supports XBee modules, which make it easy to add wireless feature to your projects.

Features:

  • Compatible with Arduino UNO, Leonardo, easy to connect with various Arduino shields
  • XBee connector for connecting various XBee modules
  • Sensor interface for connecting various sensors
  • Onboard USB TO UART for serial port debugging, also can be configured as XBee USB adapter
  • Onboard ADC, 10 bit, 38KSPS, 11 channels (6 channels for Arduino interface, 5 channels for sensors)
  • Onboard RTC
ARPI600 Features
Fig. 1: ARPI600 Features
  1. Arduino connector: for connecting Arduino shields
  2. ICSP interface: Arduino ICSP
  3. XBee connector: for connecting XBee communication modules
  4. Sensor interface: for connecting sensors
  5. Raspberry Pi connector: for connecting Raspberry Pi
  6. USB TO UART
  7. TLC1543: AD converter
  8. PCF8563: RTC
  9. CP2102
  10. 32.768KHz crystal: for RTC
  11. Power indicator
  12. XBee state LED
  13. XBee and Arduino interface RESET button
  14. XBee EASYLINK button
  15. RTC battery holder: for CR1220 button battery
  16. TLC1543 reference voltage configuration jumper
  17. RTC jumper
  18. UART jumper

    • when connecting P_RX and CP_TX, P_TX and CP_RX respectively, USB TO UART is connected to Raspberry Pi serial port
    • when connecting XB_RX and CP_TX, XB_TX and CP_RX respectively, USB TO UART is connected to XBee serial port
    • when connecting XB_RX and P_TX, XB_TX and P_RX respectively, Raspberry Pi serial port is connected to XBee serial port
  19. Arduino AD selection jumper

    • short 2 and 3 : Arduino A0-A5 as AD input
    • short 1 and 2 : Arduino A0-A5 as digital control
  20. Arduino I2C selection jumper

    • short the jumper : Arduino A4-A5 as I2C control (the A4-A5 of Arduino AD selection jumper should be opened)
  21. Arduino SPI selection jumper

    • short 1 and 2 : Arduino D11-D13 as SPI control (default)
    • short 2 and 3 : Arduino D11-D13 as digital control

How to control peripherals by Raspberry Pi

System serial port configuration

Enter the terminal of Raspberry Pi, and input:

  1. sudo nano  /boot/cmdline.txt

Then, you should modify the following lines:

  1. wc_otg.lpm_enable=0  console=ttyAMA0,115200  kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

into:

  1. dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

After this, change the inittab file:

  1. sudo nano /etc/inittab

And modify the following lines:

  1. #Spawn a getty on Raspberry Pi serial line
  2. T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

into:

  1. #Spawn a getty on Raspberry Pi serial line
  2. #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Restart Raspberry:

  1. sudo reboot

After completing the modifications described above and restarting the Raspberry Pi board, the serial debugging function is started up. In this mode, you cannot enter the terminal of the Pi via the serial port any more, but can control the serial output by the software (If you want to reset the serial port to the serial debugging output, please restore the factory settings and restart the Raspberry Pi. Therefore, it is recommended to backup the Raspbian before making any modification).

Broken things like I2C, SPI, and 1-wire bus on Raspberry PI

The latest firmware implements device tree support, which has broken things like I²C, SPI, and 1-wire bus. On StackExchange and RaspBerry PI Forum I found the following solution, that you have to insert in /boot/config.txt:

  1. # Uncomment some or all of these to enable the optional hardware interfaces
  2. dtparam=i2s=on
  3. dtparam=spi=on
  4. dtparam=i2c1=on
  5.  
  6. # Uncomment this to enable the lirc-rpi module
  7. dtoverlay=lirc-rpi,i2c-rtc,pcf8563
  8.  
  9. # Audio
  10. dtoverlay=hifiberry-dac
  11. dtoverlay=hifiberry-dacplus
  12. dtoverlay=hifiberry-digi
  13. dtoverlay=iqaudio-dac
  14. dtoverlay=iqaudio-dacplus
  15.  
  16. #heartbeat LED
  17. dtparam=act_led_trigger=heartbeat

After changing this config you need to restart your Raspberry:

  1. sudo reboot

Real Time Clock PCF8563

The PCF8563 from NXP is a CMOS Real-Time Clock (RTC) and calendar optimized for low power consumption. A programmable clock output, interrupt output, and voltage-low detector are also provided. All addresses and data are transferred serially via a two-line bidirectional I2C-bus. Maximum bus speed is 400 kbit/s. The register address is incremented automatically after each written or read data byte.

Features and benefits:

  • Provides year, month, day, weekday, hours, minutes, and seconds based on a 32.768kHz quartz crystal
  • Century flag
  • Clock operating voltage: 1.0V to 5.5V at room temperature
  • Low backup current; typical 0.25uA at VDD = 3.0V and Tamb = 25°C
  • 400kHz two-wire I2C-bus interface (at VDD = 1.8V to 5.5V)
  • Programmable clock output for peripheral devices (32.768kHz, 1.024kHz, 32Hz, and 1Hz)
  • Alarm and timer functions
  • Integrated oscillator capacitor

Further Information:

Activate the RTC:

  • Set the jumpers on RTC JMP of the ARPI600.
  • Add kernel modules to load at boot time:
  1. sudo nano /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.

i2c-dev
i2c-bcm2708
snd-bcm2835
rtc-pcf8563
  • Add kernel modules to your blacklist:
  1. sudo nano /etc/modprobe.d/raspi-blacklist.conf
#blacklist i2c-bcm2708
blacklist spi-bcm2708
  • Reboot sudo reboot
  • See if the chip could be identified:
  1. dmesg | grep rtc-pcf8563
[    4.318373] rtc-pcf8563 1-0051: chip found, driver version 0.4.3
[    4.328219] rtc-pcf8563 1-0051: rtc core: registered rtc-pcf8563 as rtc0
  • Detect I2C: As first you need to install i2c-tools with sudo apt-get install i2c-tools. After this you can use:
  1. sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

A short notice about the paramater of i2cdetect: If you have a second rev Raspberry Pi, the I2C is on port 1 ("-y 1") and if you have an Raspberry Pi that is sold before October 2012, the I2C is port 0 ("-y 0").

In the table above, you can see the device address of PCF8563 connected to Raspberry Pi. Here, the device address of PCF8563 is 51, which means the PCF8563 is identified by Raspberry Pi.

You can use i2cset in order to test the second register of the chip:

  1. sudo i2cget -y 1 0x51
  2. 0x14
  3.  
  4. sudo i2cget -y 1 0x51
  5. 0x15
  6.  
  7. sudo i2cget -y 1 0x51
  8. 0x02
  9.  
  10. sudo i2cget -y 1 0x51
  11. 0x38

Here you can find an overview about the hwclock commands:

CommandDescription
hwclock -wWrite the time of the Raspbian into PCF8563
hwclock -rSynchronize the time of Raspbian to PCF8563
hwclock - sSynchronize the time of Raspbian with hardware RCT

Now you are able to test hwclock with:

  1. sudo hwclock --rtc /dev/rtc0 -r --debug
hwclock from util-linux 2.20.1
Using /dev interface to clock.
Last drift adjustment done at 1427714563 seconds after 1969
Last calibration done at 1427714563 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
hwclock: select() to /dev/rtc0 to wait for clock tick timed out: Success
...synchronization failed

If you get this kind of output and the following commands

  1. modprobei2c-dev
  2. modprobe i2c-bcm2708
  3. echo pcf8563 0x51 > /sys/class/i2c-adapter/i2c-1/new_device
  4. modprobe rtc-pcf8563
  5. hwclock -r
hwclock: select() to /dev/rtc0 to wait for clock tick timed out: No such file or directory

are showing the same error messages, you will need to patch util-linux as you can read in the Raspberry Forum.

Patch hwclock in util-linux

At first you need to activate the deb sources in apt:

  1. sudo nano /etc/apt/sources.list
deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
deb-src http://archive.raspbian.org/raspbian/ wheezy main contrib non-free rp

and update apt-get with sudo apt-get update. In the next step you need to download the util-linux source with:

  1. cd /tmp
  2. sudo apt-get source util-linux
  3. sudo apt-get build-dep util-linux

Sometimes the reason you're building from source is because you need to patch the stock release. Now is when you do that.

  1. cd /tmp/util-linux-*
  2. wget https://raw.githubusercontent.com/MoonMaker/RaspberryPI/master/patches/util-linux-2.20_hwclock-rtc.patch
  3. patch -p0 < util-linux-2.20_hwclock-rtc.patch
  4. sudo dpkg-buildpackage
  5. sudo dpkg -i ../util-linux_*.deb

After successful installation, you can test the patched util-linux version:

  1. sudo hwclock --rtc /dev/rtc0 -r --debug
hwclock from util-linux 2.20.1
Using /dev interface to clock.
Last drift adjustment done at 1438528849 seconds after 1969
Last calibration done at 1438528849 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
/dev/rtc0 does not have interrupt functions. Waiting in loop for time from /dev/rtc0 to change
...got clock tick
Time read from Hardware Clock: 2015/08/02 23:02:03
Hw clock time : 2015/08/02 23:02:03 = 1438556523 seconds since 1969
Mon Aug  3 01:02:03 2015  -0.530354 seconds

Successfully!

ADC TLC1543

The TLC1543 from TI is a CMOS 10-bit switched-capacitor successive-approximation analog-to-digital converter. The pins A0-A5 of ARPI600 can be configured as IO pins or ADC pins. The relationship between the pins A0-A5 and the pins of Raspberry Pi board can be seen in the following table:

APRI600IO of Raspberry Pi B+
A0CE1
A1P21
A2P22
A3P23
A4P24
A5P25

Sensors

The relationship between Arduino digital control pins and Raspberry Pi IOs is illustrated in the following table:

APRI600IO of Raspberry Pi B+
D0P_RX
D1P_TX
D2P0
D3P1
D4P2
D5P3
D6P4
D7P5
D8P6
D9P7
D10CE0
D11MOSI
D12MISO
D13SCK

Rotation Sensor

The rotation sensor detects clockwise and anti-clockwise rotations: degrees as well as laps.

Clockwise rotationAnticlockwise rotationReset button
Turn rightTurn leftPress down

The incremental encoder is a kind of rotation sensor for translating the rotary displacement into a sequential of digital pulse signal. The displacement can be gained by counting the number of the pluses outputted in the course of clockwise or anticlockwise rotation. Comparing with the potentiometer, the rotary counter has no limit for counting. So, there is a reset button provided to reset the counter to the initial state, restarting at 0.

PINArduino pinFunction
VCC5V3.0V - 5.3V
GNDGNDPower supply ground
SWNCMCU.IO (encoder button status): Read the state of the reset button on the encoder.
SIBD3MCU.IO (output status): Work with SIA to judge the rotary direction of the encoder
SIAD2MCU.IO (output status): Work with SIB to judge the rotary direction of the encoder

Temperature-Humidity Sensor DHT11

The DHT11 is a ultra low cost calibrated digital temperature and humidity module. It can be used for detecting ambient temperature and humidity, through the standard single-wire interface. The sensor is operating with 3.3V - 5.5V. I'm using the the module from Waveshare where the calibration coefficients are stored in the OTP memory in the form of programs. These calibration coefficients are called during the internal signal detection process of the sensor, so that there is no need to recalibrate them.

SensorResolutionAccuracyMeasuring RangeRecommended storage condition
Temperature1°C±2°C0°C - 50°C10°C - 40°C
Humidity1%RH±5%RH (0°C - 50°C)20%RH - 95%RH(0°C - 50°C)60%RH or below

Interfaces

Pin No.SymbolDescriptions
1DOUTCommunication port
2GNDPower ground
3VCCPositive power supply (3.3V-5.5V)

How to use DHT11 from Waveshare

Here is an example how to use the temperature-humidity module by connecting it to the ARPI600 development board:

  1. Download relative codes to the development board.
  2. Connect the development board to your RaspBerry

GSM SIM900 board - GPRS shield v1.0

GSM SIM900 board
XBEE Pins
Fig. 3:

WiringPi

BCMwPiNameModeVPhysicalVModeNamewPiBCM
3.3v1 / 25v
28SDA.1ALT013 / 45V
39SCL.1ALT015 / 60v
47GPIO. 7IN17 / 81ALT0TxD1514
0v9 / 101ALT0RxD1615
170GPIO. 0OUT011 / 120ALT0GPIO. 1118
272GPIO. 2IN013 / 140v
223GPIO. 3IN015 / 160INGPIO. 4423
3.3v17 / 180INGPIO. 5524
1012MOSIIN019 / 200v
913MISOIN021 / 220INGPIO. 6625
1114SCLKIN023 / 241INCE0108
0v25 / 261INCE1117
030SDA.0OUT127 / 281INSCL.0311
521GPIO.21IN129 / 300v
622GPIO.22IN131 / 321INGPIO.262612
1323GPIO.23IN033 / 340v
1924GPIO.24ALT0035 / 360OUTGPIO.272716
2625GPIO.25IN037 / 380OUTGPIO.282820
0v39 / 401INGPIO.292921

Eclipse

Remote Debugging

If you get the following error message wiringPiSetup: Must be root. (Did you forget sudo?) while the remote debugging in Eclipse, then you need to do the following:

1) Create the bash file sudo nano /usr/local/sbin/gdbserver on your Raspberry Pi

  1. #!/bin/bash
  2. # 2015/08/14 Remote debugging with gdbserver and Eclipse
  3. # https://ludwig.im/en/projects/raspberry-pi/raspberry-pi-arpi600#remote-debugging
  4. sudo /usr/bin/gdbserver $*

2) Set the right permissions with sudo chmod a+x /usr/local/sbin/gdbserver

3) Change the following Eclipse option: Debug Configurations / C/C++ Remote Application / Debugger / Gdbserver settings the Gdbserver to /usr/local/sbin/gdbserver

Well, what do you think?

Sorin said
Hi I just read your post. The problem I am facing when trying to read in console over ssh from UART is that I dont get any xbee output. I have 2 xbees series 2 both are in the same network, I tested the communication on the XCTU SW. on the ARPI600 i placed the jumpers from XB to P and still no success. Please help, I am already working on finding a solution fro an entire day. Thx.
Thomas Ludwig said
Hi Sorin, sorry, I haven't tried the xbee interface since yet. When I have time, I'm playing with some sensors. I wish you good luck!
Lashway said
Hello, just got my own ARPI600 and have so far been dissapointed by the documentation, so my apologies if some of these questions seem a bit obvious.

When using wiringPi to manipulate the arduino pins, do you use the physical pin associated with the analog or digital pin? Does this mean that while using an arduino shield, or a stack of them, the corresponding gpio pins must be defined the their use, and so are unavailable for use?

Have you tried to use the ardupi library with this shield?

What I'm really not getting is how to treat the arduino interface like an Arduino, even doing just a simple blink code has been very confusing. Do you have any suggestions?
Comments powered by LudwigDisqus for ModX