Arduino LCD Display issue

Having an issue with writing data to the LCD screen for a dual sensor weather station.
The Humidity data (h) for the "Hum-in" writes as "3333333333.00%" its reading the humidity fine, but for whatever reason shows the above on the LCD screen, my setup has 2 LCDs and it doesn't matter which LCD i write to it displays that. The problem persists even if i swap (h) and (t), so its an issue with writing to the LCD, but i can't figure out the issue.
The Issue is with My_LCD1
Any help would be greatly appreciated.

#include <LiquidCrystal.h>
#include <Adafruit_Sensor.h>
#include "DHT.h"
LiquidCrystal My_LCD1(1, 0, 3, 4, 5 , 6);
LiquidCrystal My_LCD2(2, 0, 7, 8, 9 , 10);
#define DHT1PIN 11
#define DHT2PIN 12
#define DHT1TYPE DHT11
#define DHT2TYPE DHT11

DHT dht_1(DHT1PIN, DHT1TYPE);
DHT dht_2(DHT2PIN, DHT2TYPE);

void setup() {
  My_LCD1.begin(16, 2);
  My_LCD2.begin(16, 2);

  dht_1.begin();
  dht_2.begin();
}

void loop() {
  
  delay(2000);

  float h = dht_1.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht_1.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht_1.readTemperature(false);

    float h1 = dht_2.readHumidity();
  // Read temperature as Celsius (the default)
  float t1 = dht_2.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f1 = dht_2.readTemperature(false);

  My_LCD1.setCursor(0, 0);
  My_LCD1.print("Hum-in: ");
  My_LCD1.print(h);
  My_LCD1.print("%");
  My_LCD1.setCursor(0, 1);
  My_LCD1.print("Temp-in: ");
  My_LCD1.print(t);
  My_LCD1.print((char)223);
  My_LCD1.print("C");

  My_LCD2.setCursor(0, 0);
  My_LCD2.print("Hum-out: ");
  My_LCD2.print(h1);
  My_LCD2.print("%");
  My_LCD2.setCursor(0, 1);
  My_LCD2.print("Temp-out: ");
  My_LCD2.print(t1);
  My_LCD2.print((char)223);
  My_LCD2.print("C");
}

How are they connected? Please post a wiring diagram. Please, no Fritzing.

Are you using pins 0 and 1? Those are dedicated to serial communications.

LiquidCrystal My_LCD1(1, 0, 3, 4, 5 , 6);
LiquidCrystal My_LCD2(2, 0, 7, 8, 9 , 10);

Have you tried any simpler test sketches that only write to the displays?

You posted in the wrong category, this is for IDE issues according to the sub forum description.

1 Like

It's not a wiring issue, as i't doesn't matter which of the LCDs that i write My_LCD1 to, if i swap

LiquidCrystal My_LCD1(13, 0, 3, 4, 5 , 6);
LiquidCrystal My_LCD2(2, 0, 7, 8, 9 , 10);

to

LiquidCrystal My_LCD2(13, 0, 3, 4, 5 , 6);
LiquidCrystal My_LCD1(2, 0, 7, 8, 9 , 10);

The problem still persists. Pin 0 is being used solely for the EN pin on the LCD screens

It sounds like a hardware problem to me, it is probably that??? UhOh no schematic.

How do you know this??
It's not what it prints and I see no Serial prints..
Sometimes those sensor return a nan, Not A Number..
use isnan(t) to check and return if it is, to read again..
or maybe your screens are cursed, gremlins.. :slight_smile:
~good luck.. ~q

Did someone ask for A-sciimatic?

     +-----------------------------------------------------+
     |                  +----------+                       |
     |                  |My_LCD1 RS|-----------------------+
     |                  |        EN|-----------------------+
     |                  |        D4|---------------------+ |
     |                  |        D5|-------------------+ | |
     |                  |        D6|-----------------+ | | |
     |                  |        D7|---------------+ | | | |
     |                  +----------+               | | | | |
     |                  +----------+               | | | | |
     |                  |My_LCD2 RS|-------------+ | | | | |
     |                  |        EN|-----------+ | | | | | |
     |                  |   (D7) D4|---------+ | | | | | | |
     |                  |   (D8) D5|-------+ | | | | | | | |
     |                  |   (D9) D6|-----+ | | | | | | | | |    +----------+
     |                  |  (D10) D7|---+ | | | | | | | | | |    | DHT2 VCC |----+
     |                  +----------+   | | | | | | | | | | |    |      GND |--+ |
     |   +----------| USB |--------+   | | | | | | | | | | | +--|SIG       |  | |
     +---| D13/SCK        MISO/D12 |---|-|-|-|-|-|-|-|-|-|-|-+  +----------+  | |
         | 3.3V           MOSI/D11~|---|-|-|-|-|-|-|-|-|-|-|-+  +----------+  | |
         | Vref             SS/D10~|---+ | | | | | | | | | | +--| DHT1 VCC |--|-+
         | A0                   D9~|-----+ | | | | | | | | |    |      GND |--+ |
         | A1       NANO        D8 |-------+ | | | | | | | |    +----------+  | |
         | A2                   D7 |---------+ | | | | | | |                  | |
         | A3                   D6~|-----------|-|-+ | | | |                  | |
         | A4/SDA               D5~|-----------|-|---+ | | |                  | |
         | A5/SCL               D4 |-----------|-|-----+ | |                  | |
         | A6              INT1/D3~|-----------|-|-------+ |                  | |
         | A7              INT0/D2 |-----------|-+         |                  | |
   +-----| 5V                  GND |           |           |                  | |
   |     | RST                 RST |           |           |                  | |
   | +---| GND   5V  DO GND    TX1 |           |           |                  | |
   | |   | Vin   DI  SCK  RST  RX1 |-----------+-----------+                  | |
   | |   +-------------------------+                                          | |
   | +------------------------------------------------------------------------+ |
   +----------------------------------------------------------------------------+

Have you tried separate EN connections? The examples I can find for multiple displays show common connections for everything except EN, the exact opposite of how you have it wired.

use separate pins.
You can use A0 - A5 also.
I would spare 0 and 1 for Serial - debugging.

When using multiple LCDs you can double up on all of the LCD pins EXCEPT for the Enable pin.

You have done just the opposite.

Don

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.