finitespace / BME280

Provides an Arduino library for reading and interpreting Bosch BME280 data over I2C, SPI or Sw SPI.
GNU General Public License v3.0
212 stars 105 forks source link

Softwarewire #82

Open finitespace opened 6 years ago

finitespace commented 6 years ago

Related issue # and issue behavior

A request was made to add SoftwareWire to the library. #79

Description of changes/fixes

Added BME280I2CSoftwareWire.h/cpp. Added Config.h

@mention a person to review

@daniu-de, please review the functionality of the new additions.

Steps to test

Uncomment line 32 in Config.h: #define USING_SOFTWARE_WIRE 1 Build and run the BME_280_I2C_SoftwareWire_Test.ino sketch on a live setup.

Any outstanding TODOs or known issues

Needs testing.

finitespace commented 6 years ago

TODO: Update documentation.

daniu-de commented 6 years ago

Hi, THANKS A LOT!!!!

unfortunately I am getting a compilation error: BME_280_I2C_SoftwareWire_Test.ino: In function ‘void setup()’: BME_280_I2C_SoftwareWire_Test.ino:37:9: error: no match for ‘operator!’ (operand type is ‘TinyDebugSerial’) BME_280_I2C_SoftwareWire_Test.ino:37:9: note: candidate is: BME_280_I2C_SoftwareWire_Test.ino:37:9: note: operator!(bool) BME_280_I2C_SoftwareWire_Test.ino:37:9: note: no known conversion for argument 1 from ‘TinyDebugSerial’ to ‘bool’

However I am pretty sure that I cannot properly test it this way because I do not know how to connect the sensor directly to the raspberry and see no way to see the print output - I am using tinytx3 nodes - originally created by Nathan Chantrell and I need a RFM69CW module which sends the sensor data to a receiver which is connected to a raspberry pi. This way I can read the sensor data with a raspberry pi. I got a working Sketch for HTU21D sensor which I will change so that it sends the data of a BME280.

When I succeed to make it send the data I can post the working sketch.

At the moment my sketch gives me the following error: /root/sketchbook/libraries/BME280/BME280.cpp:31:18: fatal error: Wire.h: Datei oder Verzeichnis nicht gefunden

include

which surprises me since Wire.h should be in the path. However I am also not sure that it is right that the sketch is asking for Wire.h

finitespace commented 6 years ago

@daniu-de, what compiler/settings are you using to compile this?

The first error is because the !Serial is not supported for TinyDebugSerial. You can probably just delete line 42.

include is old code from the original version 1.0, I have removed it and committed. I was not able to compile it yet though. I will compile it when I am hope tonight (I don't think it should cause any issues).

daniu-de commented 6 years ago

Hi, hmmm ... not sure about the settings. I use arduino IDE set to attiny84 with 1Mhz

The #include Wire.h is also in BMEI2C.cpp and by commenting out this line I get:

/root/sketchbook/libraries/BME280/BME280I2C.cpp: In member function ‘virtual bool BME280I2C::WriteRegister(uint8_t, uint8_t)’: /root/sketchbook/libraries/BME280/BME280I2C.cpp:71:3: error: ‘Wire’ was not declared in this scope Wire.beginTransmission(m_settings.bme280Addr); ^ /root/sketchbook/libraries/BME280/BME280I2C.cpp: In member function ‘virtual bool BME280I2C::ReadRegister(uint8_t, uint8_t*, uint8_t)’: /root/sketchbook/libraries/BME280/BME280I2C.cpp:90:3: error: ‘Wire’ was not declared in this scope Wire.beginTransmission(m_settings.bme280Addr);

finitespace commented 6 years ago

I have committed some changes that should fix the wire includes.

daniu-de commented 6 years ago

Hi, sorry - I still got a problem: BME_280_I2C_SoftwareWire_Test.ino: In function ‘void setup()’: BME_280_I2C_SoftwareWire_Test.ino:37:9: error: no match for ‘operator!’ (operand type is ‘TinyDebugSerial’) BME_280_I2C_SoftwareWire_Test.ino:37:9: note: candidate is: BME_280_I2C_SoftwareWire_Test.ino:37:9: note: operator!(bool) BME_280_I2C_SoftwareWire_Test.ino:37:9: note: no known conversion for argument 1 from ‘TinyDebugSerial’ to ‘bool’

(that is your sketch)

mine shows the follwing error in this line: ->SoftwareWire softwareWire(SDA, SCK); BME280I2CSoftwareWire bme(softwareWire);

Error: /usr/share/arduino/Send_BME280_n.ino:104: undefined reference to `BME280I2CSoftwareWire::BME280I2CSoftwareWire(SoftwareWire&, BME280I2C::Settings const&)'

daniu-de commented 6 years ago

Another issue I am having with my own sketch is: /usr/lib/gcc/avr/4.9.2/../../../avr/bin/ld: Send_BME280_n.cpp.elf section .text' will not fit in regiontext' /usr/lib/gcc/avr/4.9.2/../../../avr/bin/ld: region `text' overflowed by 1408 bytes

Is it possible that BME280 like that uses up a bit much memory?

finitespace commented 6 years ago
Sketch uses 3308 bytes (40%) of program storage space. Maximum is 8192 bytes.
Global variables use 153 bytes (29%) of dynamic memory, leaving 359 bytes for local variables. Maximum is 512 bytes.

I was able to compile the example for Attiny84 after commenting out the Serial calls.

Attiny does not support the "Serial" library, so those calls will have to be removed.

Error: /usr/share/arduino/Send_BME280_n.ino:104: undefined reference to `BME280I2CSoftwareWire::BME280I2CSoftwareWire(SoftwareWire&, BME280I2C::Settings const&)'

Is because you need to modify the "Config.h" file to #define USING_SOFTWARE_WIRE 1 and make sure all other defines in the file are commented out.