Go Down

Topic: Help with code for LCD display 20x4 (Read 144 times) previous topic - next topic

Lollo-20

May 08, 2019, 06:07 pm Last Edit: May 08, 2019, 06:08 pm by Lollo-20
Hello.
I wrote the following code that I use to report sensor data mq-7 (carbon monoxide) and dht11 (temperature and humidity).
The problem is in the dht11 sensor, the display does not show the writing humidity with the value.
checking the code on the arduino idle an error will appear.

Where is the problem?
Kind regards.

P.S: I leave the code file, if you can tell me where I went wrong.

bperrybap

You have lots of "dead" / unused code after the updateMillis() function.
It is all the code starting  with:
Code: [Select]
Serial.println("=================================");

Everything from that line to the end of the file should be deleted to allow the code to compile.

--- bill

groundFungus

#2
May 08, 2019, 06:36 pm Last Edit: May 08, 2019, 06:40 pm by groundFungus
Code: [Select]
   digitalWrite(ledPin, ledValue);
   delay(100);

} // this closes loop()

void updateMillis()
{
   previousMillis = currentMillis;

} // this closes updateMillis

// all of the rest of the code is outside of a function which is illegal.
Serial.println("=================================");
Serial.println("Sample DHT11...");


You need to mind your curly brackets.  I don't know what you intend, but all the code needs to be in a function [loop() maybe?].  I would suggest that you move the updateMillis function definition to after the end of the code and clean up the curly brackets and then the code may compile.

You can better see the program flow and the program's blocks of code if you use the autoformat function of the IDE (ctrl-t or Tools, Auto Format).

Please post code and error messages as described in the how to use this forum-please read sticky.  Post the entire text of the error message.

Geek Emeritus

1) read the bottom half of my signature line

2) what does everything after 0x27 do in an I2C LCD system?
Code: [Select]
LiquidCrystal_I2C lcd(0x27, 2, 1,0,4,5,6,7,3,POSITIVE);


All PMs will be deleted unopened due to arrogant argumentative pot stirring Malfoys.
 If you have not read "How to use this forum - please read", in particular: "7. If you are posting code or error messages, use "code" tags":  expect rude responses

bperrybap

2) what does everything after 0x27 do in an I2C LCD system?
Code: [Select]
LiquidCrystal_I2C lcd(0x27, 2, 1,0,4,5,6,7,3,POSITIVE);
I'm assuming this is a serious question.

The parameters in the constructor configure the library.

The constructor being used is for a library  that provides and i/o class that is for devices that are not really I2C based LCDs  but rather a standard hd44780 LCD that is controlled by using i/o pins on an i2c i/o expander.
The library must be told how those i/o expander i/o pins are wired up to the LCD pins and the backlight circuit as well as the active level needed on the backlight control pin to turn on the backlight.

If you use the hd44780 library and hd44780_I2Cexp i/o class, it can figure all that out for you so the constructor for the lcd object does not need any parameters.

--- bill

Geek Emeritus

my I2C library handles that. I never saw it done this way before
All PMs will be deleted unopened due to arrogant argumentative pot stirring Malfoys.
 If you have not read "How to use this forum - please read", in particular: "7. If you are posting code or error messages, use "code" tags":  expect rude responses

bperrybap

my I2C library handles that. I never saw it done this way before
Can you provide a link to that library?
So far the only library I've seen that supports using a PCF8574 to talk to a hd44780 LCD and auto locates the i2c address as well as  auto detecting the pin mappings is my hd44780 library.

--- bill

Geek Emeritus

the only library that worked for me when I  started my project:

LiquidCrystal_PCF8574
All PMs will be deleted unopened due to arrogant argumentative pot stirring Malfoys.
 If you have not read "How to use this forum - please read", in particular: "7. If you are posting code or error messages, use "code" tags":  expect rude responses

bperrybap

the only library that worked for me when I  started my project:

LiquidCrystal_PCF8574
I am familiar with that library and while it may work for you, it does not "... handle that .." as you said (auto detect address and pin mappings like the hd44780 library).
LiquidCrystal_PCF8574 requires that the i2c address be specified in the constructor and it hard codes the pin mappings and backlight control to one specific backpack design.
Depending on the backpack that a person has, it may or may not work with their backpack.

Also, that library (LiquidCrystal_PCF8574) has s/w licensing issues. It has both LGPL and copyright violations.
The author has attempted to change the s/w license of the library but since the library was a derivative from a LGPL project, he does have the rights to do so. So regardless of the author claiming to have re-licensed his derivative as BSD, he can't do that as that is not allowed by the code he started with.
For sure the author is aware of this but has chosen to ignore the LGPL/GPL licensing rules / restrictions. (more than once)
https://github.com/mathertel/LiquidCrystal_PCF8574/issues/4

While people can use anything they want for their personal projects, using that library for a commercial closed source Arduino based product would put the product at risk since while BSD licensing does allow that, LGPL (which is the real license of this code) requires some additional things be done that are not possible when using Arduino and the  Arduino IDE.
i.e. if using LGPL based code in a project, there isn't a way to fully comply with all the LGPL license terms when using the Arduino environment other than to open source the entire project.

--- bill

Go Up