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

How to make a fixed relationship between device index and the real device? #15

Open
Pepito-design opened this issue Apr 16, 2024 · 2 comments

Comments

@Pepito-design
Copy link

Hi,
great work and it works fine ( ESP32 S3 ).
I have a bunch of temp sensors on specific places around a engine ( oil, water on different places ).
I want to give each sensor a specific (fixed) name ( e.g. oil ) to index mapping ..... should be valid after reboot / power of-on.
So I have to save the mapping in EEProm, SD card or LittleFS.
But ... index is not always the same for each sensor.
So currently it mixed up a little bit.

Question is, what is the easiest way to make that happen?
Need some kind of first time learn procedure I think.
Thinking about the following:

only ones ( learning phase )
remove all sensors from bus
for each temp sensor
     output sensor position on engine
     connect that sensor to the bus
     map sensor name / position / id  to the device address we have got
     save on EEProm , SD card or LittleFS

For the normal use afterwards:

load the saved data ( name / position /index to device address mapping )
use the saved data, report missing and new devices ( request new learn procedure in that case )

At the moment I'm struggling with that, think I'm not alone ...... :-)

How to make it simple with given functionality ...... at the moment I'm thinking too complex I think ....

@oopen
Copy link
Collaborator

oopen commented Apr 19, 2024

Hi,

Yes what you describe is the next step.

We need a mechanism to describe the expected sensors named list,
for etch sensor/item minimum elements are :

  1. DeviceAddress or DeviceAddressString (depend on storage format, I suggest using DeviceAddressString)
  2. Human readable name

Storing in this list "sensor index" si not required, and not usefull because this index can change (adding/replacing sensor ...) Using DeviceAddressString or Human-readable-name in place of index.

We need to implement a "learning procedure" & "editing procedure" by using :

  • Serial : Simple because it can prompt directly. I recommend this way.
  • WiFi : less simple, can impact program.
  • Bluetooth : more complex, need application ...

I have write the base functions, in prevision for this functionality :

### Apply on real sensors

uint8_t getSensorsCount();
bool validateAddressesRange(DeviceAddress addressesRangeToValidate[], uint8_t numberOfAddresses, bool exclusiveListSet = true);
bool validateAddressesRange(String addressesStrings[], uint8_t numberOfAddresses, bool exclusiveListSet = true);
void mapIndexPositionOfDeviceAddressRange(DeviceAddress addressesRangeToValidate[], uint8_t numberOfAddresses, int8_t mapedPositions[]);

The mapIndexPositionOfDeviceAddressRange() function was written for this purpose.

I have no time for now to write the missing functions to implement a learning & a modification procedure.

But it can't be difficult, the base is done.

See file examples/AdditionalFunctions/AdditionalFunctions.ino it is a draft to test all functions, and show usage of it.

Do to want to monitor a car ? a electric generator ?

@Pepito-design
Copy link
Author

Hi,
thanks, you understand my requirement exactly :-) Thanks
Concerning your question, motorbike and electric generator, 2 projects with ESP32 S3.
I agree, a learning phase per serial monitor is a good step. Based on that .... everybody can do his own stuff,
LCD, WEB, BlueTooth or whatever. House automation may have similar requirements.
Thanks again for your excellent solution. :-)

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