FAQs

Raspberry Pi Sensor Hat Pin Diagram

Following is various labeling used for referring Raspberry Pi set of 20 pins. The sensor hat uses various pins to feed in the sensed data to the raspberry pi.  
Raspberry Pi Pin Labeled Diagram

Raspberry Pi Pin Labeled Diagram

 

DHT22/DHT11, temperature and humidity sensor

  1. BCM pin 22
  2. Physical pin 24

PIR motion sesnor

  1. BCM pin 7
  2. Physical pin 26

Rest button

  1. BCM pin 26
  2. Physical pin 37

I2S Amplifier

  1. DOUT
    1. BCM pin 21
    2. Physical pin 40
  2. LRCL
    1. BCM pin 19
    2. Physical pin 35
  3. Ground
    1. Physical pin 19
  4. 5V
    1. Physical pin 2
  5. BCLK
    1. Physical pin 12
    2. BCM pin 12

I2S Mircophone

  1. DIN
    1. BCM pin 20
    2. Physical pin 38
  2. LRCL
    1. BCM pin 19
    2. Physical pin 35
  3. Ground
    1. Physical pin 19
  4. 3V
    1. Physical pin 1
  5. BCLK
    1. Physical pin 12
    2. BCM pin 12
 

Introduction

Raspberry Pi is capable of doing serial communication using the GPIO pins 14 and 15. Setting Raspberry Pi Serial Ports is expected to be simple and straightforward. Instead, it is confusing because online instructions are not very clear on the issues that one encounters when using different Raspberry Pi models. Following article is an attempt to set up the serial communication from your Raspberry Pi. To make it crystal clear, here we are talking about the physical serial pins 8, TxD, also referred to as BCM 14 and physical pin 9, RxD also referred to as BCM 15. Another vital thing to note here is that these serial pins work at 0-3.3 Volts. While connecting it to external devices ensure that they also are 0-3.3V devices. Note that TxD or Raspberry pi connects to RxD of the external device and similarly for the other pins. These pins collectively are also known as UART(Universal Asynchronous Receiver/Transmitter) pins.

Raspberry Pi UART

Raspberry Pi has two in-built UART, which are as follows:
  • PL011 UART
  • mini UART
PL011 UART is an ARM-based UART. This UART has better throughput than mini UART. In older versions of Raspberry Pi, the ones that do not have onboard wifi and Bluetooth module, the PL011 UART was allocated to BCM 14 and 15.
Raspberry pi UART pins

Raspberry pi UART pins

In the newer version of Raspberry Pi's the PL011 is connected to the On-board Bluetooth module. By default, Mini UART is available but linked to the core frequency of GPU. This dependency on GPU frequency makes mini UART on newer pi's unstable for most serial applications. The PL011 is a stable and high-performance UART. For better and effective communication use PL011 UART instead of mini UART.

Configure UART on Raspberry Pi

In the section below, we will look at how to configure and use UART ports effectively for both the older and newer versions of Raspberry Pi.

Older version of Raspberry Pi

Following instructions are for Raspberry Pis that do not have onboard Bluetooth module and PL011 UART module is assigned to the BCM pins 14 and 15.

Step 1. Enable kernel UART

Login into the Raspberry Pi and on console edit /boot/config.txt. Look for "enable_uart" configuration. If present change it, if not add it, so that you have following entry in your /boot/config.txt:  enable_uart=1  Step 2. Edit the file cmdline.txt. By default it contains the following:

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

Change the value of console so that it looks like below:

 dwc_otg.lpm_enable=0 console=/dev/ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait 

 

Setp 3. Reboot

Aftre a reboot changes take effect and  your serial ports are set to communicate with other serial devices.

Raspberry pi with the onboard Bluetooth module

Following instructions are for Raspberry Pi's that have in-built Bluetooth module using the physical PL011 UART.

Step 1: Disable use of Pl011 UART by Bluetooth module

Login into the Raspberry Pi and on console edit /boot/config.txt. Look for "dtoverlay=pi3-disable-bt" configuration. If present change it, if not add it, so that you have following entry in your /boot/config.txt:  dtoverlay=pi3-miniuart-bt   This step will force the Bluetooth module to use mini UART, and thus become slightly unstable. Also, disable the system services that use the UART module:  sudo systemctl disable hciuart    

Step 2:

Edit the file cmdline.txt.

By default it contains the following:  dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait 
Change the value of console so that it looks like below:

 dwc_otg.lpm_enable=0 console=/dev/ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait 

Note that 115200 is the frequency at which the serial communication will happen. Check if this is compatible with the device you are planning to connect.  

Step 3. Reboot

After a reboot changes take effect and your serial ports are set to communicate with other serial devices.

Using serial communication using Raspberry Pi Serial Ports

 
OpenEVSE FTDI Port

OpenEVSE FTDI Port

OpenEVSE FTDI to Raspberry Pi Serial Port

OpenEVSE FTDI to Raspberry Pi Serial Port

      In our case, we intended to connect Raspberry pi to OpenEvse electric vehicle charger on its serial port. The module that speaks UART is shown on the left while the right figure shows the connection via a level shifter to Raspberry Pi.         We are reproducing some python code here that is generic and can help you troubleshoot your serial connection.        

Python code to read from the serial port (read.py):

 
#!/usr/bin/env python
          

import time
import serial


ser = serial.Serial(
    port='/dev/ttyAMA0',
    baudrate = 115200,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS,
    timeout=3
)


while 1:
    x=ser.readline()
    if len(x)>1:
       print x
    time.sleep(2)

Python code to write to the serial port(write.py):

 
#!/usr/bin/env python


import time
import serial


ser = serial.Serial(
    port='/dev/ttyAMA0',
    baudrate = 115200,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS,
    timeout=5
)


while 1:
    var = raw_input(">>: ")
    print "you entered", var.strip()
    ser.write("%s\r"%var)
    time.sleep(2)

Do write to us at info@ibeyonde.com, in case you need more information.
To configure the CCam you need to set it up in Hotspot mode. When you buy a new CCam it is by default set in Hotspot mode. You can tell if it is in Hotspot mode by looking at the Hotspot indicator. If the indicator is ON the CCam is in Hotspot mode. See below Picture for the location of Hotspot Indicator [see 4 in Pic below]. In case, your CCam does not show the Hotspot indicator ON when you switch it on, then you can press the reset button twice (click-click) to get into this mode. You need to wait for about a minute for your device to boot up and initialize after power on. This mode is similar to the personal hotspot that you create on your mobile phone so that other devices can access the network via your mobile phone. In the case of CCam, this Hotspot is advertised as “CCam-”. You can see the Hotspot listed in your wifi setting page as seen below on a iPhone. It is advertised as CCam-a8da850b.
You can replace the sd card in a couple of minutes. Here is the video link for better understanding
Check item 5 in below picture and you will see the status LEDS. They are deep inside the device and you need to align your eye in from of the pin hole to view there. Status lights indicate the following:
  1. Yellow-Red blinking: The device is booting up. Wait until the device is fully booted to do any operation.
  2. Yellow-green constant: An operation is in progress.
  3. OFF: The device is in Infra mode if the hotspot indicator is OFF or in Hotspot mode if the hotspot indicator is ON.
For Upgrade/Update login into your account at http://app.ibeyonde.com. Goto Live menu. Click on the Settings button of the device that you will want to upgrade. This will take you to the device setting page. From this page you can do various operations on your device. Your device needs to be connected to the internet for the operations to go thru to your device. Click on the update button that appears on the device settings page as shown below:
When you deploy multiple CCam in proximity then they automatically discover each other and form a grid. There is no configuration required and this is done by the cloud software. The grid provides certain smart features like “Events”. The events are collection of snapshots that the machine learning algorithm thinks are linked to each other. This provides a view across cameras for related events.
You can configure grid as per your perception of what are the active parts in the view of CCam. When the CCam discovers any motion outside this active grid points it will raise an alarm.