Sensors for Ammonia/Nitrate/Nitrite?


Hi there! I’m wondering if anyone would have information on compatible Spark sensors that are able to detect the presence and concentration of Ammonia/Nitrate/Nitrite in liquid solutions. I found this conversation on Arduino’s discussion board, but it doesn’t seem to be resolved:,150564.0.html

Has anyone worked with detecting these compounds before? Any advice on figuring this problem out? Really excited to start hacking with the Core!!


As mentioned on Arduino’s forms there are few direct sensors and the only ones I know of are in expensive chemistry equipment. They mentioned using Spectrometry to figure out the concentration of the chemicals, mean your would have to calibrate the sensor to look for a change that would indicate a Nitrate chemical reaction, based on that rate you could detect the concentration, but before you could monitor, you would have to make test solutions for reference.

As for creating something like this you will need, a high power LED/Laser a diffraction grating with about 200 lines per mm, and a lens or mirror to focus the light on a CMOS sensor or a smaller light sensor. The sensor must have an analog output to a OpAmp then to your Micro controller, once you have calibrated data monitoring with a Spark cores simple. Best of Luck.


I don’t know if this would work for your application, but Hach makes ammonia and nitrate/nitrite test strips that are simple to use, but don’t have very high precision. You just dip the strip in the water for a few seconds and it changes color depending on the concentration. You could make something to automatically dip a strip in the water and then put it in front of a color sensor. The strips are single-use, so you would either have to change the strip out each time, or design something to hold several strips at a time.


I really love that color sensor, but yes I think I would want to strive for a solution that would not require the user to constantly be swapping out test strips, especially as I would like to be sending data from the water sample every half hour or so.

What I’m wondering is if there would be a way to combine the color sensor with a liquid test kit as a way of testing. Perhaps storing some of the testing solution in my device, combining it with some water, then using the RGB sensor to read the color. Similar problem in the sense that the user would have to be replacing the testing solutions periodically, but might be cleaner than swapping out test strips. What do you think?


That color sensor might work instead of a spectrometer with that liquid test kit, it just probably wouldn’t be as accurate as a spectrometer.
The test strips actually change different colors when you dip them in the water, but a liquid test kit like that will technically only turn the water one color when ammonia is present. The color doesn’t actually change at higher ammonia concentrations, it’s just more saturated so it appears to humans as darker. You would have to test that sensor to see how well it can determine different saturations of the same color. The method that test uses is supposed to turn the water green, so you might be able to put something red behind the sample so the sensor could be able to see a transition from red to yellow to green at higher ammonia concentrations.

For drawing the sample and adding the reagent you could use something like this:


@ih57452 maybe something like this?

I’m not entirely sure I see the big picture, though. You could use the dosing pump to draw in the water sample, but how would the reagent get added? My only guess would be that the other end of the pump would connect to a container with the reagent, where the two would be mixed and the RGB sensor would read the intensity of the color. Is that what you were thinking?


Hi @jeiden

There are a bunch of folks doing aquarium related projects–have you seen this thread?


According to the instructions for the test kit, you take a 5ml sample and add 8 drops of 2 different reagents. My thinking is you could take the test tube the kit comes with, drill a hole in the bottom, and connect the hose from the pump that draws the sample. That way you could run the pump to flush the water from the previous test out the top of the tube and fill the tube for the next test without having to have something to dump the water out. Then you could have 2 more pumps to drip the reagents into the top of the tube. The pump you linked to says it can be slowed down to 0.1 rpm, which would hopefully let you consistently pump a few drops. I don’t have any experience with controlling motors, so I can’t help you on slowing them down. I don’t think getting exactly 8 drops of each one is going to be critical, but I’ve never used this exact method (I’ve used the Nessler method which only has one reagent to add). More than likely, if you add more than 8, it will just be wasting chemical, and for example, if you only added 3 drops, it may only turn dark enough to read as 3ppm even if the ammonia is actually higher than that (the test says it is supposed to read up to 8ppm). Then it says you’re supposed to mix the sample after adding both reagents. You could have a fourth pump that pumps air into the bottom of the test tube to mix everything together, and then turn it off before you read it.


@ih57452 Thanks for your awesome ideas! I created a simple visual mockup of how this could work. I left out the mixing air pump for simplicity’s sake, but think that would be necessary to get an accurate reading. What are your thoughts?

The only thing I’m still unclear on is the water flushing:

My thinking is you could take the test tube the kit comes with, drill a hole in the bottom, and connect the hose from the pump that draws the sample. That way you could run the pump to flush the water from the previous test out the top of the tube and fill the tube for the next test without having to have something to dump the water out.

How would the water sample enter from the bottom of the tube, but leave from the top? Especially if the reagents are entering through the top of the tube as well? Also, where would it go once it left the tube? I can’t put the sample back in the aquarium as this would be harmful to the fish.


Looks good to me, but keep in mind I’ve never actually done this before; this is just how I would go about it if I was building it.

You could make a hole in the side of the test tube above the 5ml mark and attach an overflow tube for the flush water to run out into a bucket or something.

Also, the water in the line between the sample pump and the test tube will be effectively increasing the volume of the test tube, so I would mount the sample pump as close as possible to the test tube. If you mount the 2 test solution pumps above the top of the test tube, I would keep the tube between them and the test tube as short as possible also. The surface tension of liquid can cause it to get stuck in a long downhill section of a small diameter tube, which would make it harder to get an accurate volume of solution in each sample. You could also mount them below the test tube.



Looking for an ammonia gas sensor through Google, I stumbled upon this page and had heaps of deja-vu. Enough so that I joined this community basically to talk about my ideas on this project. I had a very eerily similar idea over a year ago but my programming and electronics fell short of my objectives.

I hope that my ideas help development at least on the physical design stage:

  1. Use a good RGB light source (doesn’t have to be bright or expensive)
  2. Use an LDR placed behind the mixed fluid to measure the light transmission:
    • (basic test) R or G or B transmission if single chemical tester colour intensifies (such as in an ammonia or Nitrite test)
    • (complex test) RGB transmission if colours change (like a wide range pH test). To deal with colour identification, it may be possible to feed R G B values through a converter to give Hue, Lightness, and Saturation values. Hue being the only important value in this case.
  3. Results can then be compared to a set of ranges which have been predefined when calibrating the chemical solutions. Provided the LED, LDR and chemical solutions are the same brands and versions in each kit, calibration needs only ever be done once per colour chemical tester.

Additional bits…

  1. I purchased some small non-medical sterile saline blood bags to store the chemical solution. Cheap, sterile enough and containable.
  2. Ideally piezo pumps but they are crazy expensive. Not sure why as they are made from as few as 3 components (piezo, 2 sides of case). I bought some cheap piezo buzzers but never got around to building the cases and testing. Other option is using a small diaphragm pump to move liquids around. At the end of the day, the less liquids you move around, the less chemical solution you use up and the more consistent you can make your results.
  3. A step motor driving a worm gear fixed to a syringe can handle the pumping in and out of test water. Combined with accurate chemical feeds, an array of one way valves, and a sediment pre-filter, you’ll be well on your way. Chemicals can’t be fed with worm gear and syringe technique as temperature variations are likely to spill or suck liquids.
  4. Excess water and waste solution from testing can be ejected for evaporation or sent to a “waste blood bag” for controlled disposal.
  5. There’s no reason why this unit has to be big. I was thinking a solar panel & suitcase style operation. test values are then logged and/or sent by GSM or other means as a simple csv result. i.e. Date stamp, pH, Ammonia, Nitrite, Nitrate, GH etc…
  6. Unit could be activated remotely or on a timer and would do the required level of “flushing” as to obtain a new fresh batch of water for every test done.

That’s basically as far as I got. I really wanted to create a portable kit made up of very standard and accessible cheap components and then open source the whole lot and create a purchasable kit from local suppliers for each continent. With that made, one could test for a huge range of chemicals, toxins, heavy metals, dissolved gasses… Huge potential and extremely flexible.


Hi there,

did you tried and got results for your experiments?

I am trying out similar activity, can anybody link to the readily available ammonia sensor ?

am basically looking out for something to carry out the same which can be interFaceble to any of the micro controller via ADC or any.

Please suggest if anything you guys came across? which will be useful to me to try out off the self. which will be great help.


This might be of interest:


Wow that is really incredible. Amazing to see a working solution that is so elegant, yet so complex. Is this your invention? As someone who tried (and miserably failed!) to solve this problem, mad props if so!


Thanks, yes I designed and built it. I was going to use Github to share the software and Thingiverse for the 3D parts, but I don’t know of any place to share the PCB design.


You should be able to share the whole lot on Hackster, if I’m not mistaken.


This may be of interest.

Usually you don’t track nitrate directly but by a colour making reaction (oxidation), you then compare the optical density of your test solution with a series of known standards of known concentration and then " look up on a graph" your OD and hence conc of nitrate.

Diphenylamine in H2sO4 yields a blue oxidation product which you will be able to track the conc. of with the colourimeter, which is a cheap spectrophotometer.

The other way to track ammonia would be with it,s pH effect on the water it is dissolved in. Ph duino or for a simple yes no you could use a pH indicator such as phenolphylene. red/pink yes clear no.

If using pH remember that it is a logrithmic scale. So from 10-11 is a lot more alkali than 7-8.

depending on the physical form of your test if it is gas/atmosphere you could go old school and use a Draeger tube.

These are single use tubes (I think), they contain crystals that change colour depending on the conc. of ammonia or whatever the tube is designed for, in the atmosphere you are testing.

I assume you are running at a pH over 4 because if you were below 4 then your sodium nitrite would become nitrous acid and a) volatile and b) detectable on starch iodide papers.

Are you showing blue on congo papers? (if so sub pH 4)


Ok. Perhaps not the other thread as it’s not been active in a while. (Deleted post)

These suggestions may have been covered on this thread.
Dosing - use a syringe with a linear actuation drive attached. (Screw thread & stepper motor)
Flushing - sequence syringes drawing from a bottle of distilled water
Colour detection - use LEDs obtained from a company such as Yuji LED where the CRI index is very high. (I’d hope the colour detector would be able to see a good spectrum, but at least light would be coming through as it should)
Piezo pump “hack”. I’ve yet to play with this but the $70 micro pumps are essentially 2 piezo discs in a 2 part injection mould + gasket. Perhaps laser cutting thin Perspex, welding glue and nimble fingers could make one


I can confirm that using a syringe for dosing works well. That is what my system uses. However, it needs some sort of feedback system. There is too much variability such as small bubbles to just count screw thread revolutions and expect the right amount of reagent to be dispensed.

The color detection part is actually not much of a problem, especially if you are using a consistent light source. If the test is designed for human perception, then even a cheap camera will probably provide more accurate color analysis than the human eye. It is important however that the reference swatches be recorded under the same lighting conditions as the samples being tested. I used the CIELab color scale to most closely match human perception.

The advantage of a camera over a color sensor is that you can just tell it what part of the image to look at. Cameras are really cheap nowdays and you can usually turn off the white balance if that concerns you. You can use lenses that allow you to get very close to the sample.

For flushing, if you want to flush with distilled water, then just use another pump. The system probably requires an agitator to agitate the solution, so just use the flushing pump and the agitator to clean the system. Dosing pumps are only $15 on Amazon,


Here is more info on how to build an autotester.