Display and Motor driver

Hello,

im a beginner with the arduino uno and only a amateur in general programming.
Actually i try to build a small controller for my heating-system in my house.

Target: if temperature of water in the radiators is <> 55°C move valve to left or right.
Also i would like to see the actual temp on a tft display.

Hardware: Arduino Uno; DS18B20 Temp Sensor; ST7735 1,77 Display; Motorshield HW130 (L293D drivers)

My Problems:

  1. (Main Problem)
    When i display the Temperature on the Display the Motor does not move anymore
    (I think it has something to do with all these deinitions for the motor and the disyplay)
  2. The display looks a bit milky (Not clear white text on black background. (Photo)
    Also it seems to override the new text over the old one without deleting it.

Can you help me? (Especialy with Problem 1)

Code:

#include <OneWire.h>
#include <DallasTemperature.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>
#include <AFMotor.h>

#define ONE_WIRE_BUS 5
AF_DCMotor motor(3);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer;
unsigned long previousMillis = 0; //Variable damit Motor nur alle 5 min dreht
const long interval = 10000; //Variable damit Motor nur alle 5 min dreht (300.000 millisec)
#define TFT_CS 6
#define TFT_RST 10 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 9
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
float p = 3.1415926;
const uint16_t Display_Color_Black = 0x0000;
const uint16_t Display_Color_Blue = 0x001F;
const uint16_t Display_Color_Red = 0xF800;
const uint16_t Display_Color_Green = 0x07E0;
const uint16_t Display_Color_Cyan = 0x07FF;
const uint16_t Display_Color_Magenta = 0xF81F;
const uint16_t Display_Color_Yellow = 0xFFE0;
const uint16_t Display_Color_White = 0xFFFF;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//Display
tft.initR(INITR_BLACKTAB);
tft.fillScreen(ST77XX_BLACK);
}

void loop() {
// put your main code here, to run repeatedly:

//TEMPSensor
sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0);
//Serial.print(sensors.getTempCByIndex(0));
//Serial.print(sensors.getTempCByIndex(0));
Serial.print("Temp C: ");
Serial.print(tempC);
Serial.println(" °C");

//Display

uint16_t Display_Text_Color = Display_Color_Black;
uint16_t Display_Backround_Color = Display_Color_Blue;
tft.setCursor(0, 0);
////tft.setTextColor(uint16_t c);
tft.setTextWrap(true);
tft.setTextSize(3);
tft.println("Temp C: ");
tft.println(tempC);
tft.println(" °C");

//Motor
unsigned long currentMillis = millis(); //Variable damit Motor nur alle 5 min dreht
Serial.print(currentMillis);
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
Serial.print("Motorloop");
motor.setSpeed(255);
if (tempC <= 55) { //Drehrichtung if
motor.run(FORWARD);
delay(500);
motor.run(RELEASE);
}
else {
motor.run(BACKWARD);
delay(500);
motor.run(RELEASE);
}
}
}

Greetings Matthias

Motorshiled:


Display:

How are you providing power for this project? You will need an external power supply as the Arduino Board (Uno?) will not have enough capacity be enough to power everything.

Hello,

actualy i provide the power over the arduino uno (USB and Extra Power supplie). (Its a very small motor with high trnsmission-factor). If the Power is not enough i will connect an additional powersupplie directly to the motorshield.
The programm does the if-part with the motor.run-code. But ate the connection for the Motor is always 0V. Only if i Comment-Out the Code fpr the display the motor runs.
My guess is that something in the library (Adafruit_ST7735.h) is colliding with something in the library (<AFMotor.h>) so that the motor run-command is not working anymore.

For the Problem with the Display: If i define the display as a 7789 (Normly its a 7735) the colors are ok. The position of the text is not rigth but i can life with that for now.

Could be. You will need to look in the libraries to map out the pins being used and see if this is the case. Or see if there is documentation about the pins they use (Adafruit web site).

SPI on the uno uses pin 10 as a chip select and you also have it used by the TFT display. You will have to dig into the library code and see what the default pins are and hopefully the libraries will
let you change them to eliminate any conflicts.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.