Hello. I am doing a science project that involves Arduino. My team and I are almost finished with the project. But with just one problem, we don't know how to use the Arduino to detect Chlorine, which is the main part of our project. I am using the Capacitive Sensor program as here in Malaysia we cant afford to buy a colorinmeter. Could someone please tell me how to use the capacitive sensor to detect chlorine?
I am not quite familiar with the coding. Your answers are mostly appreciated. Thank you.
Hello. I am doing a science project that involves Arduino. My team and I are almost finished with the project. But with just one problem, we don't know how to use the Arduino to detect Chlorine, which is the main part of our project. I am using the Capacitive Sensor program as here in Malaysia we cant afford to buy a colorinmeter. Could someone please tell me how to use the capacitive sensor to detect chlorine?
I am not quite familiar with the coding. Your answers are mostly appreciated. Thank you.
void loop()
{
long value1=capSensor_4_10.capacitiveSensor(30);
long value2=capSensor_4_12.capacitiveSensor(30);
if (value2>200) digitalWrite (outPin,HIGH); else digitalWrite (outPin,LOW);
analogVal = analogRead(value1);
mass = analogRead(chlorine);
ppm = mass / 1.5 * 1,000,000;
Serial.println(ppm);
(Even for a widely distributed library, which I'm not sure that is, it's always critical to link to the actual version of the library you're using. Partly because of how easy it is to fork things on github, there is a proliferation of identically named but subtly/not-so-subtly different libraries. Often in github forks, people don't even modify the readme or other documentation to describe what they've changed)
I believe he uses this library, which enables to make capacitive touch dectectors as shown below:
The following lines are ok, as they are adpated from the library's example:
long value1=capSensor_4_10.capacitiveSensor(30);
long value2=capSensor_4_12.capacitiveSensor(30);
But the rest, as you said before, is weird:
analogVal = analogRead(value1);
mass = analogRead(chlorine);
I don't know if such a sensor can detect the presence of chlorine or any other gas. Googling "Arduino gas sensor" provides with some cheap gas sensors that "could" be used, but I'm far from being an expert, so are they suited to chlorine?
If it's not gaseous chlorine, the subject has already been treated on the forum: use the search engine of the forum or see here for an example
So the coding is still weird. It often goes up and goes down. I modified the coding under you guys' opinions.
But it still doesn't display what i wanted to display. Could you recommend me some simple yet functional coding that can help the capacitive sensor to detect chlorine? The library i use is the standard Arduino library. Unfortunately i cant link the library folder for some reason. Could you guys recommend some simple yet functional coding instead? Thanks for your answers.
long value1 = capSensor_4_10.capacitiveSensor(30);
mass = analogRead(value1);
You define value1 as the result of the reading of the capacitive sensor. It's not the pin number, it's the value read.
So the second line is not good.
You don't need an analogRead with this library. It says:
long capacitiveSensorRaw(byte samples)
capacitiveSensorRaw requires one parameter, samples, and returns a long integer containing the absolute capacitance, in arbitrary units. The samples parameter can be used to increase the returned resolution, at the expense of slower performance. The returned value is not averaged over the number of samples, and the total value is reported.
But as it is a long int, it cannot represent formally a capacitance (you need a float for that). They say it's arbitrary units.
Anyways, value1 can't be used in the mass calculation as this:
mass = analogRead(value1);
ppm = mass / 1500 * 1, 000, 000;
(BTW, use dots '.' for floats, not commas ',')
What you need to do is calibrate your sensor. Use several test samples with known chlorine concentrations and measure the associated value1 values. Then draw a curve showing the variations of value1 against the concentration, which you will then use for routine measurements afterwards.
Then try your new sensor with several test samples and see if the readings vary and how. If you see representative variations, then you can conclude your sensor is relevant. The next step will be to calibrate it, meaning find the relation between the ppm values and the readings of the sensor. But this comes after you make sure that the readings are associated with the chlorine concentration.
Can we please just stop posting alphabetti spaghetti coding?
chlorine, a float, is never initialised, so is zero.
Is it sensible to read from pin zero?
Please read the answers you get and try what we suggest, instead of ignoring it.
Until you haven't proven that your sensor is relevant for measuring chlorine concentration, no need to go further in the code. And to be sure it works, you need to test several different solutions or gases with different concentration values. Only if in this case you get different readings can you be sure the sensor is relevant.
I won't answer anymore as long as this is not proven.
I (and I'm sorry if this sounds cruel) am chuckling at the OP saying their chlorine detection project is almost finished, just need to do the chlorine detection part.
JasonCMJ:
My team and I are almost finished with the project. But with just one problem, we don't know how to use the Arduino to detect Chlorine, which is the main part of our project.
I hope they are aware of the dangers of chlorine gas; my son who is a ff/emt just pointed out "Wouldn't want any untested, non Intrinsically safe electronics near a cloud".