I am still in the heavy learning phase with Arduino and all of the code associated with it, and while working through an online tutorial I began fiddling with the LCD screen.
Thinking it would be a pretty simple task, I began looking up the layout and code for a humidity and temperature reader that would display on a LCD screen, and much to my dismay I couldn't find anything but two separate tutorials that didn't do quite what I needed. Bound and determined to get the optimal crabitat conditions, I set out on my quest to frankenstein the code and layouts into one.
Sure, buying a thermometer and hydrometer combo for his tank probably would have been easier and cheaper, but where's the adventure in that?! What better way to segway into the world of open source electronics than with something (mildly) practical?
It was fun to make, and I hope someone finds it as useful as I will (when it reaches it's final form!)
So I realized I need to post more project logs if I want to stay motivated to finish this. Here it is!
I plan on getting an Arudiuno nano (really small with all the functionality of an UNO!!) and then designing a case to hold the LCD screen on the outside with the nano inside connecting it all together, then sending a cable out with the sensor going into the tank, eliminating the possibility of damage to the actual assembly.
Until I acquire a nano the project can't progress because I need the measurements to design the case.
In the mean time here is a layout of the original setup with the code! (developed with Fritzing)
The Code:
#include <LiquidCrystal.h> //Include LCD library#include "DHT.h" //Include Library for DHT sensors#define DHTPIN 2 //defines reader pin for the sensor as Arduino pin 2#define DHTTYPE DHT11 //set which DHT sensor is being usedDHT dht(DHTPIN, DHTTYPE);
// initialize the library with the numbers of the interface pinsLiquidCrystal lcd(7, 8, 9, 10, 11, 12);
voidsetup(){
Serial.begin(9600);
dht.begin();
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Chuck's tank!");
}
voidloop(){
delay(1000); //set rate for screen refresh can't be lower than 1000msfloat H = dht.readHumidity();
float f = dht.readTemperature(true);
lcd.setCursor(0, 1);
lcd.print(" %");
lcd.setCursor(0, 1);
lcd.print(H);
lcd.setCursor(8, 1);
lcd.print(" deg");
lcd.setCursor(8, 1);
lcd.print(f);
}
Within the quotes in the first sets of lcd.print are four spaces allowing the second print to fully display info without overlapping
You will need to download a library from: https://github.com/adafruit/DHT-sensor-library and import it into your arduino library, I believe there are instructions on the download link.
If you have any questions/suggestions post in the comments below or send me a DM!!
"crabitat" is an awesome description... this looks like a pretty groovy "crabitat-mon"