Adafruit BME280 wire length issues

Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Locked
User avatar
EL34
 
Posts: 8
Joined: Tue Jul 05, 2022 4:14 pm

Adafruit BME280 wire length issues

Post by EL34 »

I have a weather station project that is sitting on the bench working great on breadboards.
It is replacing a 20+ year old Dallas one wire weather station

The parts are (See my diagram)
Arduino mega 2560 with a W5100 Ethernet shield piggy backed on top

DS3231 clock for date time on the I2C bus
SSd1306 OLED for display on the I2C bus

Hall effect sensor in a tip bucket rain counter on an Arduino interrupt

The latest Adafruit BME280 sensor for Temp-Humidity-Barometer using this library on the I2C bus (not the old bme280)
#include <Adafruit_BME280.h>

TCA9548A Mux that switches the I2C bus inputs
The mux switches the I2C inputs to read the 3 items that are connected to it

The hall effect sensor just counts each time the .01 inch buckets tips
It is on a 25 foot 3 wire shielded cable with a 10k pull up resistor
It works perfectly with that long 25 foot cable
The interrupt function is the way to go for the hall effect sensor :)
The hall sensor is not on the I2C bus

The Arduino reads the sensors every 15 minutes and writes the data to the SD card that is on the Ethernet shield
I have a vb.net program running on a Desktop that fetches the data from the SD card every 15 minutes
All that works perfectly and has for 3 weeks on the test bench

The problem I am having is that the BME280 needs to be outside, not on the bench :)
Currently it is sitting a few inches away from the Mux
It has been running perfectly 24 hours a day on the bench while I develop this project

I tested putting the BME280 on a 20 foot 4 wire shielded cable with a foil shield
It has to leave the house and go up to where the rain tip bucket is and that is approx. 25 feet

The whole system locks up when it comes time to read the BME280 on that long 25 foot wire
I tried setting the clock speed lower
I went as low as 1000hz and I still have the same issue

I saw somewhere on the web that giving the BME280 it's own 5 volt supply may help?
The Adafruit BME supposed has pull up resistors on the board?

Just wondering what I should try next to read my BME280 on that long wire?

I did not post the code because this seems to be more of a mechanical/electrical issue than a code issue?
Thanks
Attachments
Weather1.png
Weather1.png (585.56 KiB) Viewed 215 times
Weather2.png
Weather2.png (69.73 KiB) Viewed 215 times

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adafruit BME280 wire length issues

Post by dastels »

First, get rid of the multiplexor. It's only needed it you have multiple I2C devices with the same address. The RTC is at address 0x68, the SSD1306 is at 0x3c, and the BME280 is at 0x77. Hence, no need for the multiplexor... it's just complicating both the hardware and software.

For the long cable run with the BME280, have a look at the LTC4311 active terminator: https://www.adafruit.com/product/4756.

Dave

User avatar
EL34
 
Posts: 8
Joined: Tue Jul 05, 2022 4:14 pm

Re: Adafruit BME280 wire length issues

Post by EL34 »

Thanks for the reply Dave
I'll test the setup later today without the mux and check out the LTC4311 active terminator

User avatar
EL34
 
Posts: 8
Joined: Tue Jul 05, 2022 4:14 pm

Re: Adafruit BME280 wire length issues

Post by EL34 »

I removed the mux and mux code from my program and tested it on the bench
All I2C units are working fine without the mux.

I ordered a LTC4311 I2C Extender and it will be here Saturday

Reading the info on the LTC4311, I see this on the Adafruit site
Using this board is easy: connect it to your I2C bus at the beginning of the chain (if you don't have a massively long cable, you can also try at the end of the chain)

With my 20 foot shielded cable, which do you think is best for my situation
Mount it inside with the Arduino or outside at the end of the wire with the BME280?

Thanks for your help

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adafruit BME280 wire length issues

Post by dastels »

I'd try both and see what works best.

Dave

User avatar
EL34
 
Posts: 8
Joined: Tue Jul 05, 2022 4:14 pm

Re: Adafruit BME280 wire length issues

Post by EL34 »

Saw this further into the Adafruit documentation on the pinouts page

We recommend putting the active terminator at the 'start' of your I2C chain, before a long cable (we got the best signal performance that way)

https://learn.adafruit.com/adafruit-ltc ... or/pinouts

If this works ok at the start, it would be better keeping it inside away from humidity
Even though the BME280 will be under a deck out of the rain, but still open to the air to get good temp and humidity readings

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adafruit BME280 wire length issues

Post by dastels »

Yes, that makes sense and is what I had thought as well.

Dave

User avatar
EL34
 
Posts: 8
Joined: Tue Jul 05, 2022 4:14 pm

Re: Adafruit BME280 wire length issues

Post by EL34 »

Thanks for your help on this project
Adding that LTC4311 did the trick for the long cable going to the BME280

It's been running on the bench for several days now without any issues

I am having an issue with the DS3231 clock unit
I can set the DS3231 time when uploading code to the Arduino mega using this line of code

Code: Select all

rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
The clock time will be set to the time on Windows and it keeps perfect time after that

The CR2032 battery measures 3.2 volts
I did disconnect the charge circuit on the DS3231

When I reboot the Arduino via the reset button, it somehow pulls up the time from the last time I set the time via a code upload
The Mega is not connected to the computer via USB, it is running on a 9volt DC wall wart

So for example, if upload code at 12:15pm and now it is 3pm, when I reboot, the DS3231 gets set to 12:15 again
If I upload the code again, the time is set to computer time again

I can start a new thread about this issue if needed?

Here's a pic of the Mega with Ethernet shield and the slave board that has the LTC4311, DS3231 and the Oled display
The BME680 cable and rain gauge Hall sensor cable are shown connected to a small board I piggy backed onto the Mega
The SCL and SDA and 5v +- are also on this small board
Attachments
Weather2.png
Weather2.png (644.98 KiB) Viewed 152 times

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adafruit BME280 wire length issues

Post by dastels »

You only want to set the RTC's time once (ideally) probably with a separate sketch,.

What's happening is that __DATE__ and __TIME__ are compile time constants. Their value reflect when the code was compiled. So in your example they are always 12:15pm. Until you recompile the code anyway.

Dave

User avatar
EL34
 
Posts: 8
Joined: Tue Jul 05, 2022 4:14 pm

Re: Adafruit BME280 wire length issues

Post by EL34 »

So where is that old time being stored?
If the Arduino loses power and it is not connected via USB and then is restarted it should be starting with a clean boot

Is the DS3231 storing that old time?

User avatar
argonblue
 
Posts: 93
Joined: Wed Apr 25, 2012 12:18 am

Re: Adafruit BME280 wire length issues

Post by argonblue »

It's stored in the compiled code of the sketch. Your sketch is calling rtc.adjust with a fixed date and time that is set at compile-time. Every time your sketch restarts, it will repeat that setting with the same compiled-in date and time, overwriting the running RTC values.

If you want to use that method for an initial setting, then you need to run a sketch once that calls rtc.adjust, and then load a "production" sketch, one that never calls rtc.adjust, once your RTC is set to your desired initial setting.

Or you could have an interactive mode that reads a date/time setting from the serial console.

User avatar
EL34
 
Posts: 8
Joined: Tue Jul 05, 2022 4:14 pm

Re: Adafruit BME280 wire length issues

Post by EL34 »

I comment out that line of code after the time has been set and any new code uploads do not contain that line of code

I will have to test all that again to make sure that is what I did.
Maybe I left that code line active after setting the time and uploaded it again

User avatar
EL34
 
Posts: 8
Joined: Tue Jul 05, 2022 4:14 pm

Re: Adafruit BME280 wire length issues

Post by EL34 »

Ok, I must have forgot to comment out that code line after setting the time and uploading

Code: Select all

//rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
I commented out that line and uploaded again
I removed the USB and hooked up a 9 volt wall wart for power

Resetting the Arduino with the reset button, the time was correct after it finished re-booting
Pulling the power plug and then plugging it back in resulted in the correct time also

I think it is time to put the weather sensors outdoors and call this project done
Thanks for your help on this

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”