-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add ENS16x (air quality) and ENS210 (temp & RH) sensors #19479
Conversation
Added ENS16x library enabling read-out of ENS160 and ENS161 sensor component (follow-up of CCS811 and iAQcore) Added ENS210 library to read out ENS210 temperature & humidity sensor
Add air quality sensor readout for ENS160 and ENS161 checking two possible I2C addresses (follow up sensor for CCS811 and iAQcore) Add temperature and humidity sensor readout checking two possible I2C addresses
Add USE_ENS16x and USE_ENS210
Add USE_ENS16x and ENS210
Add USE_ENS16x and USE_ENS210
Add USE_ENS16x and USE_ENS210
Add USE_ENS16x and USE_ENS210
Add USE_ENS16x and ENS210
Add USE_ENS16x and USE_ENS210
Corrected I2X number
Corrected I2C number
Please remove *.bak files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally you should have done 2 PR, one for each sensor
ALso please advise code increase and memory increase for each of the drivers for both ESP8266 and ESP32
Thanks
#define USE_ENS16x // [I2cDriver85] Enable ENS160 and ENS161 sensor (I2C addresses 0x52 and 0x53) | ||
#define USE_ENS210 // [I2cDriver86] Enable ENS210 sensor (I2C addresses 0x43 and 0x44) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not enable your drivers by default
Also comment the increase in code size for ESP8266 (and memory too would be great)
Comment those lines so people are aware of what should be used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabled by default, memory information added
BUILDS.md
Outdated
| USE_ENS16x | - | - / x | - | x | - | - | | ||
| USE_ENS210 | - | - / x | - | x | - | - | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not add your drivers by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabled by default, memory information added
#define USE_ENS16x // [I2cDriver85] Enable ENS160 and ENS161 sensor (I2C addresses 0x52 and 0x53) | ||
#define USE_ENS210 // [I2cDriver86] Enable ENS210 sensor (I2C addresses 0x43 and 0x44) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not enable your drivers by default
Also comment the increase in code size for ESP8266 (and memory too would be great)
Comment those lines so people are aware of what should be used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabled by default, memory information added
ScioSense_ENS16x ens16xa(ENS16x_I2CADDR_0); | ||
struct { | ||
uint16_t TVOC; | ||
uint16_t eCO2; | ||
uint16_t AQIS; | ||
|
||
uint8_t ready = 0; | ||
uint8_t type = 0;; | ||
uint8_t tcnt = 0; | ||
uint8_t ecnt = 0; | ||
} ENS16xdataA; | ||
|
||
ScioSense_ENS16x ens16xb(ENS16x_I2CADDR_1); | ||
struct { | ||
uint16_t TVOC; | ||
uint16_t eCO2; | ||
uint16_t AQIS; | ||
|
||
uint8_t ready = 0; | ||
uint8_t type = 0;; | ||
uint8_t tcnt = 0; | ||
uint8_t ecnt = 0; | ||
} ENS16xdataB; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use dynamically allocated memory
This is using memory in any built your driver is included even if no-one is using it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for proposal. I'll try to implement later.
Should I still split the pull request for both sensors? |
Hi @chrfriese123 I find the code increase is quite high. Is the whole libraries needed for each sensors? Thanks |
@chrfriese123 Is the ENS160 working with this driver? Are there development boards available for the ENS210? Where to get and what do the cost? |
@Jason2866 the driver is working with ENS160 and ENS161. TVOC and eCO2 output is the same. Difference is only the air quality output and the low power option for ENS161. |
@barbudor, thanks for suggestion. Ideally I don’t want to diverge too much from the official driver. But I’ll give it a try to reduce to a minimum. |
We don't care about the official driver. What we care about is Flash and RAM usage in tasmota I can confirm that there is a LOT a useless code in that library that you will never be used, starting with all the debug code full of Serial.print : 😱 This is totally forbidden in tasmota as the serial could be in use for something else. I'm trying a first cut down |
Working just on the ENS16x while both are enabled, I get
So gaining 940 bytes on announced 3100 bytes cost (from your own comments) is not neglictable I also see a while loop with an delay(10) inside. That should be totally forbidden on a shared resource system like Tasmota. I understand who you are and totally respect your will to provide an official library to your customers that support maximum of use cases. That work fine for someone who build a a product with a handfull of given sensors with a custom built firmware for that product. Let me now have a look to the ENS210 |
I've seen ENS160 modules at Mouser from Sparkfun and DFrobot but none for ENS210 |
The size cutdown is impressive. The serial.print is indeed a left over from the initial phase. |
@barbudor I haven’t seen a combined eval kit at Aliexpress. Only one with a third party RHT sensor. |
When I was saying "clone" I wasn't talking about hte module/eval-kit. I don't consider Adafruit/Sparkfun/DFRobot to do clones as far as they use legit ScioScience parts. |
Lastest cuts on both libs is now
We are almost at 50% saving in flash and 75% saing in RAM Please have a look at chrfriese123#1 So why is that so huge and also impact the RAM ?
The string is saved in flash but at boot time it is copied to the RAM because the ESP are an modified Harward architecture and you need different instructions to read RAM or Flash. So to simplify the code, all constants are loaded from Flash to RAM. I'll have a look at the Tasmora code now |
2 hours later:
I optimized the Tasmota code:
As you can see, spending a little bit of time helps a lot and leave more room for other stuff. STILL: I am unable to test the changes*, especially the latests ones which may impact more the logic. I hope you will not take offense for my razor cut and will accept the changes Thanks * if ScioSense has some budget for supporting open source projects with a little eval board ... 👀 |
cut down in libs
Thanks, for the cut down and no offence taken. I'll compile the code and run a physical test. * send you a mail |
@chrfriese123 Will you implement the suggestions? |
@Jason2866 I have already done the changes and will test this week end as I have received samples |
@barbudor No hurry, just asking if there is activity done or planned. |
Working so far except for a bug ENS16X's WebDisplay that is crashing the ESP |
Arg, detection of alternate addresses still have a problem |
All good now
ENS16X: +1984 Flash bytes, +24 RAM bytes |
@Jason2866 Still need @chrfriese123 to merge my changes in his repo to see all changes here |
fix ens16x web display
@Jason2866, @barbudor the last changes have been merged in my repo. Thanks for the great support in fixing the code. |
* Add files via upload Added ENS16x library enabling read-out of ENS160 and ENS161 sensor component (follow-up of CCS811 and iAQcore) Added ENS210 library to read out ENS210 temperature & humidity sensor * Add files via upload Add air quality sensor readout for ENS160 and ENS161 checking two possible I2C addresses (follow up sensor for CCS811 and iAQcore) Add temperature and humidity sensor readout checking two possible I2C addresses * Update BUILDS.md Add USE_ENS16x and USE_ENS210 * Update decode-status.py Add USE_ENS16x and ENS210 * Update I2CDEVICES.md Add USE_ENS16x and USE_ENS210 * Update my_user_config.h Add USE_ENS16x and USE_ENS210 * Update support_features.ino Add USE_ENS16x and USE_ENS210 * Update tasmota_configurations.h Add USE_ENS16x and ENS210 * Update tasmota_configurations_ESP32.h Add USE_ENS16x and USE_ENS210 * Update xsns_111_ens16x.ino Corrected I2X number * Update xsns_112_ens210.ino Corrected I2C number * Disable USE_ENS16x and USE_ENS210 by default * Added code size information * cut down in libs * optimize tasmota side * fix ens16x web display * final fix on alternate addresses * update code & RAM usage --------- Co-authored-by: Barbudor <[email protected]>
Description:
Related issue (if applicable): fixes #
Checklist:
NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass