After many days confirming my weather station sketch (by using the serial monitor) the time has come to place an LCD into the sketch, preferably a 20 x 4 i2c can anyone advise a novice like me on the best / easiest way to do this ?
If sketch writing is programming then i guess it is a programming question, i will start again, i have written a sketch for my Arduino Uno, it is a Weather station with a Rain Bucket, Wind Speed and Wind Direction sensors. i have it written so that i can see if it functions ok in the Serial Monitor, and it does and very accurate also. I know wish to go one step further and get the Data transferred to an LCD preferably a 20 x 4, i2c, but as i am self taught i thought i would ask for guidance on doing this has i can only find artices for LCD's on their own. I am not asking for a sketch writer just some useful info to get a novice on his way.
I am not asking for a sketch writer just some useful info to get a novice on his way.
So, you are going to add more hardware, but you have only waved your arms uselessly and indicated that the hardware will be an LCD, possibly using the I2C interface.
When you've made up your mind, and actually acquired an LCD, with some KNOWN interface, I'm sure that you'll find that the manufacturer/supplier has provided at least a vague outline of how to connect it, and which library to use to talk to it. That library will come with examples.
If the supplier you choose does not, then you deserve to be stuck with a device you can't use, though you might have saved 39 cents.
I am not waving my arms around helplessly, i am trying to get guidance, something you seem to begrudge giving, maybe you should not respond in future, and let those that genuinely want to help others do so, or is it you do not understand English so good, ok i thought i had spelt it out, i have tried several avenues of approach, i have found nothing on integrating hardware, i have already stated the interface i want is an LCD i2c 20 x 4, i have tried your stated manufacturers approach, and i have found nothing, maybe i am looking in the wrong place, i do not know.
Do i have to completely re write my sketch?
Can i add LCD information into the Void Set & Void Loop ?
gresleyman:
Do i have to completely re write my sketch?
Can i add LCD information into the Void Set & Void Loop ?
No and Yes
Essentially you simply use
lcd.print(bucket);
instead of
serial.print(bucket);
plus commands to position the cursor.
Just have a look at the hello world example that comes with the LCD library, and that should have all you need. You should find this is a lot simpler than you currently think it is.
Thanks for the info, i am nearly there, one more question, what is the easiest way to display only whole numbers on the LCD, currently i have displayed Temp:22.45c, how to display Temp:22c only.
Juraj:
the LCD libraries implement Print class for print functions. it is the same Print class as used for Serial, those are the same print functions
Not quite.
println() won't work on the LCD.
The biggest challenge in converting a program that works on the serial port to using the LCD is that LCD doesn't work like a terminal.
i.e. it has fewer columns, fewer lines and does not support line ending characters like or , or scrolling.
What that means is that when printing to the lcd instead of printing to the serial port, you will have to more aware of where you printing things.
You will have to position the cursor on the LCD and then print the desired information.
Not difficult, but it is a difference so you will have to make adjustments to the code.
bperrybap:
Not quite.
println() won't work on the LCD.
The biggest challenge in converting a program that works on the serial port to using the LCD is that LCD doesn't work like a terminal.
i.e. it has fewer columns, fewer lines and does not support line ending characters like or , or scrolling.
What that means is that when printing to the lcd instead of printing to the serial port, you will have to more aware of where you printing things.
You will have to position the cursor on the LCD and then print the desired information.
Not difficult, but it is a difference so you will have to make adjustments to the code.
--- bill
I think it depends on the LCD model and the library. I do not have the overview in LCDs, but I am sure it is easy to implement Print with terminal behavior on LCD
Juraj:
I think it depends on the LCD model and the library. I do not have the overview in LCDs, but I am sure it is easy to implement Print with terminal behavior on LCD
Obviously; however, very few offer terminal behavior like line wrapping and vertical line display scrolling, and contrary what you have said, it isn't particularly easy to implement terminal behavior on an LCD.
That is why you haven't seen it implemented in any of the "LiquidCrystal" type libraries for hd44780 displays.
But even if the library and/or display device supports a "terminal" mode, one of the challenges can be that the physical display size of the LCD is smaller so it will likely require changing the existing text output to deal with that.
In this case gresleyman specifically mentioned using a 20x4 lcd over i2c.
That can inexpensively be accomplished by using a 20x4 hd44780 display and a very inexpensive PCF8574 based backpack.
(you can even purchase a display that has the backpack already soldered to it for under $10 USD)
While quick and easy to connect and get working, it will require changing the code as I mentioned earlier.
The code will need to position the LCD cursor position before outputting text to place the text in the desired position on the LCD display.
It isn't difficult, it is just a basic difference between using a terminal and using an inexpensive LCD with a much smaller display that simply works differently than an actual terminal.