1
- # Sensirion Raspberry Pi UART SVM4x Driver
1
+ # Sensirion Raspberry Pi UART SVM4X Driver
2
2
3
- This document explains how to set up a SVM4x evaluation kit to run on a Raspberry Pi using the provided code.
3
+ The repository provides a driver for setting up a SVM4X evaluation kit to run on a Raspberry Pi over UART using the SHDLC protocol.
4
+
5
+ <img src =" images/svm4x.png " width =" 300px " >
6
+
7
+ Click [ here] ( https://www.sensirion.com/my-sgp-ek/ ) to learn more about the Sensirion SVM4X evaluation kit.
4
8
5
- <img src =" images/SVM41.png " width =" 400px " >
6
9
7
- Click [ here] ( https://sensirion.com/my-sgp-ek ) to learn more about the Sensirion SVM4x evalutaion kit.
8
10
The SVM4x evaluation kit covers evaluation of the SGP40 and SGP41 sensors.
11
+ This driver supports SVM4x firmware version 3.1.0 and above.
9
12
10
13
11
14
## Connect the sensor
@@ -20,73 +23,102 @@ Plug the provided USB cable into your Raspberry Pi and sensor.
20
23
<details ><summary >Connecting the Sensor over UART Pins</summary >
21
24
<p >
22
25
23
- Use the following pins to connect your SVM4x to your Raspberry Pi:
26
+ Use the following pins to connect your SVM4X to your Raspberry Pi:
24
27
25
- <img src =" images/SVM41-Pinout-UART .png " width =" 400px " >
28
+ <img src =" images/svm41-pinout-uart .png " width =" 300px " >
26
29
27
- | * Pin SVM4x* | * Cable Color* | * Name* | * Pin Raspberry Pi* | * Description* | * Description* |
28
- | -------------| ---------------| --------| --------------------| ---------------| ---------------|
29
- | 1 | red | VDD | Pin 2 (VDD)| Supply Voltage | 3.3 or 5V |
30
- | 2 | black | GND | Pin 6 (GND) | Ground | |
31
- | 3 | green | RX | Pin 8 (TXD) | UART communication | |
32
- | 4 | yellow | TX | Pin 10 (RXD) | UART communication | |
33
- | 5 | blue | SEL | Pin 4 (VDD) | Interface select | Leave floating or pull to VDD to select UART |
34
- | 6 | purple | NC | - | Do not connect |
30
+ | * Pin SVM4X* | * Cable Color* | * Name* | * Pin Raspberry Pi* | * Description* | * Comments* |
31
+ | ---| ---| :---:| ---| ---| ---|
32
+ | 1 | red | VDD | Pin 2 | Supply Voltage | 3.3 or 5V |
33
+ | 2 | black | GND | Pin 6 | Ground | |
34
+ | 3 | green | RX | Pin 8 | UART: Transmission pin for communication | |
35
+ | 4 | yellow | TX | Pin 10 | UART: Receiving pin for communication | |
36
+ | 5 | blue | SEL | Pin 4 | Interface select | Leave floating or pull to VDD to select UART |
35
37
36
- <img src =" images/raspi-pinout- uart-5V.png " width =" 700px " >
38
+ <img src =" images/raspi-uart-pinout- 5V.png " width =" 400px " >
37
39
38
40
> ** Note:** Make sure to [ configure your hardware serial interface] ( https://www.raspberrypi.com/documentation/computers/configuration.html#disabling-the-linux-serial-console ) on your Raspberry Pi.
39
41
40
42
> ** Note:** Make sure to connect serial pins as cross-over (RX pin of sensor -> TX on Raspberry Pi; TX pin of sensor -> RX pin of Raspberry Pi)
41
43
42
-
43
44
</p ></details >
44
45
45
46
## Quick start example
46
47
47
48
- [ Install the Raspberry Pi OS on to your Raspberry Pi] ( https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up )
48
- - Connect the SVM4x sensor as explained in the [ section above] ( #connect-the-sensor )
49
- - Download the SVM4x driver from [ Github] ( https://github.com/Sensirion/raspberry-pi-uart-svm4x ) and extract the ` .zip `
49
+ - Download the SVM4X driver from [ Github] ( https://github.com/Sensirion/raspberry-pi-uart-svm4x ) and extract the ` .zip `
50
50
on your Raspberry Pi
51
- - Compile the driver
52
- 1. Open a [ terminal] ( https://projects.raspberrypi.org/en/projects/raspberry-pi-using/8 )
53
- 2. Navigate to the driver directory. E.g. ` cd ~/raspberry-pi-uart-svm4x `
54
- 3. Check that the correct serial port is set in the define in ` svm41_uart_example_usage.c `
55
- 1. For connection over USB use (in case you have other devices connected check the USB number) ` #define SENSIRION_UART_TTYDEV "/dev/ttyUSB0" `
56
- 2. For connection over UART Pins use ` #define SENSIRION_UART_TTYDEV "/dev/serial0" `
57
- 4. Run the ` make ` command to compile the driver
58
-
59
- Output:
60
- ```
61
- rm -f svm41_uart_example_usage
62
- cc -Os -Wall -fstrict-aliasing -Wstrict-aliasing=1 -Wsign-conversion -fPIC -I. -o svm41_uart_example_usage svm41_uart.h svm41_uart.c sensirion_uart_hal.h sensirion_shdlc.h sensirion_shdlc.c \
63
- sensirion_uart_hal.c sensirion_config.h sensirion_common.h sensirion_common.c svm41_uart_example_usage.c
64
-
65
- ```
51
+ - Connect the SVM4X sensor as explained in the [ section above] ( #connect-the-sensor )
52
+ - Check that the correct serial port is set in the define in ` sensirion_uart_portdescriptor.h `
53
+ - For connection over USB (in case you have other devices connected check the USB number)
54
+
55
+ ` #define SERIAL_0 "/dev/ttyUSB0" `
56
+
57
+ - For connection over UART Pins
58
+
59
+ ` #define SERIAL_0 "/dev/serial0" `
60
+
61
+ - Compile the driver
62
+ 1 . Open a [ terminal] ( https://projects.raspberrypi.org/en/projects/raspberry-pi-using/8 )
63
+ 2 . Navigate to the driver directory. E.g. ` cd ~/raspberry-pi-uart-svm4x `
64
+ 3 . Navigate to the subdirectory example-usage.
65
+ 4 . Run the ` make ` command to compile the driver
66
+
67
+ Output:
68
+ ```
69
+ rm -f svm4x_uart_example_usage
70
+ cc -Os -Wall -fstrict-aliasing -Wstrict-aliasing=1 -Wsign-conversion -fPIC -I. -o svm4x_uart_example_usage svm4x_uart.h svm4x_uart.c sensirion_uart_hal.h sensirion_shdlc.h sensirion_shdlc.c \
71
+ sensirion_uart_hal.c sensirion_config.h sensirion_common.h sensirion_common.c svm4x_uart_example_usage.c
72
+ ```
66
73
- Test your connected sensor
67
- - Run ` ./svm41_uart_example_usage ` in the same directory you used to compile the driver. You should see the
74
+ - Run `./svm4x_uart_example_usage ` in the same directory you used to compile the driver. You should see the
68
75
measurement values in the console.
69
76
77
+ ## Troubleshooting
78
+
79
+ ### Building driver failed
80
+
81
+ If the execution of `make` in the compilation step 3 fails with something like
82
+
83
+ ```bash
84
+ make: command not found
85
+ ```
86
+
87
+ your RaspberryPi likely does not have the build tools installed. Proceed as follows:
88
+
89
+ ```
90
+ $ sudo apt-get update
91
+ $ sudo apt-get upgrade
92
+ $ sudo apt-get install build-essential
93
+ ```
94
+
95
+
96
+
70
97
## Contributing
71
98
72
99
** Contributions are welcome!**
73
100
74
- We develop and test this driver using our company internal tools (version control, continuous integration, code review
75
- etc.) and automatically synchronize the master branch with GitHub. But this doesn't mean that we don't respond to issues
76
- or don't accept pull requests on GitHub. In fact, you're very welcome to open issues or create pull requests :)
101
+ We develop and test this driver using our company internal tools (version
102
+ control, continuous integration, code review etc.) and automatically
103
+ synchronize the master branch with GitHub. But this doesn't mean that we don't
104
+ respond to issues or don't accept pull requests on GitHub. In fact, you're very
105
+ welcome to open issues or create pull requests :)
77
106
78
107
This Sensirion library uses
79
- [ ` clang-format ` ] ( https://releases.llvm.org/download.html ) to standardize the formatting of all our ` .c ` and ` .h ` files.
80
- Make sure your contributions are formatted accordingly:
108
+ [ ` clang-format ` ] ( https://releases.llvm.org/download.html ) to standardize the
109
+ formatting of all our ` .c ` and ` .h ` files. Make sure your contributions are
110
+ formatted accordingly:
81
111
82
112
The ` -i ` flag will apply the format changes to the files listed.
83
113
84
114
``` bash
85
115
clang-format -i * .c * .h
86
116
```
87
117
88
- Note that differences from this formatting will result in a failed build until they are fixed.
118
+ Note that differences from this formatting will result in a failed build until
119
+ they are fixed.
120
+
89
121
90
122
## License
91
123
92
- See [ LICENSE] ( LICENSE ) .
124
+ See [ LICENSE] ( LICENSE ) .
0 commit comments