Taskrun fails on BME280

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Friedrich
New user
Posts: 5
Joined: 02 Nov 2019, 13:12
Location: Frankfurt am Main, Germany

Taskrun fails on BME280

#1 Post by Friedrich » 17 Aug 2021, 10:04

Hi,

I'm trying to trigger a task configured for a BME280 in rules via the TaskRun command. The log shows the execution of the command, but the plugin doesn't return any values.

Same goes for the command issued over HTTP and MQTT. Only by issuing the TaskEnable command I get the sensor value. As I haven't experienced no problem with other sensors, I wondered if I'm missing something about the BME280 plugin.

Running ESPEasy version ESP_Easy_mega_20210802_normal_ESP32_4M316k on a ESP32-WROVER-B, using the standard I2C pins 4 and 5. Tested with 400kHz and 100kHz.

Best regards
Friedrich

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Taskrun fails on BME280

#2 Post by Ath » 17 Aug 2021, 11:02

I assume you are using the current BMx280 plugin? That also supports the BMP280?

That plugin will only return values if there are actual new measurements available.
If it works, does it also supply the Pressure value? As that is only returned on the BME280 and not on the BMP280.

It does turn up as intended on the I2C Scanner page?

Have you tried an older build (which ones?, you could try the 20210223 or 20210114 builds please), and does it work as expected with that build?
/Ton (PayPal.me)

Friedrich
New user
Posts: 5
Joined: 02 Nov 2019, 13:12
Location: Frankfurt am Main, Germany

Re: Taskrun fails on BME280

#3 Post by Friedrich » 17 Aug 2021, 12:12

Hello Ath,

thanks for the reply.

Sorry, I'm using the BMP280.

Yes, it appears on the I2C scanner page. On normal operation all values are returned.

I just tested it with the 20210114 build. Same behaviour.
That plugin will only return values if there are actual new measurements available.
Is there any event associated with the availability of values without the task running? So, I could use it as trigger in rules.

As I disconnected the sensor from the data lines I noticed the repeating message "BMx280 : Unable to detect chip ID (255, failed)" in the log. Does the plugin constantly communicate with the sensor?

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Taskrun fails on BME280

#4 Post by Ath » 17 Aug 2021, 12:25

The plugin indeed tries to get a measurement every second, and drops that message if it can't read it. And the message is telling that you are using the correct plugin (P028) ;)

Not sure why, with the sensor connected, it doesn't get the data though, it then just collects the last measurement it made, unless it is at that moment in the process of getting a new measurement... (i.e. 'busy'). But that would probably be too much of a coincidence happening ever time you run that TaskRun command or the automatic Interval fetches the data.

Can't say yet if I really understand what's going on here. :o
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Taskrun fails on BME280

#5 Post by TD-er » 17 Aug 2021, 15:37

As mentioned before, it is best to use the BMx280 plugin, as that one has been developed and tested extensively.
The BMP280 plugin should be removed as it is no longer needed now that the BMx280 supports both BME280 and BMP280.
The difference between both is not the air pressure, but the availability of the humidity sensor.

If the sensor does work when using the timed interval, then we can be sure the sensor is actually working.
The BMx280 plugin does use some tricks to make sure that performing a measurement is not blocking code execution on the ESP.
So it initiates a measurement and re-schedules itself a few moments later to collect the sample data.

This means it may take some time between calling taskrun and actually receiving the data.
But it also puts a limit on the minimal reading interval.
I can imagine it may return unexpected results if the set interval is < 2 seconds, or if "taskrun" is called within 2 seconds from a periodical read.

If you're seeing lots of "BMx280 : Unable to detect chip ID (255, failed)" errors, please perform an I2C scan if that happens.
It could be that the I2C bus is hanging.
If that happens, then all I2C addresses will show an error.

Is there another sensor/device connected to the same I2C bus?
What cable length do you use for the I2C bus?

Friedrich
New user
Posts: 5
Joined: 02 Nov 2019, 13:12
Location: Frankfurt am Main, Germany

Re: Taskrun fails on BME280

#6 Post by Friedrich » 17 Aug 2021, 19:53

Hi Gijs,

after rechecking with an ESP and the sensor hooked to it with 10cm wires I got the same behaviour. You confirm my suspicions that it's a timing thing coming from the sensor. With TaskEnable it takes about 2,5 secs to get the values, which I can live with. If I need it faster I'll switch to some sensors like DHT22 or SI7021 (100 to 130ms). Though I will check the I2C bus anyway as well as sensors from other suppliers, to be sure.

But so far from the 6 sensors (and plugins) I'm just working on, only the BMP280 shows this behaviour. In my first test setup I'm worked with simple ribbon cable of 80cm length and I2C at 400kHZ. So far I had no problems regarding the responsiveness.

I'm multiplexing sensor data lines using two CD74HC4067. Goal is to have a patch panel where I can plug in a sensor (I2C or others like DHT22) in any free slot and setting it up in node-red by just entering the slot number and an associated ESPEasy task number. By means of MQTT Import and rules I can select the sensor slot setting the GPIOs for the multiplexer channel. Subsequently I run an accordingly preconfigured plugin task. Just now I'm only dealing with only 30 sensor but that will go up to 200 sensors. In quickly varying measurement setups this approach saves me some configuration work and gives me a lot of flexibility. Moreover I spare task slots since I can hook up multiple sensors of one type to the same task. Thanks to MQTT import and the rules with their timers the software side of the implementation is a cakewalk. ESPEasy just rocks!

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Taskrun fails on BME280

#7 Post by TD-er » 17 Aug 2021, 20:36

There is a number of things you can try to change to get a more reliable I2C communication.

- Add 2 pull-up resistors from SDA and SCL to the 3v3 line. Some sensor boards already have some present. Typical 10k pull-up on those boards. Try 4k7. No lower than roughly 2k.
- Use shorter wire. I2C should not be used over a few decimeter long cables.
- Add an 100nF capactor as close as possible to the sensor's power pins (between Vcc and GND)
- Do not use a star network for I2C.

Also I just looked at the CD74HC4067 datasheet.
The input rise and fall times is quite high already.
2V => 1000 ns (max)
4.5V => 500 ns (max)

So at 3.3V it is probably somewhere in the middle.
I think it will make it hard to reach 400 kHz, even when using low resistance pull-up resistors and short wires.
Both high pull-up resistance (10k or more) and long wires will not help here too.

If you need to read lots of temperatures with reasonable fast read intervals, I suggest to look at the Dallas sensors.
Those can be read at 12 bit every second and they will be read at the same time (upto 4 in the same task, start at the same time)

I'm not sure if reading humidity is even useful at such a high rate.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 32 guests