Show Posts
|
|
Pages: [1]
|
|
4
|
Using Arduino / Sensors / Re: MQ-3 alcohol sensor
|
on: October 06, 2012, 11:19:26 am
|
|
yes 10k is connected to the ground and when the alcohol is present value varies from 200 to 1024 but when alcohol is not present shows value 200 my wiring is correct
|
|
|
|
|
6
|
Using Arduino / Sensors / MQ-3 alcohol sensor
|
on: October 06, 2012, 10:20:36 am
|
|
dear experts i have purchased alcohol sensor from the sparfun.com and according to data sheet i have connected 10k ohm resistor accross it and switche on for one whole day and night after that i try to write code and when alchol is not detected 200 value shows in the lcd i it should have shown value o how to solve this problem any idea ? here is the code #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); const int ledPin = 13; int sensorPin = A0; int value = 0;
const int threshold = 350;
void setup() {
Serial.begin(9600); lcd.begin(16,2);
}
void loop() { int Value = analogRead(sensorPin); value = analogRead(0);
if (Value > threshold) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin,LOW); }
lcd.print("alcohollevel:"); lcd.println(value); Serial.println(value,DEC);
if (Value > threshold) { lcd.print("alert"); Serial.print ("alert"); } else { lcd.print("normal"); Serial.print("normal"); } delay(1000); lcd.clear();
}
|
|
|
|
|
7
|
Using Arduino / Programming Questions / how to display all lcd values to serial terminal
|
on: September 29, 2012, 11:47:25 pm
|
|
dear experts i just want to display kwhr and its value in serial terminal here is the code pls help me #include <LiquidCrystal.h> LiquidCrystal lcd(3, 5, 6, 7, 8, 9); const int voltageSensor = A0; const int currentSensor = A1; const int numberOfSamples = 3000; // Calibration constants const float AC_WALL_VOLTAGE = 120.9; const float AC_ADAPTER_VOLTAGE = 14.1; const float AC_VOLTAGE_DIV_VOUT = 0.85; const float CT_BURDEN_RESISTOR = 40.2; const float CT_TURNS = 2280.0; // Calibration coefficients const float VCAL = 1.0; const float ICAL = 1.0; const float PHASECAL = 0.9; // Calculated ratio constants, modified by VCAL/ICAL const float AC_ADAPTER_RATIO = AC_WALL_VOLTAGE / AC_ADAPTER_VOLTAGE; const float AC_VOLTAGE_DIV_RATIO = AC_ADAPTER_VOLTAGE / AC_VOLTAGE_DIV_VOUT; const float V_RATIO = AC_ADAPTER_RATIO * AC_VOLTAGE_DIV_RATIO * 5 / 1024 * VCAL; const float I_RATIO = CT_TURNS / CT_BURDEN_RESISTOR * 5 / 1024 * ICAL; // Sample variables int lastSampleV, lastSampleI, sampleV, sampleI; // Filter variables float lastFilteredV, lastFilteredI, filteredV, filteredI; // Power sample totals float sumI, sumV, sumP; // Phase calibrated instantaneous voltage float calibratedV; // Calculated power variables float realPower, apparentPower, powerFactor, voltageRMS, currentRMS; unsigned long last_kWhTime, kWhTime; float kilowattHour = 0.0; void setup() { lcd.begin(16,2); } void loop() { calculatePower(); displayPower(); } void calculatePower() { for (int i = 0; i < numberOfSamples; i++) { // Used for voltage offset removal lastSampleV = sampleV; lastSampleI = sampleI; // Read voltage and current values sampleV = analogRead(voltageSensor); sampleI = analogRead(currentSensor); // Used for voltage offset removal lastFilteredV = filteredV; lastFilteredI = filteredI; // Digital high pass filters to remove 2.5V DC offset filteredV = 0.996 * (lastFilteredV + sampleV - lastSampleV); filteredI = 0.996 * (lastFilteredI + sampleI - lastSampleI); // Phase calibration calibratedV = lastFilteredV + PHASECAL * (filteredV - lastFilteredV); // Root-mean-square voltage sumV += calibratedV * calibratedV; // Root-mean-square current sumI += filteredI * filteredI; // Instantaneous Power sumP += abs(calibratedV * filteredI); } // Calculation of the root of the mean of the voltage and current squared (rms) // Calibration coeficients applied voltageRMS = V_RATIO * sqrt(sumV / numberOfSamples); currentRMS = I_RATIO * sqrt(sumI / numberOfSamples); // Calculate power values realPower = V_RATIO * I_RATIO * sumP / numberOfSamples; apparentPower = voltageRMS * currentRMS; powerFactor = realPower / apparentPower; // Calculate running total kilowatt hours // This value will reset in 50 days last_kWhTime = kWhTime; kWhTime = millis(); // Convert watts into kilowatts and multiply by the time since the last reading in ms kilowattHour += (realPower / 1000) * ((kWhTime - last_kWhTime) / 3600000.0); // Reset sample totals sumV = 0; sumI = 0; sumP = 0; } void displayPower() { lcd.clear(); lcd.print(realPower, 0); lcd.print("w "); lcd.print(apparentPower, 0); lcd.print("va "); lcd.print(powerFactor * 100, 0); lcd.print("%"); lcd.setCursor(0,1); lcd.print(voltageRMS, 0); lcd.print("v "); lcd.print(currentRMS, 1); lcd.print("a "); lcd.print(kilowattHour, 4); } how???
|
|
|
|
|