You will find out how to get to the I2C address of your display. If the standard 0x27 does not work, you can optionally connect a 20x4 LCD. Your time formats according to your choice.
After I was informed about the advantages of the I2C (= IIC) port and managed more than 120 objects, I have reordered an I2C adapter. It will upgrade my displays with I2C, and save the wiring of the 16 PINs. The adapter advantageously carries a potentiometer on board, which can adjust brightness. The photo shows a screwdriver that fixes the adapter header after insertion into the LCD. This ensures good contact (the soldering will be done later).
If you want to know more about I2C in conjunction with BME280 and OLE displays, you can follow this other project.First Part
I have tried to run the example of the libary, and I only got bricks on the display.
After all, I had GND, VCC and D0 (SDA) and D1 (SCL) as a source of errors. I can exclude some, even if I have not built the resistors from the Particle Doc. The research brought me to change the hex address and so it worked out right away.
// The address is typically 0x27. I2C Address: 0x3F // https://www.sainsmart.com/new-sainsmart-iic-i2c-twi-1602-serial-lcd-module-display-for-arduino-uno-mega-r3.html lcd = new LiquidCrystal_I2C(0x3F /*address*/, 16 /*columns*/, 2/*rows*/);
This manual approach was trial and error, and could have gone wrong. I am today on this thread from 2014, which an I2C scanner pushed the correct addresses over the serial port. So I feel responsible to document this project over the succession of 3 years.
The I2C scanner has also confirmed the manual search, and thus both the LCD 16x2 and the LCD 20x0 are controlled via the hex address 0x3F.Second Part
The second part now wants to replace the example code for the clock from the library, and present ways to format its own output.
lcd->setCursor(0 /*columns*/,0 /*rows*/); // lcd->print(Time.timeStr()); lcd->print(Time.format(Time.now(), "%d.%m. %A")); // Serial.println(Time.format(Time.now(), "%H:%M:%S")); lcd->setCursor(4,1); lcd->print(Time.format(Time.now(), "%H:%M:%S"));
In addition to determining the position of the output, specifying the column and the row, the formatting of the time.function can also be influenced. There are the small letters that influence the formatting. I have oriented myself to a PHP formatting. The Photon already has the time function on its own; an extension is not necessary on its part.
I haven't change the code:
lcd = new LiquidCrystal_I2C(0x3F /*address*/, 16 /*columns*/, 2/*rows*/);
Better in case you want to use an LCD 2004:
lcd = new LiquidCrystal_I2C(0x3F /*address*/, 20 /*columns*/, 4/*rows*/);
Like my description? You will find more under my account.
Follow me to be notified when I publish new projects!
Here is my Paypal link. You can also send me sensors, which I like to look at sometimes.