Introduction: CSR1011 - Using Infrared Sensor
The CSR1011 is a single mode Bluetooth Smart chip and this tutorial show how to access its GPIOs and read a infrared sensor state, to detect the presence of a object.
Step 1: Infrared Sensor
The infrared sensor has a transmitter and receiver circuit, positioned side by side. When an object or person passes in front of the sensor, the IR signal is reflected and detected by the receiver, which puts the output pin low (LOW), and triggers a led on the back of the sensor.
Step 2: Hardware Scheme
To connect the infrared sensor in the CSR1011 was designed a hardware to power it, because the CSR1011 is powered with 3v3 and the component needs 5v to work. On CSR the pin 31 (GPIO 31) was used to connect the infrared sensor.
Step 3: Installing the CSR UEnergy SDK
To handle application on CSR1011 is used the Integrated Development Environment (xIDE) supplied with μEnergy Software Development Kits (SDKs). The software is provided on the CD-ROM but can also be downloaded from here.
Step 4: Software Architecture
On CSR1011 the application communicates with firmware using API calls that are implemented using firmware callbacks for various events in the application life cycle. When a project is created some functions are already implemented, this functions are used in the life cycle of the application:
AppPowerOnReset(): Application function called just after a power-on reset;
- AppInit(): This function is called every boot and should contain application initialisation;
- AppProcessSystemEvent(): Function called by firmware to process system-level events, like Low battery and PIO level change;
- AppProcessLmEvent(): Function used to handles communication link-related events from firmware;
- Timers: Run on top of the hardware timer with microsecond accuracy.
Step 5: Code Example to Read the Sensor State
The code available demonstrates how to configure and get the state of the gpio to read the infrared sensor plugged in the gpio 31 of the CSR1011. To handle the access of the gpios were used functions availables on pio.h library on group__PIO__B.html at uEnergy SDK. To see the sensor measuremet use a serial program (E.g: PuTTy), the only configuration needed is set the COM and set the bound rate to 2400.