Looking for answer to my question i found this thread.
So i ask you:
I want to use 2 ST7735 displays with an arduino Nano.
I want to print different data to each display at the same time.
So far i have manage to have same data on 2 displays.
I read that i have to define different CS pin for each display and all other pins mus be the same.
So here is my code.
#include <TFT_ST7735.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include "RTClib.h"
#include <Wire.h>
#include <Adafruit_GFX.h>
#define TFT_CS1 6
#define TFT_DC 8
#define TFT_CS 9
#define ST7735_TFTWIDTH 128
#define ST7735_TFTHEIGHT 128
#define TFT_BLACK 0x0000
#define TFT_RED 0x001F
#define TFT_GREEN 0x07E0
#define TFT_WHITE 0xFFFF
#define TFT_BLUE 0xF800
#define TFT_YELLOW 0x07FF
#define TFT_CYAN 0xFFE0
#define TFT_MAGENTA 0xF81F
TFT_ST7735 tft = TFT_ST7735(TFT_CS,TFT_DC);
TFT_ST7735 tft1 = TFT_ST7735(TFT_CS1,TFT_DC);
Adafruit_BME280 bme;
RTC_DS3231 rtc;
char daysOfTheWeek[7][12] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
char dtBuffer[12];
char Day[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const char * months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
void setup()
{
rtc.begin();
//rtc.adjust(DateTime(F(__DATE__),F(__TIME__))); //Set Date and Time from PC
//rtc.adjust(DateTime(2019, 10, 27, 23, 21, 40)); //Set Date and Time Manually
bme.begin(0x76);
tft.init();
tft1.init();
tft.setRotation(0);
tft1.setRotation(0);
tft.fillScreen(TFT_BLACK);
tft1.fillScreen(TFT_BLACK);
tft.drawRect(0,2,128,128,TFT_CYAN);
}
void loop()
{
//Print Temperature
tft.setTextColor(TFT_RED, TFT_BLACK);
tft.drawString("Temperature",27,3,2);
tft.setCursor(20,20,4);
tft.print(bme.readTemperature(),1);
tft.setCursor(90,5);
tft.drawString("*C", 75,22,2); // print degree symbol and C
tft.drawFastHLine(0,46,tft.width(),TFT_CYAN);
//Print Humidity
tft.setTextColor(TFT_GREEN, TFT_BLACK);
tft.drawString("Humidity",35,48,2);
tft.setCursor(35,63);
tft.print(bme.readHumidity(),1);
tft.drawString("%",90,63,2);
tft.drawFastHLine(0,86,tft.width(),TFT_CYAN);
//Print Pressure
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
tft.drawString("Pressure",35,87,2);
tft.setCursor(12,101,4);
tft.print((bme.readPressure() / 100) , 1);
tft.drawString(" hPa",91,105,2);
//Time from RTC
DateTime now = rtc.now();
sprintf(dtBuffer,"%02u : %02u : %02u ",now.hour(),now.minute(),now.second());
tft1.setTextColor(TFT_WHITE,TFT_BLACK);
tft1.drawString(dtBuffer,25,90,2);
//Date from RTC
sprintf(dtBuffer,"%02u/%02u/%02u ",now.day(),now.month(),now.year());
tft1.setTextColor(TFT_WHITE,TFT_BLACK);
tft1.drawString(dtBuffer,41,104,2);
//Day Of Week from RTC
tft1.setCursor(7,104,2);
tft1.print(daysOfTheWeek[now.dayOfTheWeek()]);
delay(1000);
}
I have declared tft as first display and tft1 as the second.
Can anyone help me?Thank you.