1.0.6 to 1.8.1, Lost libraries and Newbie confusion

First post...

I started playing with the Arduino about 2 years ago after a nasty spinal injury whilst flying, just to keep me amused. I got as far as making an LCD read-out revcounter, temp gauge and oil pressure gauge before I started my Physio. Now that I've returned to tinkering I have been persuaded to update the laptop with 1.8.1 but that has caused a few issues.

Firstly, I now have the well-known "WConstant" problem with The OneWire and DallasTemperature_360 .cpp libraries. I amended the libraries as per the instructions found on here but when I try to Verify the file it repeatedly tells me that I still have the WConstant issue. Am I missing something by virtue of my lack of experience?

Secondly, are there any problems likely from making such a leap from 1.0.6. to 1.8.1?

Thirdly, I see there are quite a few options for the DallasTemperature libraries. I used _360 originally but would it be better to try a later format? I wasn't sure if the convention was to make the newer versions incompatible with the older ones.

Later today I'll try to copy the code onto here, as per the "How to make a post without annoying too many people" instructions at the top of the page. Apologies for the rambling message, I'm on rather a lot of painkillers!

/*  Using the isr function lets the digi2 pin sense the RISING of the voltage upslope every time the
  sensor goes above zero volts.  The millis function counts the time from switch-on and thus the
  difference between float count from start is the time interval between sensor triggering ie; once
  per revolution.
  The idea is to run all the instrumentation for a 1932 Austin Seven to save the great expense of buying original/unreliable dials.
  The LCD affected the rpm results until a serial chip was added.
  The triggering is from a hall-effect sensor and some powerful 3mm barrel magnets, currently one pass per revolution.
  The temp probe is a DS18B20 which comes pre-packaged in a stainless steel waterproof bundle and is wedged into a
  brass nut on the top of the cylinderhead water casting (so will still show "high" if all water is lost.
  An led is triggered if the rpm falls into a known danger band but this could also be adapted to make a limiter indication for max revs.
  Yellow=SCL, Orange=SDA, Orange temperature probe single wire=Pin9, Brown Servo wire=pin10, Blue hall-effect single wire=Digipin2(akaInt0)
  Oilpressure gauge. 0.5v(analog102) is 0psi, 4.5volts(analog921) is 30psi

  Rob Thomas, Dec 20, 2016.

*/

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>  //libraries for the temp probe
#include <Servo.h>
#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3 //Port numbers on the serial chip thingy
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define POL POSITIVE //Backlight polarity
#define ONE_WIRE_BUS 9  //onewire input through pin 9

Servo myservo;  // create servo object to control a servo
float value = 0;
float rev = 0; //clock count from upslope
int rpm;
int dial;

int oldTime = 0; //previous count from upslope
int time;  //difference between new and old count
int oilout = 1;
int oil = 1;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin,
                      Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin, 3, POL);

byte a[8] = {  //manufacturing the 'degree' symbol

  0b00010,
  0b00101,
  0b00101,
  0b00010,
  0b00000,
  0b00000,
  0b00000,
  0b00000
};

byte b[8] = { //manufacturing the small "2" symbol
  0b00000,
  0b00000,
  0b00000,
  0b01100,
  0b10010,
  0b00100,
  0b01000,
  0b11110
};

void isr()
{
  rev++;   //increase clock count
}

void setup()
{
  lcd.begin(16, 2);
  lcd.setBacklight(HIGH);
  lcd.print("Austin Seven");  //brief announcement of the type of vehicle
  lcd.createChar(1, a);
  lcd.createChar(2, b);
  attachInterrupt(0, isr, RISING); //digital pin 2 (a.k.a "int0")
  sensors.begin();
  pinMode(13, OUTPUT);
  pinMode(A0, INPUT);

}

void loop()
{
  delay (1000);
  oil = analogRead(A0);

  oilout = ((oil - 116) / 2.65333);
  detachInterrupt(0);

  sensors.requestTemperatures();
  time = millis() - oldTime;
  rpm = ((rev / time) * 60000); //count of revolutions in 1 second during 'delay' assuming one magnet pass per revolution
  oldTime = millis(); //resets elapsed time count
  rev = 0;
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("RPM=  ");
  lcd.setCursor(4, 0);
  lcd.print(rpm * 10);
  lcd.setCursor(0, 1);
  lcd.print("H");
  lcd.setCursor(1, 1);
  lcd.write(2);  //wrte the small "2" sign
  lcd.setCursor(2, 1);
  lcd.print("O=");
  lcd.setCursor(4, 1);
  lcd.print(sensors.getTempCByIndex(0));
  lcd.setCursor(9, 1);
  lcd.write(1); // write degree sign


  lcd.setCursor(9, 0);
  lcd.print("OIL");
  lcd.setCursor(13, 0);
  lcd.print(oilout);
  lcd.setCursor(12, 1);
  lcd.print(oil);

  dial = map(rpm, 0, 500, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(dial);                  // sets the servo position according to the scaled value
  delay(15);


  if (rpm >= 2200 && rpm <= 2400) //Vibration band warning for Austin Seven engine
  {
    digitalWrite(13, HIGH);  //White wire to 13, black to gnd.
  }
  else
  {
    digitalWrite(13, LOW);
  }
  attachInterrupt(0, isr, RISING);

}

This is what I get in the error messages on the same laptop that I've been using all along.

Well, well, well...for some reason the "WConstant" messages have disappeared overnight. Now I'm REALLY confused.

Arduino: 1.8.1 (Windows XP), Board: "Arduino/Genuino Uno"

A7tempOilRpmAOJan2017b:30: error: 'POSITIVE' was not declared in this scope

  #define POL POSITIVE //Backlight polarity

              ^

C:\Documents and Settings\Administrator\My Documents\Arduinov1\A7tempOilRpmAOJan2017b\A7tempOilRpmAOJan2017b.ino:44:41: note: in expansion of macro 'POL'

  Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin, 3, POL);

                                         ^

C:\Documents and Settings\Administrator\My Documents\Arduinov1\A7tempOilRpmAOJan2017b\A7tempOilRpmAOJan2017b.ino: In function 'void setup()':

A7tempOilRpmAOJan2017b:74: error: no matching function for call to 'LiquidCrystal_I2C::begin(int, int)'

   lcd.begin(16,2);

                 ^

C:\Documents and Settings\Administrator\My Documents\Arduinov1\A7tempOilRpmAOJan2017b\A7tempOilRpmAOJan2017b.ino:74:17: note: candidate is:

In file included from C:\Documents and Settings\Administrator\My Documents\Arduinov1\A7tempOilRpmAOJan2017b\A7tempOilRpmAOJan2017b.ino:17:0:

C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note: void LiquidCrystal_I2C::begin()

  void begin();

       ^

C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note:   candidate expects 0 arguments, 2 provided

Multiple libraries were found for "DallasTemperature.h"
 Used: C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\DallasTemperature
 Not used: C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\Arduino-Temperature-Control-Library-master
exit status 1
'POSITIVE' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I believe the problem is that you have the wrong LCD library installed. Try this one:
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

Thanks for replying. I appreciate the good advice. I lost quite a few 'items' when I put 1.8.1 on my laptop so it would make sense that I may have re-loaded either older or outdated versions of the libraries. I'll give this one a try.

I'm not really computer literate, more into metalwork such as making vintage car bodies in alloy or aircraft cowlings. This is all new to me.

There seem to be several libraries around for things like LCD screens. Is there any advice you might give with regards to how I would be best advised to update/remove/exchange libraries? I have an LCD library built in to the 1.8.1 upload (Called LiquidCrystal) and then added another that I'd previously used (called Arduin0-Liquid_Crystal_I2c_library-Master) but am now wondering if it is good pratice to remove such duplicate libraries?

Many thanks

Rob Thomas

Unfortunately there are multiple libraries named LiquidCrystal_I2C so it causes a lot of confusion. The instructions on the link I posted above say:

The library has been developed to replace the current Arduino library, therefore you will need to remove/backup the LiquidCrystal folder from the Arduino library folder the original LiquidCrystal library and replace it for this one. You will also potentially need to remove other LCD libraries like LiquidCrystal_I2C as that will also conflict with this library.

That's not generally a smart thing to do because any library you install into the Arduino IDE installation folder will be lost when you update to a new version of the Arduino IDE. So my advice is to do this:

That will make sure that none of the other LiquidCrystal libraries you have installed will interfere with the one your code is written for.

RobThomas:
Secondly, are there any problems likely from making such a leap from 1.0.6. to 1.8.1?

Not too bad. I think the WConstant.h issue you ran into dates back to the 1.0.0 and you would have run into that even in 1.0.6. The most common issue when using old code with the new IDE is the loss of support for the old specialized PROGMEM types but it's a very simple change when you run into that.

RobThomas:
Thirdly, I see there are quite a few options for the DallasTemperature libraries. I used _360 originally but would it be better to try a later format?

I don't have any experience with those libraries. My instinct would be to find the one that seems to be the most widely used and is actively developed(rather than abandoned by the author).

RobThomas:
I wasn't sure if the convention was to make the newer versions incompatible with the older ones.

Once you establish an API it's definitely best practice to avoid breaking compatibility unless absolutely necessary. However, there is no guarantee that the API will be the same from one library to another. Sometimes there is an attempt to maintain the same API across different libraries. For example, the LiquidCrystal_I2C and similar libraries tend to try to emulate the stock Arduino LiquidCrystal library's API but there are definitely some differences in some of them.

Thanks again, Pert.

I'll have another try later today and see how it goes. I'll also run it all on a desktop computer to see if there are any other issues.

Fun, isn't it!!

There should be nothing to prevent you having several different versions of the IDE on your PC if that would be useful.

...R

Thanks, Robin. I'd read somewhere that I should delete the old one. Not a good move, by the looks of things.

Anyway, putting in a new LCD_i2c library after deleting the old ones got me 99% of the way and then I needed to remove one .h file and it will now happily compile. I've still got a 100% original (working) Arduino so I'll move the sensors over to a new one and see if the wiring still works without me mucking up the old unit.

3 days of messing about. Phew!

You just need to use the "Windows ZIP file for non admin install" download link then you can have as many versions of the IDE as you like. I have 19 of them installed but that's a bit over the top.

I just noticed that you're using Windows XP so I have to break some bad news to you regarding the upgrade to Arduino IDE 1.8.1. Unfortunately the linker program used on newer versions of the Arduino IDE(I think 1.5 and newer) has intermittent problems when used on Windows XP("collect2.exe: error: ld returned 5 exit status") error when compiling. There are a couple of fixes people have found for it but I've been hearing some mixed reports of whether those fixes are working with the last few versions of the Arduino IDE. More information at:
https://forum.arduino.cc/index.php?topic=310950

pert:
I just noticed that you're using Windows XP

Time to switch to Linux, perhaps. Puppy Linux works great on older machines. :slight_smile:

...R

Do not worry. Do not feel stupid.

Whenever you update software, strange things may (will) happen.

I upgraded from a more than two year old IDE to IDE 1.6.13.

One of my programs did not compile anymore. It was one of the libraries, that was too old.

So I did a lot of research (.. looking for known solutions).
I downloaded the latest libraries indicated by Google researches.

The Google link was too old. It did not work.
The link was not even that old - it was the latest shown.

Only a guy from the forum told me to use an other link (both were on GitHub).

It DID work.

Lots of thanks to the community !!!!!!