BMP180 и экран 1.77 160x128 не хотят жить дружно на Mega
- Войдите на сайт для отправки комментариев
Отдельно все работает прекрасно (использовал примеры из библиотек), но если вызвать Serial.print(bmp.readTemperature()); в скейтче для экрана, то устройство перезапускается.
Подключение:
BMP180:
SDA - 20
SCL - 21
Экран:
SCK - 52
SDA - 51
RES - 8
RS - 9
CS - 10
Подумал, что явно какие-то пины конфликтуют "внутри" :) и передвинул (поправив в скейтче)
RES - 3
RS - 4
CS - 5
Сбросы прекратились, а Serial.print(bmp.readTemperature()); начала возвращать "0.00"
Подвинул еще:
RES - 5
RS - 6
CS - 7
Сбросы начались опять.
#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 <Adafruit_BMP085.h>
// For the breakout board, you can use any 2 or 3 pins.
// These pins will also work for the 1.8" TFT shield.
//#define TFT_CS 10
//#define TFT_RST 8 // Or set to -1 and connect to Arduino RESET pin
//#define TFT_DC 9
//#define TFT_CS 5
///#define TFT_RST 3 // Or set to -1 and connect to Arduino RESET pin
//#define TFT_DC 4
#define TFT_CS 7
#define TFT_RST 5 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 6
// OPTION 1 (recommended) is to use the HARDWARE SPI pins, which are unique
// to each board and not reassignable. For Arduino Uno: MOSI = pin 11 and
// SCLK = pin 13. This is the fastest mode of operation and is required if
// using the breakout board's microSD card.
// For 1.44" and 1.8" TFT with ST7735 use:
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
// OPTION 2 lets you interface the display using ANY TWO or THREE PINS,
// tradeoff being that performance is not as fast as hardware SPI above.
//#define TFT_MOSI 11 // Data out
//#define TFT_SCLK 13 // Clock out
Adafruit_BMP085 bmp;
float p = 3.1415926;
void setup(void) {
Serial.begin(9600);
Serial.print(F("Hello! ST77xx TFT Test"));
// Use this initializer if using a 1.8" TFT screen:
tft.initR(INITR_BLACKTAB); // Init ST7735S chip, black tab
Serial.println(F("Initialized"));
uint16_t time = millis();
tft.fillScreen(ST77XX_BLACK);
time = millis() - time;
Serial.println(time, DEC);
delay(500);
}
void loop() {
tftPrintTest();
delay(2000);
}
void tftPrintTest() {
tft.setTextWrap(false);
tft.fillScreen(ST77XX_BLACK);
tft.setCursor(4, 4);
// tft.setTextColor(ST77XX_GREEN);
tft.setTextSize(1);
tft.println("Out");
//tft.println(bmp.readTemperature());
Serial.print("Temperature = ");
}
Вывод когда все "работает":
Hello! ST77xx TFT TestInitialized
80
Temperature = Temperature = Temperature =
Вывод с опросом датчика:
Hello! ST77xx TFT TestInitialized
80
TemperaHello! ST77xx TFT TestInitialized
80
Tempera⸮Hello! ST77xx TFT TestInitialized
81
TemperaHello! ST77xx TFT TestInitialized
80