, ,

The nRF51822 comes loaded with eight configurable ADC channels.  Why not take advantage of them?  I am evolving the design of the Ladybug Blue Lite to use the nRF51822’s ADCs instead of the ADS1015 + MUX.  In the previous plan, six op amps were used.  One for VGND, one for pH, and four for EC (one for Wien Bridge, one for the Gain loop, and two for rectification).  Then a MUX switched between VOUT and VIN signals.  Removing the MUX means two more op amps are needed to participate in rectification.  Now, instead of a MCP6242 and MCP6244, the Ladybug Blue Lite will use two MCP6244’s.  Another benefit is the reduction in complexity.  I see the complexity reduction to be highlighted most in the firmware.  Previous to this change, I used a timer to give about 10 seconds wait between measuring VIN and VOUT to allow the effect of switching signals to work it’s way out of the circuit.

The change to the BoM is:

Ladybug Blue Lite with ADS1015:

Total= $3.89
Ladybug Blue Lite without ADS1015:
  • no ADS1015
  • no MUX
  • exchange MCP6242 for MCP6244.  The MCP6244 costs $.68.  $.68 – $.43 = $.25
  • one additional MOSFET: $.17
Savings: $3.89 -$.25 – $.17 = $3.47 -> a significant savings!

The Goal

The goal of this post is to understand and evaluate the nRF51822’s ADC for pH and EC measurements.

Thanks to Those That Went Before

I am truly grateful to:

  • Chris Gammell – I continue to learn A LOT from his Contextual Electronics course.  Recently, the “Full Charge Ahead” section was a great introduction to designing and laying out LiPo batteries.  Chris is also an amazing mentor.
  • Ryan of Sparky’s Widgets has made it so much easier for us to sense pH and EC readings.  I started with Ryan’s schematics and design of the minipH and miniEC boards and have evolved my designs from there.  The work I am currently doing proudly stands on the shoulders of Ryan’s.  Thank you.
  • Adafruit for their attention to learning and support.  There is so much great stuff on their site!
  • OSH Park for their excellent PCB fabrication service and hiring such terrific folks that really care about the support.

What is Good Enough

I am not concerned with sampling rate.  But resolution is a factor.  The nRF51822’s maximum resolution is 10 bits.  The ADS1015 has a 12 bit resolution.  Is the loss in resolution going to negatively affect my goal of pH and nutrient adjustment?  It shouldn’t.  In an earlier post, I noted the minimum resolution for pH is 8 bit.  With EC, the VIN, VOUT, and VGND are all measured.  It should be fine for the resolution to be 10 bits.

Running a Test

To see if I can get expected results, my first test will measure VGND when the power source = 3.3V.  VGND measures 1.6V.  The test code I used (ADC_Simple) is available at this GitHub location.  It is zipped into an Eclipse project (Note: There are some hard coded paths that you would need to modify – mostly in the makefile).

ADC Configuration

The ADC HAL SDK documentation notes the following settings for the default configuration:

  • 10 bit resolution
  • 1/3 prescaling
  • internal 1200mV VREF
The 1/3 persecuting makes sense given VREF = 1200mV.  VOUT could be between 2.5-3V.  If it is at 3V, a pre-scaling of 1/3 allows the value to be correctly read (i.e.: 3000/3 -> 1000, which is below 1200mV).


VGND = 1.6V when measured with my DMM on my test setup.  Running the ADC_Simple (GitHub location) within Eclipse, the reading from the ADC with the default settings = 450.  Converting this to millivolts:
  • 10 bits = 1024 steps (0 to 1023)
  • reference = 1200mV
  • post-scale factor = 3
VGND mV = (1200mV/1023)*450*3 = 1584 mV, close enough to 1.6V.  The reading for VGND looks good enough.


VOUT = 2.5V on my test setup.
ADC reading = 700 = 1200/1023*700*3 => VOUT =  2463 mV


VIN = 1.77 on the test setup.
ADC reading = 492 = (1200/1023)*492*3 => VOUT =  1731 mV
I note aall ADC reading are slightly scaled down.  This is to be expected as noted in this post.  Since all scale down, the results for the gain even out.  That and different circuits are measuring the voltage value so it is expected there will be variability.  I see this as reasonable variability.

Calculating the Resistance

While calculating the resistance isolates how accurate the circuit is, I’m curious to know how close the measurements came to the 200Ω resistor I am using in the test setup to represent an EC probe.
Resistance = 1K (i.e.: the feedback resistor I am using)/Gain-1
These readings are relative to VGND:
  • VOUT relative to VGND = 2463 – 1584 = 879mV
  • VIN relative to VGND = 1731 – 1584 = 147mV
Gain = VOUT/VIN = 879/147 = 5.98
Resistance = 1000/4.98 = 200.8Ω…pretty darn close!
So there we have it.  I’m going ahead and update the design to use the ADCs on the nRF51822.
That’s it for now. Thank you for reading this far.  Please find many things to smile about.