Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embassy support #2

Open
JYouren opened this issue Jan 14, 2025 · 8 comments
Open

Embassy support #2

JYouren opened this issue Jan 14, 2025 · 8 comments

Comments

@JYouren
Copy link

JYouren commented Jan 14, 2025

Hi,

I'm fairly new to rust, and am working slowly through implementing this repo in my embassy project. I have the bme680 = "0.6.0" crate working correctly (which I believe this project supports?). Will this crate work with embassy (on a raspberry pi pico) do you know?

@jgosmann
Copy link
Owner

I'm not familiar with embassy. So I cannot say for sure. But the main crate is only a wrapper around the Bosch BSEC library and should be independent of any framework. The bme680 feature makes use of embedded-hal. If that integrates with embessay, it should be possible to use, otherwise you'd need to implement the BmeSensor trait yourself. But as you're saying that you have the bme680 crate working, it seems that bsec should work with embassy.

@JYouren
Copy link
Author

JYouren commented Jan 15, 2025

Thank you for your prompt response. I will investigate the embassy part, but I know I definitely don't have access to std.

How does this library get access to the bme680, is it the bme680 instance I create through the crate I'm already using:

let mut bsec: Bsec<_, TimePassed, _> = Bsec::init(sensor, &clock)?;

Is there anything special I need to configure on my bme680 to ensure it activates the gas sensor etc?

@jgosmann
Copy link
Owner

Here's an example (without embassy). You need to create a bme680::Bme680 instance as described in the bme680 documentation. With this you can then create a Bme680SensorBuilder, set initial ambient temperature and a temperature offset, call build on it and pass the resulting sensor to Bsec::init as you're doing in the line you put into you past.

Is there anything special I need to configure on my bme680 to ensure it activates the gas sensor etc?

It's been a while since I played around with it, so I'm not entirely sure. But I don't seem to do anything special in the example I provided. I suppose, BSEC does that by itself.

@JYouren
Copy link
Author

JYouren commented Jan 18, 2025

Thanks. I spent some time on this, and made some progress with using the cross crate to build for my environment. But I didn't realise this repo uses std which isn't available on constrained devices e.g.

error[E0463]: can't find crate for std
--> /mnt/c/Users/johny/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bsec-0.5.0+1.4.9.2/src/lib.rs:186:5
|
186 | use std::time::Duration;
| ^^^ can't find crate
|
= note: the thumbv6m-none-eabi target may not support the standard library

@JYouren
Copy link
Author

JYouren commented Jan 20, 2025

I appreciate I'm going off topic here, but do you know if the output of cross build --target can be captured, and I'll fix up the std references myself?

@jgosmann
Copy link
Owner

Unfortunately, I'm not familiar with cross.

But I suppose you can grep for use std:: in the bsec crate or just look through the few files. It's unfortunately a few reference to std and I'm not sure they can be eliminated in all cases.

@JYouren
Copy link
Author

JYouren commented Jan 21, 2025

Yep, that one should be easy. But first I need to get the output from libalgobsec-sys as it seems to dynamically generate the BSEC bindings. I'm looking into how I can get that to then convert from std to embassy.

@jgosmann
Copy link
Owner

The output directory is obtained here from the OUT_DIR environment variable. According to the documentation:

OUT_DIR — the folder in which all output and intermediate artifacts should be placed. This folder is inside the build directory for the package being built, and it is unique for the package in question.

If you can't find it that way, you could also try to change the build script to use another directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants