something sometimes modifies my lcd cursor settings!

My first step into this new C++ world is a controller for a solar shower. It reads 1-wire temp sensors and makes decisions based on the season, outside and inside temperatures and buttons that have been pressed (start & stop).
There also is a 2 line lcd display showing the current status and temperatures.
I use only basic statements, like lcd.set.Cursor (5,1) and lcd.print (TempIn1C, 0). This displays what I want and where I want it, but sometimes when the system has been idle during the night I see a temperature displayed at (7,1).
There is no such value anywhere in the sketch.

Is it possible the libraries used (LiquidCrystal_I2C, Wire, OneWire and DallasTemperature) have a conflict?

My bet is that there's a clue somewhere in the code. Pity I can't see said code or I might be able to help.

I agree with delta it sounds like a code problem based on a length of the temp being printed. As the lcd does not clear old data unless its told to do so or its overwritten you can end up with old and new data at the same time. Post your complete code so we can assist you.

This is the complete code for the solar shower project.
The two lines ' lcd.print(" ");' I have added as a solution to suppress the display error.
It has not been uploaded to the board yet because there is no easy access to the usb socket.

sketch_sep22lcd.ino (7.6 KB)

And what happened when you followed this instruction:

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

?

vaj4088:
And what happened when you followed this instruction:

  This report would have more information with

"Show verbose output during compilation"
  enabled in File > Preferences.




?

That just changes the screen output of the compiler in the field below the sketch. Lots of lines are written rapidly, too fast to read anything.

Lots of lines are written rapidly, too fast to read anything.

You can scroll the window and even select and copy the text into an editor of your choice to make it easier to read or into a post here if you want.

However, the problem is much more likely to be in your code that outputs to the LCD. As has been mentioned new data sent to the LCD overwrites what is already there but does not affect any areas of the screen not written to,

Thanks UKHeliBob.
The point is I set the cursor to position 5, there are 2 digits to be displayed, yet sometimes they land at pos. 7.
It may be that the DallasTemperature library occasionally outputs 4 digits instead of 2 but I don't understand why.

It may be that the DallasTemperature library occasionally outputs 4 digits instead of 2

As a test output the values to the serial monitor so that you can examine the output later. Put markers, perhaps < and >, around the output so that you can see spaces. Also output the time from millis() and any other data that may be relevant but make sure that you output a label for each so that you can understand what you are seeing.

OneWire oneWire1 (4); //create onewire object
OneWire oneWire2 (5); //and the second one

Single passenger buses only, huh?

Do you not understand that a bus can have multiple devices attached?

 TempIn1C = sensor1.getTempCByIndex(0);
  TempIn2C = sensor2.getTempCByIndex(1);

Get the temperature from the first of one devices on one bus, and the second of one temperature from the other bus. Hmmm...

  lcd.setCursor(13,0);//show status on the lcd
  if (onState == LOW)
  lcd.print(" ON");
  if (offState == LOW)
  lcd.print("OFF");

Seems like you forgot to read these states.

Though why you need two states to know if something is on or off, I can't imagine.

return;
  }

Why? What will happen if you leave the return statement out?

 lcd.print("    ");
  lcd.print(TempIn1C, 0);

Just out of curiosity, why are you printing floats with no data after the decimal point? How does that differ from an int?

I started post #1 with this "My first step into this new C++ world is a controller for a solar shower".
That should explain a lot; the only experience I have is programming administrative tasks in Cobol, 30 years ago.

The single passenger buses originate from an earlier circuit using KTY-10 sensors. Instead of cutting off plugs and sockets I used a software solution.

My clumsy sketch is the result of a lot of trial and error. I used the serial monitor to find out what went wrong until the sketch did what I had in mind and finally removed all serial.print statements. I started using a float field and printed 2 decimals, then decided such accuracy was nonsense.

I fully agree with you the sketch could be written much better if only I had more experience.

PaulS:
Just out of curiosity, why are you printing floats with no data after the decimal point? How does that differ from an int?

It differs in a subtle way.

If you work with int, everything gets truncated instead of rounding. So 5.7 becomes 5. With a float with no decimal it will round, so 5.7 becomes 6.

It differs in a subtle way.

What is the resolution on the temperature sensors that the OP is using? Does it even make sense to store the data in a float? THAT was the real question.

PaulS:
What is the resolution on the temperature sensors that the OP is using? Does it even make sense to store the data in a float? THAT was the real question.

I was just pointing out that these two would give different output. The question as you posed it was:

How does that differ from an int?

int anInt = 57 / 10;
Serial.println(anInt);  // should print 5


float aFloat = 57.0 / 10.0;
Serial.println(aFloat, 0);    // should print 6

The cause of misbehavior of the LCD is not my newbie programming but a faulty relay board. The signal from "heaterPin" (11) should steadily enable the relay, but instead the relay is chattering. As it switches a 1 KW AC load this causes enough static to make the Arduino go crazy. I have pulled the wire from (11) and have not seen any error on the display for several days.

You shouldn't be trying to power a relay from Arduino. A relay should have it's own power supply and Arduino should switch it with a transistor. This is a common problem noobs run into with relays and motors. Arduino just can't handle the current to run them directly off the board.

I find this piece of code interesting

if (offState == LOW) //yes, it was!
    {
      digitalWrite(onState, HIGH); //prevent needless execution
      digitalWrite(heaterPin, HIGH); //heater must be off
      digitalWrite(waitledPin, HIGH);// so are the status leds
      digitalWrite(readyledPin, HIGH);
      digitalWrite(cdsValue, 200);

    }

onstate is a flag that's used in the code as either a 1 or 0 (no idea why its a int)

the fact the compiler allows it means that its seeing onstate as a 1 or 0 so you are in fact setting pin 1 or 0 to high (that could mess with a lot of things)

I think its meant to be onstate=1;

or maybe I have missed something in the code and im completely wrong

digitalWrite(cdsValue, 200);

does the same thing. That's a analog reading so ive no idea what that's writing to.

If you look at the source for digitalWrite, anything other than 0 is interpreted as HIGH. Though the function takes an uint8_t as the second argument, it treats it like you would a boolean.

Delta_G:
If you look at the source for digitalWrite, anything other than 0 is interpreted as HIGH. Though the function takes an uint8_t as the second argument, it treats it like you would a boolean.

yes but what pin would it write high as cdsValue is used as the analog read (its not allocated as a pin number)