Hello, everyone.
I have a problem that I would like to use an ILI9341 and an MCP2515 driven by an ESP32 wroom.
For some reason the two don't work with each other, but separately they do.
I suspect the SPI as the source of the problem.
This is the connection:
ILI9341 - ESP32 wroom:
VCC ---- 5V (because it asks for 5V on the back of the display)
GND ---- GND
CS ---- D15
RESET ---- D25
D/C ---- D26
SDI(MOSI) ---- D13
SCK ---- D14
SDO(MISO) ---- D12
MCP2515 - ESP32 wroom:
VCC ---- 5V
GND ---- GND
CS ---- D5
MISO ---- D19
MOSI ---- D23
SCK ---- D18
INT ---- D2
This is the code:
#include <SPI.h>
#include <mcp2515.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
//mcp pinout
//INT-D2 | CS-D5 | SCK - D18 | MOSI - D23 | MISO - D19
struct can_frame canMsg;
MCP2515 mcp2515(5); // CS pin
// ILI9341 PIN Definitions
#define TFT_CS 15
#define TFT_RST 25
#define TFT_DC 26
#define TFT_MOSI 13
#define TFT_SCLK 14
#define TFT_MISO 12
// Initialize the ILI9341 display
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST,TFT_MISO);
void setup() {
Serial.begin(115200);
mcp2515.reset();
mcp2515.setBitrate(CAN_500KBPS, MCP_8MHZ);
mcp2515.setNormalMode();
Serial.println("------- CAN Read ----------");
// Initialize the display
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.setCursor(100, 100);
tft.print("OUR TEAM");
delay(1000);
tft.fillScreen(ILI9341_BLACK);
}
void loop() {
if (mcp2515.readMessage(&canMsg) == MCP2515::ERROR_OK) {
Serial.print(canMsg.can_id, HEX); // print ID
Serial.print(" ");
Serial.print("|");
Serial.print(canMsg.can_dlc, HEX); // print DLC
Serial.print(" ");
Serial.print("|");
for (int i = 0; i<canMsg.can_dlc; i++) { // print the data
Serial.print(canMsg.data[i],HEX);
Serial.print(" ");
}
Serial.println();
}
}
Thanks very much for all your help!