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.

39 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