Close

2. Getting Started

A project log for Homemade Spectrometer

Open source experiment kit made with the AS7262 (six colors) and AS7263 (near infrared) spectral sensors and the Raspberry Pi

guillermo-perez-guillenGuillermo Perez Guillen 09/10/2023 at 02:430 Comments

In this chapter I will show you the main features of Raspberry Pi 3B+, Qwiic pHAT module and AS7262 sensor. Also we learn how to setup the Raspberry Pi and how to detect the peripheral of the sensor.

Raspberry Pi 3B+

The Raspberry Pi 3 B+ provides you with the same Pi as before, but now with gigabit and PoE capable Ethernet, as well as better overheating protection for the 64-bit processor. This computer small has a Broadcom BCM2837, an ARM Cortex-A53 64-bit Quad Core Processor System-on-Chip operating at 1.4GHz. The GPU provides OpenGL ES 2.0, hardware-accelerated OpenVG and 1080p30 H.264 high-profile decode. It is capable of 1Gpixel/s, 1.5Gtexel/s or 24 GFLOPs of general-purpose compute. 

SparkFun Qwiic pHAT v2.0 

The SparkFun Qwiic pHAT connects the I2C bus (GND, 3.3V, SDA, and SCL) on your Raspberry Pi to an array of Qwiic connectors on the HAT. Since the Qwiic system allows for daisy-chaining boards with different addresses, you can stack as many sensors as you’d like. The Qwiic pHAT V2.0 has four Qwiic connect ports (two on its side and two vertical), all on the same I2C bus. It also add a simple 5V screw terminal to power boards that may need more than 3.3V and a general-purpose button. This pHAT is compatible with any Raspberry Pi that utilizes the standard 2x20 GPIO header.

AS7262 6-channel Visible Light Sensor

The SparkFun AS7262 spectrometer detects wavelengths in the visible range at 450, 500, 550, 570, 600 and 650nm of light each with 40nm of full-width half-max detection. The board also has multiple ways for you to illuminate objects that you will try to measure for a more accurate spectroscopy reading. There is an onboard LED that has been picked out specifically for this task, as well as two pins to solder your own LED into. The AS7262 Breakout is unique in its ability to communicate by both an I2C interface and serial interface using AT commands.

Applications: 

Below you can see the spectral responsivity of this sensor.

Configuring the Pi

To get started with your Qwiic pHAT, simply plug it into the headers on the Raspberry Pi with the letters facing you. We'll use the Qwiic pHAT v2.0 in the following image to connect a Qwiic device.

Once the pHAT is plugged in, you can start plugging in AS7262 6-channel Visible Light Sensor.

The Raspberry Pi Configuration via Desktop GUI

You can use the Desktop GUI by heading to the Pi Start Menu > Preferences > Raspberry Pi Configuration. A window will pop up with different tabs to adjust settings. What we are interested is the Interfaces tab. Click on the tab and select Enable for I2C. Click on the OK button.

imageIt's recommend restarting your Pi to ensure that the changes to take effect. Click on the Pi Start Menu > Preferences > Shutdown. Since we just need to restart, click on the Restart button. The system will reboot. When it comes back up, log in and enter the following command

ls /dev/*i2c* 

imageThe Pi should respond with

/dev/i2c-1

Which represents the user-mode I2C interface. There is a set of command-line utility programs that can help get an I2C interface working. You can get them with the apt package manager. Enter the following command.

sudo apt-get install -y i2c-tools

imageIn particular, the i2cdetect program will probe all the addresses on a bus, and report whether any devices are present. Enter the following command in the command line. The -y flag will disable interactive mode so that you do not have to wait for confirmation. The 1 indicates that we are scanning for I2C devices on I2C bus 1.

i2cdetect -y 1

You will get an output from your Raspberry Pi similar to the output below.

imageThis map indicates that there is a peripheral at address 0x49, and according to the AS7262 datasheet, device address is 49 hex.

image

Conclusion

Discussions