I need pin 11 for data as required by the RH 433MHz s/w and this is used by the TFT DIN(MOSI) connection.
I would like to define it to another pin, however it doesn't seem to work. I know it is possible to get into the RH library and change the default pin from 11 but I have got other units that use this.
Please see code below of the definition area.
Any ideas?
#include <Adafruit_GFX.h> // include Adafruit graphics library
#include <Adafruit_ST7735.h> // include Adafruit ST7735 TFT library
#include <RH_ASK.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <Wire.h>
#define TFT_RST 8 // TFT RST pin is connected to arduino pin 8
#define TFT_CS 9 // TFT CS pin is connected to arduino pin 9
#define TFT_DC 10 // TFT DC pin is connected to arduino pin 10
#define ONE_WIRE_BUS 3
// initialize ST7735 TFT library
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
RH_ASK driver;
float temp = 0;
float tempUHF = 0;
void setup(void)
{
tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab
tft.fillScreen(ST7735_BLACK); // fill screen with black color
tft.drawFastHLine(0, 75, tft.width(), ST7735_WHITE); // draw horizontal white line at position (0, 50)
tft.setTextColor(ST7735_RED, ST7735_BLACK); // set text color to red and black background
tft.setCursor(34, 16);
tft.print("IN =");
tft.setTextColor(ST7735_CYAN, ST7735_BLACK); // set text color to cyan and black background
tft.setCursor(34, 90); // move cursor to position (34, 113) pixel
tft.print("OUT =");
tft.setTextSize(3);
sensors.begin();
}
Yes, I am using a UNO but am going to change it to a nano but from what you have said, its fixed on pins 11,12,13 and probably still won't work even with a nano.
It compiles OK but the TFT shows just a blank screen after uploading.
It looks as though I will be forced to alter the RH library and define the data output to another pin.
I have no idea what RH_ASK.h might be. This library is not supported by the IDE Library Manager.
However you can bit-bang the TFT on any GPIO pins with the SW_SPI constructor from Adafruit_ST7735.h
It will be SLOW.
God gave you the HW_SPI pins. Use them.
If RH_ASK uses the HW_SPI it will have a specific RH_CS pin. Make sure that RH_CS is different to the TFT_CS pin.
Note that ST7735 is a 3.3V device. It requires level shifters of some form.
It is always wise to post a link to your display and a link to any library that is not supported by the Library Manager..
I changed the to the following code and this frees up pin 11 for the Receiver data. #define TFT_SCLK 5 // TFT SCLK pin is connected to arduino pin 5 #define TFT_MOSI 4 // TFT MOSI pin is connected to arduino pin 4
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
RH_ASK.h is part of the RadioHead library by Mike McCauley. It uses simple ASK transmitters and Receivers.
I used part of my information from https://simple-circuit.com/arduino-st7735-tft-display-example/
and this includes the following information:
"The ST7735 TFT works with 3.3V and the Arduino uno works with 5V, supplying the TFT control lines directly with 5V my damage it, so we have to add the five 1K ohm resistors. The ST7735 board is supplied with 5V which comes from the Arduino board (the TFT board contains AMS1117 3V3 voltage regulator which steps down the 5V to 3.3V)."
Not sure if the 1K resistors are enough protection? I have tried direct connection to 5V arduino pins without any problems. I will either put them in or use a proper level changer.
I can't supply the link to the Ebay supplier as that particular unit is no longer available.