Hi, I am trying to use the library in Arduino IDE v1.6.2
here is the snippet of the code
//pin definition for the SMBUS Mega 2560
#define NO_INTERRUPT 1
#define I2C_TIMEOUT 1000
#define SDA_PORT PORTD //port definition SMBUS
#define SDA_PIN 1 //SDA PIN20
#define SCL_PORT PORTD //port definition SMBUS
#define SCL_PIN 0 //SCL PIN21
// doco from here
// http://playground.arduino.cc/Main/SoftwareI2CLibrary
#define I2C_WRITE 0
#define I2C_READ 1
#define CHARGE 0x0d
// include the necessary libraries
#include <SoftI2CMaster.h> //SMBUS over I2C library
byte deviceAddress = 11; // this variable represents the image to be drawn on screen
int led1Pin = 37;
int led2Pin = 36;
int led3Pin = 35;
int led4Pin = 34;
int led5Pin = 33;
int gaugebutton = 45;
int previous = LOW;
long time = 0;
long debounce = 200;
unsigned long timer; // the timer
unsigned long INTERVAL = 5000; // the repeat interval 1sec
void setup()
{
timer = millis(); // start timer
pinMode(led1Pin, OUTPUT);
pinMode(led2Pin, OUTPUT);
pinMode(led3Pin, OUTPUT);
pinMode(led4Pin, OUTPUT);
pinMode(led5Pin, OUTPUT);
pinMode(gaugebutton, INPUT);
Serial.begin(115200); // start serial for output
i2c_init();
// Serial.println(i2c_init());
scan();
}
int fetchWord(byte func)
{
i2c_start(deviceAddress<<1 | I2C_WRITE);
i2c_write(func);
i2c_rep_start(deviceAddress<<1 | I2C_READ);
byte b1 = i2c_read(false);
byte b2 = i2c_read(true);
i2c_stop();
return (int)b1|((( int)b2)<<8);
}
void scan()
{
byte i = 0;
for ( i= 0; i < 127; i++ )
{
Serial.print("Address ");Serial.print(i);
bool ack = i2c_start(i<<1 | I2C_WRITE);
if ( ack )
Serial.println("OK");
else
Serial.println("NO");
i2c_stop();
}
}
And I get these compile error messages:
complete_fuel_gauge.ino: In function 'void setup()':
complete_fuel_gauge.ino:52:12: error: 'i2c_init' was not declared in this scope
complete_fuel_gauge.ino: In function 'int fetchWord(byte)':
complete_fuel_gauge.ino:61:41: error: 'i2c_start' was not declared in this scope
complete_fuel_gauge.ino:62:17: error: 'i2c_write' was not declared in this scope
complete_fuel_gauge.ino:63:44: error: 'i2c_rep_start' was not declared in this scope
complete_fuel_gauge.ino:65:27: error: 'i2c_read' was not declared in this scope
complete_fuel_gauge.ino:67:12: error: 'i2c_stop' was not declared in this scope
complete_fuel_gauge.ino: In function 'void scan()':
complete_fuel_gauge.ino:76:42: error: 'i2c_start' was not declared in this scope
complete_fuel_gauge.ino:81:14: error: 'i2c_stop' was not declared in this scope
Error compiling.
It seems to me as these functions are not exposed by the library, but this is pretty much a guess.
Could you please have a look and possibly fix it up?
Hi, I am trying to use the library in Arduino IDE v1.6.2
here is the snippet of the code
And I get these compile error messages:
It seems to me as these functions are not exposed by the library, but this is pretty much a guess.
Could you please have a look and possibly fix it up?
Thank you