LCD I2c not working?

Hi All,
After a windows re-install I have a problem with a few programs that worked fine before the event:

The error code is has follows:
Arduino: 1.6.1 (Windows 7), Board: "Arduino Nano, ATmega328"

Using library LiquidCrystal_I2C in folder: C:\Users\Mel\Documents\Arduino\libraries\LiquidCrystal_I2C (legacy)

Using library LiquidCrystal in folder: C:\Users\Mel\Documents\Arduino\libraries\LiquidCrystal

Using library FastIO in folder: C:\Users\Mel\Documents\Arduino\libraries\FastIO (legacy)

Using library Wire in folder: C:\Users\Mel\Documents\Arduino\libraries\Wire (legacy)

Using library OneWire in folder: C:\Users\Mel\Documents\Arduino\libraries\OneWire (legacy)

Using library dallastemperaturecontrol in folder: C:\Users\Mel\Documents\Arduino\libraries\dallastemperaturecontrol (legacy)

C:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs -IC:\Users\Mel\Documents\Arduino\libraries\LiquidCrystal_I2C -IC:\Users\Mel\Documents\Arduino\libraries\LiquidCrystal\src -IC:\Users\Mel\Documents\Arduino\libraries\FastIO -IC:\Users\Mel\Documents\Arduino\libraries\Wire -IC:\Users\Mel\Documents\Arduino\libraries\OneWire -IC:\Users\Mel\Documents\Arduino\libraries\dallastemperaturecontrol C:\Users\Mel\AppData\Local\Temp\build753045471005925550.tmp\CactusPropNanoAAA.cpp -o C:\Users\Mel\AppData\Local\Temp\build753045471005925550.tmp\CactusPropNanoAAA.cpp.o

CactusPropNanoAAA.ino:18:44: error: 'POSITIVE' was not declared in this scope

Error compiling.

I think I've lost some Libraries, but then find that things like FastIO are in fact in one of the LCD libs, so what should I do! Does FastIO need to be in it's own folder named the same?

Here's my code, can you see anything wrong!! By the way, why are some of my #include coloured RED, or is that a stupid question!!

#include <LCD.h>
#include <LiquidCrystal.h>
#include <FastIO.h>
#include <I2CIO.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 12 on the Arduino
#define ONE_WIRE_BUS 12
#define DS1307_I2C_ADDRESS 0x68
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3,POSITIVE);  // Set the LCD I2C address 

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire); 
/*
Connections:
 Heater1 pin 3
 Heater2 pin 4
 SDA to Arduino Analog pin 4
 SCL to Arduino Analog pin 5
 LightPin Analog pin A7
 TempPin pin 12
 */

//*****constants*****
int Light,LightPin=A7,TargetTemp,Heater1=3,Heater2=4,TempPin=12;
float TEMP;

void setup()
//----------------Start of Set up---------------------
{
	TargetTemp=23;  //Set Normal/Target temp to 23c
	pinMode(Heater1,OUTPUT);
	pinMode(Heater2,OUTPUT);
	pinMode(13,OUTPUT);
	Wire.begin();
	lcd.begin(20,4); // tells Arduino the LCD dimensions
	// start serial port
	Serial.begin(9600);
	//Serial.println("Dallas Temperature IC Control Library Demo"); 
	// Start up the library
	sensors.begin(); // IC Default 9 bit. If you have troubles consider upping it 12. Ups the delay giving the IC more time to process the temperature mesurement
}
//------------End of Setup loop------------------------
//--------------Start of Main loop------------------
void loop()  
{
	GetTime();
	GetTemp();
	TestIt();
	digitalWrite(13,HIGH);    //LED ON
	delay(100);               //For 100mS
	digitalWrite(13,LOW);     //LED OFF
}
//------------End of main loop-----------------------------
void GetTime()
{
	byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
	getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
	{
		lcd.setCursor(0,0);
		lcd.print(" ");
		lcd.print(hour, DEC);
		lcd.print(":");
		if (minute<10)
		{
			lcd.print("0");
		}
		lcd.print(minute, DEC);
		lcd.print(":");
		if (second<10)
		{
			lcd.print("0");
		}
		lcd.print(second, DEC);
		lcd.print(" ");
		lcd.print(dayOfMonth, DEC);
		lcd.print("/");
		lcd.print(month, DEC);
		lcd.print("/");
		lcd.print("20");
		lcd.print(year, DEC);
		//delay(1000);
	}
}
//------------------------------------------------------------------------------------------
void GetTemp()
{
	// call sensors.requestTemperatures() to issue a global temperature
	// request to all devices on the bus
	sensors.requestTemperatures(); // Send the command to get temperatures
	TEMP=(sensors.getTempCByIndex(0)); // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire
}
//-----------------------------------------------------------------------------------------------------------
void TestIt()
{
	Light=analogRead(LightPin);
	Light=map(Light, 0, 1023, 0, 255);
	if(Light>200)
	{
		TargetTemp=25;
	}
	if(Light>160 && Light<200)
	{
		TargetTemp=18;
	}
	if(Light<160)
	{
		TargetTemp=14;
	};

	// Set Temp******
	lcd.setCursor(1,1);
	lcd.print("Target Temp:");
	lcd.print(TargetTemp);
	lcd.print(".00c ");
	lcd.setCursor(1,2);
	lcd.print("Current Temp:");
	lcd.print(TEMP); 
	lcd.print("c ");

	if (TEMP < TargetTemp)
	{
		digitalWrite(Heater1,LOW);    //Heater ON, Relay board uses LOW to switch relay ON.
		digitalWrite(Heater2,LOW);
		lcd.setCursor(1,3);
		lcd.print("Heater ON ");
		lcd.print(Light);
		lcd.print("  ");
	}
	if (TEMP > TargetTemp)
	{
		digitalWrite(Heater1,HIGH);
		digitalWrite(Heater2,HIGH);  //Heater OFF, Relay board uses HIGH to switch relay OFF.
		lcd.setCursor(1,3);
		lcd.print("Heater OFF ");
		lcd.print(Light);
       if(Light <100)
       {
		lcd.print("  ");
       }
		//lcd.clear();
	}
}
//*************************************************************************************************************

// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
	return ( (val/10*16) + (val%10) );
}
//-----------------------------------------------------------------
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
	return ( (val/16*10) + (val%16) );
}
//------------------------------------------------------------------
// Gets the date and time from the ds1307
void getDateDs1307
(
byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
	// Reset the register pointer
	Wire.beginTransmission(DS1307_I2C_ADDRESS);
	Wire.write(0);
	Wire.endTransmission();
	Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
	// A few of these need masks because certain bits are control bits
	*second = bcdToDec(Wire.read() & 0x7f);
	*minute = bcdToDec(Wire.read());
	*hour = bcdToDec(Wire.read() & 0x3f); // Need to change this if 12 hour am/pm
	*dayOfWeek = bcdToDec(Wire.read() &0x07);
	*dayOfMonth = bcdToDec(Wire.read());
	*month = bcdToDec(Wire.read());
	*year = bcdToDec(Wire.read());
}
//==================================================================================

Any help would be very welcome..

Regards

Mel.

Was all the text in orange colour?

FWIW it simply looks like verbose output and only an error on the second last line.

If you are worried about the libraries, delete all the non-standard libraries, then re-install them.

  1. Close IDE
  2. Delete non-standard library directories
  3. Start IDE
  4. Install non-standard libraries.

Note u can also re-install by simply copying non standard library folders under the libraries folder - but make sure IDE is not running.

It looks like you have have a library conflict.
From your code it looks like you are trying to use fm's library.
"POSITIVE" is a symbol from fm's library.

From your compile line it looks like the IDE found a "LiquidCrystal_I2C" library.
You can't have the LiquidCrystal_I2C library installed at the same time as fm's library
since both have a header file named LiquidCrystal_I2C.h that the sketch is including
as the IDE will get confused and end up using both libraries
at various points during the build process which won't work.

Also, you shouldn't need to include any of these headers:

#include <LCD.h>
#include <LiquidCrystal.h>
#include <FastIO.h>
#include <I2CIO.h>

in your sketch as fm's LiquidCrystal_I2C header and library should handle the other I/O stuff
for you.

--- bill

Hi Bill,
Thanks for you reply and help, but if I remove the libs you mention, then I get a string of Errors, including the POSITIVE one:

Arduino: 1.6.1 (Windows 7), Board: "Arduino Nano, ATmega328"

CactusPropControlNano.ino:18:44: error: 'POSITIVE' was not declared in this scope

CactusPropControlNano.ino: In function 'void GetTime()':

CactusPropControlNano.ino:48:78: error: 'getDateDs1307' was not declared in this scope

CactusPropControlNano.ino: In function 'void TestIt()':

CactusPropControlNano.ino:223:1: error: a function-definition is not allowed here before '{' token

CactusPropControlNano.ino:228:1: error: a function-definition is not allowed here before '{' token

CactusPropControlNano.ino:241:1: error: expected initializer before '}' token

CactusPropControlNano.ino:249:2: error: 'second' was not declared in this scope

CactusPropControlNano.ino:250:2: error: 'minute' was not declared in this scope

CactusPropControlNano.ino:251:2: error: 'hour' was not declared in this scope

CactusPropControlNano.ino:252:2: error: 'dayOfWeek' was not declared in this scope

CactusPropControlNano.ino:253:2: error: 'dayOfMonth' was not declared in this scope

CactusPropControlNano.ino:254:2: error: 'month' was not declared in this scope

CactusPropControlNano.ino:255:2: error: 'year' was not declared in this scope

CactusPropControlNano.ino:256:1: error: expected '}' at end of input

Error compiling.

Regards

Mel.

Not quite sure what you meant by:

if I remove the libs you mention,

I created a test sketch by cutting and pasting your exact sketch you posted above and only changed the includes to this:

//#include <LCD.h>
//#include <LiquidCrystal.h>
//#include <FastIO.h>
//#include <I2CIO.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>

so that the uneeded includes were not being included and it compiles just fine if the proper libraries are installed.

I don't know which i2c lcd library you were using or were trying to use but that LiquidCrystal_I2C constructor along with using a .begin(cols, rows); works with fm's library.
I would recommend that you install fm's library:
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

Use V1.2.1 not the repository download and when you install it call the library
directory "LiquidCrystal"
If you are using the recent IDEs, like 1.6 or 1.6.1 you can install it in your sketchbook
area as long as you call the library directory "LiquidCrystal" otherwise is must replace
the LiquidCrystal library that comes with the IDE.

--- bill

bperrybap:
I don't know which i2c lcd library you were using or were trying to use but that LiquidCrystal_I2C constructor along with using a .begin(cols, rows); works with fm's library.
I would recommend that you install fm's library:
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

Use V1.2.1 not the repository download and when you install it call the library
directory "LiquidCrystal"
If you are using the recent IDEs, like 1.6 or 1.6.1 you can install it in your sketchbook
area as long as you call the library directory "LiquidCrystal" otherwise is must replace
the LiquidCrystal library that comes with the IDE.

--- bill

hi Bill,

i follow your instruction with new install of arduino 1.6.1 and fm's library.

i do not work for me. not print any character, led light is 30% light...

i use

[code]
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27);  // Set the LCD I2C address

void setup()
{
   
  lcd.begin(16,2);               // initialize the lcd 

  lcd.home ();                   // go home
  lcd.print("Hello, ARDUINO ");  
  lcd.setCursor ( 0, 1 );        // go to the next line
  lcd.print (" FORUM - fm   ");
  delay ( 1000 );
}

void loop()
{
  lcd.setCursor ( 0, 1 );        // go to the next line
  lcd.print (" test  ");
}

[/code]

The constructor you are using in this latest sketch is not a full constructor like what you had in the first example code you posted. The constructor you are now using is guaranteed not to work unless you are using one of fm's ElctroFun backpacks and modified it for backlight control.

There are over 40,000 ways the PCF8574 output port pins on the backpack can can be wired up to the HD44780 LCD signal lines/pins. This "wiring" is actually done in the PCB etch of the backpack. Since there is no standard, not everyone did it the same.
The constructor tells the library how the PCF8574 pins are connected the HD44780 signal lines.

In your first example, you used a full constructor that told the library the pin mappings.
I'm not sure if the mappings are correct for your backpack but you did specify the full mapping.
In the second example, you used a partial constructor and allowed the library to pick a default internal mapping. (which I do not recommend)
The default internal mapping is for fm's ElectroFun LCD io expander, and to date, I've not seen any other PCF8574 backpack use that pin mapping.

In order for things work correctly you have to tell the library how the PCF8574 output port pins are wired to the LCD.
The s/w cannot figure this out and different boards used different mappings. It is no different than when wiring the LCD directly to Arduino pins; you have to tell the library which pins are wired up to which HD44780 LCD signals. That is done by putting the pin mapping information in the constructor.

If the incorrect pin mappings are put into the constructor, it will not work, just like if you told
the LiquidCrstal library the incorrect arduino pins when the LCD is wired directly to the Arduino.

--- bill

Hi H_Power.

Are you another instance of Cactusface ?
Or are you hijacking his active thread here, confusing the others contributing here ?

@Cactusface:
It wasn't Bill telling to remove a bunch of libraries, that was aisc.

aisc:
If you are worried about the libraries, delete all the non-standard libraries, then re-install them.

oops,
I totally missed that response #5 was not from CatusFace.
Sorry about that.
Seems like the thread has become a bit confusing now.

Anyway, the key take aways from all of this is:

  • These i2c LCD backpacks use a PCF8574 i/o expander chip to talk to the HD44780 LCD signals
  • There are 40,000+ ways that a PCF8574 chip can be wired up to the HD44780 LCD signals.
  • Different vendors use different designs that wire them up differently.
  • Some libraries hard code the PCF8574 wiring (pin mappings) and some allow it to be configured.
  • fm's library allows configuring the pin mapping in the constructor
  • If you don't fill in the full pin mapping in fm's LiquidCrytsal_I2C constructor, it uses a default that is very unlikely to work with your backpack.
  • There is no way to automatically figure out the pin mappings in s/w
  • When the library uses incorrect pin mappings, nothing can be displayed on the LCD

--- bill

I hate controversy, but...

@MAS3 - it may pay to read more carefully before responding inaccurately....

@Cactusface:
It wasn't Bill telling to remove a bunch of libraries, that was aisc.

Quote from: aisc on Mar 16, 2015, 08:00 am

❝If you are worried about the libraries, delete all the non-standard libraries, then re-install them.

At no point did I advice the OP to "remove" any libraries, from his sketch.

You need to read the original post again and Bill's reply.

The OP had a question about his installed libraries and his sketch.

I addressed the OP's question regarding the "existence" of his libraries and not his sketch - and my advice was delete/re-install and not remove.

Furthermore, there is nothing wrong with Bill's advice to remove conflicting libraries.

OK, i'll reread the posts.
Would you care to reread my post and find any reason why that would cause any controversy or reason for you to defend your post ?
I didn't attack or question your post in any way, and to be sure i did and still don't think there is anything wrong with the advice you gave.
Things go wrong if people are responding to words of a third party while addressing a second party, and that's what i was trying to point out.
I even quoted you, and included the reinstall part as that can't be left out in a correct advice.

bperrybap seemed to be confused in this thread, and these were possible reasons for that, and that was why i tried to point this out.
Just trying to straighten out the thread, sorry if you feel that was inappropriate.

@MAS3 : Apologies if there has been any misunderstandings, but u certainly introduced a bit of confusion for me anyway :slight_smile: since it was actually Bill who advised the OP to remove the conflicting/unnecessary libraries. All's well that ends well.

Salve a tutti,

qualcuno sa spiegarmi perché se carico uno sketch su Arduino uno con la versione 1.0.4 il display i2 con interfaccia seriale funziona, mentre se lo carico con la versione 1.6.1 no ?

grazie in anticipo .