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

Sensor_SHT85: handle multiple sensors and multiple wires and multiple I2C modules #16

Open
1 of 3 tasks
mitra42 opened this issue Sep 21, 2024 · 4 comments
Open
1 of 3 tasks

Comments

@mitra42
Copy link
Owner

mitra42 commented Sep 21, 2024

Sensor_SHT85 is tested for a single sensor - my test hardware is a SHT30 shield plugged into an Lolin D1 mini, using its default address of 0x45

It would be a more generically useful module if it could.

  • a: support multiple sensors - e.g. one at 0x45 and one at 0x44
  • b: support multiple wires - e.g. a sensor at 0x45 on one set of pins, and another on a different set of pins
  • c: was able to work with other sensors on the same I2C - i.e. not restarting the Wire.

This will require some cleverness - some notes below.

@mitra42
Copy link
Owner Author

mitra42 commented Sep 21, 2024

a: support multiple sensors - e.g. one at 0x45 and one at 0x44

How do we load the module twice, ideally without duplicating the code. I can see different ways to tackle this, but they might not work
a1: via defines so the module is loaded more than once, but I don't think this will work well with the way the Arduino IDE compiles each cpp, the cpp file isnt "included" like the .h is.
a2: splitting the sensor_SHT85 into something like a library that exists once and something trivial that can be loaded multiple times that calls it (like sensor_SHT85 itself calls the SHT library). But we still have the challenge of how to do this structurally.

UPDATE: Solved by a different method - passing an _ARRAY version of the addresses to sensor_SHT85.cpp this should be extendable to other sensors

@mitra42
Copy link
Owner Author

mitra42 commented Sep 21, 2024

c: was able to work with other sensors on the same I2C - i.e. not restarting the Wire.

I think the wires can be supported by splitting the Wire setup into a separate module (system_wire) and only including its header and setup() if any module that needs it is used. (this would happen in _settings.h)

@mitra42
Copy link
Owner Author

mitra42 commented Sep 21, 2024

b: support multiple wires - e.g. a sensor at 0x45 on one set of pins, and another on a different set of pins

This is a similar problem to "a1" we need to include multiple instances of the Wire and setup() them all.

@mitra42
Copy link
Owner Author

mitra42 commented Oct 4, 2024

This module has been reorganized to make it easier to do things like above. Now defines a wrapper class for the SHT85 library

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

No branches or pull requests

1 participant