jxl77
January 19, 2024, 12:38pm
1
I am using BME280 sensor library with ESPhome, but want to make a small change in the library file
esphome->config->.esphome->build->dev1->src->esphome->components->bme280->bme280.cpp
I removed
.esphome->build->dev1->.pioenvs->dev1->src->esphome->components->bme280
this forced a new compilation of bme280
but it obviously did not used the modified bme280.cpp
How can I do that in a simple way ?
You need to use external components to do that.
jxl77
January 19, 2024, 4:51pm
3
Thanks Dilbert,
I understand now that external components is the way to go.
But I I dont understand precisely the way to do it, even after reading carefully the doc.
I made a jxl_components directory where I copied the bme280 folder (with my modif)
Where should I put this folder ?
I put it in
esphome->config
and put in the yaml file
external_components:
- source:
type: local
path: jxl_components
# Example configuration entry
sensor:
- platform: bme280
temperature:
name: "BME280 Temperature"
oversampling: 16x
accuracy_decimals: 3
pressure:
name: "BME280 Pressure"
accuracy_decimals: 2
humidity:
name: "BME280 Humidity"
accuracy_decimals: 2
address: 0x76
update_interval: 5s
but it doe not work. I have
INFO ESPHome 2023.12.5
INFO Reading configuration /config/dev1.yaml...
Failed config
sensor.bme280: [source <unicode string>:45]
Platform not found: 'sensor.bme280'.
where should I put it ?
jxl77
January 19, 2024, 9:13pm
4
I have found my mistake
the jxl_components neds indeed to be put in
config/jxl_compponents
but my mistake was to put only the cpp files (and .h), while one needs to put all the content of the repository, including the .py files
then with the yaml content
then include in the yaml file
external_components:
- source:
type: local
path: jxl_components
# components: [ bme280_base, bme280_i2c ]
# Example configuration entry
sensor:
- platform: bme280_i2c
temperature:
name: "BME280 Temperature"
oversampling: 16x
accuracy_decimals: 3
pressure:
name: "BME280 Pressure"
accuracy_decimals: 2
humidity:
name: "BME280 Humidity"
accuracy_decimals: 2
address: 0x76
update_interval: 5s
everything works.
I have now full precision ( 3 decimals) on the bme280
by changing
// float temperature = (*t_fine * 5 + 128) >> 8;
// return temperature / 100.0f;
return ((float)(*t_fine * 5 + 128)/25600);