I2C conflict MCP3424 and Adafruit Iduino TF028

Hello

I have Arduino Leonardo, Adafruit Iduino TF028 display and ADC: MCP3424.

MCP342x.h correctly supports MCP3424.

When the display and ADC work separately - it is OK.

When I connect these two devices on the Arduino platform - ADC works and sends the measurement to Serial Monitor.

Adafruit Iduino TF028 display is frozen (on the display has frames and texts). Additionally, the touch screen of this display works correctly.

Adafruit Iduino TF028 and ADC do not use the same pins. ADC needs only +5V, 0, SCL, SDA to work - there is no hardware conflict

#include <Wire.h>
#include <MCP342x.h>

/* Demonstrate the use of convertAndRead().
 */

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_TFTLCD.h>
#include <TouchScreen.h>
#include <MCUFRIEND_kbv.h>
#include <OneWire.h>

long Voltage[4]; 

#define YP A3  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM 9   // can be a digital pin
#define XP 8   // can be a digital pin
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
 #define LCD_CS A3
 #define LCD_CD A2
 #define LCD_WR A1
 #define LCD_RD A0


#define TS_MINX 100
#define TS_MAXX 920

#define TS_MINY 70
#define TS_MAXY 900

// optiona
#define LCD_RESET A4
#define BOXSIZE 40
#define PENRADIUS 3

#define MINPRESSURE 10
#define MAXPRESSURE 1000
MCUFRIEND_kbv tft;

MCP342x MCP = MCP342x(0x68);



void setup(void)
{
  Serial.begin(9600);
  Wire.begin();

  // Enable power for MCP342x (needed for FL100 shield only)
  pinMode(9, OUTPUT);
  digitalWrite(9, HIGH);
  
  // Reset devices
  MCP342x::generalCallReset();
  delay(1); // MC342x needs 300us to settle, wait 1ms
  
  // Check device present
  Wire.requestFrom(address, (uint8_t)1);
  if (!Wire.available()) {
    Serial.print("No device found at address ");
    Serial.println(address, HEX);
    while (1)
      ;
  }


  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.setRotation(1);
  tft.fillScreen(BLACK);
  tft.drawLine(0, 0, 0, 120, BLACK);
  tft.setCursor(0, 60);
  tft.drawRect(0, 0, 160, 125, WHITE); tft.setCursor(48, 48); tft.setTextColor(WHITE);  tft.setTextSize(4);  tft.print("CH1");
 tft.drawRect(160, 0,159, 125, WHITE); tft.setCursor(208,48); tft.setTextColor(BLUE);  tft.setTextSize(4);  tft.print("CH2");
 tft.drawRect(0, 125, 160, 114, WHITE); tft.setCursor(48, 158); tft.setTextColor(WHITE);  tft.setTextSize(4);  tft.print("CH3");
 tft.drawRect(160, 125, 159, 114, RED); tft.setCursor(208,158); tft.setTextColor(RED);  tft.setTextSize(4);  tft.print("CH4");
  Serial.begin(9600);

}




void loop(void)
{
  long value = 0;
  MCP342x::Config status;
  // Initiate a conversion; convertAndRead() will wait until it can be read
  uint8_t err = adc.convertAndRead(MCP342x::channel1, MCP342x::oneShot,
				   MCP342x::resolution16, MCP342x::gain1,
				   1000000, value, status);
  if (err) {
    Serial.print("Convert error: ");
    Serial.println(err);
  }
  else {
    Serial.print("Value: ");
    Serial.println(value);
  }
  
  delay(1000);
}

A quick Google search turned up nothing for an "Adafruit Iduino TF028 display". Could you please provide a link to this display?

Hello
Required information:

http://www.openplatform.cc/index.php/home/index/details/apiid/388
https://botland.com.pl/index.php?controller=attachment&id_attachment=3221

Ah. So the TF028 display is not, in fact, anything to do with Adafruit. That explains why I couldn't find it.

As a display shield, it uses most of the pins available. Including D2 and D3 which, on the Leonardo, are the same pins as the I2C SDA and SCL pins. So the display and your I2C ADC are competing to use those pins. At least one of them will lose.

So, hardware conflict.

Pick one, can't be both
Screenshot 2024-09-14 at 14.56.26

Actually, they can. Weird as it seems, CS and CD do double duty as half of the touchscreen signals on those display shields (and D8 and 9 also do double duty as the other half of the touchscreen signals and the lower 2 bits of the LCD databus). Drove me batty at first figuring out how that could work. I had to figure it out when I attached one of those shields to an rPi Pico.

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