4D Systems uLCD-35DT + YUN + DHT11 sensor

Hello Everyone,

Just wanted to post a great, but simple layout that works perfectly after all my tweaking time, experimenting and research. I hope to save you most of the headache I had, but enjoy putting together a nice project. :slight_smile:

Prologue:
I bought the 4D Systems uLCD-35DT-AR (Started Kit) from Mouser a few months ago, but have been too busy with my other projects to mess with it until now. So back to the study guides from 4D Systems and Youtube. Not much on Youtube for 4D Systems uLCDs. Also, FYI, I bought the whole uLCD-35DT-AR kit because it includes everything you need to program this baby. Be sure you spend the extra $20. There is no need for me to be nickel and diming things when a few more dollars sets me up properly. Believe me, you will need this stuff. I have found that the Revision 1 pdf's are most uptodate in 2014.

The project I have here on the uLCD screen uses 3 LED digit objects using the Visi-Genie portion of the 4D Systems software IDE.
LED_Digit 0 = the Celsius Scale
LED_Digit 1 = the Fahrenhet scale,
LED_Digit 2 = Humidity

I am in landscape mode, but you can experiment with whatever style you like. All these concepts are clearly explained in the intro material to the 4D Systems and with the links I provide below. Don't be afraid to experiment. That's what we do!
Many minor details are omitted because you will find them in the tutorials and study guides that you must read before trying to program this beautiful machine.

Parts
1 each YUN with power supply-you could just as easily use a Uno R3-I did that first-make necessary code changes to the print functions
1 each 4D systems uLCD-35DT-AR (Starter Kit) --or similar (mine runs the Diablo16 chip). You do not need the shield for this. Nor will I elaborate about it.
4D Systems Workshop 4 Software-mandatory for programming the uLCD-DT35
1 each 1k resistor --for the uLCD to pull it down at Pin 4 of the Arduino and the Reset Pin on the uLCD-please see
"ViSi-Genie Connecting a 4D Display to an Arduino Host" page 33 for the graphic. Download here:
http://www.4dsystems.com.au/downloads/Application-Notes/4D-AN-00017_R_1_0.pdf

1 each 2 gb micro SD card formatted in FAT16-comes with the uLCD-35DT-AR kit
1 each DHT11 Temp/Humidity sensor
1 each 10K resistor for the DHT-unless wired in module already
1 each breadboard with power supply
A bunch of male wires with various lengths to connect devices together

Set up
Caveat-even when using the powered breadboard be sure to at least run a ground wire from the YUN to the breadboard (-), otherwise you'll find that the DHT11 may not work correctly. (Of course, you can run the DHT11 right off the YUN)
I use the 5v powered breadboard because it provides more power to run the uLCD-35DT. Still ground the YUN to breadboard.

4D Systems Programming Workshop 4 Software--It is free
http://www.4dsystems.com.au/product/4D_Workshop_4_IDE/

Please see the instructions for this from 4D systems after you have installed the software package. You can also go to the website at:
http://www.4dsystems.com.au/appnotes/
and search for relevant tutorials and data. There are plenty. Be sure to use the right ones for your chip type on the uLCD.
Find the "Serial Connection to an Arduino Host_4D-AN-00092_R_1_0.pdf" and read it. Very helpful

To help you see how to set up the LCD specifically for temps, look over and understand this 4D publication
"ViSi-Genie Displaying Temperature Values from an Arduino Host" aka 4D-AN-00015-R-1-0 in pdf format.
http://www.4dsystems.com.au/appnotes
download the zip file to have all included files available

You will need this Arduino library from 4D to assist you and make life easier, and to run this sketch:

#include "SoftwareSerial.h"  
#include "Arduino.h"
#include <genieArduino.h>
#include <Bridge.h>
#include "DHT.h"
#include <Console.h>

Genie genie; //need to create this instance

SoftwareSerial mySerial (10,11); // // creates a virtual Serial and assigns pins for RX, TX on the YUN

int pinD4 = 4; //this is necessary to do a reset on the 4D Systems uLCD-35DT at program start

#define DHTPIN A0     // what pin we're connected to on the Arduino from the DHT data pin


#define DHTTYPE DHT11   // DHT 11

// DHT Sensor use
// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is on Arduino
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
// Connect pin 4 (on the right) of the sensor to GROUND


// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);


int pin13 = 13;//defining digital pin 13 -will be using only for setting HI-LO of onboard LED

void setup() {
//get all the services started
  Bridge.begin();
  Console.begin();
  mySerial.begin(9600); //used for uLCD communication
  Console.println("DHTxx test!"); //don't forget to use Console for the display data with the IP addressed YUN
  pinMode(pin13,OUTPUT);
  dht.begin();
  
  genie.Begin(mySerial);   // Use Serial0 for talking to the Genie Library, and to the 4D Systems display

  digitalWrite (pin13, LOW);
  delay(100);
  digitalWrite (pin13, HIGH);
  delay(100);

  //resetting 4D Systems uLCD-35DT display-must be done at the beginning in the setup-screen will flicker
  pinMode(pinD4,OUTPUT);
  digitalWrite(pinD4,LOW);
  delay(100);
  digitalWrite(pinD4,HIGH);
  delay(3500); //need this much delay time
  
}

void loop() {
  // Wait between sensor measurements.
  delay(2000);
  

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  int h = dht.readHumidity();
  // Read temperature as Celsius
  int t = dht.readTemperature();
  // Read temperature as Fahrenheit
  int f = dht.readTemperature(true); //converts to Fahrenheit thru the DHT library
  
  //why ints instead of floats above? It is because 4D WriteObject() function below only accepts int as 3rd parameter
  
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Console.println("Failed to read from DHT sensor!");
    return;
  }

  // Compute heat index
  // Must send in temp in Fahrenheit!
  int hi = dht.computeHeatIndex(f, h);
  
//((char)176); = degree symbol
//Properly formatted screen output-merely decorative, but definitely easier to read
//Of course none of the Console stuff is necessary, but gives visual feedback during experimentation
//Can also be setup in Client/Server mode to a Web page if you wanted. Some other tutorial

  Console.print("Temperature: "); 
  Console.print(t);
  Console.print((char)176); //this is the degree symbol as it can't be recognized any other way in Arduino that I've seen
  Console.println("C");
  Console.print("Temperature: "); 
  Console.print(f);
  Console.print((char)176);
  Console.println("F");
  Console.print("Heat index:  ");
  Console.print(hi);
  Console.print((char)176);
  Console.println("F");
  Console.print("Humidity:    "); 
  Console.print(h);
  Console.println("%");
  Console.println();
  
  
 //4D system Visi-Genie code--writing the sensor data back to the uLCD screen
 genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, t);         //Write to Leddigits0 the value of Celsius
 delay(50); //required delay
 genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x01, f);         //Write to Leddigits1 the value of Fahrenheit
 delay(50);
 genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x02 , h);    // Write Leddigits2 the value of Humidity
 delay(50);
 
  
}

This should do it for you all. Hope this is fun for you. If you have questions please post. We'll work through it.
One last caveat: be sure the 5 wire connector for the uLCD is plugged in correctly to both the lcd and the Arduino YUN. It is possible to reverse these FYI. The wire is labeled properly.

One last thing, I have no affiliation with any company mentioned here today.

houdinihar

Great post - thanks for sharing. I'm considering purchasing a 4D screen for my Yun, but I've seen in other posts that some have had trouble since the Yun uses its serial ports to allow the linux and arduino chips to talk to one another. How did you overcome this? Thanks!