update
This commit is contained in:
9
sensirion/README.md
Normal file
9
sensirion/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Sonde Sensirion SFA30
|
||||
|
||||
La sonde est connecté sur le port UART5. On peut utiliser la [bilbio python officielle](https://sensirion.github.io/python-shdlc-sfa3x/installation.html).
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
sudo pip3 install sensirion-shdlc-sfa3x --break-system-packages
|
||||
```
|
||||
38
sensirion/SFA30_read.py
Normal file
38
sensirion/SFA30_read.py
Normal file
@@ -0,0 +1,38 @@
|
||||
'''
|
||||
Read data from sensor (only once)
|
||||
/usr/bin/python3 /var/www/moduleair_pro_4g/sensirion/SFA30_read.py
|
||||
'''
|
||||
|
||||
import time
|
||||
import json
|
||||
|
||||
from sensirion_shdlc_driver import ShdlcSerialPort, ShdlcConnection
|
||||
from sensirion_shdlc_sfa3x import Sfa3xShdlcDevice
|
||||
|
||||
# Connect to the device with default settings:
|
||||
# - baudrate: 115200
|
||||
# - slave address: 0
|
||||
with ShdlcSerialPort(port='/dev/ttyAMA5', baudrate=115200) as port:
|
||||
device = Sfa3xShdlcDevice(ShdlcConnection(port), slave_address=0)
|
||||
device.device_reset()
|
||||
|
||||
# Print device information
|
||||
#print("Device Marking: {}".format(device.get_device_marking()))
|
||||
|
||||
# Start measurement
|
||||
device.start_measurement()
|
||||
#print("Measurement started... ")
|
||||
|
||||
time.sleep(5.)
|
||||
hcho, humidity, temperature = device.read_measured_values()
|
||||
|
||||
# Prepare data as a JSON object
|
||||
data = {
|
||||
"formaldehyde_ppb": hcho.ppb,
|
||||
"humidity_percent": humidity.percent_rh,
|
||||
"temperature_celsius": temperature.degrees_celsius,
|
||||
}
|
||||
|
||||
# Convert the dictionary to a JSON string
|
||||
json_output = json.dumps(data, indent=4)
|
||||
print(json_output)
|
||||
22
sensirion/SFA30_read_loop.py
Normal file
22
sensirion/SFA30_read_loop.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import time
|
||||
from sensirion_shdlc_driver import ShdlcSerialPort, ShdlcConnection
|
||||
from sensirion_shdlc_sfa3x import Sfa3xShdlcDevice
|
||||
|
||||
# Connect to the device with default settings:
|
||||
# - baudrate: 115200
|
||||
# - slave address: 0
|
||||
with ShdlcSerialPort(port='/dev/ttyAMA5', baudrate=115200) as port:
|
||||
device = Sfa3xShdlcDevice(ShdlcConnection(port), slave_address=0)
|
||||
device.device_reset()
|
||||
|
||||
# Print device information
|
||||
print("Device Marking: {}".format(device.get_device_marking()))
|
||||
|
||||
# Start measurement
|
||||
device.start_measurement()
|
||||
print("Measurement started... ")
|
||||
while True:
|
||||
time.sleep(10.)
|
||||
hcho, humidity, temperature = device.read_measured_values()
|
||||
# use default formatting for printing output:
|
||||
print("{}, {}, {}".format(hcho, humidity, temperature))
|
||||
BIN
sensirion/Sensirion_formaldehyde_sensors_datasheet_SFA30.pdf
Normal file
BIN
sensirion/Sensirion_formaldehyde_sensors_datasheet_SFA30.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user