Comments (8)
Well this looks like compilation did work, no? Have you tried to continue with the next step and run the executable as in the guide?
So run ./sps30_example_usage
?
from embedded-uart-sps.
oh sorry
I totally forgot and overlooked this command.
./sps30_example_usage
Now the sensor is finally working. Perfect
Is it possible to stop the application automatically after e.g. 10 measurements?
Thanks a lot.
Sometimes you don't see the forest in front of trees.
Michael
PS: i would like to start and stop the application via node-red and display the output in a debug window.
is that feasible?
from embedded-uart-sps.
You have to modify the sps30_example_usage.c file and replace the while(1) {..}
block with something like this:
int16_t i;
for (i = 0; i < 10; i++) {
sensirion_sleep_usec(SPS30_MEASUREMENT_DURATION_USEC); /* wait 1s */
ret = sps30_read_measurement(&m);
if (ret < 0) {
printf("error reading measurement\n");
} else {
printf("measured values:\n"
"\t%0.2f pm1.0\n"
"\t%0.2f pm2.5\n"
"\t%0.2f pm4.0\n"
"\t%0.2f pm10.0\n"
"\t%0.2f nc0.5\n"
"\t%0.2f nc1.0\n"
"\t%0.2f nc2.5\n"
"\t%0.2f nc4.5\n"
"\t%0.2f nc10.0\n"
"\t%0.2f typical particle size\n\n",
m.mc_1p0, m.mc_2p5, m.mc_4p0, m.mc_10p0, m.nc_0p5, m.nc_1p0,
m.nc_2p5, m.nc_4p0, m.nc_10p0, m.typical_particle_size);
}
}
from embedded-uart-sps.
Now the sensor is finally working. Perfect
Good to hear :)
Is it possible to stop the application automatically after e.g. 10 measurements?
Well you could replace the endless loop in the example with a for loop like @psachs suggested.
Do you intend to let the sensor running in the background? Because if you stop measurements after just 10s, precision won't be that good since the device should be measuring for more than 30s to achieve good results. But to leave it running you'd may need to change the code in the beginning as well to only start measurements if they aren't running already.
PS: i would like to start and stop the application via node-red and display the output in a debug window.
is that feasible?
I don't have any experience with node-red. But I'm curious how your setup looks like and what you try to achieve 🙂
from embedded-uart-sps.
Hello,
first of all thank you for the great support.
So regarding the measurement, I think that the sensor does not necessarily have to run 24/7.
It's certainly better for life.
It would be enough for me, for example,
one measurement every hour with e.g. 10 or 20 measurements,
because of the accuracy.
or does it not matter that the sensor is running 24/7?
I did that with the code from
Tried @psachs.
Unfortunately:
pi@raspberrypi:~/release/sps30-uart-3.0.0 $ make rm -f sps30_example_usage cc -Os -Wall -fstrict-aliasing -Wstrict-aliasing=1 -Wsign-conversion -fPIC -I. -I. -I. -o sps30_examp le_usage ./sensirion_arch_config.h ./sensirion_uart.h ./sensirion_shdlc.h ./sensirion_shdlc.c ./sps_gi t_version.h ./sps_git_version.c ./sps30.h ./sps30.c ./sensirion_uart_implementation.c ./sps30_example_ usage.c ./sps30_example_usage.c: In function ‘main’: ./sps30_example_usage.c:82:30: error: ‘SPS30_MEASUREMENT_DURATION_USEC’ undeclared (first use in this function) sensirion_sleep_usec(SPS30_MEASUREMENT_DURATION_USEC); /* wait 1s */ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./sps30_example_usage.c:82:30: note: each undeclared identifier is reported only once for each functio n it appears in make: *** [Makefile:10: sps30_example_usage] Error 1 pi@raspberrypi:~/release/sps30-uart-3.0.0 $
1000 thanks
my sps30_example_usage.c file:
`#include <stdio.h> // printf
#include "sensirion_uart.h"
#include "sps30.h"
/**
- TO USE CONSOLE OUTPUT (PRINTF) AND WAIT (SLEEP) PLEASE ADAPT THEM TO YOUR
- PLATFORM
*/
//#define printf(...)
int main(void) {
struct sps30_measurement m;
char serial[SPS30_MAX_SERIAL_LEN];
const uint8_t AUTO_CLEAN_DAYS = 4;
int16_t ret;
while (sensirion_uart_open() != 0) {
printf("UART init failed\n");
sensirion_sleep_usec(1000000); /* sleep for 1s */
}
/* Busy loop for initialization, because the main loop does not work without
* a sensor.
*/
while (sps30_probe() != 0) {
printf("SPS30 sensor probing failed\n");
sensirion_sleep_usec(1000000); /* sleep for 1s */
}
printf("SPS30 sensor probing successful\n");
ret = sps30_get_serial(serial);
if (ret)
printf("error %d reading serial\n", ret);
else
printf("SPS30 Serial: %s\n", serial);
ret = sps30_set_fan_auto_cleaning_interval_days(AUTO_CLEAN_DAYS);
if (ret)
printf("error %d setting the auto-clean interval\n", ret);
ret = sps30_start_measurement();
if (ret < 0)
printf("error starting measurement\n");
printf("measurements started\n");
do {
int16_t i;
for (i = 0; i < 10; i++) {
sensirion_sleep_usec(SPS30_MEASUREMENT_DURATION_USEC); /* wait 1s */
ret = sps30_read_measurement(&m);
if (ret < 0) {
printf("error reading measurement\n");
} else {
printf("measured values:\n"
"\t%0.2f pm1.0\n"
"\t%0.2f pm2.5\n"
"\t%0.2f pm4.0\n"
"\t%0.2f pm10.0\n"
"\t%0.2f nc0.5\n"
"\t%0.2f nc1.0\n"
"\t%0.2f nc2.5\n"
"\t%0.2f nc4.5\n"
"\t%0.2f nc10.0\n"
"\t%0.2f typical particle size\n\n",
m.mc_1p0, m.mc_2p5, m.mc_4p0, m.mc_10p0, m.nc_0p5, m.nc_1p0,
m.nc_2p5, m.nc_4p0, m.nc_10p0, m.typical_particle_size);
}
}
} while (1);
if (sensirion_uart_close() != 0)
printf("failed to close UART\n");
return 0;
}
`
from embedded-uart-sps.
Hi @mike197678
It seems that you're using v3.0.0, could you try with the latest release https://github.com/Sensirion/embedded-uart-sps/releases/latest ?
The sensor is made for continuous operation but there are various reasons to not wanting to do this (e.g. power savings or longevity). However, due to internal calibrations it will yield more precise values when running continuously. Thus, as @rnestler suggested, you should run the sensor for at least 30s (and even more is better) before trusting the values.
from embedded-uart-sps.
Hi @abrauchli
hello, yes exactly, version 3.1.0 works with a minute break. Perfect.
Then I can change the break time.
So now I just have to get the values somehow in node-red.!?
from embedded-uart-sps.
Great, thanks for the reply! I'm closing the issue since we won't be able to support you with node-red.
Feel free to open a new one if you think there's an issue with the driver.
from embedded-uart-sps.
Related Issues (20)
- sps30_stop_measurement issuing the wrong command HOT 3
- Adafruit Feather 32u4 Bluefruit LE: Unable to receive data HOT 6
- Distinguish between different SENSIRION_SHDLC_ERR_MISSING_STOP errors HOT 4
- Voltage via UART? HOT 3
- Only getting NaN readings via UART on Raspberry Pi 3 HOT 4
- SPS30 communication on uart HOT 1
- help wanted for SPS30 with UART communication HOT 2
- Atmel SAM4S implementation HOT 2
- Handle SHDLC Execution Error Codes and Device Error Flag properly
- Arduino example wrong #define HOT 2
- Support for Nano 33 BLE Sense HOT 4
- 40: internal function argument out of range HOT 2
- Output format is float values only — integer format not supported HOT 2
- First measurement read in sps30_example_usage.c always fails HOT 1
- Sps30 HOT 1
- UART HAL Recieve HOT 2
- STM32 UART EXAMPLE SPS30 HOT 3
- sensor probing failed HOT 4
- SPS30 with STM32F401 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embedded-uart-sps.