Network drop when talking to SPI-TFT-display on arduino Yun

Hi! I've encountered a strange behaviour that I can not explain – maybe you can help.

I'm running an Arduino Yun (2016 Version) with one of adafruits 1.44" TFT displays (Adafruit 1.44 Color TFT LCD Display with MicroSD Card breakout [ST7735R] : ID 2088 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits). The display is run from hardware SPI-pins and using pins 2, 3 and 4 for CS, RST and DC and working well using the libraries (<Adafruit_ST7735.h> and <Adafruit_GFX.h>).

I usually connect to the linux part of the Yun using SSH (or occasionally using the browser to get to the WebGUI) and use the bridge to display things that the linux gets from the internet.

Now what I discovered: As soon as I upload a sketch that connects the 32u4 to the TFT (like with the line

tft.initR(INITR_144GREENTAB);

), the linux part is no longer reachable – neither by SSH, nor by http.

I know that the linux is somehow connected to the SPI-pins – might the TFT block the line somehow (as it happend with your CC3000 or the RA8875-breakout boards, that couldn't cope with more than one SPI device? / see older posts from me) and block the processor? Or could it be something with the SPI-speed? My wires to the display are about 10 cm long (4 in).

I have to upload a sketch that does not use the SPI/tft to be able to use connect to the linux again. It's interesting to see, that the linux is still running - but wasn't responding through any channel while the 32u4 was using SPI to write to the TFT-display.

Eventually though, after a few more tft.print("x"), Arduino Yun looses it's network connectivity completely and can't be reached anymore until it is rebooted. What might cause this behaviour?

Thank you for your help,
Dani

Hey,

What other includes do you have? Could you also provide your setup() ?

Thanks

Thanks for asking

I'm using an Arduino Yun and the above mentioned 1.44" TFT Display from adafruit.

Pins:

Yun->TFT
5V  Vin
-  3.3V
Gnd  Gnd
SCK  SCK
MISO  SO
MOSI  SI
TFT_CS  2
RST  3
D/C  4

Furthermore, I use the following script:

/* Kanti Baden Internet Wecker
 * Testsuite zum Testen, ob alle Komponenten korrekt angeschlossen sind
 */

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <Process.h>

#define TFT_CS     2
#define TFT_RST    3
#define TFT_DC     4

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);

#define piezo_pin 11
#define taste_blau_pin 12
#define taste_rot_pin 13

#define ldr_pin A0
#define z_pin A1
#define y_pin A2
#define x_pin A3
#define led_pin 5

long int zeit_offset = 0; // Millisekunden seit Mitternacht

void setup() {
  pinMode(piezo_pin, OUTPUT);
  pinMode(taste_blau_pin, INPUT_PULLUP);
  pinMode(taste_rot_pin, INPUT_PULLUP);
  pinMode(led_pin, OUTPUT);
  pinMode(ldr_pin, INPUT);
  pinMode(x_pin, INPUT);
  pinMode(y_pin, INPUT);
  pinMode(z_pin, INPUT);

  Serial.begin(57600);

  tft.initR(INITR_144GREENTAB);   // initialize a ST7735S chip, green tab
  digitalWrite(led_pin, HIGH);
  tft.fillScreen(ST7735_BLACK);   // zuerst mal schwarz machen
  tft.setRotation(3); 
  tft.setCursor(0,0);
  tft.setTextColor(ST7735_WHITE);
  tft.setTextWrap(true);
  tft.println("Alarmclock 2.0 (0.01)");
  tft.println("Daniel Suesstrunk");

  Bridge.begin();
  Process p;    // Create a process and call it "p"
  if(!p.running()){
    p.begin("php-cli");  // Process that launch the "php-cli" command
    p.addParameter("/usr/bin/millis_seit_mitternacht.php"); // Will return an Integer
    p.run();    // Run the process and wait for its termination
  }

  zeit_offset = p.parseInt();
  Serial.println(zeit_offset);
}

void loop() {
  static long tft_update_time = 0;
  if (millis() > tft_update_time){
    display_zeit();
    tft_update_time = millis() + 60000;
  }
}

void display_zeit(){
  tft.fillRect(0,50,48,7, ST7735_BLACK);
  tft.setCursor(5,50);
  tft.setTextColor(ST7735_WHITE);
  tft.setTextWrap(false);
  long sekunden_des_tages = ((millis() + zeit_offset)%(86400000)) / 1000;
  long stunden = sekunden_des_tages / 3600;
  long minuten = (sekunden_des_tages - (stunden * 3600)) / 60;
  
  if (stunden < 10){tft.print("0");}
  tft.print(stunden);    
  tft.print(":");
  if (minuten < 10){tft.print("0");}
  tft.println(minuten);
  Serial.print("Zeit:");
  Serial.println((millis() + zeit_offset)%(86400000));
}

Thanks for looking at it.
Dani

I suspect power issues - how are you powering all of this? Is it a clean/stable power supply?

Interesting fact: When using Software-SPI (bitbanging MOSI and SCLK), I don't have the issue! So I think it does have to do something with Hardware-SPI-Pins.

Power: I'm either using my Macbook Pros USB port or a strong (2800mA, 5V) outlet power supply – same behaviour.

Thanks for thinking along with me.

Dani