Go Down

Topic: I2C communication with atmega328 (Read 729 times) previous topic - next topic


I am newbie in Arduino. I am trying to interface TC74 with Atmega328. TC74 works with I2C protocol. I simulated the circuit in Proteus. I also use LM016L LCD display to monitor the TC74 data. But my LCD displays only the number -1. I can not understand the problem. I wish all of your help.....Here is my code.....

#include <Wire.h>
#include <LiquidCrystal.h>
#define RSPin 6
#define EnablePin 7
#define DS4 9
#define DS5 10
#define DS6 11
#define DS7 12

#define LCDColumns 16
#define LCDRows 2

LiquidCrystal LCD(RSPin, EnablePin,DS4,DS5,DS6,DS7);
int temp_address = 72;

void setup()
 pinMode(0, OUTPUT); 
 LCD.begin(LCDColumns, LCDRows);


void loop()
Wire.requestFrom(temp_address, 1);
int c = Wire.read();



Feb 15, 2016, 03:54 pm Last Edit: Feb 15, 2016, 03:58 pm by Koepel
Please don't use a simulator. There are many question about simulators on this forum, it almost seems that there is not a single simulator that actually works with less know chips. Did you really think that a simulated TC74 is the same as the real thing ? not a chance.

Grab an Arduino board and connect the TC74.
Run the I2C scanner : http://playground.arduino.cc/Main/I2cScanner
Is the TC74 detected ?

Please remove this line : while ( Wire.available ( ) ) ;
After the Wire.requestFrom() returns, the I2C transmission has finished and the received bytes are in a buffer in the Wire library. There is no need to wait.

Test the LCD by writing text to it.
Test the sensor by writing its data to the serial monitor.
If both work, then you can combine them and write the data to the LCD.

Go Up