I2C and analog together?

So I’m trying to create a temperature gauge using a Seeeduino V4.2, the LCD RGB Backlight, and the High Temp sensor. I know that the LCD uses I2C and that the Temp sensor is analog but I can’t seem to get them both working at the same time. The LCD basically freezes up when the temp sensor is plugged in either the second I2C port or the UART port.



Is this because the analog signal is interfering with the I2C data?



I can get the temp to read through the serial monitor if the LCD isn’t plugged in, or the LCD working with the code below if the temp sensor isn’t plugged in.



Is there anyway to get them both to work at the same time? The code below is basically my starting point for my future project.



Thanks!

[code]#include <Wire.h>
#include “rgb_lcd.h”
#include “High_Temp.h”

rgb_lcd lcd;

HighTemp ht(A4, A5);

void setup()
{
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(“Fade/Temp Demo”);
ht.begin();
}

void breath(unsigned char color)
{

for(int i=10; i<255; i++)
{
    lcd.setPWM(color, i);
    delay(5);
}

lcd.setCursor(0, 1);
lcd.print("Temp = ");
lcd.setCursor(7, 1);
lcd.print(ht.getThmc());

for(int i=254; i>=10; i--)
{
    lcd.setPWM(color, i);
    delay(5);
}

}

void loop()
{
breath(REG_RED);
breath(REG_GREEN);
breath(REG_BLUE);
}
[/code]

Has anyone here used I2C and analog sensors together before? I’m new to Arduino and Grove so I’m not sure if I’m trying to do something that isn’t possible or if I just need to connect them differently.



Thanks.

I think the problem you’re having is that you’re using A4/A5 for the analog input for the temp sensor, right? A4 and A5 are also SCL and SDA on the I2C bus, you can’t be using them and I2C at the same time. Try switching to A0/A1 for the temperature sensor.

Thank you so much! Yep that was it. I had to wire the temp sensor directly to the analog pins A0 & A1 on the side to get it to work.



Things seem to be working nicely now. Appreciate the help.