A Salad A Day – 5th Post – Update to DIY pH Sensor Circuit


, ,

One of the reasons I write up posts like the one on the pH Sensor Circuit is to improve the circuits I build.  I find I’m the type of person that loves learning yet learns best by building, documenting, discussing with others, and evolving with the new learning.  So I was extremely excited when I received this comment on reddit:

[–]SparkysWidgets 1 point 4 hours ago


As a side note since I have more space here than twitter you can switch to the internal reference on the Arduino, you wont need to gain the pH signal (1.1V ref) only offset it

Talk about a YIPPEE! moment.  So that’s what the AREF pin on the Arduino is all about.  Yes, it was right there in the oodles of documentation.  But somehow, when the firehose of things to learn about circuits and firmware was open to me, I didn’t look closely at the AREF pin.  AREF pin – my apologies.  This post is dedicated to you.

The Goal

The goal of this post is to simplify the pH sensor circuit I discussed in the last post.  I will do this by changing the design to accommodate SparkysWidgets recommendation.

Thanks to Those that Go Before

THANK YOU SparkysWidgets for giving me this advice.

The Simplification

The glass probe measures a small amount of voltage that is input into an Op Amp.  This Op Amp is used to apply a magnification (gain) of 5.1 to values coming in from the AC signal.  The gain op amp passes the signal to another op amp that shifts the signal from going into negative values to being between 0 and 5V.  The AC signal goes into an ADC where it is converted to a DC signal.  The DC signal is then read by the Arduino.  I deviated from SparkysWidgets schematic by using Arduino’s ADC.

Now I have learned that if I use the AREF pin and the ADC on the Arduino, the signal can be read without having to apply the gain op amp.I do not need to apply a gain op amp.  Now the circuit consists of an op amp, a charge pump, some resistors, some capacitors, and firmware that interprets a voltage into a pH reading using the Nernst equation.


In the post on the pH sensor circuit, I discussed VREF and its importance in adding accuracy to the AC to DC signal conversion. AREF is the VREF for Arduino’s ADC.  If my Arduino sketch includes analogReference(INTERNAL); Arduino’s ADC will use VREF = 0 – 1.1V.  





Now the AREF is VIN to the Op Amp.  In order to get the correct range given a gain of 2, I changed R13 and R12 to a voltage divider that divides the voltage by 4.  So instead of 0 – 1.1V, the VIN is 0 to .275V.  The output of the Op Amp multiplies .275V by 2 = .55V.

V(high) = 1.1V = V(in acidic pHs) + V(offset) = .414V + .55V =  .964V

V(low) = 0V = V(in base pHs) + V(offset) = -.414V + .55V = .136V

The Arduino sketch will receive readings between .136V and .964V.

The other change I made was to place a low pass filter capacitor on the AC signal’s input into the op amp.  As with the earlier post, this will help filter out spikes/noise that will occur.


Going through this update tested my knowledge of voltage dividers and using an op amp to shift an AC signal from readings that have negative values to having all reading above 0V.  Thanks to SparkysWidgets, I was able to simplify the pH circuit.  While doing this, I finally took a look at AREF.  Simple for you maybe.  Exciting for me to add this knowledge.  Again THANK YOU SPARKYSWIDGETS!


Thank you for reading this far.

Please find many things to smile about.

A Salad A Day – 4th Post – DIY pH sensor


, , ,

Chris noted at the beginning of week 3 of Contextual Electronics the value of knowing the design behind a circuit versus settling for a complete solution from a 3rd party.  In my case, I constantly wonder – how the heck does the pH sensor figure out the pH?  And the complimentary question – same for conductivity!  My highest priority in my DIY hydroponics station is “support free.”  After shipping software for over 20 years, I realize this is impossible. However, it is an important principle.  It is always better to have intimate knowledge of what I am building.  Besides – it brings me a YIPPEE! MOMENT – so much to learn.

The Goal

The goals of this post include getting:

  • an intuitive feel for what measuring pH is all about.
  • a strong grasp of the parts that go into a pH measuring circuil.
  • Get you engaged so that together we can build and learn together.

Non Goals

  • discussing what pH values mean to a plant’s health.  This is covered in other posts.
  • a working prototype.  This post focuses on getting to know the pH circuit.
  • choice of probe.

Thanks to Those that Go Before

 Learning is amazing.  How extraordinary to be able to learn from others who willingly share their knowledge.  THANK YOU!  For knowledge is indeed more powerful than currency.  And community learning is indeed more powerful than a textbook.

  • EME Systems for a great article on the hows and whys of a pH circuit.
  • @SparkysWidgets –  I bought a pH circuit.  His phSensor schematic and blog post is all you need to get started.  Because I lack the background in electronics, I didn’t understand much of the post at first.  This got me writing out what I learned here.
  • The pH Pages – useful info on how to build a pH sensor.  
  • Chris Gammel - our very knowledgable and gifted instructor of Contextual Electronics.  A course I would highly recommend if you are interested in turning your prototypes into PCBs and learning tons about electronics along the way.  The more time I spend with Chris, the more I realize what an exceptional person – both in knowledge and in ethics – he is.  Chris is amazing at clarifying circuit concepts!
  • Dave Jones for his excellent videos on different aspects of stuff we need to know about electronics.  The recent one on Op Amps is terrific.
  • The Hydro subreddit.  Thank you to all the knowledgable folks who kindly share their experience and what they have learned.
  • The AskElectronics subreddit.  Thank you for answering questions that might seem obvious to you.  
Again – thank you.  It is a much better learning environment than what I remember 20 or so years ago.  At that time, it seemed we took “knowledge is power” to be ME motivated and not understand shared knowledge is far more powerful than ME knowledge.

The Parts of a pH Measuring Device

Not knowing much about the innards of a pH measuring device, I spent a bit of time reading up on what the heck makes these things work.  It turns out a pH measuring device consists of a probe and a voltmeter.  My apologies if you are rolling your eyes at this obvious conclusion.  Up until now, the pH was just a number on a spreadsheet.  Now I am constantly wondering why?  I’m loving the mix of life, chemistry, electronics, math and programming.  But there is a good chance you have already enjoyed learning all this – probably in 5th grade science… For others who didn’t learn this stuff but are now interested, I’ll summarize what I learned.

The probe  is a glass electrode.  It measure the hydrogen ion (H+ ion) concentration in a liquid.  The image and a better explanation can be found on this post.


pH Probe (glass electrode)

When the probe is put into the liquid, the H+ ions move toward the glass electrode.  This creates a tiny current which is what a pH sensor measures.  More H+ ions scurrying about means a higher voltage, which means the liquid is more acidic.  Lower – more basic.  When I look at it that way, I can see the comparison between a pH probe and a battery.  Like a battery, a pH probe generates current.  A pH probe does this by getting the  H+ ions to scurry about.  

Like a battery, the voltage can be measured.  Voltage of electrodes is measured using the Nernst equation.  This equation is used to validate that a change in 1 pH unit occurs when  the voltage changes by -59.16mV.  pH values can range from 0 (high acidity) to 14 (strong base).  Given the pH range and the voltage change (59mV) per pH unit, the range of voltages the pH probe will read is: +/-7*59mV or +/-413mv.  At  pH 7 (neutral pH) the probe produces 0 volts.

When the voltage change is not -59.16 mV

There are two adjustments that must be made to get accurate readings:

  • temperature
  • probe degradation

The charts on SparkysWidgets post gives a nice visualization of the relationship between the pH values and temperature:

The amount of volts between pH units  depends on the temperature of the solution.  -59.16 mV assumes the solution is at a temperature of 25°C/77°F.  Googling for the temperature coefficient returned  -0.1984 mV per °C. That makes the slope -54.2 millivolts per pH unit at 0°C, and -74.04 millivolts per pH unit at 100°C. 
Like a battery, the voltage potential for the gas probe weakens over time.  An accurate reading should calibrate the pH readings to accommodate the degradation of the signal.  To calibrate, I need a solution known to be at pH 7 and one known to be at pH 4.  Every once and awhile – say every two weeks, – I must take a reading for these know solutions and adjust for temperature.  If the voltage of the known solutions is not 0 V for pH 7 and (59.16*4) .237V for pH 4, the readings need to be adjusted to these variances.

The Circuit


Time to design the pH sensor.  The requirements include:

  • the voltage produced by the pH probe can be read from an Arduino Uno’s digital i/o pin.
  • “fairly accurate” readings.  A pH of 5 is only 59mV from a pH of 6.  That is a very small amount of differential voltage to measure accurately.  This is because the pH probe is made of glass which creates a very small electrical current.  This means it has a very high output impedance, typically around or more than 100MΩ. SpakysWidgets notes: “A typical probe has an impedance of anywhere between 50MΩ and 500MΩ, and since 100MΩ*1nA=.1v even having a single stray nano amp can throw our measurement off by almost 2 entire ph units.” In order to get a meaningful reading, the design must eliminate most noise and outside disturbances.
  • voltage measurements must be able to interpret both negative and positive voltages since the voltage difference is +/- .414V
  • low BoM.

The Design


The requirements lead to the protagonists of the pH sensor being op amps.  I’ll use two:

  • one op amp will isolate the circuit that will be measured from the circuit that is providing the reading.  This will go a long way in preventing disturbances from being introduced by the pH sensor.
  • one op amp will amplify the signal so that it can be read by the Arduino’s digital i/o pin.
the most important characteristics of the op amp are in its abilities to be as “ideal” as possible when considering attributes that would introduce changes to the pH measurement:
  • low input bias – in the picoAmps
  • high input impedance – meaning the op amp will draw as little current as possible.  This will also help minimize changes to measurements because of the parts used.
I’ll also need:
  • an ADC to convert the incoming analog signal into a digital signal that can be read by the Arduino Uno. 
  • charge pump to handle the -5V readings when using Arduino’s 5V as the power supply.
  • some capacitors to filter out noise.


Why reinvent the wheel?  Besides, at this point in my learning I am still being introduced to components and what they do.  I decided to learn the design of the circuit by walking through SparkysWidget’s schematic on GitHub.  In this section I will walk through the components I mentioned before.

Op Amps

 Op Amps are the central component of a pH circuit.  It’s job is to:

  • adjust the pH signal so that it can be read by an Arduino (through an ADC).
  • filter out noise in the pH signal.

Adjust the Signal

The diagram I came up with helped me to understand what is going on.  Even though SparkysWidgets said these things, I didn’t grasp what was really going on until I broke the steps down.  The process helped me better understand the fundamentals of an Op Amp.  I’ll explain what is going on in each step in case it helps you.


Before the voltage signal generated by those active Hydrogen ions can be read by the Arduino (and converted to digital from analog by an ADC), the tiny signal coming from the pH probe must be transformed into a value between 0 and 5V – the voltage range the Arduino will read.  The diagram shows this in three forms:

  • block – if the step was a black box, this is what it is doing
  • 101 – simplified “behind the curtain” drawing using standard drawing of a non-inverted op amp.
  • behind the curtain – pieces of the schematic come from SparkysWidgets schematic in GitHub.

1. Signal comes in from pH probe

I noted above that the signal created by the pH probe ranges from:

  • pH 0 = .414 volts
  • pH 7 = 0 volts
  • pH 14 -.414 volts

2. Amplify Signal

Googling for “gain op amp” gave me the formula for the gain:

Using the resistors in SparkysWidgets schematic, Gain = V(out)/V(in) = 1+R8/R7 = 1+4.7 = 5.7

Gain = V(out)/V(in) = 5.7.  Or V(out) = 5.7*V(in).  When the pH of the solution is 0 (strong acid), V(in) is .414.  When the pH is 14, V(in) is -.414.

So the V(out) based on V(in) and the Gain is:

V(out acidic pHs) = 5.7*.414V = 2.36V

V(out base pHs) = 5.7*-.414V = -2.36V 

3. Shift Signal

To read the voltage value from the Arduino, the range of readings must be between 0V and 5V.  One way to do this is to add 2.5V to the reading.  The V(out) values of the Gain op amp become the V(in) values for the offset op amp.  Mapping this to 5V and 0V:

V(high) = 5V = V(in acidic pHs) + V(offset) = 2.36V + 2.5V =  4.86V

V(low) = 0V = V(in base pHs) + V(offset) = -2.36V + 2.5V = .14V

The Arduino sketch will receive readings between .14V and 4.86V

Get Rid of Noise

Given the pH probe uses glass, it’s pretty hard to get a great signal.  On top of that, there is inevitably going to be some noise.  The standard way this gets handled is to put a low pass filter in the circuit at the spot it works best to pluck out the noise.  This is why SparkysWidgets schematic includes the 1uF capacitor on the gain op amp.




 I thought this explanation summarized how the capacitor is used to throw out high frequency noise:


The capacitor’s impedance decreases with increasing frequency.


Chris’s Drawing Helps See How a Capacitor Works In High and Low Frequency Signals

This low impedance in parallel with the load resistance tends to short out high-frequency signals, dropping most of the voltage across series resistor R1.

The spikes (noise) gets swallowed up by the capacitor since as the spike is winging through the circuit it wants to travel the path of least resistance.  When it has a choice between The path with the resistor and the capacitor with a low impedance, its going to choose the capacitor path.  


As obvious from its acronym, the ADC takes in the shifted analog signal coming from the shift op amp and digitizes so the Arduino can interpret a value.


Most pH charts like this one need one decimal point resolution.  I want to be able to read a pH of 7 and a pH of 7.1 accurately.  I don’t need to distinguish between 7.12 and 7.13.

I noted earlier there is -59.16mV per pH unit when the temperature is 25°C.  The signal was then amplified by 5.7.  This changes the amount of voltage between pH units to -59.16*5.7= -337.212mV.  A pH value of 7.1 occurs at 33.721mV per .1 unit of pH.  Given that, an ADC with 8-bit resolution should be good enough.

Because I was following SparkysWidgets recommendation of using the MCP3221, I didn’t think to consider the Arduino”s ADC.  Luckily folks on the AskElectronics subreddit did:

[–]deadycool 3 points 19 hours ago

Why won’t You use Arduino’s analog inputs?

I’ll start with using the Arduino’s ADC and see if it is “good enough.”  For now I think it is.  Using the Arduino’s ADC will save a level of complexity since I don’t have to think about I2C or SPI to communicate with the ADC as well as lowers the BoM.

Which Communications Interface

If I were to use a separate ADC, I could use Serial, I2C, or SPI to communicate with it.  I’ve used Serial communications on an Arduino enough to feel I can get better accuracy over I2C or SPI.  I chose I2C because of this digikey search.  ADCs with the SPI interface were $1 or more than ADCs with the I2C interface.  It looks like the difference is a higher sampling rate for the SPI bus.  This makes sense because the SPI is a faster bus than I2C.  However, the sampling rate offered by ADCs using the I2C bus to communicate with an Arduino are fine for my needs.  A goal is to save on the BoM where it makes sense to do so.  In this case, using the I2C bus makes sense.

I’ll compare results using the Arduino’s analog input with the same part SparkysWidgets uses – the MCP3221.  The cost is $1.73 for a quantity of 1 on digikey.com.  The default clock speed for the I2C bus on an Arduino is 100KHz, which is plenty fast enough.  Figure 6.2 of the data sheet recommends 10K pull-up resistors for the SDA and SCL lines.

Get Rid of Noise

mash_taiters noted out a good “rule of thumb” : you should always include decoupling capacitors to the supply pins of ICs (usually 0.1uF). They are cheap, small, and will save you headaches.

These words of advice are retold in6.4.2 of the data sheet:  A bypass capacitor from VDD to ground should always be used with this device and should be placed as close as possible to the device pin.  A bypass capacitor value of 0.1 µF is recommended.  Adding this capacitor should handle any noisy spikes.  


The reasons I might wish to use a voltage reference IC include:

  • a stable reference voltage to measure the input/output voltage.
mash_taiters pointed out to me: “…Vcc [VDD] powers the ADC circuitry, whereas Vref is used as a comparison or reference for the input you’re measuring. For this reason you need to give it a very stable and accurate voltage…”
  • a simpler/more exact mapping from analog to digital.

kizzap noted: “As for Vref, the voltage you pick here can be very critical in determining the range of the signal the ADC can read. It can also dictate how difficult the maths will be in your code:
Say you have a 12-bit ADC. that means you have 4096 steps between 0Volts and Vref. if you have Vref as 5 Volts, you will get 1.2207…mV per step (ignoring INL and DNL here btw). if instead you use say a 4.096V reference, aside from it generally being more stable then a tap off your logic supply, it makes the maths much easier, as you will get a clean 1mV per division.”

I am assuming – I may be wrong – that using  VDD instead of including a voltage reference IC like the MCP1541  ok for this application. 

Charge Pump

SparkysWidgets uses the TPS60400.  The data sheet has a nice drawing of how to easily set up this chip within the circuit:



The Schematic

I’ve concluded the schematic SparkysWidgets has provided to us is very close to what I would create given my new found knowledge.  So I’m just going to reference this one.  THANK YOU SPARKYSWIDGETS! 


Thanks to those that have gone before, I found it wasn’t that overwhelming to build a pH sensor circuit.  The firmware still needs to be written.  This won’t be too difficult given the large amount of information folks have shared.  Amazing.

I thought I knew more about Op Amps than I did.  It took me a surprisingly long time to figure out what the op amps were doing and how they were doing it.  Even with the information SparkysWidgets provided.  My challenge is interpreting what is being said in the context of my new to circuits context.  I post this in case others might be in the same learning boat and could benefit from my interpretation.  Also, I am hoping folks will correct errors I have made or suggest improvements to be made.  That would be spectacular!


What’s Next

I need to prototype this circuit so I’ll be ordering parts and laying them out on a breadboard.

While I am waiting on parts, I will be delving into building an EC (conductivity) circuit.  I am assuming the two circuits will be similar and am excited to find out.



Thank you for reading this far.


Please find many things to smile about.






















V(acidic pH mapping to 5V) = 

0V = V(in base pHs) + V(offset base pHs) , V(offset base pHs) = 0V – (-2.36) = 2.36


Breaking down what is going on, an analog measurement is made then amplified.  This must mean an OpAmp is going to play an important role in the circuit.    The analog signal is converted to digital.  Seems like I’ll need an ADC.  Finally, a conversion function is needed.  Here is where the math comes in.  I am not strong at math so I thank Sparky for coming to the rescue.

By the way – if you are like me and new to using OpAmps, I highly recommend Dave Vewers’s Youtube video (TBD: link and name of video)  .  By watching this video you get the added bonus of learning what a “dill” is.

Sparky points out the pH is logarithmically proportional to the acidity – which is the activity of a hydrogen ion concentration.  A logarithmic relationship between a pH value and the activity of the hydrogen ions means:

For each pH step we see a ten fold concentration change, for example a pH of 8 has 1/10th the ion activity as a pH of 7.

No wonder my cucumber plant’s leaves turned yellow when it’s pH was off by over 1 step.  The poor plant was not able to take in the proper amount of nutrients.  I can see why maintaining the correct pH level is so important to the health of a plant.

To keep me from guessing, Sparky points out the logarithmic relationship is:

 pH = -log10(activity of the hydrogen ion concentration)

All this really means is when the concentration is greater on either side of the probe, the ion flow will induce a slight voltage between the probes electrodes, this voltage can swing both +/- which will indicate either an acid or base.

pH values can range from 0 (high acidity) to 14 (strong base).  pH 7 is in the middle.  Any pH reading < 7 is said to be acidic.  A reading > 7 is basic.  Sparky assures us a probe 

generates -59mV/pH.  Given that, the effective range is +/- .059*7  volts or +/- .413 volts.


But wait – temperature and using a worn down probe need to be taken account when making a reading.  I don’t know how yet.  Sparky is building up the suspense!

Build the Circuit

The OpAmp


wikipedia article on op amp:


While we were designing the thermocouple in Contextual Electronics, Chris walked us through the data sheet for an LM324 OpAmp.

  • Supply voltage: The range of voltage that can be measured.  The data sheet for the LM324 states a comfortable range of TBD – data sheet

In order to build an adequate amplifier there are a few consideration

s other then those pointed out by the ideal probe section. One consideration is the very high impedance that a pH probe has. Not only are the probes very high impedance they also are susceptible to noise, and the input stage is very vulnerable to drift/offset characteristics of the amplifiers used to interface the probe. There are a lot of Op-amps that can be chosen for the job, dont just look at the Input Impedance of the Op-Amp :)


A typical probe has an impedance of anywhere between 50MΩ and 500MΩ, and since 100MΩ*1nA=.1v even having a single stray nano amp can throw our measurement off by almost 2 entire ph units. The goal then is to choose an op amp that is adequate enough that will not load down the probe but that also has characteristics which will keep both the cost down and the accuracy up. When combined with the previous considerations about probe age and drift, a basic roadmap is made on how we can simply and effectively amplify and interface a pH probe signal.


A very basic design we can utilize is a simple unity gain amp, a buffer circuit to separate the high impedance probe from our “low” impedance multimeter. We will build this design first for a couple reasons, the first being it is an effective way to compare our probes to the ideal probe model. the second reason being its really easy to build and can take only a few seconds, and demonstrates a base for how the offset(in an inverting config) will alter the signal. While I suppose you could use an LM358 for this I would recommend at very least the ST TL072 or a CA3140 this is to be sure not to load down the probe and get false readings.


In analog synthesis, to generate almost any signal with op amps, it is necessary to have positive and negative voltages. This allows the op amp to generate a signal that spans positive and negative voltage values.

 And there it is – a YIPPEE MOMENT!

  • take an analog measurement of the voltage change two things.  Here the voltage change is between….. TBD
  • since the voltage change can be very small, magnify the change so that it can easily be read by the other chips participating in the circuit
  • convert the analog measurement to a digital measurement.
  • Apply an algorithm that takes the digital measurement and interprets it into what I am monitoring – in this case the pH value.

This is the lens through which I need to understand from a vegetable growing perspective.  The other viewpoint is the design of a pH sensor’s circuit.  As with other domains, electronic circuits has patterns.  Once I learn the pattern, I can apply this pattern to multiple scenarios.  The pattern of the pH sensor is:

  • take an analog measurement of the voltage change two things.  Here the voltage change is between….. TBD
  • since the voltage change can be very small, magnify the change so that it can easily be read by the other chips participating in the circuit
  • convert the analog measurement to a digital measurement.
  • Apply an algorithm that takes the digital measurement and interprets it into what I am monitoring – in this case the pH value.
The pattern is the one I learned in the Contextual Electronics when we designed a circuit for a thermocouple.  
For the pH sensor, I want to take an analog measurement of a voltage change that has units between 0 and 14.  This is not the same as what I can measure with my Arduino circuit, which is 0 to 5V.
As the SparkysWidgets post points out (and the logarithm entry in Wikipedia notes), the pH is logarithmically proportional to the acidity (activity of a hydrogen ion concentration).  SparkysWidgets tells me the relationship is:

 pH = -log10(ah)

I’ll trust this person to be right.  Sparky then goes on to say:

All this really means is when the concentration is greater on either side of the probe, the ion flow will induce a slight voltage between the probes electrodes, this voltage can swing both +/- which will indicate either an acid or base.



Speaking electronics, the pH on the left side is the voltage.


I like to divide discussion of design and functionality into:

  • The job being done.  If I don’t do this circuit, what additional work would I be doing?  The more I think of this in terms of energy I would have to spend, the more I am able to focus on the most time consuming and least desirable tasks.  I guess being lazy has its advantage when it comes to design!
  • A block diagram.  The block diagram gives me a very high level map of the modules that are needed to complete the job.   I’ll keep taking it down a level until I’m at the wire-connecting-to-chip level.
  • A Fritzing diagram.  The prototype uses a breadboard and jumper wires.  Fritzing provides a better visual and has more components for breadboard drawing than does the ECAD (?) tool I use – Kicad.  (TBD: LINK TO KICAD).

The Job

The water node reports readings and adjust the contents of three different chemistries (pH UP, pH DOWN, nutrients) in the nutrient reservoir.

The job of the water node is to :

  • report the readings of the water temperature, pH, and conductivity when it is requested.
  • Adjust the pH UP or DOWN when given a command to adjust to a pH level.
  • Adjust the nutrients when given a command to adjust to a range of PPM.

The Block Diagram


The BoM

 The price for prototype parts includes:





ph Kit


See this post

EC Kit


AtlasScientific Web Page

Water Temp sensor


Previous post



spare parts

3 Peristaltic Pumps

$85 (3 + a little over $10 shipping)


3 N-channel power MOSFETs



3 1N4001 Diodes



1 Button


spare parts



spare parts

1 1KΩ Resistor


spare parts

1 4.7KΩ Resistor


spare parts




The Fritzing Diagram




The green LED is on when the prototype is first plugged in.  I then will use PWM to set the LED to 1/4 the full strength.  The LED will go to full strength when data is being taken or sent and then return to 1/4 full strength.

Testing the Circuit

I broke the prototype into chunks.  Testing first then adding on another chunk.


 I started with the LED because this is Arduino 101 stuff.  I used the Fade sketch that comes with the Arduino IDE.


I then wired up the pH sensor.  I detailed how I did this in an earlier post.  The pH circuit uses a serial interface.  This requires a TX and RX pin on the Arduino for sending and receiving data.  As shown in the Fritzing diagram, I put a yellow jumper wire between pin 13 on the Arduino and the breadboard hole. This serves as the TX line from the Arduino (RX line from the pH circuit).  A green jumper goes from pin 12 of the Arduino to the TX pin of the pH circuit.  So pin 12 is the RX pin from the Arduino. I used Atlas-Scientific’s sketch to test the circuit.  I am not testing the probe at this time – only the circuit.  I sent several of the commands listed in the Atlas-Scentific data sheet for the pH circuit.

i command (version) returns 



Next I wired up the EC sensor.  As with the pH sensor, I covered how I did this in an earlier post.  A pro of using both circuits from Atlas-Scientific is they are identical in pin outs, use a serial interface, and use the same commands.  Once I figured out how to work with the pH circuit, I already knew how to work with the EC circuit.  This allowed me to use the same sketch I used to test out the pH circuit.  The only change was setting pin 10 as the TX pin on the Arduino and pin 9 as the RX pin.


Now I have two chips that use the serial line to communicate.  As I pointed out in the earlier post, the serial library does not multiplex.  I’ll use a similar solution to what I did earlier.


Water Temperature

I wired up the water temperature sensor just as it is shown in the Fritzing diagram.  I then wrote and ran an extremely simple test sketch that just reads the temperature 5 times.  The WaterNodeTest.ino sketch can be found in the bitknitting gitHub  TBD


I have one pump set up. I’m waiting for two more from Adafruit.  All three circuits are identical.  I’ll test the other two when the parts arrive this week.  For the test of the one pump I have, I ran a very simple sketch 

How much pH Up/Down is needed per gallon?  http://generalhydroponics.com/site/index.php/resources/faqs/ph_dynamics_and_adjustment/

Answer: Start out with one milliliter per gallon. Wait 15 To 30 minutes, and test your water again. Frequently you will only need 1 to 2 ml of pH Up/Down per gallon of water. You may need additional pH Up/Down if you have hard water. The General Hydroponics Flora Series is pH buffered to facilitate keeping the pH in a favorable range.



You might consider just reading SparkysWidgets post (I’ll refer to this post as Sparky in the rest of this post.  Awkward, but I do not know the person’s name behind the post.)and ignoring the rest of this post.  It does a great job covering what a pH sensor is.  Sparky’sWidg. However, my interpretation might help others that learn through a similar lens that I use and documenting my interpretation has the added advantage of jogging my memory when I need to do so in the future.

The SparkysWidgets post (I’ll refer to this post as Sparky in the rest of this post.  Awkward, but I do not know the person’s name behind the post.) is a great source for getting the context of how a pH value is measured from the scientific and math viewpoint.

It turns out how a pH sensor gets its job done is straightforward.   A pH sensor:

  • takes an analog measurement of the voltage change between two electrodes.  This is a small value, so..
  • the measurement is amplified to be measurable within the range of +/-5V.
  • the amplified value is converted from analog to digital so that the Arduino can read the value.
  • the Arduino through an Arduino sketch reads in the +/-5V value.  
  • Calculates the pH (which includes adjustment for temperature).  As noted in this post: “The pH of any solution is a function of its temperature. Voltage output from the electrode changes linearly in relationship to changes in pH, and the temperature of the solution determines the slope of the graph.”
  • Adjust the pH based on the 
The “secret sauce” is the conversion function.

Sparky points out the pH is logarithmically proportional to the acidity – which is the activity of a hydrogen ion concentration.  A logarithmic relationship between a pH value and the activity of the hydrogen ions means:

For each pH step we see a ten fold concentration change, for example a pH of 8 has 1/10th the ion activity as a pH of 7.

No wonder my cucumber plant’s leaves turned yellow when it’s pH was off by over 1 step.  The poor plant was not able to take in the proper amount of nutrients.  I can see why maintaining the correct pH level is so important to the health of a plant.

To keep me from guessing, Sparky points out the logarithmic relationship is:

 pH = -log10(activity of the hydrogen ion concentration)

Info I got from the pH pages noted:

In theory, a pH probe produces about 59 millivolts (mV) per pH unit, and at pH 7 (neutral pH) the probe produces 0 volts. Acid pHs produce negative voltages. Basic pHs produce positive pHs.


pH values can range from 0 (high acidity) to 14 (strong base).  Given the pH range and the voltage change (59mV) per pH unit, I can now calcite the range of voltages the pH probe will read: +/-7*59mV or +/-413mv (.413 volts).


My pH sensing circuit needs to read the value the pH probe receives, magnify the reading to be within the +/-5V range, convert it to a digital signal and then then apply the conversion function.  And then – a YIPPEE MOMENT!  I can read the pH value of the nutrient bath that is feeding my vegetables.





The Circuit

I find building circuits more fun and approachable if I think of the parts as workers in a workshop.  I’m tempted to give them names like “Harry” and “Fred” but the last time I did this I got an F on a test because the teacher insisted on the Latin names for the trilobites he wanted us to identify.  So I won’t be adding this familiarity.  The workers that I need to hire to make pH sensors include:

  • Two Op Amps:
    • One Op Amp will isolate reading from measuring the voltage. Sparky notes: A typical probe has an impedance of anywhere between 50MΩ and 500MΩ, and since 100MΩ*1nA=.1v even having a single stray nano amp can throw our measurement off by almost 2 entire ph units). Because a copy of the part of the circuit that gets the reading from the pH probe is used (a unity gain buffer),   measuring the pH does not affect the reading of ion activity by the pH probe.  
    • The other Op Amp will amplify the tiny voltage change read in from the pH probe to a +/-5 v range.
  • charge pump to handle the -5V readings when using Arduino’s 5V as the power supply.
  • An ADC to convert the analog reading into a digital value that can be interpreted by the Arduino sketch.
  • Some capacitors to filter out noise.




Zero volts output at neutral pH (=7.0) 

Positive voltage in acids, pH<7 

Negative voltages in bases, pH>7 

Total realistic pH range is 0 to 14. 

Generates -59.16 millivolts per pH unit at room temperature (=”Nernst potential”). Note that this is a negative slope–higher pH, lower voltage. 

the full scale range is +/-0.414 volts. (+/-0.05916*7), at 25 degC. 

Temperature coefficient of the Nerst potential is -0.001984 mV per °C. That makes the slope -54.2 millivolts per pH unit at 0 degrees Celsius, and -74.04 millivolts per pH unit at 100 degrees Celsius. 

Googling for “gain op amp” gave me the formula for the gain:

A Salad A Day – 3rd Post – Change in Grow Station Design


, , ,

I just finished my last post where I discussed the system design for my grow stations.  In that post, I decided to evolve BTLE as the communication protocol between a node and the Base Station.  Then the Base Station would talk to my iPhone over BTLE and 802.11, depending on if the iPhone was in range of BTLE.  Keeping in mind that I am lazy, I’ve made one more leap in simplification of my design.  I decided the iPhone app will have the functionality of the Base Station.  Ba Ba Ba BOOMP – good bye middle man hardware!

I enjoy this phase of a project.  It is the time I reflect on how truly lazy I become, especially as I get older.  As I thought through my passion to grow 100% of our lettuce with the least amount of effort on my part, I realized collecting and analyzing sensor readings was not a high priority use case.  What was important was a plant living in an environment with the proper care and feeding.  This boils down to main functions of the water node.  Automatic adjustment of pH and nutrients plus a quick update on the sensor readings just to get a warm and fuzzy that the numbers are within a “normal range”.

By removing the Base Station:

  • The system is less expensive, simpler, and will be faster for me to build.  I will enjoy a focus on the nodes and iPhone app.
  • A significant support challenge has been minimized.  I have a lot of experience in networks not working.  Of course, anyone using an 802.11 shares my experience.  With the first design I had designed for 3 wireless RFs (RFM69HW, 802.11, and BTLE).  Then I went down to two (802.11 and BTLE).  But why stop there?  Do I really need to see what the nutrient level is on a beach?  While it certainly would be nice to get an alert if the pump stopped working when I am on vacation so that I can get someone to look into it, I’ll leave that to future versions.

The Goal

The goal of this post is to iterate on the system design of the growth station such that the iPhone incorporates the functionality of the Base Station.

Updated Lettuce Grow Station

Here is the *new and improved* block diagram.  It is far simpler!


What’s Next

My next post will cover a breadboard version of the water node!


Thanks for reading this.  Any feedback you have would be greatly appreciated.  Please find many things to smile about.

A Salad A Day – 2nd Post – Lettuce Grow Station Design


, , ,

In this post I’m going to go over the system design of the Lettuce Grow Station.  I will be using Arduino + sensors + wireless + iPhone app to measure and automate the growth stage of my lettuce.  I better get going since the seeds should be done with germination in a few weeks.

The Goal

The goals of this post include:

  • defining the technology of the lettuce grow station
  • moving my knowledge forward in the two areas – hardware/software and hydroponics – where my passion is focus.
  • connecting with others who share my passion from which I can learn or I can share what I have learned

The Non Goals

  • aesthetically pleasing grow station.  At some point I will address a grow station that fits into my house and is pleasing to look at.  This time around I am going for functional.  I will need to make several iterations!
  • easy to move around.  Some of the components – the nutrient bucket and LEDs – will be too heavy to move around.  At some point I’d like an AeroGrow size for growing herbs on my kitchen countertop.  In fact, I have that today!   The challenge is its ability to grow a salad a day.
  • minimizing cost over robust, quick response, and important features.

Thanks to Those that Go Before

I like to take a moment and reflect on the great works of folks that I have benefited from their knowledge.  Community learning is an incredibly positive experience.  THANK YOU!!!  For this post, I’d like to thank: 

  •  the Hydro subreddit.  Thank you to all the knowledgable folks who kindly share their experience and what they have learned.
  • Chris Gammel - our very knowledgable and gifted instructor of Contextual Electronics.  A course I would highly recommend if you are interested in turning your prototypes into PCBs and learning tons about electronics along the way.  There is no way I would be able to get this far without Chris’s class and his recommendations/insights.
  • Adafruit, SparkFun, and OshPark for making it so easy for us DIY’rs.  The amount of learning material these companies provide is staggering.  They are all so approachable.  Very prompt and helpful in replies.

The Lettuce Growth Station

Ah yes, begin with the end in mind.  In my last post, I started my germination station.  Now I am excited to tackle getting to this:


Did you see the rainbow and bright lights?  Me neither.  But I do see a magnificent head of butter crunch lettuce grown through hydroponics methods.  This is what my grow station needs to be able to do.  I am not sure what I am doing (advice craved!).  There will be many iterations.   But the reward for building a grow station that can grow lettuce like this is quite tasty.

The Features

I am lazy.  Thus the #1 feature is saving me time.  From my previous attempts at hydroponics, I found the following:

  • maintaining the right pH for a plant is extremely critical.  If not, the plant will not be able to take in food.  Since I like to anthropomorphize my protagonist – in this case a head of lettuce – I imagine the lettuce is like me.  Extremely grumpy when not fed correctly.  Only it gets worse.  The poor plant is reliant on me to feed it with the right nutrients.
  • maintaining the right nutrient level is tricky.  While I’ll be taking conductivity readings and adjusting the nutrients accordingly, the conductivity readings cannot tell me which nutrients are deficit.  What if the poor lettuce is lacking nitrogen yet I decide to blast it with potassium?  What kind of a grower AM I?  Someone should probably call the plant police on me!
  • The amount of light is very important.  My lettuce plants will need appropriate levels of LUX and PAR lighting.  I like LED lighting.  High powered LEDs let out a lot of light and are more efficient than others.  I’m ok with paying more – although I am also interested in the difference between DIY LED fixtures and buying an equivalent.
  • The care and maintenance of the water part of the lettuce grow station requires the most amount of time.  I’ll focus on minimizing this.
  • I will be adding more stations.  After all, what is a salad without tomatoes?
  • I want to view and control my grow station from my iPhone.  My new friends can talk to me at anytime from anywhere.
  • I want the system to be responsive. When I ask for a reading from my iPhone I don’t want to wait very long to get a response from the Base Station.

The Building Blocks

I’ve divided the system components of the Lettuce Grow Station into three functions:

  • Grow – these blocks include the lighting and the hydroponics system.  The hydroponics system includes the parts where the plants grow and a reservoir that holds the water mixed with nutrients that the plants will feed from.
  • Control – the control blocks receive readings for conductivity, pH, and water temperature and send this information to my iPhone.
  • Interact – I view and act on the readings from an iPhone app that I will write.


In this section I’ll give a high level explanation of the details of components in the Grow boxes.


The requirements of the LED fixture includes:

  • Enough light for the plants to go through a healthy grow and flower growth cycle
  • Ability to automate time on and time off 
  • optimized for energy savings (ongoing effort)

I am not quite sure what the “best” LED fixture is for my needs so I’ve been exploring several potentials.  I measured the lumens  using a  LX1010B Light Meter.  I measured the PAR value using the DIY PAR meter I  purchased awhile back.

* *

AeroGrow  LUX: 7,000 PAR: 180 µmolphotonsm-2s-1

T5  LUX: 13,000 PAR: 247 µmolphotonsm-2s-1

* *

UFO – 135W LUX: 30,000 PAR: 680 µmolphotonsm-2s-1 90W: 670 µmolphotonsm-2s-1

DIY LEDGroupBuy Fixture LUX: 91,000 PAR:650  µmolphotonsm-2s-1

I took the LUX measurement at 5″ below the center of each light.  Lumens will be greater for full spectrum lights.  Lights like the UFO – that have light in the blue and red wavelengths – will have less lumens but should have a higher PAR since the energy from the blue and red wavelengths are absorbed the most by plant leaves.  For this reason, many see PAR readings a better representative of a light’s usefulness for plant growth.  However, I do not have a PAR meter I am comfortable is accurate yet and I do not have a spectral distribution of these lights.

PAR values are measured in µmolphotonsm-2s-1.  I am still learning about PAR values and how much is enough for each type of plant.  Also, I am not sure the DIY PAR meter has accurate results.  Actually, I assume inaccuracy so I am using the DIY PAR meter readings to get a general idea and to also spark me into taking better light measurements.

Back to the amount of LUX…

superAngryGuy had a great posting in the hydro subreddit on the amount of LUX a plant should get:



15,000 – 20,000

the lower end of what we want for veg growth

35,000 – 40,000

what we want to try to hit for flowering

75,000 or so

it’s pointless to go beyond this level of light intensity, saturation level

It looks like our seed starters have enough light.  The AeroGrow keep pumping along growing a small amount of mint and basil.  The UFO’s should be fine for lettuce.  The high LUX measurement of the DIY LEDGroupBuy fixture makes it a better choice for my next project – A Salad A Day -> Tomatoes.  Of course, the light can be adjusted to fit within a reasonable range as needed.

I bought a UFO 135W from eBay for $102.50.  I was curious how the PAR compared to the 90W UFO I had previously bought from eBay for $62.96.  It turns out the light values are very close.  The 90W was a good deal.  It looks like prices have gone up since I purchased.

The DIY LEDGroupBuy Fixture is something I put together using the circuit I discussed in an earlier post.  I did not include an Arduino.  I just plug it in with a timer and off it runs.  I bought two Lumia 5.1, 1 48W power supply, and 10 LDD-700Hs from LEDGroupBuy  This cost me roughly $358 – which I’ll roughly associate with 2 UFOs – means each light cost $358/2 = $179.  Higher than what I will pay moving forward.  I might try buying just CREE LED arrays instead of the customized Lumia 5.1′s.  The price will be much lower.   

Light Meter

For now I will use the meters that I have, adding an apogee to calibrate the PAR levels.

Hydro System

I recently built a system that I’m going to try out:



The components that make up the hydro system include:

  • 2 4″ x 4″ x 48″ vinyl fence post. I got these at Home Depot but can’t find them online. 
  • 4 4″ x 4″ end caps
  • 2″ net pots.  A net pot will be used to hold each plant.   Once the plants I am germinating grow roots, I will put the rock wool into a net pot and then place the net pot in one of the holes.
  •  1/4″ PVC tubing to get the nutrient enriched water from the main tube to the top of the net pot.




  • 1/2 inch outer diameter, 5/8″ inner diameter tubbing from SunlightSupply to go from the nutrient bucket and act as the main feeder to the per net pot tubing.  The nutrients initially are pumped into this tubing and go to the end of the post.  Along the way the nutrients is distributed to each net pot through the smaller diameter tubing.  The tubing is very flexible to accommodate bends that I’ve got to make to get the tube to the top of the post.

Water Node

The job of the water node is to :

  • send the readings for the water temperature, pH. and conductivity upon the request of the Base Station.  
  • Respond to pH UP and DOWN adjustment commands sent from the Base Station.
  • Respond to nutrient adjustments when sent from the Base Station.
The water node will consist of a PCB, a water proof case, a probe for measuring the pH level, a probe for measuring the conductivity level, and a probe for measuring the water temperature.
I will use the same sensors that I used in my water node prototype.   This includes:
The parts of the PCB will include:
  • Parts such as the ATMega328P to run the Arduino Sketch.
  • a wireless chip capable of communicating with the Base Station that is within eye sight at a maximum of 100′ away.
  • the pH sensor circuit + connection for the probe
  • the conductivity circuit + connection for the conductivity sensor’s probe
  • a water temperature sensor
  • a pump and tubing for pumping pH UP when the Base Station tells the water node the pH level is too low
  • a pump and tubing for pumping pH DOWN when the Base Station tells the water node the pH level is too high
  • a pump and tubing for pumping more nutrients into the nutrient reservoir when the Base Station tells it to add a specific amount of nutrients.


 The job of the Base Station is to:

  • Request and receive sensor readings from water nodes.
  • Send commands to a water node to adjust the pH and/or nutrients (as needed).
  • Respond to requests from the mobile client.

Water Node to Base Station

Up until now, I have been exploring 433MHz solutions, in particular the RFM69HW and most recently the RFM85.  Earlier, I explored other RF alternatives for node to Base Station communications.  Then I created a BoM for a RFM69HW breakout board which showed the price for a RFM69HW to be $3.85.  This got me looking at the RFM85 – which should :-) work, but I have not tried yet.  I can get the RFM85 for $.90.  This is a very low cost option.  But then….Adafruit came out with their Bluetooth breakout board - Bluefruit LE.  I had snubbed my nose at BTLE mostly because of chip cost.  Yet, after all my trials and tribulations with different chips I’m rethinking my current plan and will determine if BTLE – specifically the nrf8001 chip from Nordic Semiconductor.  This is the BTLE used in Adafruit’s Bluefruit.  Yes, the chip costs more.  However, having worked in distributed systems for decades and then doing these in-home RF experiences gives me the background to have confidence that a big part of system maintenance and debugging will be communications.  So now I’ll rationalize my reasons for BTLE being the better in-home RF with the following reasons:
  • BTLE has more momentum than other RF solutions I have been exploring.  There are already consumer devices that use BTLE.  I can’t say the same for RFM69HW.  This means a bigger developer community which means more robust chips and firmware.
  • Interoperability with other devices that use BTLE will be easier since the lower levels of communications are the same. I would focus on the application level communications.
  • There are multiple supplier of BTLE chips.
  • Because of a larger market and aging of BTLE, chip prices will go down.
  • BTLE has a robust set of features such as RSSI, making it an easier and more robust in-home wireless protocol yet is not as heavy weight as 802.11.
  • Lady Ada – whom I respect for her ability to select chips and trends – has jumped in with her Bluefruit offering.  If it is good enough for Lady Ada….
  • I have written iOS apps that use BTLE between the iPhone and an Arduino.  The APIs keep improving.  BTLE is integrated very nicely into the iOS app ecosystem.
  • My requirement of 100′ between a node and a Base Station can be met with BTLE.  According to the wikipedia article on BTLE, the maximum distance is 160′.  I don’t assume my testing will achieve this range.  However 160′ is  60% greater distance than what I have specified- which should be plenty of room to meet the average communications.
  • The power requirements for BTLE seem “reasonable.”  I have not tested, however I am encouraged by results documented in papers such as this one from Microsoft Research and UW

BLE achieved lower power consumption (10.1 uA, 3.3 V supply at 120 s interval), compared with ZigBee (15.7 uA), and ANT (28.2 uA). 

Base Station to iPhone

There are two iPhone to Base Station interactions.  The first occurs when my iPhone is – you guess it! – 100′ or less from the Base Station.  I’ll use BTLE for that.  The second occurs when I have my iPhone at another location.  For this I need Internet connectivity.  I will use the ever so popular 802.11 Internet wireless protocol to enable this feature.  I like the BTLE for local because there will be a better response time going directly to the iPhone instead of going through the internet.  I like the 802.11 because it allows the Base Station to be positioned near the nodes while at the same time giving me “anytime/anywhere” access to the nodes.


I will write an app for my iPhone that receives sensor data from the Base Station and sends commands to the Base Station.  I have written many iOS apps in the past so I am confident on how I go about this.  I have yet to design the interface.  This is something I will wireframe soon.  I have always found in distributed system designs such as this (well actually more complicated) that putting off what I see on the phone’s display, what buttons I can push, robustness, and response speed makes for a much less desirable system.


What’s Next

I will keep iterating on the design.  Please let me know what can be better – or share your thoughts.  I am learning as I am going and crave advice.

I just got my new soldering station.  A YIPPEE! moment.  I’ll be practicing my SMT soldering techniques on some practice boards.

I will start putting together a prototype of this system in time for the plants currently enjoying their spa time in my Germination Station.

I’m thinking about starting an Open Source PAR Meter project based on the effort and conversation on this forum thread.


Comments Since the Original Post

from Jmadman311 via /r/hydro/ sent 4 hours ago

Hey MK, had some comments while I was reading.

I better get going since the seeds should be done with germination in a few weeks.

Lettuce germination should be done in 2-3 days and maybe after 7-10 days it would be ready for transplant into a system, not a few weeks!

maintaining the right nutrient level is tricky. While I’ll be taking conductivity readings and adjusting the nutrients accordingly, the conductivity readings cannot tell me which nutrients are deficit. What if the poor lettuce is lacking nitrogen yet I decide to blast it with potassium?

Adjusting the EC of the solution and keeping it constant (I believe I grew my lettuce at 0.5-0.6 EC) is all you need to do. To tell what nutrients are in deficit you need some very expensive and complicated ion-sensitive sensing equipment, which, given that you write that you are lazy, are likely beyond the scope of your project. It’s also worth mentioning that they are completely unnecessary. That sort of thing would be appropriate for a massive-scale commercial grower who was optimizing the economics of his operation by making sure the plants had exactly the nutrients they needed. For a simple home grow of lettuce, using a vegetative-style nutrient where the N>P and K is decently high (I think I used 3-2-5), you’ll be fine.

High powered LEDs let out a lot of light and are more efficient than others. I’m ok with paying more – although I am also interested in the difference between DIY LED fixtures and buying an equivalent.

Again, if you are lazy, building a DIY LED is going to be beyond your scope. :) I did it, but it took a huge amount of effort in finding the right parts and doing the construction. On the other hand, the purchase price for LED lighting is really, really high if you don’t make it yourself. (But still pretty high if you make it yourself. I made a light that outputs around 10,000 lumens and it cost me around $300.)

The requirements of the LED fixture includes:

Enough light for the plants to go through a healthy grow and flower growth cycle Ability to automate time on and time off 

You’re growing lettuce which you don’t want to go through a flowering cycle. And automating time on/off is a simple $10 light timer from Home Depot/etc.

As for the construction of the system, looks like you’ve got the right parts. For the electronic control, I’m really interested in it. I’d love to eventually set something up with a similar pH/EC sensor with automated control of pH. Very cool stuff.


[–]Jmadman311 1 point 1 day ago

No problem, I am by no means an expert but I am happy to share some of my experiences.

In my experience, when I would put a small group, say 20 lettuce seeds, between two layers of paper towel saturated with water, in a ziploc plastic bag, on a heated germination mat, I was getting close to 100% germination in 2 or 3 days. I do believe that lettuce seeds do not have great longevity; so it’s possible that if your seeds are old, or were not stored at low temperature, they may have low viability.

My LED light utilized the peaks in the action spectrum of chlorophyll, with LEDs just at 447.5nm and 655nm from Luxeon. It put out about 10,000 lumens with a 70/30 red/blue intensity ratio. I successfully grew tomatoes with this light. There were 18 total LEDs. Check out a vid I took when I first finished it:



[–]Jmadman311 1 point 20 hours ago

luxeonstar.com, their star-shaped coolbase ones, deep blue and deep red.


THANK YOU for reading this far.  Please find many things to smile about.



A Salad A Day – 1st Post – Lettuce Germination Station

I’m starting “A Salad A Day” project.  I’ll start with a lettuce station.  Comments are most welcome! I am hoping to get your feedback on what you would like to see and/or how what improvements I should make.  Better – how about you starting your own lettuce station and we compare results along the way?  


Source: Kratky Discussion, Big Plans, and Hydroponic Seedlings


The Goal

The goals of this project are to provide:

  •  100% of my daily lettuce usage.  I have a salad a day.  We also use lettuce in other meals, most notably as a hamburger topping.  
  • learn a lot about two of my passions – gardening and hardware/software.  This is where I could use your help.  I may have passion but I lack knowledge.  I am new to electronics, hydroponics – especially when it comes to nutrients.  The plants I have grown hydroponically have been at best OK, but not nearly as magnificent as I see pictures of from the hydroponics folks on the /r/hydro subreddit.  I just made my first PCB board with a tremendous boost in knowledge from Chris Gammel and his Contextual Electronics course.  

The goal of this post is to get to start the Lettuce Germination Station.

Thanks to Those that Go Before

 An extroardinary aspect of the Internet is its enablement of community learning.  Frontrunners in this community who put the love of each one of us before the love of money.  They are proving that a person can make more than a decent living while at the same time sharing what they learn as well as learn from others.  Twenty years ago, we were not as forthright with our knowledge.  This proprietary culture bent us in the direction of greed – always wanting more for ourself.  I thank all of you who passionately learn and share what you learn.  THANK YOU!

For this post I would like to thank in particular the Hydro subreddit.  Thank you to all the knowledgable folks who kindly share their experience and what they have learned.

Growth in Two Stages

I am separating the lettuce growth cycle into two stages.  

The first stage is the growth period between planting the seed and transplanting the seed into the hydroponics station.  


Stage 1: Germination

I’ll refer to this as the GERMINATION STATION.  

The second stage is growing the lettuce plant into a tasty star of my salad.


Step 2: Growing UP

 I’ll refer to this stage as the GROW STATION.

Germination Station

I’ll be able to build the germination station in less than an hour because I have all the pieces to get going.


For lighting during the first stage, I will be using the T5 setup I discussed in this post and compared its light measurements with other light setups I had at the time in this post.   It has been awhile since I purchased, but I recall the cost being around $50 at Home Depot.



mhpgardener pointed out in this youtube video that seed starts do not need the pricier LEDs.  This makes sense since the leaves are not that big and the main goal is to grow healthy roots.  


Great plants start with great seeds. 


I’ll be trying Seattle Seed Company’s Buttercrunch Lettuce seeds.  One seed pack costs $3 + tax.  For me this came to $3.29 (our sales tax is currently 9.5%).  I’m estimating there are around 50 seeds in a packet.  I’ll be planting 2 seeds at a time.  This makes the cost per planting to be $3.29/25 or $.13 per planting.

I support a local company that wants to provide a quality experience.  More and more I find myself searching out our local small businesses to put a face behind a product. Something I don’t get in the larger chains.  Also, I like the idea of supporting our local economy.  With that said, I’ll keep an eye for how many seeds actually make it to the next stage.  It will be an ongoing dance between the seeds I use as well as honing my skills in growing from seed.  I’d love to hear where you get your seeds and how well they have done for you.

I’m starting with Buttercrunch.  I plan to open our pallet to a variety of lettuce types once I have a better feel for growing a continuous crop of lettuce.

Plant Starters

There are many different materials I could use for plant starters.  For now, I’ve chosen to use Grodan’s rock wool plant starters.  A sheet of 98 costs $16.21 + sales tax.  The total comes to $17.75 or $17.75/98 $.18 per planting.


 As Grodan points out:

The most important quality a high grade Rockwool should have is uniform wetting. The Rockwool should wet easily but not remain water-soaked.

Dome House

I bought this dome awhile back at a nearby hydroponics store.  



They cost a little less than $20.  I ended up using a Jiffy starter pack enclosure I recycled that had cost me $5.  


It should be good enough.

 I also use a heat mat which I’ve had for awhile.  The heat mat adds about $20 to the cost.  The final part is a timer.  The cost was with sales tax came to $11.94.


Once the plant has cotyledons, I am going to introduce nutrients at 1/4 strength.  I am not sure 1/4 strength is the best amount. My intent is to provide the growing plant with just enough food to thrive but not too much to kill it.  How and what nutrients I use will be something that will evolve over time as I learn from both growing and what others are doing.  I had purchased pH Perfect Sensi Grow because their claim sounds too good to be true (and you know what they say – “If it sounds too good to be true, it probably IS too good to be true.”  It has also been said “A sucker is born every day.”  It wouldn’t be the first time I wear the shame of sucker if marketing claims don’t reflect reality :-) ).  Their claim:

If you use any pH Perfect base nutrient as directed, you will never again have to monitor and adjust your pH.

YOWZA!!  or as I like to say a YIPPEE! moment.  Since supplying my family with our lettuce needs will be chock full of learning, I will boldly start believing in this statement.  I’ll come back and compare with other nutrients and methods over time.  I paid $33.64 for 1Liter.  I haven’t thought of a good way to break down the amount of nutrient per plant.  I’m going to make a guestimate of $.05 per plant for nutrients during germination.  The cost of nutrients will be something I hope to understand better as I gain more experience.

I won’t take pH measurements, but will take nutrient (i.e.: conductivity, or EC level) measurements.   I bought this inexpensive TDS Tester for $17.07 with tax.  It seems to work pretty well.  Also, it seemed that several on the hydro subreddit used this tester with success.


I do not have an accurate measurement of KWH for the T5.  I will start recording this when it is time to turn on the light – around 3 to 5 days after putting seeds into the rock wool.  Most likely it will be the biggest recurring cost.

Approximate Cost of Germination Station

One time cost:

Part Cost
T5 lighting $50
Dome Home $5
Heat mat $20
Timer $12
TDS Tester $17.01
TOTAL $104.01

The price of the parts add up quickly. No surprise the largest cost is for lighting.  I like that I don’t have to use more expensive LEDs for seed starting. On the positive side,  all the parts can be used again.

Recurring cost:
Part Cost
Buttercrunch lettuce seeds $0.13
Rock wool starters $0.18
Nutrients $0.05
Energy TBD
TOTAL $0.36

I am curious to know the energy costs.  As I noted earlier, energy is probably the biggest recurring cost.  Also, the $0.36 assumes 100% of the plants make it to salads and hamburger buns.  This is unrealistic.  I’ll adjust as I see how many plants survive.

Time To Start

And off I go.  I planted approximately 24 seeds in 12 rock wool starter cubes.  I’ll add a post as the plants and I continue our journey.

What’s Next

I’ll get started on setting up the Growth Station in the next post.  This will include Arduino + wireless to sense and automate plant care.  I will be relying on several of the project I have discussed in earlier posts.  Hopefully, I’ll get to a system that will allow me to be lazy yet well stocked with tasty lettuce.

Comments Since Posting

I’m thrilled to hear about similar projects as well as different aspects to compare contrast.  Here are some of the comments:

theUrbanGreenhouse 1 point 4 hours ago

I plan on doing the same thing pretty soon. Just bought a little 8×6 greenhouse for the backyard and got some more material for vertical systems. You’ll be a little ahead of me so I’ll be looking forward to some updates.

Two things I can add right now: My energy cost for running two T5 fixtures for a month using an 18-6 lighting schedule was just under $4. I know we have different cost/kwh but that should give you some sort of guesstimate. Also, lettuce has very easy nutrient requirements so when it comes to introducing nutes definitely go easy on them, maybe even a bit less than 1/4 strength. I remember my 1/4 strength of the GH Flora line was a lot higher eC than the 1/4 strength of the Canna AquaVega.


[–]contentkaiser 1 point 5 days ago

This is exactly what I do (off-season) with my hydro set-up! You are working with a much smaller scale system, but it’s still a fun experiment. I’d recommend throwing in a tray of sprouting seeds (don’t even need light/nutes) and a tray of microgreens in perlite under one of your fluorescent tubes – that’ll give you some low maintenance variety and some nutritive additions.

If you’re feeling super adventurous – you can also keep a plastic tote underneath your hydro system w/ mealworms in it, just add vegetable waste and kitchen scraps (dry) and dry mealworms to put on your salads for a little protein.


]Jmadman311 1 point 5 days ago

I’d be very surprised if you got an accurate pH and that it would stay stable over time. pH is one of the most important things to control and you should consider getting a cheap meter to do so!!

Also, did you soak your rockwool before use? I have read that the pH of the rockwool environment tends to be quite high, above 8, unless the cubes are pretreated by soaking them in a mild acid like l


[–]mikeg53 1 point 4 days ago

Cool. Look forward to it.

As a point of reference, my 446g romaine head fed 4 people with nice size salads on Saturday.

It took 104 days from seed planting to eating. This guy was in the middle of the garden and I neglected to cut him when he really needed to be – it was ready in 75-80 days, the last 4 weeks didn’t do much for growth except make an even more dense center pack of leaves.




[–]RamblingMutt 1 point 4 days ago

I just started growing lettuce as well, as an experimentation chamber to hopefully move onto a large NFT system. The seeds have but a few wee roots right now.


Fidget likes to watch the bubbles, which I know don’t really need to be on but I like it to look all sciency.

emon juice.

In any case I’m looking forward to more updates!




Thanks for reading this far.  Please find many things to smile about.






Final board check of RFM69HW Breakout Board before Manufacturing


, , ,

I was watching a video for the Contextual Electronics course I am taking.  This one covered using a free DFM tool, freeDRM.   The freeDRM tool would most typically be used by an Advanced Circuits  customer.  I am using it as a free tool in the way Chris did – as a sanity check.

The thing I need to keep in mind is the design rules are different for Advanced Circuits and OshPark.  Advanced Circuits’ design rules are discussed in this document.  The design rules from OshPark are more important since this is where the board will be fabricated.  From the OshPark Design Rules web page:

  • 6 mil minimum trace width
  • 6 mil minimum spacing
  • at least 15 mil clearances from traces to the edge of the board
  • 13 mil minimum drill size
  • 7 mil minimum annular ring

I plotted the Gerber files and ran freeDRM on them to see if the tool detects any design errors…and…

there were errors I needed to fix.   What this pointed out to me was the importance of setting the Design Rules to those of the fabrication company.

Design Errors

There were two sets of design errors that were considered “show stoppers”:

  • the drill size and diameter of many of the vias.
  • the track width of several traces.


I made a mistake on the diameter and hole size of most of the vias.  The error results for this are listed here.  The text in the error report notes: Requirements:We require a minimum of .005” annular ring for vias…

OshPark’s minimum annular ring is 7 mils – 2 mils larger.



via size errors

I am very happy the tool caught these errors.  While at the same time I feel like banging my head on the desk for making this avoidable error.

The reason?  I did not set the design rules correctly!  Here is what I was using before I fixed the via size errors:


hmmm…not good. Most of the vias use the default settings.  Why is the trace width 4 mils when OshPark clearly notes a 6 mil minimum trace width?  Why is the minimum via drill size 5 mils when OshPark states the minimum drill size should be 13 mils.  Finally, why is the via diameter 13 mi?  The minimum defaults should be a via diameter of 27 mils (7 mil annular ring*2  + 13 mil drill size = 27 mils).  From what I can tell it means I was clueless about the importance and setting of design rules prior to laying down vias and tracks.  Hopefully, knowledge means I won’t repeat this mistake on my future PCB layout efforts.  

I updated the design rules to be:


I ran the FreeDFM tool a few more times until I got a YIPPEE! moment:


Now I’m not sure about the “Problems Automatically Fixed.”  I’m going to ignore these for now.  I think I’m ok at this point for fabrication.  I am sure I will find out soon enough if I am not! 


Thanks for reading this far.  Please find many things to smile about!

RFM69HW Breakout Board Layout


, , ,

I just spent a good part of the last week or so laying out the RFM69HW BreakoutBoard.  Whew!   I might have spent my youth differently If I had only known that unravelling a knotted up ball of yarn was an important skill in building a PCB.   I have been moving right along taking my idea of wanting an RFM69HW breakout board to PCB.  In the first post I created the schematic.  In the subsequent post I picked the parts and ordered them from digikey.  Now it is time to lay out the parts and draw the in kicad’s PCB layout tool – PCBnew.  

Updated schematics and board layout can be downloaded from the Bitknitting GitHub repository.

Thanks to Those that Go Before

THANK YOU to the exceptional folks that share their electronics knowledge.  I have a deep gratitude.

I hope every learner has the opportunity to tap into the people and knowledge that I have been able to tap into.  Each day brings in a new piece of knowledge about electronics or embedded systems that becomes a important in support of my passion to build stuff that brings me fresh tomatoes year round with minimum effort.  

It is always important for me to acknowledge the key contributors to a post.  For this post, a moment of gratitude goes to:

  • Chris Gammel - our very knowledgable and gifted instructor of Contextual Electronics.  A course I would highly recommend if you are interested in turning your prototypes into PCBs and learning tons about electronics along the way.  There is no way I would be able to get this far without Chris’s class and his recommendations/insights.
  • Felix Rusu (lowerpowerlab.com)has posted the schematic and board layout (also in Eagle) for the Moteino.  This is well worth a look (the github link to the Moteino schematic and board layout).  I downloaded the free copy of Eagle, got familiar with how to show and hide different layers, and stared at how Felix decided to layout the Moteino.
  • Martynj and Plutonomore from the jeelabs forums.  Both have been very willing to share their knowledge in this space – something both have a lot of!  Martynj spent time walking me through the basics of why the cc3000 and RFM69HW SPI bus is having trouble sharing the SPI bus as well as other insights.  Plutonomore created a RFM69HW Arduino Shield and posted his work.  A wonderful way for me to gain insight from a person who has gone before.

The Goal

The goal of this post is to layout the parts that I ordered on digikey onto a virtual representation of the RFM69HW breakout board.  The key things I will be doing include:

  • chip placement on the front and back of the PCB.
  • drawing traces to connect the chips – i.e.: the copper routes in the PCB that replace the jumper wires used on a breadboard.  
I will be using kicad’s PCBnew tool.  I will not be delving into how kicad works.  This video might help if you want to get an idea on the purpose and how the PCBnew tool works.

The Process

As in the previous post on associating parts to schematic symbols for the RFM69HW breakout board, I start with the net list.  After reading in the net list into PCBnew, the steps include:

  • another look at part selection.  Schematic -> PCB is a very iterative process.  Place parts and connect circuits.  Get feedback.  Think about.  Move around parts and traces or start over.  Repeat over and over until the layout “should work.”
  • defining the width and length of the board and drawing a board outline.
  • placing parts and drawing traces.  

Another Look at Part Selection

The Level Shifter

My increased knowledge of SPI  and the need to bridge a 5V (digital i/o pin) Arduiino Uno with a 3.3V IC (here is a nice explanation and proposed solution) – like the RFM69HW – got me rethinking the approach I took.  Until this look, I had decided on:

  • not addressing the MISO line.  This line (as MISO suggests – Master In, Slave Out) has the RFM69HW sending 1′s and 0′s to the Arduino Uno.  See this post for more details on sending 1′s and 0′s between 3.3V and 5V components.
  • using the 74LVC245 (data sheet) to level shift the MOSI, CS, and CLK lines from 5V signals to 3.3V signals.
I changed my mind.  I do want to address the MISO line.  I kept having the recurring thought that some of the circuits I plan to prototype will use the cc3000.  Recall from my post on creating the schematic where I reviewed the MISO line’s challenge, I included this comment from Adafruit support:

In practice, the CC3000 has a quirk: it doesn’t release the MISO line when the CS pin is HIGH. On the CC3000 Shield, we added a buffer chip that isolates the data lines correctly. The breakout doesn’t have a buffer, but you can add one externally.

While I’ve moved from using the breakout board to using the cc3000 shield, I decided to make the RFM69HW breakout board more robust.  The other benefit is I will most likely learn something new.  Which is one of the main reasons I am creating this breakout board in the first place.

The 74LVC245 – the Chip Leaves MISO Shiftless

The 74LVC245 can go from 5V -> 3.3V, but cannot shift from 3.3V -> 5V.  So I can’t use that chip.  I decided to replace the 74LVC245 with the a 74HCT level shifter.  I’ve chosen the 74HCT125 (data sheet).  This IC has 4 buffers, the perfect amount to handle the 4 SPI lines.

The updated pdf of the schematic with the 74HCT level shifter is located in the Bitknitting GitHub repository.

As noted in the general description within the  74HCT125 data sheet:

The 74HC125; 74HCT125 is a quad buffer/line driver with 3-state outputs controlled by the output enable inputs (nOE). A HIGH on nOE causes the outputs to assume a high impedance OFF-state.

My first pass connected  the CS line to a buffer’s OE pin.  This is because CS is LOW  when MOSI/MISO data is sent and received between the Arduino and the RFM69HW.  Chris recommended simplifying the layout by always having OE set to low. His recommendation made sense to me because I don’t expect the signal to get much noise.

Test Points

I assume there will be additional iterations on the PCB board.  So for my earliest fabrications, I will be putting in test points so that I can test the signals.  I decided to change these from through hole – where I solder on a piece of wire to attach a multimeter to – to a copper pad.  This means less soldering and no test wires dangling from the breakout board.

Define the Board Size

I took a stab at laying out the parts without drawing traces and will start with a 1″ x 1″ board.  I will be using OshPark for fabrication.  This is where Chris had us go to when I ordered my Getting To Blinky boards.

Considerations I used to determine the board size included:

  • fitting all parts and components on a 2 layer board.  I don’t see any reason to have more than 2 layers.
  • cost to fabricate the board(s).  The larger the board, the more it will cost me to make.

  The pricing info  comes from OshPark’s home page:

2 layer boards are $5 per square inch (with 3 copies of your board included in that price) and ship in under 12 calendar days from ordering. 
4 layer boards are $10 per square inch (also including 3 copies of your board), go to the fab once a week, and have a 2 week turn time from the fab.

This adds $1.67 / breakout board to the cost of goods.  In the previous post, I purchased 4 sets of parts.  Hopefully I will be able to solder 3 together.  I definitely will need to practice soldering since I have not soldered SMT packaged parts.  Luckily, we’ll soon be doing SMT soldering in the Contextual Electronics course I am taking.  I have also ordered SMT soldering practice boards.  In the upcoming weeks I will practice, practice, practice soldering SMT packaged parts – that look smaller than an ant – to practice boards.

Place Parts and Draw Traces

Placing parts and drawing traces reminds me of putting a puzzle together. It can be frustrating. it can be funIn the sort of way Mary Poppins sings in Disney’s Mary Poppins movie:

In every job that must be done there is an element of fun.  You find the fun and snap, the job’s a game…

The Ratsnest

My layout started with an appropriately named state –  a ratsnest:


First Pass at Layout

Here is my first pass:




The red is the front of the board, the green is the back of the board.  The RFM69HW takes up a large portion of the front of the board.  The back of the board has the 74HCT125 and the MCP1703.  I also put the capacitors on the back.  It took me awhile to figure out non-crossing paths when the traces need to connect components that are mirroring each other.


After spending several days creating layouts, these things helped me get this far:

  • being able to analyze other works – like Felix Ruso’Moteino layout - gives perspective from folks that have “been there done that.”
  • error checking tools – ERC for the schematic and DRC for the layout – are great friends!  I benefited from Chris’s words of wisdom in the Contextual Electronics course.  I receive some errors from ERC that I chose to ignore.
  • running kicad’s autorouter tool gave me a reference layout.  Since it would be very difficult – if not impossible – for the auto routing tool to generate a final layout, I did find it useful to see where  it drew traces.  I did not evolve this the auto routed layout.  Rather, I stared at it a long time and used some of the trace paths it recommended.  It was a great way to see another view for unraveling the rats nest.

Chris reviewed the board and made many recommendations to improve the PCB layout:

  • Simplifying the layout by always having OE set to low.  My first pass connected  the CS line to a buffer’s OE pin.  The OE signal is LOW at the right time, because CS is LOW  when MOSI/MISO data is sent and received between the Arduino and the RFM69HW.   if you are not familiar with SPI bus traffic, perhaps this earlier post  on debugging the SPI bus will be useful.  
    Chris’s recommendation made sense to me because of the simplicity of the board. I don’t expect enough noise to add in setting the OE to low based on the signal from the CS line changed the routing in my second pass between the OE line of each buffer and GND.
  • Rotating the RFM69HW such that GND is in the upper left corner instead of lower right.  This puts the Antenna – an area that will most likely be more noisy – off in a corner.  I had also put the voltage regulator right next to the antenna – a particularly poor choice because of the noise that will come from the power signal.  Now the voltage regulator was as far as possible from the antenna.
  • Adding a copper pour region under the Antenna area to provide a ground plane for the antenna. 
  • Moving the decoupling capacitors for the RFM69HW to be closer to the RFM69HW’s 3.3V pin.  I changed the location in both the schematic as well as moved the capacitors (C4 and C5) closer to the 3.3V pin of the RFM69HW.
  • Do not use any VIAs near decoupling capacitors.  As Chris noted to me,  VIAs add inductance and worsen high frequency noise.  The circuit is best if there is the lowest inductance path to GND.Lowest inductance path to ground. That’s why want lower path.  Because the inductance acts like an open circuit, high frequency signals look like a short.  
  • I made an OOPS! error and placed R1 on the same layer and underneath the RFM69HW module.  I moved this down to the test point for the CS_5V and flipped.  This puts the pull up resistor (R1) as close as possible to the incoming CS signal.  Now there is a front trace (to the test pad) and back trace (to R1).
  • I switched which level shifter’s buffers were used by the MOSI, MISO, CLK, or CS lines used so that the result minimized cross-over routes.  I also switched the connector pins (P1), which helped a bit in minimizing cross-over routes.
  • I had made the VIAs too small.  Given OshPark’s design rules, the minimum VIA (outside) diameter must be 27 mils (13 mils for the hole (inside diameter) plus 2*7 mils for the annular ring.  I set the design rules for the VIA to have an outside diameter of 27 mils and an inside diameter of 13 mils.
  • I used a track width of 10 mils.  OshPark’s design rules also note a minimum track with of 6 mils.  There is room to run wider tracks.  
  • I used a track width of 24 mils for +3.3V, +5V, and GND tracks .  For the VIA size, I used an outside diameter of 34 mils and an inside diameter of 24 mils.
  • Added a copper pour to the backside so that GND pads can access GND without having to draw traces.  This will help minimize the number of traces that need to be drawn and have  potential cross-over with other traces.o lower the number of nets.
I found this track width calculator to help me better understand what minimum track width is possible.  It turns out the track widths I chose are more than large enough.  Might as well leave them larger since there is room on the board to do so.

Second Pass at Layout

A Yippee! moment – my second pass at the layout after applying Chris’s recommendations and running ERC and DRC:


Adding the copper pour for the GND net on the back (green) was a great help in lowering the number of tracks that needed to be routed since many pads were GND pads.

The copper pour GND net on the top (red) in the upper left corner (recommended by Chris) made a lot of sense once I understood a bit more on how planes work.   I do not want the GND circuit to connect to P12 TST (the hole for the antenna).  Doing so will short the board.  And it isn’t providing the “ground” mirror that the antenna would benefit from.   As it shown in the image, while the signal to GND travels to the GND pads, signal to GND DOES NOT travel to ANA (pad or hole for antenna).  

This is great!  Now there is copper helping out with the GND circuit and copper providing a ground for the antenna!

Thoughts on Learning Layout

I found these to be the most helpful in learning layout:

  • Chris’s Contextual Electronics course is an amazing opportunity to learn how to build a PCB.  I highly recommend it.
  • being able to analyze other works – like Felix Ruso’s Moteino layout – gives perspective from folks that have “been there done that.”
  • error checking tools – ERC for the schematic and DRC for the layout – are great friends!  I benefited from Chris’s words of wisdom in the Contextual Electronics course.  I receive some errors from ERC that I chose to ignore.
  • running kicad’s autorouter tool gave me a reference layout.  Since it would be very difficult – if not impossible – for the auto routing tool to generate a final layout, I did find it useful to see where  it drew traces.  I did not evolve this the auto routed layout.  Rather, I stared at it a long time and used some of the trace paths it recommended.  It was a great way to see another view for unraveling the rats nest.

Third Pass at Layout

Here I am – patting myself on my back and surprised that my arm doesn’t break from my enthusiastic patting….when I get an email from Chris.  He asked if I had watched the video on via stitching that he had made.  That is another amazing aspect of the Contextual Electronics course.  If we get stuck or could learn something that directly affects what we are designing, Chris will make a video on the subject, clearly explaining through example.  

Via stitching is a new term for me.  Here’s a definition I found on this post that made sense to me:

Via stitching is a technique used to tie together larger copper areas on different layers, in effect creating a strong vertical connection through the board structure, helping maintain a low impedance and short return loops.

Chris pointed out  I connect the two GND planes with a single trace.


High frequency noise should flow through the GND as easy as possible to get back to its source.  If there is only a single trace to connect the top and bottom GND plane, there will be high inductance than if the GND planes are stitched together using vias.

The above image shows overlapping GND planes in the upper left corner of the PCB.  I stitched them together by “sewing on” vias.  A bit of BitKnitting!  Here is the updated PCB layout:


Fourth Pass at Layout

While Chris was laying down test points for our Contextual Electronics project, he said something so obvious that in my excitement to finish the PCB layout I had completely forgotten.  A test point is just an exposed piece of copper where a probe can be inserted within a circuit.  Um…duh…this is how I was looking at SPI bus data all along!  I removed the test points near the connectors that allow access to the RFM69HW breakout board from the Arduino.  

That brings me to showing my fourth pass:


Fifth Pass at Layout

Chris just showed us another thing we can do to improve our layouts that I wanted to share.  He noted pads 9, 10, and 11 had a lot of space around them that should be “tightened up” and the width of the spokes should be made smaller so that soldering would be easier.  In other words, he recommended adjustments to the thermal relief pads.  Thermal relief pads was another new term for me.  I found JYelton’s response on Stack Exchange to provide a very clear explanation of a thermal relief pad:

A thermal relief pad is essentially a pad which has fewer copper connections to a plane (such as a ground plane).

A normal pad would simply be connected in all directions, with the solder mask exposing the area to be soldered. However the copper plane then serves as a giant heatsink which can make soldering difficult, because it requires that you keep the iron on the pad longer and risk damaging the component…

Just to show a visual on normal vs thermal relief pads:


Normal vs Thermal Relief PCB Pad

The pad at left is connected to the copper plane (green) in all directions whereas the pad at right has had copper etched away such that only four “traces” connect it to the plane.

The goal then is to restrict the heat flow so that soldering onto pads 9,10, and 11 is easier.

Chris’s  recommendations include:

  • minimize the clearance
  • minimize the anti pad clearance
  • minimize the spoke/trace width between the pad and the copper pour
The two images show a “before” and “after” image.

* *

Fourth Pass

Fifth Pass

Another day, another opportunity to learn.  Today i learned that when there is a GND plane, I should evaluate the amount of space and the copper traces/spokes of thermal relief pads (and what the heck a thermal relief pad is)…

What’s Next

Please let me know how I can improve the layout.  My hope is by sharing I can help those folks that are new to this stuff and learn from folks that have done this.  There is so VERY MUCH I do not know/understand in this space!

The next step is to close on the PCB layout, get parts, and order boards from http://oshpark.com/.  

If I don’t get any feedback from you, I will close the PCB layout by checking the footprints I drew with the actual part.  If all is well – off to Oshpark for fabrication!  

Thanks for reading this far.  Please find many things to smile about.




Associating Parts to the Schematic Symbols for a RFM69 Breakout Board


, ,

In my last post, I created a schematic for a RFM69HW breakout board.  I am using this effort to increase my understanding of what we are covering in the Contextual Electronics class and understanding of electronic concepts/practical implementations.  This post is the next step in the process of going from “gee – I could use a breakout board that did…” to “I am using a breakout board that I built.”  As it is said: “give a man person a fish and you feed him them for a day; teach a man person to fish and you feed him them for a lifetime”

This post is dah BoM!   Files for the schematic, net list, and BoM can be found on the bitknitting github repository.

Thanks to Those that Go Before

I continue to experience a sense of gratitude to the amazing community of knowledgable engineers who willingly share their knowledge.  THANK YOU! I’ve never enjoyed learning so much (and I am getting better at realizing “Google is my friend!” :-) ).

It is important to take a moment and acknowledge these exceptional efforts.

  • The folks I noted in my last post – plutonomore, Felix from lowpoweredlab.com, Adafriuit
  • Chris Gammel – our very knowledgable and gifted instructor of Contextual Electronics.  A course I would highly recommend if you are interested in turning your prototypes into PCBs and learning tons about electronics along the way.
  • Chip – who provided actionable feedback on this post.  His  comment was on chip power dissipation.  I added it when I discuss the part choice for the voltage regulator.  Chip’s feedback is a big reason why I write these posts.  More please!!!!

The Goal

The goal of this post is to associate parts with the symbols on the schematics.  The key things I will be doing include:

  • making sure there are accurate models of the chips.  Getting the footprint as exact as possible regarding pad sizes of the components will be key to being able to solder a component onto a PCB.
  • identifying and buying parts from digi-key.    

The Process

Each step in the process:

  • Start with the net list
  • Associate footprints with schematic symbols
  • Build the BOM

Is outlined below. I found the hardest task was finding a part. I used Digikey.com for all parts except the RFM69HW, which Digikey does not carry.  Digikey has an overwhelming number of parts.  Imagine a store where there are rows and rows of items – most of the same size – and you have to read the fine print – in this case a whole bunch of gobly gook within a data sheet for a part with words that make sense to the “been there, done that” electrical engineers – while trying desperately to narrow the search.  It was very overwhelming.  This is another area where Chris’s Contextual Electronics course was valuable.  Chris went through many digikey.com shopping excursions with us.  There is a lot to pick up from someone like Chris who has “been there, done that” AND can transfer that knowledge! The second hardest task is creating a footprint in the likely event that kicad does not have the footprint in its system.  I am a n00b to standard SMT component footprints and am extremely glad Chris covered footprint sizes in several of the Contextual Electronics units. This document is helpful if – you are like me 5 weeks ago – 0805 does not mean anything to you.

I will continue using kicad .  The goal is not to document how to use kicad to do the tasks that need to get done.  The main ones for this post – using CVpcb and creating footprints – is covered in this tutorial.  A PDF of the schematic and kicad files are located in the bitknitting github repository).  The kicad CVpcb tool is used for associating the footprint of a part that I’ll find on digikey.com with a schematic symbol.   

Start with the Netlist

The first thing I need to do is create a list of the schematic symbols and then map a footprint of a part to each symbol.  This is done in kicad by generating a net list (This post by the Curious Inventor shows screen shots of a kicad net list).  The net list is super important because it is the glue that binds the design (schematic) with reality (the PCB layout).

Associate Footprints with Schematic Symbols

The next step is to make sure each component found on the schematic has information on the placement of pads that will connect the component to the circuit.  The criteria for my parts selection include:

  • in stock
  • inexpensive in quantities of 1
  • SMT component
  • it can do the job
  • standard footprint with a size I have a chance of soldering correctly.  Even the larger SMT footprints seem small to my eyes.  

The following sections will go through each type of component using the contents of the BOM spreadsheet related to that type of component.  I will use a BOM spreadsheet that I made in Google Docs to put the information on parts, part size, cost, and ordering URL.  The BOM spreadsheet is located here within the bitknitting github repository. 


Below are the entries for the capacitors in the BOM spreadsheet.  Based on what I learned in the last post, I initially intended on using electrolytic capacitors for the 10uF caps.  They are bigger, but heck – I thought the experts had spoken.  Chris recommended ditching electrolytic and stick with ceramic during my fantastic 1:1.  He noted electrolytic are more sensitive to temperature and voltage, they dry out over time, and they are bulky.  Good enough for me!  I am relieved that I can use 0805 sized 10uF caps.  I watched Chris as he did a search on digikey.com.  One of the filters I didn’t understand what the temperature coefficient.  Chris chose X7R capaciors – which after viewing the excellent table 1 in this post, made sense.  Although X5R capacitors were $.20 and X7R capacitors were $.30, I felt the extra range in temperature afforded by the X7R capacitor was worth it.

Here are my choice for capacitors:

Component MFG Name MFG Part Number Distributor Part Number Package size Quantity 1 piece price 1 piece subtotal 100 piece price 100 piece subtotal 1000 piece price 1000 piece subtotal Distributor Part Number Link
.1u CAPACITOR Kemet C0805C104K5RACTU 399-1170-1-ND 0805 2 0.1 0.2 0.01 1 0.01 10 http://www.digikey.com/product-detail/en/C0805C104K5RACTU/399-1170-1-ND/411445
1u CAPACITOR Samsung CL21B105KOFNNNE 1276-1026-1-ND 0805 1 0.1 0.1 0.0196 1.96 0.01785 17.85 http://www.digikey.com/product-detail/en/CL21B105KOFNNNE/1276-1026-1-ND/3889112
10u CAPACITOR Nichicon CL21B106KOQNNNE 1276-2872-1-ND 0805 2 0.3 0.6 0.1236 12.36 0.07262 72.62 http://www.digikey.com/product-detail/en/CL21B106KOQNNNE/1276-2872-1-ND/3890958

A YIPPEE! moment.  The 0805 footprint is already in kicad. 


The schematic uses 2 resistors.  I used the footprint size and then narrowed the search to the least expensive in quantities of 1.  Here is what I ended up with:

Component MFG Name MFG Part Number Distributor Part Number Package size Quantity 1 piece price 1 piece subtotal 100 piece price 100 piece subtotal 1000 piece price 1000 piece subtotal Distributor Part Number Link
470 ohm RESISTOR Panasonic ERJ-6GEYJ471V P470ACT-ND 0805 1 0.1 0.1 0.0149 1.49 0.00544 5.44 http://industrial.panasonic.com/www-cgi/jvcr13pz.cgi?E+PZ+3+AOA0001+ERJ6GEYJ471V+7+WW
10K ohm RESISTOR Stackpole Electronics Inc RMCF0805JT10K0 RMCF0805JT10K0CT-ND 0805 1 0.03 0.03 0.0088 0.88 0.0032 3.2 http://www.digikey.com/product-detail/en/RMCF0805JT10K0/RMCF0805JT10K0CT-ND/1942577

ConnectorsI am not surprised about the low price given how common resistors are in a circuit.  I am surprised in the difference in cost between the two resistors.


The schematic uses three types of connectors:

  • a 7 pin connector in which a male header will be soldered on so that the pins on the header will connect the breakout board to the breadboard.  This isn’t an actual part – but rather througholes on the breakout board. This is similar to how most breakout boards that sit on a breadboard are done.
  • Test points.  Each test point needs a part.

Here was what I originally chose for test points off of digikey:

Component MFG Name MFG Part Number Distributor Part Number Package size Quantity 1 piece price 1 piece subtotal 100 piece price 100 piece subtotal 1000 piece price 1000 piece subtotal Distributor Part Number Link
TEST POINTS Harwin Inc S1751-46R 952-1478-1-ND http://www.digikey.com/product-detail/en/S1751-46R/952-1478-1-ND/2264564 9 0.29 2.61 0.1888 18.88 0.13068 130.68 http://www.digikey.com/product-detail/en/S1751-46R/952-1478-1-ND/2264564

After bumbling around with test point parts on digikey and talking with Chris, I decided to use 22 AWG gauge solid copper wires as a test point.   By doing so, $2.61 is shaved off the prototype boards and this style is what I am used to.

Each test point will be a through hole on the PCB.  I’ll solder in a different color wire in each, then connect the ends to probes.  For example, I’ll connect the MISO/MOSI/CS/CLK lines to the MISO/MOSI/CS/CLK probes of my logic analyzer.


Using Wires for Test Probes

I’ll remove the test points after I get a few PCBs fabricated – once I feel comfortable that the circuit is working.

  • A hole for a piece of copper wire acting as an antenna.  There is no physical part. It is just a hole in the board.

Voltage Regulator

As I discussed in the last post, I will use the MCP1703:

Component MFG Name MFG Part Number Distributor Part Number Package size Quantity 1 piece price 1 piece subtotal 100 piece price 100 piece subtotal 1000 piece price 1000 piece subtotal Distributor Part Number Link
VOLTAGE REGULATOR Microchip Technology MCP1703T-3302E/CB MCP1703T-3302E/CBCT-ND SOT23-A 1 0.65 0.65 0.41 41 0.41 410 http://www.digikey.com/product-detail/en/MCP1703T-3302E%2FCB/MCP1703T-3302E%2FCBCT-ND/1776945

A YIPPEE! moment. Kicad has the footprint for the SOT23-A sized chip.  One less part to go cross-eyed attempting to exactly match the dimensions of the part’s pads and placement in the footprint modeler.

Follow up: Chip commented:

Your selection of the 1703 in the SOT-23A case has a more limited power dissipation. That case has a high thermal resistance which in English that means that the SOT-23 will get hotter for a given load current than some of the other cases. Probably not a problem if your only application is to wake up once a minute take a reading, send a packet and then go back to sleep.

If you might use your breakout board in some more continuously transmitting application the SOT-23 might not cut it. Consider the SOT-223 case instead. It is five times as efficient at heat dissipation. For detailed descriptions see section 6.2 of the 1703 datasheet.

Felix had a counter reply:

I’ve not ever seen any heating or smoke out of that regulator in my own practice. Some people reported heating but I suspect they misused it or shorted the outputs (which WILL cause heating).
Wireless programming for instance is very RF intensive for a period of 20-30 seconds or even more depending on the sketch size. And there is no heating. So it’s a bit of a myth that the SOT23A is a bad choice. If it were, I would have replaced it over the several revisions of Moteino.

An aspect I love about community learning!  Folks like Felix and Chip that have “been there, done that”.  They come from a different context and have different experiences to share.

Level Shifter

Also discussed in the last post was the part for the level shifter:

MFG Part Number Distributor Part Number Footprint Quantity 1 piece price 1 piece subtotal 100 piece price 100 piece subtotal 1000 piece price 1000 piece subtotal Distributor Part Number Link
74LVC245ADB,118 568-2274-1-ND SSOP20 1 0.44 0.44 0.2793 27.93 0.0033 3.3 http://www.digikey.com/product-detail/en/74LVC245ADB,118/568-2274-1-ND/946736

A YIPPEE! moment.  Kicad has the footprint for the SSOP20 sized chip.


Last – but certainly not least – is the star of the breakout board, the RFM69HW:

Component MFG Name MFG Part Number Distributor Part Number Footprint Quantity 1 piece price 1 piece subtotal 100 piece price 100 piece subtotal 1000 piece price 1000 piece subtotal Distributor Part Number Link
IN-HOME WIRELESS (@433MHz) HopeRF RFM69HW-433S2 RFM69HW-433S2 http://www.hoperf.com/upload/rf/RFM69HW-V1.3.pdf 1 3.85 3.85 3.85 385 3.85 3850 http://www.hoperfusa.com/details.jsp?pid=136

 I put a link to the data sheet under the footprint column because the RFM69HW has a unique footprint:


Creating a footprint for the RFM69HW has brought up a concern.  There are many different in-home wireless parts.  They don’t speak with each other.  In particular, the RFM69HW is not sell in the volume to make me feel comfortable that the part will be around for a few years.  HopeRF has had many chips before this.  I need to find out how long the company has been around, what has been the lifespan of their other chips, and details about distribution in the U.S.  Right now I buy RFM69HW chips from Anarduino.  The cost is lower than other places and the service has been excellent.  With that said, I have no idea if this distributor will be around in the future.  This is something I will look into.  For now, I will continue to use the RFM69HW as the in-home wireless solution.  

Let’s Go Shopping

While not quite as much fun as shopping at Adafruit, I had a grand time putting parts into my shopping cart.  I ended up getting enough parts for 4 boards.  I figured my soldering skills would kill at least one – who am I kidding?  More than one….Also, I will receive 3 PCBs when I order from OshPark.   Here’s my digikey shopping cart:


Next I hopped over to Anarduino.com and ordered 3 additional RFM69HW-433 MHz chips.  I already have one from earlier tinkering that I’ll repurpose to complete the boards.


That’s a Wrap

I found part selection to be tedious.  The data sheets don’t make this task any fun at all!  Each one with their own style.  Each one with particular criteria to pay attention to.  I can tell it will be awhile before I feel comfortable that I am picking the “best” part for the job.  At this point, I am going for “it works”.  Chris and his Contextual Electronics course continue to be extremely valuable on my journey to make this breakout board.

All files – schematics, BoM, net list are available on the bitknitting github repository.

What’s Next

I’m getting to the fun stuff!  This week I’ll be laying out the parts in kicad’s PCB tool – PCBnew – and drawing the traces.  More on that in my next post!


Thanks for reading this post.  Please find many things to smile about.








Creating a Schematic for a RFM69 Breakout Board


, , ,


I’m in the thick of the Contextual Electronics course.  I’m learning a a lot about designing circuits, using kicad, picking parts, and building a PCB.  The course has inspired me to make a breakout board for the RFM69 (@ 433MHz) that is controlled with an Arduino Uno instead of  a Moteino.  The RFM69HW breakout board will allow me to easily prototype the Base Station (early version discussed here) connected to one of the seemingly many Arduino Unos I have collected.   The Base Station receives sensor readings from the sensor nodes and then sends these over the Internet to my iPhone.  The breakout board will help me more easily test the capabilities of the components/parts I am thinking of using.  One of which is using the RFM69HW versus the RFM69W.  Do I need the RFM69HW or is the RFM69W good enough?  That’s just one of the questions.  

The Goals

The goal of this post is to build a schematic in kicad’s eeSchema tool that correctly identifies the circuit and components for an RFM69HW breakout board.  Future posts will discuss laying out the components on a PCB, ordering the PCB and parts, and – the YIPPEE moment (hopefully!) – soldering the parts onto the PCB and testing the breakout board.

The kicad files I created are in this github repository

Thanks to Those that Go Before

Learning electronics is an amazing community experience.  There are many very gifted people who have willingly and enthusiastically share their work. 

It is in this spirit I thank:

  • plutonomore has posted a schematic and board layout (Eagle) that is a RFM69HW shield for the Arduino.  You might want to stop reading any more of this post and build/learn from this exceptional effort (the link to plutonomore’s discussion and files).  I chose to roll my own because I want to increase my knowledge of building PCBs so that I can apply this to building PCBs for my hydroponics efforts.
  • Felix Rusu (lowerpowerlab.com)has posted the schematic and board layout (also in Eagle) for the Moteino.  This is well worth a look (the github link to the Moteino schematic and board layout).
  • Adafruit’s cc3000 breakout board and shield have helped me understand the pitfalls when 3.3V and 5V components co-exist.  I admire Adafruit.   My passion to learn about building PCBs has grown in some part to Adafruit because they take a “YES WE CAN!” approach.  They have made electronics accessible and take care not to land us in the hospital because we had an “OOPSIE” in our circuit!   They spend a significant effort on our learning and helping us learn.  I am happy to buy prototype components from them.  
‘THANK YOU!  I have gladly purchased items from both Felix and Adafruit (I am not aware of efforts from plutonomore to sell items).  They put a lot into their work.  THANK YOU!!

RFM69 Breadboard Challenges

The challenges I have run into trying to use the “off the shelf”  RFM69HW / W with the Arduino Uno on a breadboard include:

  • the pins on the RFM69 are spaced at 2mm (see p. 78 of the RFM69 data sheet) whereas a breadboard’s pin spacing is 2.54mm (0.1inch).
  • The Arduino Uno sends data over digital i/o pins using a 5V range.  Meanwhile, the RFM69′s sends 1′s and 0′s using 3.3V.  If you are new to level shifting, I thought Sparkfun’s tutorial on Logic Levels was very clear and easy to follow .  Thanks Sparkfun!
The schematic addresses these challenges.
Now it’s time to talk about selections for things like power source, voltage regulator, and level shifters.

Power Supply

The power source for the RFM69HW will be the Arduino.   Under 2.3.1 of the RFM69HW data sheet, transmitting data using the most powerful RF signal requires 130mA of current.  Based on Table 2 in the data sheet, the RFM69HW is at risk of being damaged if the amount of voltage supplied is greater than 3.9V.  The Arduino will need to provide at least 130mA of current and a maximum power of 3.9V.

Power can be supplied to the Arduino either through:

  • The 3.3V or 5V pins provide regulated voltage
  • Power jack (7-12V)
  • VIN – say from a wall wart (7-12V)
  • USB – 5V regulated

The Arduino has two pins that provide either 3.3V or 5V or regulated power (from the overview of the Arduino Uno).   Since the RFM69HW requires 3.3V of power, can I use the 3.3V source?  The answer turns out to be no because the maximum current draw for the 3.3V power source is 50mA. The maximum current draw for 5V depends on which power source the current is coming from (I got this info from here).  If the voltage is supplied by the USB, Arduino’s voltage regulator is not used so the circuit can draw up to 500mA.  Because the 5V (and 3.3V) power is regulated, I decided to go use the Arduino’s 5V source to power the RFM69HW.  The maximum draw current is not defined for the 5V.  I (might incorrectly) assume the maximum draw current to be similar to when using the USB for a power source – 500 mA.  Also, the components draw between 100-200mA, which should be well in the range of the 5V power source.  I couldn’t find the maximum draw current when using this power, however others have used it when requiring less than 500mA, so this should give me enough current.  

Since the VIN to the RFM69HW should not be greater than 3.9V, I’ll need to put in a voltage regulator.

Part Selection: Voltage Regulator

Since I do not the acquired knowledge to build a circuit that includes voltage regulation from scratch,, I decided to pretty much duplicate voltage regulators from other schematics.  The ones I looked at included  Adafruit’s voltage regulator from the cc3000 shield:


And LowPowerLab.com’s voltage regular for the Moteino R4:


I decided to use the same voltage regulator that Felix uses for the Moteino R4 – the MCP1703 (data sheet).  The data sheet specifies the MCP1703 can handle a maximum of 250mA of draw current.  While the 5V power supply can provide the circuit with 500 mA of current – which from 251mA upward would be too much for the MCP1703 to handle – 250mA is more than enough for the current draw requirements of the components.

Ferrite Bead

Besides chip selection, the most obvious difference was Adafruit included a ferrite.  I found an explanation on hackaday that adding a ferrite bead is not necessary, but further filters the signal noise.  While I realize this is “good practice”, I am not including a ferrite bead in an effort to keep the design as simple as possible.  I am assuming the decoupling capacitors will smooth out that nasty high frequency noise

Decoupling Capacitors

I did not understand the term “decoupling capacitors” before I wrote this.  Here is what I have learned.  Decoupling Capacitors:

  • filter out high frequency noise 
  • filter out low frequency noise 
  • store charge so that when the IC busts into activity, some of the current draw can come from the capacitor when the chip wants more current than the voltage supply can provide at that moment.
Decoupling works by using two capacitors in parallel on a circuit
  • one filters out high frequency noise, a 0.1uF ceramic capacitor
  • one filters out low frequency noise and provides additional charge for the IC when it bursts into action.   I will use a 10uF electrolytic capacitor.
There are decoupling capacitors on the schematic swarming close to a voltage regulator and the RFM69HW.  They are placed in parallel on the circuit.  The decoupling capacitors for the RFM69HW are placed close to the chip between the chip’s Vcc line and the circuit’s GND.  I want to get the decoupling capacitors that are there for the RFM69HW as close to the chip as possible so that noise filtering and energy can be accessed by the RFM69HW as quickly as possible.

How I Got to What I know

Designing the schematics highlighted specific areas of electronics where I am clueless.  i say  “specific areas” because  I have no idea what I don’t know.   One area that I clearly didn’t have a grasp on was capacitors.  Luckily, there are folks on the web who are not only smart but also capable to share what they know in a way that I can understand.  Spoiler alert – DC current can’t flow through a capacitor….

I bumbled across a quest to understand capacitors in the context of decoupling capacitors when I put two capacitors in series near the RFM69HW to act as decoupling capacitors and then asked for feedback on the schematic.  Ummm??? series? If I’m putting these in series, I don’t understand capacitors.  Why?  The answer to this Why? came from a wonderful reply I received from adafruit_support_mike on the Adafruit forum when I asked for feedback on the schematic.

adafruit_support_mike’s reply:

I see a minor problem with the way you’ve routed the decoupling capacitors for the two chips: you have them in series with the chip:


and that won’t work. current can’t flow through a capacitor. The symbol puts a gap in the ‘wire’ as a reminder of that. Charging a capacitor is kind of like pushing one magnet with another.. voltage pushes charge carries into one plate, and the increased charge on the plate pushes carriers with the same charge out of the opposite plate:


The displacement makes it look like current is flowing through the capacitor for a little while, but a given voltage can only push so many carriers into one side and out the other. Once you reach that limit, the current apparently flowing through the capacitor stops. To push more charge in/out/through, you have to raise the voltage again. There’s always a practical limit to how far your input voltage can rise, so there’s always a limit to the amount of current you can send ‘through’ a capacitor. The input voltage is the only thing keeping the extra charge carriers in the capacitor’s upper plate, so if you reduce the input voltage, some of the carriers will flow back out of the upper plate. That allows carriers to flow back into the lower plate, creating the appearance of current flowing the capacitor the other way.That’s handy if you have a signal where you care about the changes (called the ‘AC component’), but not about the absolute voltage (called the ‘DC component’). It doesn’t work for powering chips though. A decoupling cap takes advantage of the in-and-back-out nature of charge on the upper plate, but to make it work you have to connect it like this:


There’s a DC path from the power supply to the chip’s VCC pin, and also to the upper plate of the capacitor. The supply voltage pushes charge carriers into the cap just like before.f the chip suddenly wants more than the DC path to the voltage supply can provide, the voltage at the chip’s VCC pin will fall. That also lowers the voltage across the cap, so some of the charge carriers stored in the cap will flow out of the upper plate. That creates additional current for the chip’s VCC pin.

adafruit_support_mike’s explanation helped me understand the role a capacitor can play when an IC needs bursts of transient energy.  For example, when the RFM69HW transmits data in “burst mode”, it draws 130mA of current.

Back to the Work of Others

There is a lot of great information on topics like decoupling capacitors on the Internet.  The challenge is finding the “right” ones to learn from.  Given all our different learning styles and the context of knowledge we are coming from, there is no “one size fits all” set of information.  The information that helped me included:

  • I assume the reason the use of the term “decoupling” has to do with filtering out the high and low frequencies.  I liked the explanation on this blog post that discusses what decoupling capacitors are all about:

When an otherwise good design works, but is erratic, unreliable or just goes crazy then nine time out of ten it is the power supply de-coupling…Things can get so bad that the noise can stop a circuit from functioning correctly. It is to get rid of this noise that we have to de-couple the power supply. “

later on in the blog post:

For effective supply de-coupling that frequency has to cover as wide a range as possible and certainly the range of noise being generated by the circuits. So this is why we often see two different values of capacitor used in parallel. One large one to filter out the low frequency variations and a small on for the high frequency noise. Typical values are 47uF and 0.1uF or 0.01uF (10nF) …

  •  The advice given in this document on Decoupling Techniques by Analog Devices helped give me more insight into the practical side of decoupling capacitors.  Figure 2 in the document contains:
    • A large electrolytic capacitor (typically 10 µF – 100 µF) no more than 2 in. away from the chip.  The purpose of this capacitor is to be a reservoir of charge to supply the instantaneous charge requirements of the circuits locally so the charge need not come through the inductance of the power trace. ‹ 
    • A smaller cap (typ. 0.01 µF – 0.1 µF) as physically close to the power pins  of the chip as is possible.  The purpose of this capacitor is to short the high frequency noise away from the chip.
    • All decoupling capacitors should connect to a large area low impedance ground plane through a via or short trace to minimize inductance.
  • plutonomore recommended this document Low Dropout Regulators—Why the Choice of Bypass Capacitor Matters.  The document provides insight into how and why the size of a capacitor matters.

SPI -Talking Between the Arduino and the RFM69HW

The Arduino Uno talks to the RFM69HW using the SPI bus.  The “traffic lanes” of SPI include CLK, MISO, MOSI, and CS.  Three of the traffic lanes – CLK, MOSI, CS – send traffic FROM the Arduino TO the RFM69HW.  MISO sends data FROM the RFM69HW TO the Arduino.  Here’s where I need to take into account the logic level differences between a 5V logic level and a 3.3V logic level that I noted earlier.

Arduino UNO Voltage Signals for HIGH/LOW SEND/RECEIVE

Sparkfun’s tutorial on sending 1′s and 0′s between 5V and 3.3V components has a nice image showing the voltages required for the Arduino to send or receive a 1 or a 0.



Talk Direction











>= 3V



<= 1.5V

Let’s pretend the Arduino sends a 1 followed by a 0 on the MOSI traffic lane to be read by the RFM69HW.  The Arduino will send out a voltage signal that is at or above 4.2V to represent the 1, and a voltage signal at or less than .9V to represent the 0.   Here we are confronted with an “UH OH” moment.  The maximum voltage the RFM69HW can receive is 3.9V (see the RFM69HW data sheet, p. 11).  This means if the Arduino sends a voltage signal representing a 1, there is a good chance the RFM69HW will be damaged (beyond repair).  POOF – there goes that chip!  

3.3V Voltage Signals for HIGH/LOW SEND/RECEIVE


Talk Direction











>= 2V



<= .8V

This time, let’s pretend the RFM69HW sends a 1 and then a 0 over the MISO traffic lane TO the Arduino.  If the RFM69HW sends a voltage signal between 2.4 and just below 3V – which as you can see in the table is an OK value for sending a 1 from a 3.3V component- the Arduino does not know how to interpret this signal since the minimum voltage for a 1 is 3V and the maximum voltage for a 0 is 1.5V.

Hmmm… our biggest challenge is sending and receiving a 1.  The Arduino Uno could SEND a 1 at a voltage that is higher than the RFM69HW is specified to accept.  On the other hand, the RFM69HW could send a 1 at a voltage the Arduino can’t figure out if it should receive a 1 or 0.

Now with that said, I run into schematics that have a 5V device – usually an Arduino – talking with a 3.3V device without “up shifting” the 3.3V’s voltage signal to be within the range.  An example of this is Adafruit’s cc3000 breakout board (here is the schematic for both Adafruit’s cc3000 shield and breakout board).  The breakout board includes the 74HC40500 high to low level shifter (data sheet) – preventing the 3.3V chip (in this case the cc3000) from receiving a voltage that will fry the chip.  However, the MISO is not level shifted.  As noted in a comment from Adafruit support:

In practice, the CC3000 has a quirk: it doesn’t release the MISO line when the CS pin is HIGH. On the CC3000 Shield, we added a buffer chip that isolates the data lines correctly. The breakout doesn’t have a buffer, but you can add one externally.

For those lucky folks who have the cc3000 shield instead of the breakout board, Adafruit included a 74AHC1G125 (data sheet).

 I ran into the problem on the MISO traffic lane that occurs without it and talked about it in this post.


This way the “up shift” needed by the MISO traffic line happens.  I decided not to include the 74HAHC1G125 because I plan to use the RFM69HW in circuits that do not include the cc3000.  The schematic is simpler and the BoM is less.

Part Selection: Level Shifting for Talking on the SPI Bus

 I’m going to go with the 74LVC245 (data sheet) for handling a 1 coming from the Arduino and going to the RFM69HW.  Adafruit sells a breadboard friendly version.  Another option is to use resistors and put in voltage dividers between each 5V and 3.3V traffic lane.  I decided to use a chip instead of resistors because soldering one component seemed simpler than soldering 6 resistors.  Also, at one point I posted a 5V to 3.3V circuit using voltage dividers.  I recall getting feedback that using voltage dividing is not as robust as using a level shifter.  Although I don’t have the in-depth knowledge to do the contrast/comparison between using a level shifter and down shifting the voltage using voltage dividers.

Pull-Up Resistor

I added a 10Ω ohm pull-up resistor  (SparkFun has a great explanation of pull-up resistors) to the Arduino’s CS line.  This makes sure the conversation is over between the RFM69HW and the Arduino over SPI is “over”.  I covered basic SPI traffic in this post.


The RFM69HW Arduino library on GitHub uses an Interrupt Service Routine to monitor when data should be read from the MISO traffic line.  I won’t level shift the interrupt traffic land since it is not a shared line.

The Antenna

My appreciation of the antenna has grown during my exploration of in-home networking options.  After reading:

I decided to go with the antenna option that  lowpowerlab used for the Moteino.  I soldered on a copper wire that according to this online calculator should be 6.8 inches for a 1/4 Wavelength at 433MHz.  


Copper Wire Monopole Antenna

The great part about this project is the discovery of how much I thought I knew but really did not!  One area where this is true is the role of the ANA pin on the RFM69HW.  It was one thing to stick a wire in a breakout board I purchased from Felix at lowerpowerlabs.com.  It was another to understand the implications when working through the circuit.  I only hope persistence beats density when it comes to learning electronics!

My “knock my head against the wall” misunderstanding of how the antenna works was understanding the role of the ground plane.  I realized I was getting my terms mixed up.  I kept wanting to short out the ANA pin!!!  As pointed out in this wikiepedia entry on the ground plane

In antenna theory, a ground plane is a conducting surface large in comparison to the wavelength, such as the Earth, which is connected to the transmitter’s ground wire and serves as a reflecting surface for radio waves. In printed circuit boards, a ground plane is a large area of copper foil on the board which is connected to the power supply ground terminal and serves as a return path for current from different components on the board.

Just having a ground plane on the PCB serves the purpose of “ground” for the antenna. If the ANA was connected to GND, then a return path in the circuit is created – which is not what we want since the ANA is not drawing current it is pulsing the 1′s and 0′s which the wire picks up.

A HUGE SHOUT OUT to Chip’s indefatigable willingness to evolve my understanding on the Sparkfun forum!  Since I was confused on how to apply terms, I thought it best to write down what Chip helped me understand.


ANA – it is the pin on the RFM69HW that sends out a current to the…
Wire – a piece of copper of the appropriate length* that is soldered onto a connector that conducts the current. The wire in proximity to a ground plane forms an antenna that generates a shaped electromagnetic field (radiates) so that another RFM69HW with an antenna connected to its ANA pin can pick up the field and receive the info in the current.
The wire and ground plane together form the antenna(the job of ANA is to send out a current, the job of the antenna is to radiate the current).


Test Points 

My first thought was to place LEDs along the SPI bus and INT traffic lanes so that I can test the traffic going between the Arduino and RFM69HW with a logic analyzer (I discussed using a logic analyzer with SPI traffic in this post).  Chris (the master mind behind Contextual Electronics) pointed out the SPI’s bus speeds would be too fast for LEDs.  He recommended test points, which I liberally included in the schematic. .


A Test Point



Figuring out if the data is flying around the SPI bus is worth pulling out all stops.  So I added an LED based on what I saw in plutonomore’s schematic (the link to plutonomore’s discussion and files).   An LED is placed in the path of the CLK and CS traffic lanes.  Perhaps because electronics is new to me, I thought what plutonomore did was clever.

 As plutonomore notes:

LED2 blinks unmistakably when SCK is high and CSS is low, thus indicating that the RFM69HW wireless module is being accessed.”    You can see this in image below.




Since the SCK is like a heart beat, there will be times when SCK is high and CS is high.  In this case, the LED won’t light.  



The Schematic

The kicad files – as well as a pdf file for folks that do not use kicad – for the schematic is located in this github repository.  

We are using kicad in the Contextual Electronics course.  After 5 weeks of consistent use I have to say kicad is a powerful and fairly easy to use schematic-to-PCB tool.  My complaint is the Mac version is unusable.  I end up using bootcamp to boot my Mac into Windows 7 and use kicad on Windows – which works very well.  If you want to give kicad a try, install it from here and perhaps learn by creating a PCB by following the Chris’s “Getting To Blinky” series of videos.

What’s Next

My next post is about associating parts to the schematic symbols.  

Thank you for reading this post.  I hope you find many things to smile about.


Water Sensor Node: Arduino + Atlas Scientific pH & Conductivity Sensors + Water Temp Sensor


, , , , ,

(but before I begin…I’ve had a hard time getting a post out recently.  I am in the middle of the most amazing course offered by Contextual Electronics on learning how to build a PCB.  Each day brings on a lot more to learn.  So far taking this course has been a wonderful experience.  There is a fee and I have no reason to sing its praises – although so far it is exceeding my expectations. Once I learn and go through the process of building a PCB, my goal is to build PCBs and cases of the nodes and Base Station.)

In a previous post I discussed the Air Sensor Node.  In this post I’ll be building a Water Sensor Node.


The Water Sensor Node will measure properties of the water that are important to a plant’s growing cycle – water temperature, EC, and pH.  It will respond to a request to get and send readings to the Base Station.

The Goals

In this post I will:

  • identify and discuss the choice of components for my Water Hydroponics Sensor Node.
  • run the water sensor node through a sample sketch to show its features.

The Parts List

Part  Cost  Info
pH Kit


Previous Post
Conductivity Kit $108.87  Atlas Scientific Web Page
Water Temperature sensor  $6.40  Previous post
10 screw terminals


Wires + breadboard    -  from parts
Moteino w/ RFM69HW @ 433  $24.14   Previous post
wall wart      -    from parts 

Total: $250.41  (shipping included)


I decided against an LCD and buttons to locally control the node.  Instead I will control nodes through an app I’ll write for my iPhone.  More on that in a later post.  By using an iPhone app, I’ll be minimizing the additional hardware cost and complexity added in by an LCD and buttons.  

pH and Conductivity Sensors

The pH and Conductivity kits  are both from Atlas Scientific.   



I bought the kit.  The kit includes a “circuit” PCB (which is the small rectangular PCB near the BNC connector and below the probes on the above images of the kits) which is breadboard friendly. This is ideal for Arduino prototyping.  They also supply sample Arduino sketches which were very helpful in getting used to how the probes work.  And very important – their support is excellent.  I like what Atlas Scientific has done with their products.  Their “secret sauce” (IP) – measuring pH and conductivity in this case – is locked into the software of the sensor’s circuit board.  I am relying on their expertise and quality of equipment.

I have come across these challenges:


  • The more prototypes I do the more I lose time on faulty wiring!  Even more than usual with my Arduino prototypes, it is easy for something to affect the wiring to the point the circuit doesn’t work.  The common occurrence for me was the PCB holding the BNC would not reliably secure itself into my breadboard.
I found this gem, but have not ordered any:
This is  the Single Circuit Carrier Board.  It gets rid of the wiring between the BNC and the circuit.
  • The circuits use the SoftwareSerial library. The SoftwareSerial library is limited to listening to one port at a time.  In order to support two sensors, I needed to switch which port I was listening on and also keep track of the two instances representing the SoftwareSerial ports when the sketch is running.  Perhaps a better communications method between the Arduino and the circuit is I2C.
  • It wasn’t uncommon for roughly 30-50% of the Conductivity readings to contain non-printable ASCII (junk) characters.  My thoughts are many of these errors are caused by the two challenges noted above as well as noise within the circuit.
  • I wish there I didn’t have to choose which Conductivity probe.  This will be discussed more later.  The challenge is the K0.1 probe can detect the conductivity for a lot – but not all – of the plants.  Some plant’s conductivity readings fall within the K1.0 probe.
  • I’m lazy.  Thus, the required calibration is “one more thing.”  i note more about calibration later on.  I wish there was an easier way to calibrate, or it self calibrated, although I have no idea how it could self calibrate.  I guess I am truly lazy.


It is always a good practice to not single source.   I have not investigated alternatives.  I will “lock and load” on the Atlas Scientific products for now so that I can focus on the tons of other aspects of this project that I need to complete.  When I have time I will evaluate options like the pH sensor from Sparky’s Widgets.  I like the fact that it uses I2C to communicate between the Arduino and the sensor.  

Design Constraints

My design constraints include:

  • integrates with Arduino
  • does not require me to have to create algorithms to measure pH and conductivity based on the characteristics of the liquid the probe is in.  I want to leave this to experts.  I am assuming the folks at Atlas Scientific have experts on staff that have a deep knowledge on how to get and calculate these measurements as well as provide a robust solution.  I use “assuming” because their web site does not provide any company/people info.  I might be incorrect – I could be buying nice packaging and assuming expertise because of the professionalism of the presentation and support.  I read this negative comment on the Sparkfun product post but have not talked with AtlasScientific or the person that wrote it:
 oneRSP2k | about 3 months ago *  2

I have had nothing but problems with this probe. It provides Inaccurate readings. The pH probe cannot be submersed, only the tip can, otherwise you will ruin the probe. We purchased this in order to speedup development time, not donate beta testing time to Atlas Scientific. It nearly cost me a client. If you read through their documentation you will find glaring errors that indicate issues with their document review process.  We also had several of their temperature probes (ENV-TMP-D) shipped to us that read almost 3deg C high at room temperatures (factory calibration). When I called them on this, they confirmed they “had a bad batch” but didn’t offer to replace my bad sensors. Save your money and time and look into another solution

While comments like these add to my concern that the product is not as robust and full of expertise as I assumed, I also put them in perspective after creating and shipping software!

  • accurate measurements of plants in a hydroponics growing environment
  • easy to use.  For example – both circuits use the same commands – which require sending commands such as “r\r” to get a sensor reading back as a string.
For the most part, the products from Atlas Scientific meet these requirements.  I say for the most part because the circuits use the Software Serial library to communicate with the Arduino.  There are two challenges I had with this: 1) Results are returned as a string.  About 1 in 5 readings were corrupted with non printable ASCII characters. 2) only one Software Serial port can be listening at a time.  Perhaps an I2C interface with the Arduino would have been a better choice than Software Serial.

 In-Home Wireless

I’m pretty sure the RFM69W will work well for the water node.  For now I’m sticking with the RFM69HW since I will most likely be running a water node from a wall wart.  The power will need to be there since I will need it to run pumps, lights, and other equipment.  

Power Source

The Conductivity circuit needs 5V.  Everything else can run at 3.3V.  Since the Moteino provides a voltage regulated 3.3V, I used a leftover 5V cell phone charger wall wart when placing the water node where it will be used.  I took the covering off the wire and used screw terminals I found on Sparkfun. 



I bought ten since a big expense was in shipping ($3.69).  The screw terminals are ok, not great.  I ended up doing what this guy recommended:

SD | about 3 years ago 1
reply | report
I tried plugging one of these in my breadboard (probably not meant to be used with a breadboard) and it wasn’t going in very well with the pins the way they are built. All I had to do to make it work was twist the pins 90° with some needle nose pliers and now this little baby plugs right into the breadboard nice and snug.

Even after doing this the screw terminals would occasionally pop out.  Bummer.

For debugging, I use the Moteino’s 3.3V.  Although the Conductivity circuit requires 5V, it will return results at 3.3V – although many are not usable.  This means switching wiring on the Moteino such that when the water node is powered by the Wall Wart – Moteino’s Vin is hooked up. .


 When the water node is getting power through USB, Moteino’s 3.3V is hooked up to provide power to the sensors

pH Measurements 

As shown in the image below, keeping the pH at the right level for a plant is an important aspect of healthy growth.  Since how much of a nutrient a plant will absorb depends on the pH,  as the plant is growing it is important to first check and adjust the pH level before checking and adjusting the nutrients based on conductivity readings.



I discuss my first use of Atlas Scientific’s pH sensor in a previous post.  

Conductivity Measurements

(here is a FAQ on why it is important to measure Electrical Connectivity when practicing hydroponics)..

 (please see this post if you need a backgrounding in TDS vs. EC)

The first thing I needed to do was choose a conductivity probe.  Atlas Scientific offers three types of conductivity probes (discussed in this document).: 

K0.1…………. 5.94 to 1,620
K1.0…………. 702 to 21,600
K10.…………. 19,440 to 49,680

 The values are in TDS.  So which one?  I will be using the recommended values from this chart.    Armed with this info, and also with feedback from the great people on the hydro subreddit, the “best” probe for hydroponics is the K0.1.  Not unusual – I let the excitement of buying a probe come before looking at the chart and verifying with other folks….I got the K1.0.  I’ll be using the K1.0 until I can replace it with the K0.1.  The other mistake was buying the kit on eBay versus directly from Atlas Scientific.  When a smaller company is involved, I have always found  the best support comes directly from the folks who make the product.  Given my own experience as a small business shipping software, I know how hard support can be for folks like me who tried to save a few bucks.  In the future, I wish to support Atlas Scientific’s efforts and will buy directly from them.

The probe returns three readings.  Each reading is separated by a comma:

<EC>,<TDS>,<salinity value>

The example given in the EC circuit data sheet:

Example: 50000,32800,32<CR>

Salinity Value

According to this book,  the salinity should go no higher than 50.

it [Sodiium] should not be in excess of 50 ppm.


Before using the sensors and once a year after that, they need to be calibrated.  I am not going to cover the commands and actions for calibration in this post.  You will need to do this before taking readings.

As noted the Conductivity Circuit’s data sheet:

In order to provide the engineer with the greatest possible accuracy E.C. Circuits now ship uncalibrated. This is because micro voltage changes in your circuit design cannot be compensated for at the factory. 

Calibration requires calibration solutions.  Both of the kits I bought included the calibration solutions shown below.  

I’ll discuss how I calibrated the probes when I go into the Arduino Sketch I wrote for the Water node.


I was thrilled to move from a 5V Arduino environment to a 3.3V Moteino setup.  That is until I looked more closely at the conductivity circuit.  While the pH circuit can run at 3.3V or 5V, the conductivity circuit must run at 5V.  While a bit of a pain, the mixture of 5V and 3.3V parts is getting pretty common in my circuits.  I did try running the conductivity circuit at 3.3V.  The readings showed more errors than I got when running the circuit at 5V.  I ended up powering the Moteino, pH circuit, and conductivity circuit with a 5V Wall Wart that I had lying around which originally charged a cell phone I owned in the past.  I hooked it up to the breadboard as shown in an earlier image.  

Both the pH and conductivity sensor components are easy to include in a circuit using a bread board.  

My familiarity with the pH probe was a time savings in getting started with the conductivity sensor.  I used the easy to follow wiring diagram to set up the probe connector and conductivity stamp on a breadboard and then hooked it up to the Arduino.




I bet a major support issue is how the BNC connector should be wired to the pH circuit.  In the first video I watched on wiring the circuit and BNC connector, the wiring used a wire between the stamp and connector.  Now – as shown in the picture – the recommendation is to align the connector and stamp to share the same row of pins.  

Here’s what I ended up with:



The Sketch

For the past few weeks I was implementing a water sensor node experience in which the node constantly sent readings to the base station.  I then decided that my priority was not gathering readings for post analysis, but rather getting readings when I request them from my iPhone.  Thus, my sensor reading collection model went from constantly getting readings and sending them to the Base Station to the Base Station requesting a reading.  This drastically simplified the base station’s job since it no longer had to send data to an Internet service such as Google Docs or Xively.  

Now the job requirements of the Water Node include:

  • Commands can come from the Base Station as well as locally through the serial port (for easier debugging).
  • measuring and sending (temperature corrected!) the readings for the water temperature, EC, and pH within the nutrient tub when requested by the Base Station.
  • automatically adjust pH based on what is growing (future)
  • automatically adjust EC based on what is growing (future)
I will use Mains electricity as the power source since I will need this power source for the other parts of the system such as LEDs and pumps. 

Taking Readings

The good news is the sensors use the same commands to take sensor readings.  I evolved the sketch provided within the documentation available for the EC sensor.  Please open up this sketch if you wish to follow along.   The readings that will be taken include water temperature, pH, E.C., and salinity. Things to note:
  • Results are returned as character strings.
  • As noted earlier, the SoftwareSerial library is used as the communication method between the Arduino and the circuit.
  • The same commands are used for both sensors.  Thus, the learning curve when introducing a new sensor is much lower than if I mixed circuits from other vendors.
  • While not obvious in the sketch – in fact, the simple sketch provided by the conductivity sensor does not do this probably because the sketch is generic to other sensors (like the pH sensor) – how to take measurements are different depending on the sensor.  With the pH sensor, I can take one reading (or more accurately enough readings until I get one that does not contain non-printable ASCII characters).  With the conductivity sensor, the recommendation in the circuit data sheet is to take 25 readings and then use the next (accurate) reading.
  • The sketch allows any of the commands to be passed in.  This means I can calibrate (once a year) and get readings (often).

The Sketch I Wrote

You can download the sketch – waterNode_03.ino from here.  I will go over the general points here but you’ll need to look at the sketch to get a better feel for all that is going on.  

The water temperature sensor was discussed in this previous post.  I copy/pasted the getTemp() function from Sparkfun’s H20_pHrobe.ino sketch.  The function is quick and gets valid results.


 Alas, the Arduino IDE does not have much in the way of debugging support.  Instead I liberally sprinkle the sketch with DEBUG_PRINTXXX macros found in debugHelpers.h.  

#ifdef DEBUG

#define DEBUG_PRINT(x)  Serial.print (x)

#define DEBUG_PRINTHEX(x) Serial.print(x,HEX)

#define DEBUG_PRINTF(x) Serial.print(F(x))

#define DEBUG_PRINTLN(x) Serial.println(x)

#define DEBUG_PRINTLNF(x) Serial.println(F(x))


#define DEBUG_PRINT(x)

#define DEBUG_PRINTF(x)

#define DEBUG_PRINTLN(x)




These can be turned on or off using the #define DEBUG.

Sending a Command

There are two ways a command can come to the water node: locally via a serial monitor which is very useful when debugging and from the Base Station using the RFM69HW to communicate between the two devices.  The code that will get executed when a character comes in from the serial port is found in the serialEvent() function.  How serialEvent() works is covered in the docs on Arduino functions.  The code that gets executed when a command comes from the base station occurs in the loop() function within the code if(radio.receiveDone()){}.  

Serial Monitor 
Entering a ? will display the available commands. Any of the commands listed in the circuits document – either the pH or the Conductivity circuits – can be sent to through the serial monitor.  Entering a 0 changes which port is listening for sensor readings.  If I enter a 0, the readings will come through the pins designated for the pH circuit.  If I enter a 1, the readings will come in through the pins designated for the conductivity circuit.

Base Station
A command from the Base Station is really a command sent from my iPhone.  I’ll detail this in another post…the way I communicate from Base Station to iPhone is through an HTTP request.  Thus, when a reading comes in, I send a string containing all sensor readings as soon as I can.  I’ll send cached results if I cannot get a return in a quick enough time.  The Base Station sends the ‘a’ command to the water node to request (and hopefully receive!) all readings within a string.

Taking a Reading

pH and Conductivity

After trying different options to read the pH and conductivity sensors, and honoring the constraint that 25 readings are needed before a valid conductivity reading should be taken, I decided to use the “C\r” (continuous) command to retrieve readings.  The way the sketch reads the sensors:

  • listen on the pH port.   Send a temperature reading to the pH circuit so that measurements will use the current water temperature.
  • Keep sending the “C\r” command to get the pH circuit to send continuous readings.  Even though the pH circuit does not need the sketch to get pre-readings before taking the real reading, there have been many times when a command needed to be repeated before the circuit would respond. The number of times varied.  For that reason the sketch keeps sending “C\r” commands to the pH circuit. 
  • Every second send the “C\r” command through the pH port.  I opted to continuously send the command because sometimes it took several tries at a command before the circuit would act on the command.
  • When a reading comes in through the pH port, check to see if it is a valid reading.  If the reading is valid, put the pH reading into a substring (sensorReadingpH).  Stop sending the “C\r” command.  Let the sketch know a reading is available (phStringReceived).
  • listen on the conductivity port.  Send a temperature reading to the EC circuit for the same reason one was sent after switching ports to the pH circuit.
  • Keep sending the “C\r” command until the port lets the sketch know it has received an EC reading (isECReadingInContinuousMode).
  • Keep getting Conductivity readings until a reading after the 25th reading is a valid reading.  Put the reading into a substring (sensorReadingEC)
  • After the first reading, turn off the “C\r” command
  • After 26 readings,  do the same as with the pH reading only use variables and such related to the conductivity readings.  Let the sketch know a reading is available (ECStringReceived).
  • Switch to taking a pH reading….switch to taking an EC reading…with to taking a pH reading…..switch…switch….


Reading the water temperature is done right before the string is created that holds all the sensor readings.  The “meat and potatoes” of getting a water temperature reading is found in the getTemp() function which I talked about earlier.

Sending a Reading to the Base Station

If readings are available, the water node will send a string of readings when the ‘a’ command comes in from the Base Station.  If all the readings are not available, the water node sends a string noting a reading is not ready yet.  The Base Station needs to determine if it got a valid string and if it did not to keep requesting for a valid string of readings until one is received.  The way the sketch sends a reading:

  • An ‘a’ command is detected from bytes received from the Base Station (within the code if(radio.receiveDone()){})
  • If readings are available for both circuits, create a string that contains the readings and send it back to the Base Station.   If readings are not available, send a string containing: “ERROR|No readings available, try again”.  I use the | key to delineate between sentences. The flag variable, pHAndConductivityReadingsAvailable, tells the sketch whether there are recent readings.  If this variable = 1, only the pH reading is available.  If 2, only the conductivity, if 3, both readings are available.  By using this flag, I can separate taking readings – which happen constantly – to sending a reading – which happens with the Base Station sends the ‘a’ command.  

Sending a Reading to the Serial Monitor

All commands found in the data sheets for the pH and conductivity circuits can be sent to the water node when the node is hooked up to a serial monitor.  Besides being a tremendous debugging aid, this is the only way right now I can calibrate the sensors.  The sketch knows whether commands are being sent by the Base Station or the Serial Monitor by checking the bool isRemoteInput.

That’s All For Now

It took me longer than I had planned to get the water node going and to write this post!  Come to think about it, I can’t think of a project that hasn’t taken longer than I have planned.  Some of the time spent was exploring the best way to put together the pH, conductivity, and water temperature sensors.  As well as understanding the how the Atlas Scientific sensors work.  I hope the information is useful to you.  

My next step with the water node is to put in automatic adjustment of pH and nutrients.  Before that, I will finish up my work on my iPhone app talking to the Base Station and displaying results on the iPhone.  While doing all this, I will be having an amazing learning experience with my fellow learners at Contextual Electronics.




Get every new post delivered to your Inbox.