I have it set to 57600. Soooo... I'm gonna let you in on a little secret, and you may have picked up on this already but...
I don't know how to code.
You'd be surprised how often I can chop up various bits of coding and, with a bit of knowledge about syntax and knowing how to find the functions of different libraries, get it to work.
Most of the time it's not too bad troubleshooting, but this one is really throwing me for a loop.
This was 2 examples chopped up and Frankenstein'd together.
First we have the "I2CDemo" from the Zanshin_BME680 library:
/*! @file I2CDemo.ino
@section I2CDemo_intro_section Description
Example program for using I2C to set and read the Bosch BME680 sensor. The sensor measures
temperature, pressure and humidity and is described at
https://www.bosch-sensortec.com/bst/products/all_products/BME680. The datasheet is available from
Bosch at https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME680_DS001-11.pdf \n\n
The most recent version of the BME680 library is available at https://github.com/Zanduino/BME680
and the documentation of the library as well as example programs are described in the project's wiki
pages located at https://github.com/Zanduino/BME680/wiki. \n\n
The BME680 is an extremely small physical package that is so tiny as to be impossible to solder at
home, hence it will be used as part of a third-party breakout board. There are several such boards
available at this time, for example \n
| Company | Link |
| ------- | ---------- |
| Sparkfun | https://www.sparkfun.com/products/14570 |
| BlueDot | https://www.bluedot.space/sensor-boards/bme680/ |
| Adafruit |
https://learn.adafruit.com/adafruit-BME680-humidity-barometric-pressure-temperature-sensor-breakout
|
\n\n
Bosch supplies sample software that runs on various platforms, including the Arduino family; this
can be downloaed at https://github.com/BoschSensortec/BSEC-Arduino-library . This software is part
of the Bosch "BSEC" (Bosch Sensortec Environmental Cluster) framework and somewhat bulky and
unwieldy for typical Arduino applications, hence the choice to make a more compact and rather less
abstract library.
This example program initializes the BME680 to use I2C for communications. The library does not
using floating point numbers to save on memory space and computation time. The values for
Temperature, Pressure and Humidity are returned in deci-units, e.g. a Temperature reading of "2731"
means "27.31" degrees Celsius. The display in the example program uses floating point for
demonstration purposes only. Note that the temperature reading is generally higher than the ambient
temperature due to die and PCB temperature and self-heating of the element.\n\n
The pressure reading needs to be adjusted for altitude to get the adjusted pressure reading. There
are numerous sources on the internet for formulae converting from standard sea-level pressure to
altitude, see the data sheet for the BME180 on page 16 of
http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf. Rather than put a floating-point
function in the library which may not be used but which would use space, an example altitude
computation function has been added to this example program to show how it might be done.
@section I2CDemolicense License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version. This program is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
received a copy of the GNU General Public License along with this program. If not, see
<http://www.gnu.org/licenses/>.
@section I2CDemoauthor Author
Written by Arnd <Arnd@Zanduino.Com> at https://www.github.com/SV-Zanshin
@section I2CDemoversions Changelog
| Version | Date | Developer | Comments
| ------- | ---------- | ---------- | ------------------------------------------------------------ |
| 1.0.3 | 2020-07-04 | SV-Zanshin | Issue #25 implement clang-formatting |
| 1.0.2 | 2020-05-09 | SV-Zanshin | Issue #8 clean up comments and code |
| 1.0.1 | 2019-01-30 | SV-Zanshin | Removed old comments |
| 1.0.1 | 2019-01-26 | SV-Zanshin | Issue #3 convert documentation to Doxygen |
| 1.0.0b | 2018-06-30 | SV-Zanshin | Cloned from original BME280 program |
*/
#include "Zanshin_BME680.h" // Include the BME680 Sensor library
/**************************************************************************************************
** Declare all program constants **
**************************************************************************************************/
const uint32_t SERIAL_SPEED {
115200
}; ///< Set the baud rate for Serial I/O
/**************************************************************************************************
** Declare global variables and instantiate classes **
**************************************************************************************************/
BME680_Class BME680; ///< Create an instance of the BME680 class
///< Forward function declaration with default value for sea level
float altitude(const int32_t press, const float seaLevel = 1013.25);
float altitude(const int32_t press, const float seaLevel) {
/*!
@brief This converts a pressure measurement into a height in meters
@details The corrected sea-level pressure can be passed into the function if it is known,
otherwise the standard atmospheric pressure of 1013.25hPa is used (see
https://en.wikipedia.org/wiki/Atmospheric_pressure) for details.
@param[in] press Pressure reading from BME680
@param[in] seaLevel Sea-Level pressure in millibars
@return floating point altitude in meters.
*/
static float Altitude;
Altitude =
44330.0 * (1.0 - pow(((float)press / 100.0) / seaLevel, 0.1903)); // Convert into meters
return (Altitude);
} // of method altitude()
void setup() {
/*!
@brief Arduino method called once at startup to initialize the system
@details This is an Arduino IDE method which is called first upon boot or restart. It is only
called one time and then control goes to the main "loop()" method, from which
control never returns
@return void
*/
Serial.begin(SERIAL_SPEED); // Start serial port at Baud rate
#ifdef __AVR_ATmega32U4__ // If this is a 32U4 processor, then wait 3 seconds to init USB port
delay(3000);
#endif
Serial.print(F("Starting I2CDemo example program for BME680\n"));
Serial.print(F("- Initializing BME680 sensor\n"));
while (!BME680.begin(I2C_STANDARD_MODE)) { // Start BME680 using I2C, use first device found
Serial.print(F("- Unable to find BME680. Trying again in 5 seconds.\n"));
delay(5000);
} // of loop until device is located
Serial.print(F("- Setting 16x oversampling for all sensors\n"));
BME680.setOversampling(TemperatureSensor, Oversample16); // Use enumerated type values
BME680.setOversampling(HumiditySensor, Oversample16); // Use enumerated type values
BME680.setOversampling(PressureSensor, Oversample16); // Use enumerated type values
Serial.print(F("- Setting IIR filter to a value of 4 samples\n"));
BME680.setIIRFilter(IIR4); // Use enumerated type values
Serial.print(F("- Setting gas measurement to 320\xC2\xB0\x43 for 150ms\n")); // "�C" symbols
BME680.setGas(320, 150); // 320�c for 150 milliseconds
} // of method setup()
void loop() {
/*!
@brief Arduino method for the main program loop
@details This is the main program for the Arduino IDE, it is an infinite loop and keeps on
repeating. The "sprintf()" function is to pretty-print the values, since floating
point is not supported on the Arduino, split the values into those before and those
after the decimal point.
@return void
*/
static int32_t temp, humidity, pressure, gas; // BME readings
static char buf[16]; // sprintf text buffer
static float alt; // Temporary variable
static uint16_t loopCounter = 0; // Display iterations
if (loopCounter % 25 == 0) { // Show header @25 loops
Serial.print(F("\nLoop Temp\xC2\xB0\x43 Humid% Press hPa Alt m Air m"));
Serial.print(F("\xE2\x84\xA6\n==== ====== ====== ========= ======= ======\n")); // "�C" symbol
} // if-then time to show headers
BME680.getSensorData(temp, humidity, pressure, gas); // Get readings
if (loopCounter++ != 0) { // Ignore first reading, might be incorrect
sprintf(buf, "%4d %3d.%02d", (loopCounter - 1) % 9999, // Clamp to 9999,
(int8_t)(temp / 100), (uint8_t)(temp % 100)); // Temp in decidegrees
Serial.print(buf);
sprintf(buf, "%3d.%03d", (int8_t)(humidity / 1000),
(uint16_t)(humidity % 1000)); // Humidity milli-pct
Serial.print(buf);
sprintf(buf, "%7d.%02d", (int16_t)(pressure / 100),
(uint8_t)(pressure % 100)); // Pressure Pascals
Serial.print(buf);
alt = altitude(pressure); // temp altitude
sprintf(buf, "%5d.%02d", (int16_t)(alt), ((uint8_t)(alt * 100) % 100)); // Altitude meters
Serial.print(buf);
sprintf(buf, "%4d.%02d\n", (int16_t)(gas / 100), (uint8_t)(gas % 100)); // Resistance milliohms
Serial.print(buf);
delay(10000); // Wait 10s
} // of ignore first reading
} // of method loop()
And then we have "SerialDisplay" from the Adafruit LiquidCrystal library.
/*
LiquidCrystal Library - Serial Input
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.
This sketch displays text sent over the serial port
(e.g. from the Serial Monitor) on an attached LCD.
The circuit:
LCD RS pin to digital pin 12
LCD Enable pin to digital pin 11
LCD D4 pin to digital pin 5
LCD D5 pin to digital pin 4
LCD D6 pin to digital pin 3
LCD D7 pin to digital pin 2
10K resistor:
ends to +5V and ground
wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 25 July 2009
by David A. Mellis
http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/
// include the library code:
#include "Wire.h"
#include "Adafruit_LiquidCrystal.h"
// initialize the library with the numbers of the interface pins
Adafruit_LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// initialize the serial communications:
Serial.begin(9600);
}
void loop()
{
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}
}