Trying to use the real time clock library that connects to a DS1307. In my case, it is actually connecting to a DS3231. This is fine. The DS3231 uses the same instruction set and register addresses as the 1307, and funs on 3.3V rather than 5. Great fit for the Teensy 3.5, and also is much more stable and more accurate. The connection to the TS3.5 is via I2C. I also have a "digital tube" 4 place 7 segment display, a GPS module, and a TFT module attached.
It appears that every time I try to read from the DS3231, the program stops.
SCL on the 3231 is connected to pin 16, SDA is connected to pin 17.
I am frankly confused about how to use the Wire library on the Teensy 3.5 since it seems as though I can connect to pins 7 & 8 , 16 and 17, or 18 and 19. How do I specify? Also, if I were to use SDA1/SCL1, how would I initialize a wire object?
Same concerns about Serial and SPI.
My code is below. Forgive the large amounts of commented out stuff. I'm debugging.
Ed
It appears that every time I try to read from the DS3231, the program stops.
SCL on the 3231 is connected to pin 16, SDA is connected to pin 17.
I am frankly confused about how to use the Wire library on the Teensy 3.5 since it seems as though I can connect to pins 7 & 8 , 16 and 17, or 18 and 19. How do I specify? Also, if I were to use SDA1/SCL1, how would I initialize a wire object?
Same concerns about Serial and SPI.
My code is below. Forgive the large amounts of commented out stuff. I'm debugging.
Ed
Code:
#include <ILI9341_t3.h>
#include <font_Arial.h> // from ILI9341_t3
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#include <TM1637.h>
#include <TinyGPS++.h>
#include <DS1307RTC.h>
#include <Time.h>
#include <TimeLib.h>
#include <Wire.h> //uses the wire0, which is wire
#define CS_PIN 8
#define TFT_DC 9
#define TFT_CS 10
// MOSI=11, MISO=12, SCK=13
//make LED display portable
#define tm_CLK 34
#define tm_DIO 33
/*
// set up touch screen and glcd
XPT2046_Touchscreen ts(CS_PIN);
#define TIRQ_PIN 2
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC);
*/
// create tiny gps and time objects, related variables.
TinyGPSPlus gps;
TM1637 tmLED(tm_CLK, tm_DIO);
int8_t TimeDisp[] = {0x00, 0x00, 0x00, 0x00};
TimeElements myTime;
time_t mySeconds;
boolean colon_blink = true;
long tzOffset = -5; //time zone set for est.
int oldSeconds;
int oldMinutes;
void setup() {
Serial.begin(9600);
Serial1.begin(4800);
tmLED.init();
tmLED.set(BRIGHTEST);
tmLED.display(TimeDisp);
/* tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
ts.begin();
*/
while (!Serial && (millis() <= 1000));
// RTC.read(myTime);
Serial.println(myTime.Year);
Serial.println(myTime.Month);
Serial.println(myTime.Day);
Serial.println(myTime.Hour);
Serial.println(myTime.Minute);
Serial.println(myTime.Second);
}
boolean wastouched = true;
void loop() {
Serial.println("Hello World");
//initially, comment out touch management so we can get display working correctly
/* boolean istouched = ts.touched();
if (istouched) {
TS_Point p = ts.getPoint();
if (!wastouched) {
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_YELLOW);
tft.setFont(Arial_60);
tft.setCursor(60, 80);
tft.print("Touch");
}
tft.fillRect(100, 150, 140, 60, ILI9341_BLACK);
tft.setTextColor(ILI9341_GREEN);
tft.setFont(Arial_24);
tft.setCursor(100, 150);
tft.print("X = ");
tft.print(p.x);
tft.setCursor(100, 180);
tft.print("Y = ");
tft.print(p.y);
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.println(p.y);
} else {
if (wastouched) {
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_RED);
tft.setFont(Arial_48);
tft.setCursor(120, 50);
tft.print("No");
tft.setCursor(80, 120);
tft.print("Touch");
}
Serial.println("no touch");
}
wastouched = istouched;
delay(100);
*/
// get current time
// RTC.read(myTime);
// Serial.println("Unsuccessful RTC read");
// update clock displays
if (myTime.Minute != oldMinutes) {
TimeDisp[0] = myTime.Hour / 10;
TimeDisp[1] = myTime.Hour % 10;
TimeDisp[2] = myTime.Minute / 10;
TimeDisp[3] = myTime.Minute % 10;
oldMinutes = myTime.Minute;
}
if (myTime.Second != oldSeconds) {
tmLED.point(colon_blink);
tmLED.display(TimeDisp);
colon_blink = !colon_blink;
oldSeconds = myTime.Second;
Serial.println(myTime.Year);
Serial.println(myTime.Month);
Serial.println(myTime.Day);
Serial.println(myTime.Hour);
Serial.println(myTime.Minute);
Serial.println(myTime.Second);
}
}