Adafruit backpack not working I2C?

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
rich420
 
Posts: 4
Joined: Fri May 31, 2013 12:07 am

Adafruit backpack not working I2C?

Post by rich420 »

Hi

I am a total newb and attempting to build an environment controller. The Adafruit LCD backpack I have works fine in SPI mode with the pads shorted on the back but when I tried to switch to I2c and use the code below, the LCD simply fails to illuminate once the shorting link has been removed. An DS1307 RTC board is sharing the same I2C bus on A4, A5

Is the backpack faulty or am I missing something?

Thanks in advance for any help.

Code: Select all

#include <Wire.h>
#include <LiquidCrystal.h>
#include <RTClib.h>

RTC_DS1307 RTC;

int sensorPin = 0;      // Set our temperature sensor pin
LiquidCrystal lcd(0);   // Initialize our LCD

void setup () {
  lcd.begin(16, 2);      // Set up LCD as 16x2 screen

  Wire.begin();          // Start our wire and real time clock
  RTC.begin();
  
  if (! RTC.isrunning()) {                       // Make sure RTC is running
    Serial.println("RTC is NOT running!");
    //RTC.adjust(DateTime(__DATE__, __TIME__));  // Uncomment to set the date and time
  }
}

void loop () {
  
  DateTime now = RTC.now();  // Read in what our current datestamp is from RTC
  
  int reading = analogRead(sensorPin);                   // Read in value from our temp sensor
  
  float voltage = reading * (5.0 / 1024.0);              // Calculate the voltage
  float temperatureC = (voltage - 0.5) * 100;            // Calculate degrees celsius
  float temperatureF = (temperatureC * 9.0 / 5.0) + 32;  // Convert to degrees farenheit
  
  lcd.clear();                            // Clear the LCD screen
  if (now.hour() < 10) lcd.print("0");    // Check if we need to add leading zero
  lcd.print(now.hour(), DEC);             // Output current hour
  lcd.print(":");
  if (now.minute() < 10) lcd.print("0");  // Check if we need to add leading zero
  lcd.print(now.minute(), DEC);           // Output current minute
  lcd.print(":");
  if (now.second() < 10) lcd.print("0");  // Check if we need to add leading zero
  lcd.print(now.second(), DEC);           // Output current second
  
  lcd.setCursor(0, 1);      // Move cursor to our second line
  lcd.print(temperatureC);  // Output the temp in celsius
  lcd.print((char)223);     // Output the degrees character
  lcd.print("C ");
  lcd.print(temperatureF);  // Output the temp in farenheit
  lcd.print((char)223);     // Output the degrees character
  lcd.print("F");
  
  delay(5000);    // Wait 5 seconds before looping
}

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit backpack not working I2C?

Post by adafruit_support_bill »

There shouldn't be a conflict with the DS1307 address. Are any of the address jumpers set?
If you post a photo of your setup & connections, we may be able to spot the problem.

rich420
 
Posts: 4
Joined: Fri May 31, 2013 12:07 am

Re: Adafruit backpack not working I2C?

Post by rich420 »

Hi Bill,, thanks for the reply.

Here is a fritzing of the circuit.

Image

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit backpack not working I2C?

Post by adafruit_support_bill »

Any address jumpers set?
Make sure you don't have SDA/SCL swapped. A4 is the data, A5 is the clock.

rich420
 
Posts: 4
Joined: Fri May 31, 2013 12:07 am

Re: Adafruit backpack not working I2C?

Post by rich420 »

adafruit_support_bill wrote:Any address jumpers set?
Make sure you don't have SDA/SCL swapped. A4 is the data, A5 is the clock.
Hi Bill, sorry no address jumpers have been set, are they the A0, A1, A2 pads? Please instruct me on this and how it affects the code.

The connections from the backpack are correct.

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit backpack not working I2C?

Post by adafruit_support_bill »

If any of the jumpers were set, you would need to specify a different address in the constructor. But it sounds like everything is connected right. If you contact [email protected] with a link to this thread we can get a replacement out to you.

rich420
 
Posts: 4
Joined: Fri May 31, 2013 12:07 am

Re: Adafruit backpack not working I2C?

Post by rich420 »

Thank you Bill, that is superb. I'll take you up on that ;)

Thanks for your time and help.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”