According to StarFive, developers have successfully used photosensitive sensors on VisionFive/VisionFive 2, and the specific instructions are as follows:
- Development board: VisionFive/VisionFive 2
- Flame sensor: Flame sensor with AO output
- Analog to digital conversion module: ADS1115
- DuPont Line: Many
2. Principle of flame sensors
The specific flame sensor modules used in this demo are as follows:
Similar to photosensitive sensors, digital output interface (DO) and analog output interface (AO) are provided on this flame sensor.
Because VisionFive itself does not have an ADC module, this demo specifically uses an ADC module to help the board read the AO simulation output information of the flame sensor and obtain the flame intensity value.
The working principle of the flame sensor is similar to that of the photosensitive sensor. At the top of the flame sensor, there is a Photoresistor. Due to the Photoelectric effect, the stronger the light, the lower the resistance value. With the increase of the light intensity, the resistance value decreases rapidly. On the contrary, it outputs a low-level signal. As the resistance value changes, the voltage signal of its AO will also change. By using the ADC module, the voltage signal can be converted into a digital signal.
However, flame sensors are specifically designed to detect fire sources or other light sources with wavelengths ranging from 760 nanometers to 1100 nanometers, and are not sensitive to daily lighting or natural light.
It should be noted that although flame sensors are used to sense flames, they are not fire resistant and typically operate at temperatures ranging from -25℃ to 85℃. Therefore, please keep a distance from the flame when using it to avoid burning out the sensor.
The ADC module used in this demo is ADS1115, as follows:
ADS1115 is a 16-bit precision ADC signal conversion module that uses the IIC interface to communicate with the board. It can simultaneously measure four sets of voltage signals for conversion, and can work between 2V and 5.5V. It can be used in conjunction with various development boards and microcontrollers, and can be used in many applications such as automobiles, televisions, and sensors.
3. The use of flame sensor
Based on the principle of the flame sensor mentioned above, we can learn that to obtain the specific flame intensity value measured, it is necessary to perform analog-to-digital conversion through ADS1115.
Firstly, connect the AO interface of the flame sensor module to the AO interface of ADS1115, so that ADS1115 can obtain the analog voltage signal output by the flame sensor.
Then, refer to the following figure and connect ADS115 to VisionFive:
The power supply voltage should be determined based on the actual sensor used. The flame sensor module and ADS1115 module in this demo uses a 5V power supply voltage.
Then, write the following program:
#- * - coding: utf-8- * - # file:~/projects/flash/plain_ Ao.py
Import ADS1115 import timeimport numpy
#Initialize ADS1115 module
#Read the data of channel 0 of ADS1115 module, which is A0
Volt=ads. readADCSingleEnded (0)
Per=numpy. inter (volt, [0, 5000], [0, 100])
Print ("% d mV of A0, val is% f"% (volt, per))
Time. sleep (0.1)
The logic of the above program is to detect the AO of the flame sensor module through ADS1115, and then convert it to the corresponding flame intensity value.
To run the above programs, it is also necessary to install the corresponding third-party support libraries numpy and ADS1115. However, the ADS1115 extension library uses i2c-1 by default, but VisionFive uses i2c-0. Therefore, after installing the extension library, it needs to be processed to use it, as follows:
#Install Extension Library
Pip install SMBus
Pip install numpy
Pip install ADS1115
#Modify ADS1115 library file
Vi~/. local/lib/Python 3.10/site packages/ADS1115/__ Init__ Py # Modify smbus2. SMBus (1) in this file to smbus2. SMBus (0), then save and exit
After writing, run
flame_ao.py, then use a flame to approach the test. Please keep a distance from the flame during use to avoid burning out the sensor.
The actual testing of this demo is as follows:
- Open flame:
- Without open flame:
During testing, the test environment is illuminated by a desk lamp, but when there is no fire, the analog output of the flame sensor is basically 0.
When using an open flame to approach, the analog output of the flame sensor significantly increases to over 80.
When the open flame is extinguished and approached, the analog output of the flame sensor still obtains data.
Therefore, using it can effectively detect the flames of flames.
In this demo, we learned how to read the analog output signal of a flame sensor for flame detection.
Flame sensors are a part of safety equipment that can help us protect houses, offices, and stores from the impact of fires. Almost all modern houses, apartments, shopping centers, cinema halls, theaters, office buildings and stores are equipped with safety equipment including flame sensors.