Thanks guys - slowly going cross eyed.
How does one migrate to the modern libraries?
I am reluctant to revert to earlier systems as it seems counterintuitive.
Does the standard liquid crystal library work in conjunction with the I2C interface?
As I said i'm a complete newbie feeling my way along and learning a lot, but conscious of massive gaps in my understanding.
I am now so tangled up in this, I think I am going to have to start again from first principles. can anyone point me in the right direction especially regarding I2C libraries?
If you can bear to read on, here is a rough summary of where I am at.
I am using two 20*4 lcd displays. These are connected via I2C modules. Google found me U-tube demonstrations for how to set them up hence using the below:
LiquidCrystal_I2C LiquidCrystal Arduino library for the DFRobot I2C LCD displays
This also provided me with a tutorial which i mentioned below (and which previously compiled ok)
Logic got me the rest of the way and i have been happily running both displays to show temperatures from 5 one wire sensors and progressively developing the system to get to my goal.
Until I upgraded to the 1.6.8 software.
My sketch is as shown below.
I have been poking around with it but did not save changes - it seems to have done that automatically on closing. frustrating.
The
/#include <FastIO.h>................>>>...................#include <LiquidCrystal_I2C.h>/
section was the code originally used to call up the LCD I2C libraries.
That left me with the #include <Wire.h> issues.
I am now getting error messages in compiling for
LiquidCrystal_lcd2(ADDR2,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
SKETCH;
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <Wire.h>
/*#include <FastIO.h>
#include <I2CIO.h>
#include <LCD.h>
#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_SR.h>
#include <LiquidCrystal_SR2W.h>
#include <LiquidCrystal_SR3W.h>
#include <LiquidCrystal_I2C.h>*/
#include <DallasTemperature.h>
/-----( Declare Constants and Pin Numbers )-----/
#define ADDR1 0x26
#define ADDR2 0x27
#define Rs_pin 0
#define Rw_pin 1
#define En_pin 2
#define BACKLIGHT_PIN 3
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define ONE_WIRE_BUS_PIN 2 //multiple temp probe pin 2
int loc1;
int loc2;
int loc3;
int loc3a;
int loc4;
int loc5;
int Dt;
int ppctrl;
const int analogInPin = A0; // Analog input pin that the pressure transducer is attached to
int PsensorValue = 0; // value read from the pressure trans
int PoutputValue = 0; // value output to the LCD
int Pressure;
/-----( Declare objects )-----/
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS_PIN);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Setup lcd display
LiquidCrystal_lcd1(ADDR1,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
LiquidCrystal_lcd2(ADDR2,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
/-----( Declare Variables )-----/
// Assign the addresses of your 1-Wire temp sensors.
DeviceAddress Probe01 = { 0x28, 0xFF, 0xCE, 0x9C, 0x52, 0x15, 0x02, 0xA0 }; // ambient
DeviceAddress Probe02 = { 0x28, 0xFF, 0x53, 0xAE, 0x15, 0x15, 0x01, 0x1D }; // after turbo
DeviceAddress Probe03 = { 0x28, 0xFF, 0xEE, 0x96, 0x15, 0x15, 0x01, 0xEA }; // after cooler
DeviceAddress Probe04 = { 0x28, 0xFF, 0x7F, 0x60, 0x15, 0x15, 0x01, 0xE8 }; // oil temp
DeviceAddress Probe05 = { 0x28, 0xFF, 0x85, 0x97, 0x52, 0x15, 0x02, 0xAD }; // engine bay
//DeviceAddress Probe03 = { xxxxx };
void setup()
{
// Initialize the Temperature measurement library
sensors.begin();
// set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
sensors.setResolution(Probe01, 12);
sensors.setResolution(Probe02, 12);
sensors.setResolution(Probe03, 12);
sensors.setResolution(Probe04, 12);
sensors.setResolution(Probe05, 12);
lcd1.begin (20,4); // <<-- our LCD is a 20x4, change for your LCD if needed
lcd2.begin (20,4);
// LCD Backlight ON
lcd1.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd1.setBacklight(HIGH);
lcd2.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd2.setBacklight(HIGH);
/* need to install security control code here */
lcd1.home (); // go home on LCD
lcd1.print("Sookin' Diesel");
lcd2.home (); // go home on LCD
lcd2.print("Innit though");
delay(2000);
lcd1.home ();
lcd1.print(" ");
lcd2.home ();
lcd2.print(" ");
} //end set up
void loop()
{
// Command all devices on bus to read temperature
sensors.requestTemperatures();
// read the analog pressure in value: - work in progress
PsensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
PoutputValue = map(PsensorValue, 0, 1023, 0, 700);
float Pressure = (PoutputValue*100)-2700;
float temp1 = sensors.getTempC(Probe01);
//float tempx = sensors.getTempC(Probexx);
if (temp1<10)
loc1 = 12;
else loc1 = 11;
float temp2 = sensors.getTempC(Probe02);
if (temp2<10)
loc2 = 12;
else loc2 = 11;
float temp3 = sensors.getTempC(Probe03);
if (temp3<10)
loc3 = 12;
else loc3 = 11;
float temp4 = sensors.getTempC(Probe04);
if (temp4<10)
loc4 = 12;
else loc4 = 11;
float temp5 = sensors.getTempC(Probe05);
if (temp5<10)
loc5 = 12;
else loc5 = 11;
// for Dt
float Dt = temp2 - temp3;
if (Dt<10)
loc3a = 4;
else loc3a = 3;
lcd1.setCursor (0,0); // go to start of 1st line
lcd1.print("Ambient");
lcd1.setCursor (loc1-1,0);
lcd1.print (" ");
lcd1.setCursor (loc1,0);
lcd1.print (temp1);
lcd1.setCursor (16,0);
lcd1.print(" C ");
lcd1.setCursor (0,1);
lcd1.print("Turbo out:");
lcd1.setCursor (loc2-1,1);
lcd1.print (" ");
lcd1.setCursor (loc2,1);
lcd1.print(temp2);
lcd1.setCursor (16,1);
lcd1.print(" C ");
lcd1.setCursor (0,2);
lcd1.print("Cooler:");
lcd1.setCursor (loc3-1,2);
lcd1.print (" ");
lcd1.setCursor (loc3,2);
lcd1.print(temp3);
lcd1.setCursor (16,2);
lcd1.print(" C ");
lcd1.setCursor (0,3);
lcd1.print("Dt:");
lcd1.setCursor (loc3a-1,3);
lcd1.print (" ");
lcd1.setCursor (loc3a,3);
lcd1.print(Dt);
lcd1.setCursor (8,3);
lcd1.print(" C ");
lcd1.setCursor (12,3);
lcd1.print("P/P");
if (temp1+3 < temp3)//test temp out of cooler is more than 3 c above ambient temp then run the pump
{lcd1.setCursor (16,3);
lcd1.print("RUN");}// need to add pin output to control pump relay
else
{lcd1.setCursor (16,3);
lcd1.print("OFF");}
lcd2.setCursor (0,0); // go to start of 1st line
lcd2.print("Boost press:");
lcd2.setCursor (loc1-1,0);
lcd2.print (" ");
lcd2.setCursor (loc1,0);
lcd2.print (Pressure);
lcd2.setCursor (16,0);
lcd2.print(" Bar ");
lcd2.setCursor (0,1);
lcd2.print("Oil Temp:");
lcd2.setCursor (loc4-1,1);
lcd2.print (" ");
lcd2.setCursor (loc4,1);
lcd2.print(temp4);
lcd2.setCursor (16,1);
lcd2.print(" C ");
lcd2.setCursor (0,2);
lcd2.print("Engine Bay:");
lcd2.setCursor (loc5-1,2);
lcd2.print (" ");
lcd2.setCursor (loc5,2);
lcd2.print(temp5);
lcd2.setCursor (16,2);
lcd2.print(" C ");
lcd2.setCursor (0,3);
lcd2.print("Exhaust:");
lcd2.setCursor (loc4,3);
lcd2.print("");
lcd2.setCursor (16,3);
lcd2.print(" C ");
delay(500);
} // end of main loop
/-----( Declare User-written Functions )-----/
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00)
{
Serial.print("Error getting temperature ");
}
else
{
Serial.print("C: ");
Serial.print(tempC);
Serial.print(" F: ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
}
}// End printTemperature
//( THE END )*