Thursday, April 3, 2014

Measuring pH using Dormant Labs PH Module V2 and Arduino

Here is a quick setup guide to start measuring ph using the Dormant Labs PH Module V2.

You will need:
  • PH 4 and 7 Calibration Solution
  • A Arduino
  • Dormant Labs PH Module V2 (available here)
  • A PH Probe
  • Three small cups, two to hold the two calibration solutions, and one to hold water for rinsing the ph probe 
  • 4 dupont male to female cables

First connect the ph probe to the ph module


Then
  • Connect V+ to Arduino 5v or 3v pin
  • Connect GND to Arduino GND pin
  • Connect SDA to Arduino SDA pin(For UNO it is A4)
  • Connect SCL to Arduino SCL pin (For UNO it is A5)
  • Attach USB to Arduino


Get the source code from here:
https://gist.github.com/rezahussain/bb7715534688d8dc0520

and upload it using the Arduino IDE. If you do not have the arduino IDE get it from the arduino site.

After uploading the code, open the serial monitor and you should see output like this:



You are now ready to calibrate your ph probe.

Fill one cup with PH 4.0 calibration solution, one with 7.0 calibration solution, and a third with water.
Remove the cover from the ph probe and rinse it with water.


Then dip the probe in the 4.0 solution, swirl it around for a little bit, and write down the value you see for the avgPhVolts. For me, I saw 0.95v.


Rinse the ph probe in the water, then dip in the 7.0 calibration solution and write down what you see for avgPhVolts.


Here are the values I got:


Now I replace the volt4, volt7, and calibrationTempC, then re-upload to the Arduino.


After re-uploading your probe is now calibrated! The serial monitor of the arduino IDE will show the correct information. Edit the code as you like now.

93 comments:

  1. Saludos, ¿que tipo de sonda de Ph seria la recomendada?
    ¿la temperatura seria ambiental o del liquido?
    gracias

    ReplyDelete
  2. Hello, I use this one at home http://www.omega.com/pptst/PHE735215_735315.html

    The sensor measures ambient/environment temperature, if your liquid temp is different, then you will need to measure that using a temp sensor.

    ReplyDelete
  3. is hardware open source? I want to check if it has galvanic isolation.

    ReplyDelete
    Replies
    1. Hello, it is not open source, but it does have galvanic isolation.

      Delete
    2. Is there a way to calibrate with 7.0 & 10.0 solutions?

      Delete
    3. Hello David, I have ordered ph 10 calibration solution and will amend this tutorial or make another for 7 & 10 calibration.

      Delete
    4. Here is the 7 & 10 ph calibration tutorial
      http://rezaalihussain.blogspot.com/2014/07/measuring-ph-with-dormant-labs-ph.html

      Delete
  4. Hello - I am creating my first arduino project to dose acid in a swimming pool. I am trying to pick a ph board. I see several on the internet. I find yours and the atlas most interesting with the most support documentation. I still have a couple of questions, what is the resolution that can be read? Can it read 2 decimal points? How stable is it over time? How many do you have running? What if any is the major issues (it seems pretty simple , can't be many). And I see some units on the internet do not seem to be able to read both acid and base solutions without a jumper change because it sounds like the arduino cannot read negative voltages and lastly what is the advantage of reading Voltage instead of getting serial data like the atlas unit?

    Thank you,

    Anthony

    ReplyDelete
    Replies
    1. Sorry for the late reply just saw this post,
      The board has more than 0.01 resolution, but that is probably the limit you will hit because that is the limit of ph probes. The board doesnt do hardware averaging, so you can use the ph readings from your probe in real time, but the example code does do averaging to stabilize the reading. You can increase the averaging or reduce it, but the averaging used in the example code is what I use in my own projects. The only major issue is if you want to use multiple versions of this board together you will need to learn i2c multiplexing.

      The arduino cannot read negative voltages, I solved that problem on this board by shifting the negative voltage into the positive range via an op amp.

      Ok, the advantage of reading a voltage is that is what the ph probe outputs. With the code here you get to see exactly how the voltage is converted to ph, and verify that that is the correct way, or make your changes.

      If you just get a serial output like you say is on the atlas stamp, then you have to trust that they are doing the voltage to ph conversion correctly. You don't have to trust my version, you can just read the code and see.

      Delete
  5. I just purchased one. I decided the activity and commitment of this blog will make all the difference in the would if I need help.

    Anthony

    ReplyDelete
  6. I know there is temp comp on the board. It this to comp for the liquid temperature or the board temperature? If it is for the liquid, does the board heatup during operation enough to be above the ambient that the liquid would be at?

    ReplyDelete
    Replies
    1. Hi Anthony

      The temp comp on the board is to provide an ambient temp reading that can be used to temp-adjust the ph reading.

      Delete
  7. if my pool temp is ar 90F, should I override the board temp with this temp in C?

    ReplyDelete
  8. Hi! We are group of high school students from the Philippines who are interested with your PH module. We would like to adopt it in line with our Science Investigatory Project. We would like to buy your device and innovate it. How long would the shipping take? We are willing to pay for the shipping if it would take lesser days. (Ideally, we need it as soon as possible, probably within 3-5 days with FedEx) And can you PLEASE assist us with our project by sending us the already assembled device? We are expecting for your reply as soon as possible. And we hope that you could help us. Thank you!

    ~Thea Kaylee Libunao
    ~Daryll Allam
    ~Jude Guliman
    ~Dayl Mendoza

    ReplyDelete
    Replies
    1. Hello, email me at crownonfire@gmail.com or reza@dormantlabs.com, I have replied to you on tindie and facebook as well. Its the weekend so I will stay up late to reply, since we are in different timezones.

      Delete
  9. First.... To all looking at buying this.. I highly recommend. Awesome product. I bought this and a few other ones, but the Galvanic isolation on this one is helping me to get consistent data. I got this working on my Arduino Uno, but I ran out of pins so I switched to a Mega and now the only output I'm getting is "avgMeasuredPH-" from the first serial.print command after initializing the serial connection. I just copied & pasted code. I'm sure it has something to do with the SDA & SCL. pins (20 & 21). any help would be awesome!

    ReplyDelete
  10. Replies
    1. I just got some free time(weekend), did you get it to work? In this tutorial http://rezaalihussain.blogspot.com/2014/07/measuring-ph-with-dormant-labs-ph.html I do use an arduino mega.

      There are two known cases of people saying they have trouble getting it to work with an arduino mega now.

      For a mega the first things I would check are that you are using 5v for the module, since the mega's i2c pullups are for 5v, and then that the usb cable is connected directly to the computer.

      I am using an 2560 mega in the linked tutorial.

      Let me know

      Delete
  11. Im used to using ph meters, but my first time building one ,I need accuracy so I need to be able to calibrate it often without having to reupload a sketch everytime I would like to calibrate just wanted to know if you had a tutorial or know of one where I could calibrate with a button or something? Thanks in advance

    ReplyDelete
    Replies
    1. The module v1 had this functionality but everyone that emailed me wanted a to upload a sketch instead of pressing a button. https://www.tindie.com/products/rezahussain/arduino-ph-shield-by-dormant-labs/
      http://rezaalihussain.blogspot.com/2012/09/arduino-dormant-labs-ph-shield-tutorial.html

      I have one of these units left that you can buy, but v1 doesn't have galvanic isolation. Email me at crownonfire@gmail.com if you still want it.

      I will be uploading a tutorial for v2 using a pcduino and button, but it might be awhile before it comes out.

      Delete
  12. Hello Reza – I am confused on you temp compensation. I am not seeing where the actual temperature during normal use is being compensated to the calibration temp. I am seeing calibration temp being compensated to 25 deg. When the subroutine “getRoomTemperatureC” returns the current ave temp in celcius, it just prints it.

    Thank you,

    Anthony

    ReplyDelete
  13. Okay - After some research I think I answered my own question. It seems that temperature does not matter at 25 deg cel and / or a ph of 7. deviate from those values and then is is a concern. In my case I am measuring a solution near 7 (about 7.5) at a temp of less than 32 deg cel. looks like my error will be about 0.03 according to a chart I found. It looks like the math in the script will be about 0.06.

    ReplyDelete
    Replies
    1. Wow, I left out the code for final room temp compensation. It seems I took a shortcut for the calibration code too. I unified it and updated the code.

      https://gist.github.com/rezahussain/bb7715534688d8dc0520

      Give me your values for volt4,volt7,calibrationTempC and a room temp and I can confirm by calculating by hand as well.

      Delete
  14. Got the sensor running on my Netduino and need to calibrate it.
    Problem is, that I can only get a PH solution of 6.85 and not 7.
    Looking at the code, you have used fixed values like 4 and 7 in your calculations.
    Can I replace the value 7 with 6.85?

    PS. Anyone using a Netduino - you need pull up resistors,.
    One from 5V to SDA and one from 5V to SCL.
    I used 2.2KOhm

    ReplyDelete
    Replies
    1. Yes, you should be able to replace the 7 with 6.85 in the loop() function, but the other functions should remain as is.

      Delete
  15. Good morning, I am mistaken or this device also measures the conductivity of electrons of the solution?

    ReplyDelete
    Replies
    1. Hello, sorry this does not measure EC levels in solution or connect to EC probes.

      Delete
    2. Do you know any sensor that can measure the conductivity of electrons?

      Delete
    3. Not off of the shelf... if I had to get an EC reading into my arduino, I would hijack the signal from an existing EC meter like this..http://www.ebay.com/itm/EC-Electrical-Conductivity-Meter-Tester-Water-1999-s-cm-ATC-Backlight-Aquarium-/131299303440?pt=Vintage_Electronics_R2&hash=item1e920c6010


      Delete
    4. You will need to do some soldering but it should be fairly straight forward

      Delete
  16. The temp that shows up is the ambient temperature. With that said, should I recalibrate seasonally if say the room varies between colder in winter and warmer is summer? When I say varies, I'm talking up to 85f in the summer and down to 55f in the winter. Perhaps, I should calibrate based off the reservoir, that varies 60f - 75f?

    ReplyDelete
    Replies
    1. Hello, you would modify this line, and find a way to feed the reservoir temp into it. That is the best way.

      double roomTempCompensatedMeasuredPH = adjustPHBasedOnTemp(measuredPH,roomTempC);

      You do not need to recalibrate, you just need to do correct temp compensation.

      Delete
  17. Hello, I would like to use this, but I am using an arduino mega and I use sda and scl pins for the clock, Could I use others pins for the comunication??
    Thank you

    ReplyDelete
    Replies
    1. Do you mean you have a clock i2c device communicating with the arduino on the i2c pins? If so then it will work you just need to make sure that the i2c device doesnt have the same i2c address as the ph module.

      Delete
  18. Do you have available datasheet for this sensor?

    ReplyDelete
  19. hi reza i am mohammedrady can you helpme in this projcte

    ReplyDelete
  20. Good day, friend you have the source code of this project (Dormant Labs PH Module V2) to work with pic microcontroller?

    ReplyDelete
    Replies
    1. Hello, no I haven't had a chance to work with pics yet. Still using arduino for small stuff and ARM for bigger stuff.

      Delete
  21. Heya, I am going to be using this module in a few freshwater aquariums. Would it be better to calibrate to water temp instead of room temp?

    ReplyDelete
    Replies
    1. Hello Sheldon,

      you should calibrate using room temp, because that is what your calibration solutions are at. Once calibrated, you should change the line

      double roomTempC = getRoomTemperatureC();
      double roomTempCompensatedMeasuredPH = adjustPHBasedOnTemp(measuredPH,roomTempC);

      To

      double aquariumTemp = 25;//assuming your aquarium is at 25 deg celsius
      double aquariumTempCompensatedMeasuredPH = adjustPHBasedOnTemp(measuredPH,aquariumTemp);

      Then change the rest of the program accordingly.

      Delete
  22. Is it possible tot read the value out of te arduino bij UDP to my domotics system?

    ReplyDelete
    Replies
    1. It is, but is beyond the scope of this tutorial.

      Delete
  23. What is the measure of the BNC connector?

    ReplyDelete
  24. Reza, fantastic product. Will recommend it to all my friends. BTW, I'm just wondering whether you have any EC module available for sale?

    ReplyDelete
    Replies
    1. Thanks! At the moment there is no EC module or plans for one. That could change in about 2 years time.

      Delete
  25. Hi Reza, I just wondered if your module Dormant Labs PH Module V2 can be run
    with any PH electrode or not. I'm thinking about this one, it's very cheap:
    http://www.aliexpress.com/item/PH-Electrode-Probe-BNC-Connector-for-
    Aquarium-PH-Controller-Meter-Sensor-gib/959990218.html . Will it work?

    ReplyDelete
    Replies
    1. And next question - is it galvanically separated? I'm thinking of using together with some EC module (didn't choose which exactly) and I'm worried a little 'bout interference between them.

      Delete
    2. Hello ytubeadmin,

      Yes that ph probe will work, but remember its cheap because it has 0.2ph error.

      For question number 2 yes the ph module galvanically isolates the micro controller from the probe.

      Delete
  26. Hi Reza
    I need 10 of these for an experiment I am going to run, can you supply that number in a short time scale?

    Dave
    ps. Excellent how to by the way

    ReplyDelete
    Replies
    1. Thanks!

      I have updated the tindie store (https://www.tindie.com/products/rezahussain/dormant-labs-ph-module-v2/?pt=full_prod_search), I only have 10 units left, after that I start R&D on v3 which might take a year or 2.

      Delete
  27. This comment has been removed by the author.

    ReplyDelete
  28. Hi Reza
    Thanks for updating tindie, by the time I got the boss to pay for them there were only 8 left!...will you be getting any more made up or is that it?
    Cheers
    Dave

    ReplyDelete
  29. What will version 3 bring to the table?

    ReplyDelete
    Replies
    1. The big two are configurable i2c addressing + ORP. Then other mostly minor improvements.

      Delete
  30. This comment has been removed by the author.

    ReplyDelete
  31. Dear Mr Hussain,
    I just bought yout pH module and a good probe with a good accuracy.
    I have 2 calibration solution (pH 6.863 et 4.something)

    I have changed 2 lines in the for loop to manage this difference as you explained previously.
    I have a 10.0 ph solution for test and I read 9.75 wich is too low
    I measure the tap water and I got 8.25 wich is way too high

    I have the ambiant temperature = 30 Celcius (it seems too much here)

    I follow line by line your very well done tutorial but now I need, the accuracy is under my expectations ans I dont know why.

    Regards,
    Phil

    ReplyDelete
    Replies
    1. Hello Phil,

      For this tutorial you need 7 ph calibration solution and 4 ph calibration solution. 6.863 and 4.something won't work bc the calibration code is designed to work across a 3ph difference between solutions.

      That is what I would check first.

      Best Regards,
      Reza

      Delete
  32. Hi Reza,
    Thanks for your quick reply.
    I have solutions at pH2, pH4, pH7 et and pH10
    I used the pH 4 solution and pH7 for calibration.

    I measured those solutions with a professionnal pHmeter and I got :
    pH2 = 1.853
    pH 4 = 4.023
    pH7 = 7.00
    pH10 = 9.62

    With your module I got :
    pH2 = 1.65
    pH4 = 3.95
    pH7 = 7.00
    pH10 = 9.51

    Those differences are not acceptable.
    may be it's a temperature compesation problem.
    Your module display 27.75 celcius ! (a way too high)

    please help me to resolve this big accuracy problem.
    Regards,

    Phil

    ReplyDelete
    Replies
    1. Hello Phil,

      1. Do you know your ambient temp?
      2. Also are your solutions at room temp?
      3. can you give the outputs for avgMeasuredPH and roomTempCompensatedPH?

      Thanks,
      Reza

      Delete
    2. To clarify, the temp is important because if the temp isn't 25 deg C, then your professional ph meter is wrong.

      Delete
  33. Hi has anyone tried this probe and a Intel Edison board can't get the probe to Work cant see it on i2c or with the sketch :/

    ReplyDelete
    Replies
    1. Hello Christian,

      I haven't worked with an edison board but it seems from here https://communities.intel.com/thread/55439 that you should try using 4.7kohm pullup resistors and or change the i2c frequency.

      Delete
    2. okay thanks, i was debugging on the the board and i fried the board i got from you :( sucks biiip :/

      Delete
    3. Do you have any more left ?

      Delete
    4. Damn Sold out since Apr 30, 2015

      any plans to restock ?

      Delete
    5. Sorry no plans to restock, v3 is the next time it will be on sale.

      Delete
    6. With the info on this site I got it to work in no-time.
      Calibration is fine also.

      But when I add your code to my excisting code I get this:
      avgMeasuredPH-avgMeasuredPH-inf roomTempCompensatedPH-inf avgRoomtTempC-23.8125 avgPhVolts-0.7201 7CalVolts-0.6700 4CalVolts-0.9864 4CalTempAdjusted-3.9550

      Not sure were to look for. Can you give me a pointer?

      Delete
  34. This comment has been removed by the author.

    ReplyDelete
  35. It was due to #include SoftwareSerial.h

    ReplyDelete
  36. This comment has been removed by a blog administrator.

    ReplyDelete
  37. Am using the board in a green house and it is pretty humid in there.
    Should I coat the board in some way, or will it be ok?
    Not sure if any components will rust

    ReplyDelete
    Replies
    1. I haven't had mine rust yet, and I haven't had any reports of rusting. It shouldn't bc all pads are covered with solder. If you really want to then I recommend you use a silicone conformal coating. Something like this http://www.amazon.com/MG-Chemicals-Silicone-Conformal-Coating/dp/B004SPJOKK

      Delete
  38. Hi, this instrument can I use for long time/ continuos ? For example, I need to use in an tilápia tank / aquarium and I need to get some information about ph. Can I put the instrument intro the water all the time or I need to mesurement and desintall? Thanks!

    ReplyDelete
  39. hi reza thank you i want buy this device how can buy it thanks reza

    ReplyDelete
  40. Hi Reza

    Have you completed the V3 yet with ORP?... I need a PH and ORP board for a project. How long unitl it is ready if you have not finished it?

    ReplyDelete
  41. Is there any way to install a LCD display to make it portable?

    ReplyDelete
  42. Again having some issues. Last time results shown 'inf' due to software serial libra en this time to virtual wire library. Is there a fix since I cant work around it.

    The other issue seems to be that a master-slave setup is being used to communicate with the pH pcb. I already have master slave arduino setup so my slave can't access the PH. If I try the I2C bus locks up since it can't be master and slave at the same time.

    ReplyDelete
  43. Hello!
    Any updates on v3? Any plans for EC? Or can you recommend any alternatives?
    Thanks!

    ReplyDelete
  44. Hola, sabes como activar un dosificador de Acido Hidroponico cuando la lectura del PH supere 6,5. Es para controlar una plantación de Hortalizas.

    ReplyDelete
  45. hallo,
    wann kommt V3 auf den Markt. Einzige Bord mit Isolation trennung im Netz.

    ReplyDelete
  46. Hi I really appreciate your all efforts which is specially for the ph test well done.
    ph test

    ReplyDelete
  47. good as no reaction comes I have found an alternative
    https://www.whiteboxes.ch/product-category/boards/?v=3a52f3c22ed6

    ReplyDelete
  48. I have been your silent reader for a while, and now I think you should know how valuable and helpful the information and tips you have shared with us. Thank you for sharing. Would love to see your updates again and maybe we can share ideas and collaborate with each other in the future.

    Elcometer

    ReplyDelete
  49. Do you still producing this module? We are looking to get some. Thank you

    ReplyDelete