Hi
Using Leonardo and 2004 LCD screen I2C. For some of the reasons, there are no output reading from the Dallas DS18B20 sensors. Working around I discovered that disabling the lcd.begin() function restores the output. Looks that something is conflicting there, but cannot find where the bug is.
Any Ideas how to fix it?
Here's the code:
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3,POSITIVE); // Устанавливаем дисплей
DallasTemperature ds(&oneWire);
void setup()
{
//lcd.begin(20,4);
- ds.begin();*
- ds.setResolution(9);*
- Serial.begin(9600);*
- lcd.setBacklight(HIGH);*
}
void loop()
{
- ds.requestTemperatures();*
- float tempC0 = ds.getTempCByIndex(0);*
- float tempC1 = ds.getTempCByIndex(1);*
- Serial.print(tempC0); Serial.print(" - ");Serial.println(tempC1);*
// lcd.print (tempC0); lcd.print(" - "); lcd.print (tempC1);
- delay(1200);*
}
Where did you get the LCD library? It has a lot more parameters to the constructor than I would expect.
Try moving the DS18B20s to a different pin, twelve perhaps.
Tried all ports, same result.
pin 2 is shared by OneWire and LCD 
pin 2 is shared by OneWire and LCD 
The pin 2 in the LCD constructor refers to pin 2 of the I2C expander on the I2C backpack, but pin 2 on the Leo is the I2C SDA pin (SCL is p1n 3). What pins are used for the I2C in the project?
OP, it would help if you post a schematic of your project and a clear photo of your wiring.
Also read the how to use this forum-please read sticky to see how to properly post code.
Try this library for HD44780.
instead lcd.setBacklight(HIGH); use noBacklight(); & backlight(); or displayOff(); & displayOn();
wildbill:
Try moving the DS18B20s to a different pin, twelve perhaps.
leahonsky:
Tried all ports, same result.
I assume you mean "each available pin" when you said "all ports". When you moved the DS18B20 did you also move the required pull-up resistor?
https://playground.arduino.cc/Learning/OneWire/
"At the master, a 4.7k pull-up resistor must be connected to the 1-wire bus."
enjoyneering:
Try this library for HD44780.
Tried this library, gives me the same result.
groundFungus:
OP, it would help if you post a schematic of your project and a clear photo of your wiring.
It's connected to pin 2 and 3. Photo of the wiring is below.
johnwasser:
I assume you mean "each available pin" when you said "all ports". When you moved the DS18B20 did you also move the required pull-up resistor?
Right, using different pins and moving the resistor as well.
As alread said, pin2 is used by LCD and DS18x20
FIXED: wrong pull up resistor used, more than 4 MΩ.
Consider topic closed. Thks for help.