Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Liquid Display i2c (Read 849 times)
CJ
Newbies
*
Offline



Posts: 2
Liquid Display i2c
Nov 16th, 2018 at 3:09am
 
I am using an Elegoo Nano with a DHT11 Sensor.  I want to connect a LGDehome IIC/I2C/TWI LCD 1602 16x2 Serial Interface Adapter to it. On the display,  I connected the black to ground, red to5 volts, SCL to A5 on the Nano, SDA to A4.  As you will see in the code, I also am running the DHT11 to a serial port on a monitor.  It seems to work well on the monitor , but nothing shows on the lcd. Below is my code:

Code/
Code:
#include <LiquidCrystal_I2C.h>
#include <dht.h>
#include <Wire.h>
#define dht_apin A0 // Analog Pin sensor is connected to
dht DHT;
//#include <LiquidCrystal.h>

//LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal_I2C lcd(0x27, 16, 2);



void setup() {

  Serial.begin(9600);
  delay(1000                             );//Delay to let system boot
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
  delay(1000);//Wait before accessing Sensor                                                                                                            

}//end "setup()"

void loop() {
  //Start of Program

  DHT.read11(dht_apin);

  Serial.print("Current humidity = ");
  Serial.print(DHT.humidity);
  Serial.print("%  ");
  Serial.print("Temperature = ");
  //                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Serial.print(DHT.temperature);
  Serial.print((int)round(1.8 * DHT.temperature + 32));
  Serial.println(" F ");

  delay(500);//Wait 5 seconds before accessing sensor again.
 // int chk = DHT.read11(dht_apin);
  lcd.setCursor(0,0);
  lcd.print("Temp: ");
  lcd.print(DHT.temperature);
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0,1);
  lcd.print("Humidity: ");
  lcd.print(DHT.humidity);
  lcd.print("%");
  delay(1000);
  //Fastest should be once every two seconds.

}// end loop() 


/Code

What am I doing wrong???
Thanks

Back to top
« Last Edit: Nov 16th, 2018 at 2:53pm by Visual Micro »  
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10565
United Kingdom
Re: Liquid Display i2c
Reply #1 - Nov 16th, 2018 at 2:55pm
 
Hi,

This forum is really just support for the Visual Micro extension. Visual Micro remains compatible with the Arduino IDE so you would see the same issue with the Arduino IDE. This means that you can use the standard Arduino forums for support such as arduino.cc/forums or stackoverflow etc.

In this case I would recommend you always start with the examples that come with your library. In the LCD I2C examples you will see that they use lcd.begin() in the setup() to initialize the I2C connection

Code (C++):
void setup()
{
// initialize the LCD
	lcd.begin();

	// Turn on the blacklight and print a message.
	lcd.backlight();

} 

Back to top
 
WWW  
IP Logged
 
CJ
Newbies
*
Offline



Posts: 2
Re: Liquid Display i2c
Reply #2 - Nov 16th, 2018 at 9:24pm
 
Thank you.
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print