Hi everyone, I've setup a DS1307 breakout board from adafruit
and a BME280 Temp+humidity+pressure breakoutboard from adafruit in i2c on a teensy3.1. I can get them to work individually but when both are plugged in, only the BME280 is communicating.
However, when i initially power the teensy, the RTC time will show only for the first cycle of the loop. Can anyone tell me where do i setup the i2c addresses for the chips, or point me in the right direction. I know the BME280 address is 0x77 and the DS1307 is 0x68. I also have pull up resistors for both ( i know i should take two out).
Thanks for the help.
and a BME280 Temp+humidity+pressure breakoutboard from adafruit in i2c on a teensy3.1. I can get them to work individually but when both are plugged in, only the BME280 is communicating.
However, when i initially power the teensy, the RTC time will show only for the first cycle of the loop. Can anyone tell me where do i setup the i2c addresses for the chips, or point me in the right direction. I know the BME280 address is 0x77 and the DS1307 is 0x68. I also have pull up resistors for both ( i know i should take two out).
Thanks for the help.
Code:
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include "ILI9341_t3.h"
#include <TimeLib.h>
#include <DS1307RTC.h>
#define SEALEVELPRESSURE_HPA (1013.25)
#define TFT_DC 9
#define TFT_CS 10
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC);
int rly1 = 14;
int rly2 = 15;
int rly3 = 16;
int rly4 = 17;
Adafruit_BME280 bme; // I2C
unsigned long delayTime;
void setup() {
pinMode(rly1, OUTPUT);
pinMode(rly2, OUTPUT);
pinMode(rly3, OUTPUT);
pinMode(rly4, OUTPUT);
Serial.begin(9600);
Serial.println(F("BME280 test"));
tft.begin();
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(2);
tft.println("Waiting for Arduino Serial Monitor...");
bool status;
// default settings
status = bme.begin();
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
Serial.println("-- Default Test --");
delayTime = 1000;
Serial.println();
}
void loop() {
TimeRead();
printValues();
if (bme.readTemperature() *9/5 + 32 < 83) {
digitalWrite(rly1, HIGH);
}else{
digitalWrite(rly1, LOW);
}
delay(5000);
}
void TimeRead() {
tmElements_t tm;
if (RTC.read(tm)) {
Serial.print("Time = ");
Serial.print(tm.Hour);
Serial.write(':');
Serial.print(tm.Minute);
Serial.write(':');
Serial.print(tm.Second);
Serial.print(", Date (D/M/Y) = ");
Serial.print(tm.Day);
Serial.write('/');
Serial.print(tm.Month);
Serial.write('/');
Serial.print(tmYearToCalendar(tm.Year));
Serial.println();
} else {
if (RTC.chipPresent()) {
Serial.println("The DS1307 is stopped. Please run the SetTime");
Serial.println("example to initialize the time and begin running.");
Serial.println();
} else {
Serial.println("DS1307 read error! Please check the circuitry.");
Serial.println();
}
delay(9000);
}
}
void printValues() {
Serial.print("Temperature = ");
Serial.print(bme.readTemperature() *9/5 + 32);
Serial.println(" *F");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Approx. Altitude = ");
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(" m");
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.println();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
// tft.fillRect(0,0,320,320,ILI9341_PURPLE);
// tft.fillRect(1,1,200,100 ,ILI9341_BLACK);
tft.setCursor(0, 0);
tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(3);
tft.print("Temperature:" );
tft.println(bme.readTemperature() *9/5 + 32);
tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(3);
tft.print("Humidity:");
tft.println(bme.readHumidity());
tft.println();
tft.print("Pressure:");
tft.print(bme.readPressure() / 100.0F);