0

I am controlling a solar tracker, and it needs to be reset every 10 minutes or it loses its mind. My program works fine, controlling power relays, so I have added I2C&Power to be able to see the status remotely. For now it is set up on the workbench with fairly short cables. I also have a RTC and the i2cscanner finds them all..

LCD init code is pretty basic:

// 20 x 4  LCD Display
#include LiquidCrystal_I2C.h
// set the LCD address to 0x3F for a 20 chars 4 line display\/ Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); 

then

lcd.begin(20,4);  
lcd.clear();
lcd.setCursor(2,0);
lcd.print("PV Control 3.9");

My LCD (20x4) works fine at first, writing the top line with the name of the program, then the bottom line with a temperature reading, then every 10 minutes I need the second line to show when the power is off for 10 seconds. It shows "power off" just fine, but after the delay(10000) it is supposed to overwrite that line with "power on" but nothing changes...

Serial.println("POWER OFF");
lcd.setCursor(4,1);
lcd.print("-Power Off- ");
digitalWrite(power1,HIGH);  // DC HOUSE power off
digitalWrite(power2,HIGH);  // DC HOUSE power off
delay(10000);   
Serial.println("POWER ON");
lcd.setCursor(4,1);
lcd.print("-Power On-  ");
digitalWrite(power1,LOW);  // DC HOUSE power on
digitalWrite(power2,LOW);  // DC HOUSE power on

The problem is that it continues to say "power off" and doesn't overwrite it.

I can see from the Serial Monitor that the program is running fine, but the LCD doesn't change after the first set of lcd.prints at those character positions.

I haven't heard of anybody having this problem, but perhaps someone out there know about this. Any suggestions would be very welcome.

Question is: How can I make the LCD update lines that have been originally written?


UPDATE: Problem solved by simply clearing and rewriting the display when things change. I can't debug libraries but at least it is working now.

6
  • 2
    it needs to be reset every 10 minutes or it loses its mind - I'm not familiar with electronic devices losing their mind, so to speak. Can you elaborate? As for your other problems, it is impossible to answer without seeing your code.
    – Nick Gammon
    Oct 26, 2016 at 5:39
  • 1
    Please post the code that does not work, otherwise your question is unanswerable. Also the exact ref of your LCD would be good to know (they are not all the same). Finally a wiring diagram might be helpful too.
    – jfpoilpret
    Oct 26, 2016 at 7:11
  • 1
    Have you tried to isolate the problem, ie remove all other sensors and only keep code that handles the display updates at specific times?
    – jfpoilpret
    Oct 26, 2016 at 7:12
  • Ha. Loses its mind means it becomes non-responsive - comatose. I suppose I can be criticized for anthropomorphizing computer equipment. :
    – SDsolar
    Oct 28, 2016 at 1:18
  • If you look above you will see the source code is pretty basic. And the problem has been solved by simply clearing the display and rewriting it.
    – SDsolar
    Nov 4, 2016 at 16:48

1 Answer 1

-1

Ah ha. I solved it by using lcd.clear() and simply repainting the entire display with every change. I have much simpler LCD programs that don't require doing this, but it worked in this instance.

Same code as above, but with this before each power notification:

lcd.clear();
lcd.setCursor(2,0);
lcd.print("PV Control 3.9");

etc...


UPDATE: Now that I have two 20x4 LCD screens showing readings from two separate Arduinos (PV Controls and Weather station) I have discovered that it is very important to keep the screen writes to a minimum. No time delays in between writing parts of the screen, for instance (like when I had Serial.print statements in there for debugging), doing all the readings and calculations before writing the screen, and timing the screen updates to be infrequent, like on the order of 65 seconds for weather and 10 minutes for the PV. I2C does not have collision detection so it is important to try to prevent the two screens from being updated at the same time. The I2C&Power arrangement is working great. One source of power is all it takes to activate the entire network.

4
  • 2
    Neither the question nor this answer are adding much value to the site. You have an unspecified LCD, with an unspecified library, called by code you haven't posted. Your solution doesn't clarify why this is needed in this case and not other cases.
    – Nick Gammon
    Oct 28, 2016 at 9:16
  • @Gammon, you must not have read the actual question.. I suggest you scroll back up and take a look. Meanwhile, the problem is solved by clearing and rewriting the display. I don't have the expertise to debug libraries, but at least it now works.
    – SDsolar
    Nov 4, 2016 at 16:47
  • I see a drive-by downvoted this answer. I don't get that. Bottom line is that this answer solved the problem. Some peoples' kids.....
    – SDsolar
    Nov 11, 2016 at 2:51
  • @Gammon, re adding value to the site: For me, this added a lot of value. I may not be like you so we may come to different conclusions. Your comment that it does not add much value is at least parsed enough to not be an absolute, but there are a lot of different levels of people using this information. Why not record our experiences?
    – SDsolar
    Nov 11, 2016 at 3:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.