analogReference(EXTERNAL)

First project. UNO with a SEEED, four relay shield piggyback. A humidity sensor attached to A0. The sensor is powered by 24vac transformer and generates a 0-5vdc signal proportional to. common terminal of the CO2 sensor is landed at AREF. 1.25volt signal landed at AO. analogReference(EXTERNAL) declared on line before the analogRead.

Pin AO has 1.25 vdc but the CO2 point returns a value of 1023 and not 500 as expected. Tested same configuration on A1 and get same result.

const int V1 = 4;
const int V2 = 5;
const int V3 = 6;
const int V4 = 7;
const int V5 = 8;
const int V6 = 9;
const int pump = 10;
const int fan = 11;
const int LED13 = 13;

int CO2_in = A0; //<<<<<<<<<<<<<<
int RH_in = A1; //<<<<<<<<<<<<<<

const int Sw1 = 1;

int i = 0;
long Ltime = 0;
long A = 0;
int tempvalue1 = 0; //<<<<<<<<<<<<
int CO2 = 0; //<<<<<<<<<<<
int tempvalue2 = 0; //<<<<<<<<<<<
int RH = 0; //<<<<<<<<<<<

void setup()
{pinMode(V1, OUTPUT);
pinMode(V2, OUTPUT);
pinMode(V3, OUTPUT);
pinMode(V4, OUTPUT);
pinMode(V5, OUTPUT);
pinMode(V6, OUTPUT);
pinMode(pump, OUTPUT);
pinMode(fan,OUTPUT);
pinMode(LED13, OUTPUT);

pinMode(Sw1, INPUT);
Serial.begin(9600);}

void loop(){
if (i == 0)
{(i = 1);
Ltime = millis();
digitalWrite(V1,LOW);
digitalWrite(V2,LOW);
digitalWrite(V3,LOW);
digitalWrite(V4,LOW);
digitalWrite(V5,LOW);
digitalWrite(V6,LOW);
digitalWrite(pump,LOW);
digitalWrite(fan,LOW);}

{analogReference(EXTERNAL); //<<<<<<<<<<<<<<<<<
tempvalue1 = analogRead(CO2_in); //<<<<<<<<<<<<<<<<<<
CO2 = (tempvalue1 * 1.95503);
tempvalue2 = analogRead(RH_in);
RH = (tempvalue2 * 0.097751);}

Could you explain how the sensor is connected, or make a drawing. Which sensor is it ?

Using 24V near an Arduino board could easily damage it.
The AREF pin is used only in a very few special situations. You can select the internal 5V as reference or the 1.1V internal reference.

The analogRead() returns an integer value. If you want to do calculations with floating point number, you have to convert it to float.

Unit will be used to sample air at workstation in an automotive garage. An air pump will draw air samples from each workstation, through 1/4inch tubing, valves will cycle the source between the workstations and a single array of sensors will sample for CO2, relative humidity and temperature. On a rise in CO2 the exhaust fan will be started and run for an hour. CO2 in whole numbers is more than adequate (sensor is rated for +/- 5ppm) and floating point will not be required.

Voltage between ARef and AO is roughly 1vdc. If I eliminate the analogReference(External) then AO drifts between 0 and 1023 even though the voltage applied to AO is 1vdc.

Photo2.pdf (125 KB)

Wiring diagram.pdf (110 KB)

data sheet for CO2 sensor attached. This is a typical device widely used in the HVAC industry.

cdl_cwl_d0814.pdf (806 KB)

Thanks for the photos !

It is a normal industrial 4-20mA output.
Here is an schematic : 0...20 or 4...20mA current loop sensors - #2 by Nick_Pyner - Sensors - Arduino Forum
The 4-20mA is going through the 220 ohm, creating a voltage of 0.88V to 4.40V.
That is the voltage an Arduino can read.
The 0.1uF is for safety. It will smooth the signal and filter large peaks.
The 10k is also for safety, it protects the input of the Arduino.
I suggest to use both the 0.1uF and the 10k for safety.

Do not use the AREF. It is not ment for this.
Please use a common ground.

That sensor can also be used with a DC voltage. That makes it a lot easier to make a common ground.
For example this:
A 24V DC power supply for the sensor. The black wire, "0V" or GND connected to the sensor GND and the Arduino GND. The sensor "CO2 OUT" connected to that circuit (with 220ohm, 0.1uF, 10k), and the output of that to Arduino A0.
The Arduino can be powered with a DC-DC converter, that converts the 24V DC to 9V DC.

That common ground will also be connected to a computer when you connect an USB cable. So you have to know that the common ground is okay and is not connected to an AC voltage.

If you have turned on the power with the circuit in your diagram, something might be damaged.

Thanks for the response. I am moving a little slow, just getting over the flu, could take me ad day to collect the supplies. I'll dig through my box of parts, pretty sure there are a couple of 24vdc power supplies. Will rewire with DC, common ground, eliminate the 24vac (I think the valves will operate DC also.), eliminate the ARef and fabricate your 4-20ma schematic. And replace the UNO if it is damaged.

I'll post the results as soon as I can.

Chrs

The valves .... I didn't think of that.

Since you use relays for the valves, you might have to use a seperate 24V AC power supply for the valves.
There are also 4-20mA optocouplers, that would isolate the Arduino from the rest.
But I assume that the valves work at DC as well.

Which valves are they ? Do they need a special modulation signal ?

The valves are Belimo B210 TR24-SR. They accept 24vac or dc. 2-10 vdc control. I am using a 6vdc power supply and switching it through a relay shield. 6vdc guarantees valve opens to desired percentage. A solenoid air valve would be a better choice but these were free.

I replaced the receptacle and transformer with a plug strip and added a 24 vdc power supply from my junk box.The valves draw 1va and only 2 cycle at any time. 500ma is sufficient. All negatives commoner together.

As soon as I can get out to Radio Shack ill get a new UNO, resistors and capacitors.

Also those valves have a "common" or GND. So it should work all together.
I don't know what "Non-Spring Return Actuator" means, I think that 10V is constantly needed to keep them open.

The input impedance of the 2-10V input is 100k. That needs very little current, so with some extra hardware, the Arduino could fully control the valves. Using 6V and a relay might work, but what fun is that ? :sleeping:

To make a higher voltage from 5V : toneAC v1.2 - Twice the volume, higher quality, higher frequency, etc. - #70 by Peter_n - Audio - Arduino Forum
I used the toneAC for the voltage tripler, and that is only for one output.
Three simple voltage doublers would need three frequency outputs of the Arduino, that might require a special library.

When you have 9V or 10V to power the Arduino, you can use that and a OpAmp and RC filter and a PWM output.

Perhaps there are modules to create proportional voltages between 0-10V. But I can't find them yet.

"non-spring return" In HeatingVentilationandAirConditioning control valves can be fail/spring open, fail/spring closed or no spring/fail in position. Down south Air Handlers can often fail to cooling. On loss of control signal the unit will go to full cooing. When I moved North the last thing my old boss said to me was, "Remember, everything fails to heat up there." On loss of control signal or loss of power the heating valve will SPRING open allowing full flow through the coils and reduce chance of frozen coils.

The valves in my air sampling system were used on small fan coil units. To keep the cost down the spring is eliminated.

I have a new UNO, a second SEEED Relay Shield, air pump, it's all wired for VDC with common ground and programmed for the most part. Took all day to assemble and wire.

The CO2 sensor is wired per your suggestions and is reading +/- 5ppm.

Thanks for the help.

Thanks.
Those are nice valves for projects.