Show Posts
|
|
Pages: [1]
|
|
2
|
Using Arduino / Programming Questions / Re: trouble - using interupt via LDR when a LCD screen is used
|
on: March 31, 2013, 09:19:11 am
|
ok  I think its sorted it; with help from yourselves  thank you v much // include the library code: #include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <dht11.h>
dht11 DHT11;
#define DHT11PIN 7
// Define pins for CO2 Sensor int CO2_ReadPin = A0; int CO2control = 13; int CO2_Value; int ppm; int ldr = A5; unsigned int ldrvalue = 0;
void setup() { // Setup for co2 controller pinMode(CO2control, OUTPUT); digitalWrite(CO2control, LOW); // set up the LCD's number of columns and rows: lcd.begin(20, 4); // Serial.begin(9600); //DISPLAY TEMPERATURE lcd.setCursor(0, 0); // print the Temperature title lcd.print("Temperature"); lcd.setCursor(17, 0); lcd.print(char (0xdf)) + lcd.print("C"); //DISPLAY RELATIVE HUMIDITY lcd.setCursor(0, 1); // print the Relative Humidity title lcd.print("Humidity"); lcd.setCursor(17, 1); lcd.print("%"); //DISPLAY CO2 READINGS lcd.setCursor(0, 2); // print the CO2 title lcd.print("CO2 > "); lcd.setCursor(17, 2); // print the CO2 'ppm' lcd.print("PPM"); //SQUIRREL-LABS lcd.setCursor(3,3); lcd.print("Squirrel-Labs"); // Setup for CO2 Sensor
int CO2_Value = 0; // variable set to zero int ppm = 0; // variable set to zero }
void loop() { int chk = DHT11.read(DHT11PIN); // Loop for CO2 Sensor CO2_Value = analogRead(CO2_ReadPin); // read Teensy input pin 38 unsigned int ppm = ((unsigned long)analogRead(CO2_ReadPin) * 2500)/1024; // calc ppm ldrvalue = analogRead(ldr); if (ldrvalue < 700) { digitalWrite(13, LOW); lcd.setCursor(6,2); lcd.print("Off "); lcd.setCursor(3,3); lcd.print("Night Mode "); } else { if (ppm < 1300) digitalWrite(CO2control, HIGH); lcd.setCursor(6,2); if (ppm < 1300) lcd.print("On "); if (ppm > 1500) digitalWrite(CO2control, LOW); lcd.setCursor(6,2); if (ppm > 1500) lcd.print("Off "); //SQUIRREL-LABS lcd.setCursor(3,3); lcd.print("Squirrel-Labs"); } delay (2000); //TEMP lcd.setCursor(14, 0); // print the Temperature valie lcd.print((float)DHT11.temperature, 0); //HUMIDITY lcd.setCursor(14, 1); // print the Relative Humidity value lcd.print((float)DHT11.humidity, 0); delay (1000); //CO2 lcd.setCursor(11, 2); // print the CO2 value if(ppm < 1000) lcd.print(" "); if(ppm < 100) lcd.print(" "); if(ppm < 10) lcd.print(" "); lcd.print(ppm); delay(2000); }
|
|
|
|
|
3
|
Using Arduino / Programming Questions / Re: trouble - using interupt via LDR when a LCD screen is used
|
on: March 31, 2013, 08:10:06 am
|
So Here is one way I experimented with before looking into interrupts: am I on the right path?? // include the library code: #include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <dht11.h>
dht11 DHT11;
#define DHT11PIN 7
// Define pins for CO2 Sensor int CO2_ReadPin = A0; int CO2control = 13; int CO2_Value; int ppm; int ldr = A5; unsigned int ldrvalue = 0;
void setup() { // Setup for co2 controller pinMode(CO2control, OUTPUT); digitalWrite(CO2control, LOW); // set up the LCD's number of columns and rows: lcd.begin(20, 4); // Serial.begin(9600); //DISPLAY TEMPERATURE lcd.setCursor(0, 0); // print the Temperature title lcd.print("Temperature"); lcd.setCursor(17, 0); lcd.print(char (0xdf)) + lcd.print("C"); //DISPLAY RELATIVE HUMIDITY lcd.setCursor(0, 1); // print the Relative Humidity title lcd.print("Humidity"); lcd.setCursor(17, 1); lcd.print("%"); //DISPLAY CO2 READINGS lcd.setCursor(0, 2); // print the CO2 title lcd.print("CO2 > "); lcd.setCursor(17, 2); // print the CO2 'ppm' lcd.print("PPM"); //CO2control Display Status //SQUIRREL-LABS lcd.setCursor(3,3); lcd.print("Squirrel-Labs"); // Setup for CO2 Sensor
int CO2_Value = 0; // variable set to zero int ppm = 0; // variable set to zero }
void loop() { ldrvalue = analogRead(ldr); if (ldrvalue <????) digitalWrite(13, LOW); //not sure as yet to the correct value to use else digitalWrite(13, HIGH); if (ldrvalue <???); //not sure as yet to the correct value to use lcd.setCursor(6,2); lcd.print("Off"); int chk = DHT11.read(DHT11PIN); // Loop for CO2 Sensor CO2_Value = analogRead(CO2_ReadPin); // read Teensy input pin 38 unsigned int ppm = ((unsigned long)analogRead(CO2_ReadPin) * 2500)/1024; // calc ppm if (ppm < 1300) digitalWrite(CO2control, HIGH); lcd.setCursor(6,2); if (ppm < 1300) lcd.print("On "); if (ppm > 1500) digitalWrite(CO2control, LOW); lcd.setCursor(6,2); if (ppm > 1500) lcd.print("Off"); delay (2000); //TEMP lcd.setCursor(14, 0); // print the Temperature valie lcd.print((float)DHT11.temperature, 0); //HUMIDITY lcd.setCursor(14, 1); // print the Relative Humidity value lcd.print((float)DHT11.humidity, 0); delay (1000); //CO2 lcd.setCursor(11, 2); // print the CO2 value if(ppm < 1000) lcd.print(" "); if(ppm < 100) lcd.print(" "); if(ppm < 10) lcd.print(" "); lcd.print(ppm); delay(2000); }
|
|
|
|
|
4
|
Using Arduino / Programming Questions / Re: trouble - using interupt via LDR when a LCD screen is used
|
on: March 31, 2013, 08:03:56 am
|
|
Hi, Thanks for the quick response,
The code as it stands works ok (so far)
I would like to add the functionality that when it's dark (using and LDR) it over rides the co2 relay control and swithches it off until it gets light again so the main co2 dosing can take place via the relay...
hope that makes sense.. I looked into functionality that would do it and interrupts came out of googles searches every time so thought that was the direction I had to take.
T
|
|
|
|
|
5
|
Using Arduino / Programming Questions / solved - using interupt via LDR when a LCD screen is used
|
on: March 31, 2013, 07:49:48 am
|
Hi all, I have a project which is effectively a co2 dosing system in the first instance for tropical plants, I intend on adding humidity controls aswell. what Im tryig to do is: if the light is on then run the main program which monitors temp, humidity (dht11) and co2 (NDIR sensor) - currently the co2 sensor activates a relay and this is working ok. I have been doing the research so that I can automatically shut off the above functions if it's dark but running into problems and not sure how to move forward, I've looked into interrupts but I am using a standard LCD which uses pins 2 and 3 so my LDR would have to be an analogue input. Hope this makes sense. heres the code so far:
// include the library code: #include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <dht11.h>
dht11 DHT11;
#define DHT11PIN 7
// Define pins for CO2 Sensor int CO2_ReadPin = A0; int CO2control = 13; int CO2_Value; int ppm;
void setup() { // Setup for co2 controller pinMode(CO2control, OUTPUT); digitalWrite(CO2control, LOW); // set up the LCD's number of columns and rows: lcd.begin(20, 4); // Serial.begin(9600); //DISPLAY TEMPERATURE lcd.setCursor(0, 0); // print the Temperature title lcd.print("Temperature"); lcd.setCursor(17, 0); lcd.print(char (0xdf)) + lcd.print("C"); //DISPLAY RELATIVE HUMIDITY lcd.setCursor(0, 1); // print the Relative Humidity title lcd.print("Humidity"); lcd.setCursor(17, 1); lcd.print("%"); //DISPLAY CO2 READINGS lcd.setCursor(0, 2); // print the CO2 title lcd.print("CO2 > "); lcd.setCursor(17, 2); // print the CO2 'ppm' lcd.print("PPM"); //SQUIRREL-LABS lcd.setCursor(3,3); lcd.print("Squirrel-Labs"); // Setup for CO2 Sensor
int CO2_Value = 0; // variable set to zero int ppm = 0; // variable set to zero }
void loop() { int chk = DHT11.read(DHT11PIN); // CO2 Sensor CO2_Value = analogRead(CO2_ReadPin); unsigned int ppm = ((unsigned long)analogRead(CO2_ReadPin) * 2500)/1024; // calc ppm // co2 relay control if (ppm < 1300) digitalWrite(CO2control, HIGH); lcd.setCursor(6,2); if (ppm < 1300) lcd.print("On "); if (ppm > 1500) digitalWrite(CO2control, LOW); lcd.setCursor(6,2); if (ppm > 1500) lcd.print("Off"); //TEMP lcd.setCursor(14, 0); // print the Temperature value lcd.print((float)DHT11.temperature, 0); //HUMIDITY lcd.setCursor(14, 1); // print the Relative Humidity value lcd.print((float)DHT11.humidity, 0); //CO2 lcd.setCursor(11, 2); // print the CO2 value if(ppm < 1000) lcd.print(" "); if(ppm < 100) lcd.print(" "); if(ppm < 10) lcd.print(" "); lcd.print(ppm); delay(2000); }
apologies: my comments could be better. Any Help pointers greatly appreciated T
|
|
|
|
|
6
|
Using Arduino / Sensors / Re: Displaying LM35 & DHT11 on LCD : only looping twice through program
|
on: January 25, 2013, 10:09:06 pm
|
Thanks Very Much for the advice Ok, I have it working, heres what I did. Looked at creating an array but I would have to understand this a bit more, so I followed "michinyon" advice and tested the sensor part, and it worked, I then removed the string usage and replaced with lcd character placement; Is this a type of array? either way it works now: i intend on completing the tutorials so as to get a better understanding of all things Arduino. Thanks again for the pointers  here's the code: #include <LiquidCrystal.h> #include <dht11.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int temp, humidity, hCheck;
#define tempPin 1 #define humidityPin 6
dht11 DHT11;
// initialise LCD library and pins void setup() { Serial.begin(9600); lcd.begin(16, 2); }
void loop() { temp = (5.0 * analogRead(tempPin) * 100.0) / 1024; delay(10); hCheck = DHT11.read(humidityPin); if(hCheck != 0) humidity = 255; //Must be an error else humidity = DHT11.humidity; showData(temp, humidity); Serial.print("Humidity : ");Serial.println(humidity); Serial.print("Celcius : ");Serial.println(temp); delay(1000); } void showData (int temp, int humidity) { lcd.setCursor(0,0); lcd.print(temp) + lcd.print(char (0xdf)) + lcd.print("C"); lcd.setCursor(13,0); lcd.print(humidity) + lcd.print("%"); }
|
|
|
|
|
7
|
Using Arduino / Sensors / *Solved* Displaying LM35 & DHT11 on LCD : only looping twice through program
|
on: January 25, 2013, 02:47:40 pm
|
Hi Folks, I am new to the world of Arduino but absolutly love the concept of it  I got a Sensor Kit and Uno from ebay which contained a DHT11, LM35 and LCD 16,2. I downloaded some sample code for a similar kit with the additions of light & Tilt and adapted that code as far as i could, I have got the values displayed on the LCD but they are not refreshing. I have had a good read of many forum posts but cant seem to find the solution. heres the adapted code ///////////////////////////////////////////// // This demo code uses 4 different sensors and an LCD module // to demonstrate reading a displaying continuous sensor data. // Data is read from a mechanical tilt sensor to show FLAT or TILT // An LDR is used to measure light level and is roughly converted to Lux // A DHT11 is used to measure Humidity in %RH // Finally an LM35 is used to measure temperature in degress C // // This code may be freely used and copied. // // Gareth Davies - June 2012 // ////////////////////////////////////////////////
#include <LiquidCrystal.h> #include <dht11.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int temp, humidity, hCheck;
#define tempPin 1 #define humidityPin 6
dht11 DHT11;
// initialise LCD library and pins void setup() { lcd.begin(16, 2); pinMode(humidityPin, INPUT); pinMode(tempPin, INPUT); }
void loop() { temp = (5.0 * analogRead(tempPin) * 100.0) / 1024; delay(10); hCheck = DHT11.read(humidityPin); if(hCheck != 0) humidity = 255; //Must be an error else humidity = DHT11.humidity; showData(temp, humidity); delay(1000); } void showData (int temp, int humidity) { String s1, s2, s3; String spaces = " "; s1 = String(temp) + char(0xdf) + "C"; if(humidity == 255) s2 = "ERROR"; else s2 = String(humidity) + "%"; s3 = s1 + spaces.substring(0, 16 - s1.length() - s2.length()) + s2; lcd.setCursor(0,0); lcd.print(s3); }
Please accept my humble apologies if this is a daft question / post Edit: After playing a little more i added some serial commands and ran project again - Interestingly the programme only looped twice i.e. only displayed via serial temp, humidity values twice. Kindest Regards Tony
|
|
|
|
|