Skip to content

Conversation

@Radyr
Copy link
Contributor

@Radyr Radyr commented Sep 10, 2025

My first attempt at a module for the Sensiron SCD40.

It should also work with the SCD41 and SCD43 but not tested as I dont have those to hand.

@gfwilliams
Copy link
Member

This looks great, thanks! Please could you convert:

  REQUEST_SINGLE_LOOKUP : Uint8Array([0x219d>>8,0x219d]),
  REQUEST_SINGLE_LOOKUP_RHT : Uint8Array([0x2196>>8,0x2196]),
  // and so on

to just:

  REQUEST_SINGLE_LOOKUP : [0x21,0x9d]),
  REQUEST_SINGLE_LOOKUP_RHT : [0x21,0x96]),
  // and so on

While Uint8Array is good for big arrays of bytes, there's quite a bit of overhead for just storing 2 bytes worth of data, so in this case just storing the data in a standard array should be a lot better.

@Radyr
Copy link
Contributor Author

Radyr commented Sep 10, 2025

Thats useful to know, it also looks a lot nicer

@gfwilliams
Copy link
Member

Thanks! I've just changed the code a bit though, because as you had it you were still putting the full 16 bit data into the second array item (when what you really wanted was just the low 8 bits).

I'm pretty sure it's ok, but please could you give it a test? Changes I made are e46466e

@Radyr
Copy link
Contributor Author

Radyr commented Sep 11, 2025

Apologies, I didnt spot the change of the values. I was in two minds to do that initially.

I've tested it against the chip and getting good results still

@Radyr
Copy link
Contributor Author

Radyr commented Sep 11, 2025

I was having another think about the measurements. Should the raw data also be returned?

I haven't looked into it, but I'm guessing it might be more efficient to store the data as returned from the sensor, rather than the converted values.

@gfwilliams
Copy link
Member

I think what you're doing (sending back the converted data) is absolutely fine. If someone really wants the raw data they can always modify it later or access the sensor via I2C themselves.

@gfwilliams gfwilliams merged commit 89da563 into espruino:master Sep 12, 2025
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

Successfully merging this pull request may close these issues.

2 participants