Ladybug Shield Beta V1 – Cleaning Up the Design


I finished testing the Ladybug Alpha V2….for the most part all works.  Still there is more to fix.  I just sent Beta 2 off to OSH Park.  I skipped Beta 1.  I had done a version where I had removed the pump circuits.  I decided to put these back in after testing the pumps.

The Goal

The goal of this post is to document changes to Ladybug Alpha V2 that change the schematic and layout.  

 Thanks To Those That Went Before

  • Thanks to OSH Park for their exceptional PCB fabrication and support.  OSH Park is excellent at keeping customers happy.  OSH Park – thank you for your exceptional support and company culture that makes me want to support you as a company.  Thanks to’s interview of Laen – OSH Park’s CEO – I now know that it is OSH and now Osh.
  • Thanks to Adafruit for their excellence in support, tutorials, and open source availability of schematics/layout.  This post borrows the design for a single power source in Adafruit’s motor shield.  Adafruit has done an excellent job not only selling to, but supporting and caring about customers.  I know when I have a question and post it on the forum – one of the incredibly knowledgable and kind folks (typically Mike or Bill) respond in a small amount of time – along with great answers from folks that are not employed by Adafruit.  Adafruit – like OSH Park – are high on my list of companies to buy products from.  The products are of great quality, come with excellent additions – like libraries for Arduino programming, tutorials, and are well supported.
  • As always, thank you to Chris Gammell.  I am continuing to learn A LOT from Chris’s Contextual Electronics courses.  I like the new format where we work on smaller projects together.  Each one has given me many opportunities to strengthen my knowledge…well, I try anyways.
  • Ryan of SparkysWidgets fame has a great product in his minipH and miniEC.  I recommend these break out boards.  It is what I evolved my designs from.  Thank you for your open source schematics and Arduino sketches.  Ryan is extremely helpful and kind.   Thank you.

Open Source

The Kicad files for the Ladybug Beta V2 are located at this GitHub location.

Beta 2 Changes

Changes from Alpha 2 to Beta 2 include:

  • changes to how the components as well as the pumps get power.
  • removal of temperature readings.
  • addition of test points.

The Power Design

The current design:

  • includes a voltage regulator between the Arduino’s VIN and the 5V used by the pH and EC circuit.
  • assumes two power sources.  One for the pH and EC circuit (5V) and one for the pumps (12V).
The Ladybug Shield Beta 1 will clean this up, removing the voltage regulator and the need for two power sources.  The design will borrow from Adafruit’s power source on their motor shield.  Here is an image of part of the AF_mshield_v12.sch
Pasted Image 3 25 15 10 08 AM

A 12V Wall Wart will be plugged into the Arduino’s barrel jack.  The 12V Wall Wart will power both Arduino’s 5V power supply as well as power the pumps.  While there are three pumps, the pumps will not be used at the same time.  For this reason the pumps will share a power source.   A nice aspect of Adafruit’s design is the lining up of GND such that both the 12V and Arduino’s 5V voltage sources are relative to the same GND.  My earlier attempts mistakenly did not align Arduino’s GND with the pump’s power source GND.  Well, it did help me understand what is meant by aligning the GND….  

From the FAQ section of Adafruit’s motor shield documentation:

My Arduino freaks out when the motors are running! Is the shield broken?

Motors take a lot of power, and can cause ‘brownouts’ that reset the Arduino. For that reason theshield is designed for seperate (split) supplies – one for the electronics and one for the motor.Doing this will prevent brownouts. Please read the user manual for information about appropriatepower supplies.

Adafruit’s design accommodates this by using a jumper and including a 2-terminal block for the V+/V- of a power supply.  When the jumper is not on the shield, the pumps use an external power source.  The “standard” power source – USB or a power source plugged into the barrel jack – is used for circuits on the shield that use the Arduino’s 5V power source.  The GNDs of the two power sources is aligned.

I’ll also make a small modification to add a green LED on the line to detect if the shield is getting power.  


I decided to not use temperature to adjust the probes.  Even though measuring pH is all about figuring out the amount of H+ ions clinging to the probe’s glass membrane.  When the temperature of the nutrient bath varies from the ideal of 25˚C, the amount of H+ ions changes.  I experimented adjusting the temperature and decided not remove the thermistor circuit for measuring temperature.  I made this decision:

  • I’m growing plants in my house. The water temperature will not vary much.  Perhaps the lighting will warm up the nutrient bath.  However, I am using LEDs.  LEDs do not dissipate much heat.
  • The measurements need to be precise, but inaccurate and span a range of values.  
  • While there will be a .1 inaccuracy, the leafy plants I wish to grow with the help of the Ladybug shield are cool-season vegetables.  As noted in this article, a healthy temperature range for a nutrient bath supporting cool-season vegetables is between 10˚C/50˚F and 21˚C/70˚F.  I will use 10˚C for my rough calculations since it is farthest away from the ideal 25˚C.  When the nutrient’s bath is at 25˚C, the amount of voltage between pH values is 59.16mV.  When the nutrient bath’s temperature is at 10˚C, the voltage between pH values is 59.16+(10-25)*.198 = 56.19mV, close to 3mV.  Since the resolution of the ADC set to 1mV LSB works well, an Arduino Sketch will be able to pick up this difference.  I would address this difference if I required both precision and accuracy.

for the environments in which I will be using the Ladybug Shield, the temperature will not vary enough from 25˚C to include temperature adjustment.  While the readings would be more precise, the range that is allowed for healthy growth is large enough that introducing the additional will not affect growing healthy plants.

Test Points

I am finding it difficult to look at two signals on a scope if the contact for the probes is one of the chip’s pins.  Now that I have a better idea on what to test, I am putting test points at the places I have found myself constantly measuring – the EC and pH inputs into the ADC, each phase of the EC signal processing.


Just a short update so that we’re on the same page on what the Ladybug shield is shaping up to be.  If this version passes tests, I should be close to completing the hardware!



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


Getting pH readings on my iPhone from the Ladybug Shield


, , , ,

As I get older, I evolve choices to which make me happier.  Perhaps selfish but life is so incredibly short…why not surround each other and ourselves with happiness?  Using my iPhone to interact with the Ladybug Shield makes me far happier than using an LCD.  Besides, programming in Swift is..well…fun….at least fun relative to other programming languages I have bumbled about.

I want to start using the Ladybug Shield around my house.  This “forces” me to get my nose out of the scope and into the UI.

The Goal

The goal of this post is to go through the process of building a minimal iPhone app that display pH and EC readings from a Ladybug Shield.

Open Source

The Arduino and XCode files are located at this GitHub location.

Adding BLE

The Ladybug Shield does not include BLE.  After many starts and stops, I ended up adding the RedBearLab BLE Shield.  

IMG 3383



I spent too much time trying to get the Bean to work (which I had used in a previous prototype).  Ultimately, the Bean could work, but the challenges that got me to decide on using the RedBearLab BLE Shield over the Bean for this prototype included:

      • getting a stable/solid wire connection between the Bean and Arduino over the I2C pins.  At one point I soldered header pins onto the Bean’s holes which screwed up the board….I ordered another….yah, D’OH mistake :-).
      • The Ladybug Shield uses the ADS1015 – another I2C device.  I use Adafruit’s ADS1015 library which assumes the ADS1015 is the master.  This means both the Arduino and the Bean must act as slaves.  This was ok, but complicated my coding.
      • The Bean is a 3.3V device. The Ladybug Shield and Arduino are running at 5V.  I was running into communication over I2C freezing when the ADS1015 and Bean were both involved.  Yes, I could add a level shifter as I have done in the past…but it is one more thing to deal with. 
      • The Bean needs an external power supply.  The easiest is to use a C-Cell battery.  My bad was to keep leaving the Bean on with the battery in.  I’d come back in the morning to yet another dead battery.
      • The Bean must use the older (1.0.5) version of the Arduino SDK.  In general these type of 3rd party dependencies become necessary evils.  While the Bean’s abstractions make getting a BLE app between the Arduino and an iPhone easier, the cost of not being able to update the SDK is high for folks that have at least an intermediate level of BLE programming.
      • The RedBearLab shield uses the nrf8001 BLE chip (data sheet).  I gave up a more friendly library of APIs, being “forced” to gain familiarity with a library for the nrf8001.  My BLE requirements are very minimal so it didn’t take me much time to get the Arduino sketch pumping out pH and EC readings over BLE.

The ReadBearLab shield uses SPI.  Instead of using a CS pin, it has two pins – REQN and RYDN.  As noted in the nrf8001 data sheet:

However, nRF8001 does not behave as a pure SPI slave device; nRF8001 can receive new data over-the air at any time or be busy processing a connection event or new data. Consequently, the traditional CSN signal used to initiate an SPI transaction is replaced by two active low hand-shake signals; RDYN andREQN  

Nordic Semi’s library (for Arduino)  defaults REQN and RYDN to pins 8 and 9. These can be set to any of the pins 2 to 10.  For this prototype the Ladybug Shield will work with the default pins.

Sending pH and EC Over BLE

I did not need real time readings so I decided it was good enough to package the pH and EC value in the RedBearLab’s advertisement packet.  I should be packing the readings into the data portion of the advertisement packet.



This shouldn’t be too hard once some amount of familiarity with Nordic’s interface – Application Controller Interface (ACI) is accomplished. if I follow the steps outlined in this support post:

  • Once the nRF8001 sends the ACI Device Started Standby event, you can use the ACI OpenAdvPipe command (lib_aci_open_adv_pipes) on the broadcast pipe.  When you are opening a pipe using the ACI Command OpenAdvPipe, you need to wait for the Command Response Event [that says the pipe is open…not just that the request was queued]
  • update the data in the Pipe by using the ACI Set Local Data command ( lib_aci_set_local_data)
  • Then start advertising using the ACI broadcast command.
These steps point out what is going on within a figure in the nrf8001 data sheet that discussing setting broadcast data:

Since this effort is “quick and dirty” I decided to set the RedBearLab’s peripheral name to the pH and EC values.  The details are covered in the Arduino sketch LadybugShield_BLESlave_V1.ino:

void loop()
{//don't do anything until BLE is ready
  if (ble_isAdvertising())
    float pH_value = takepHReading();
    DEBUG_PRINTF("--> pH: ");
    uint16_t EC_value = takeECReading();
    DEBUG_PRINTF("--> EC: ");
    DEBUG_PRINTLNF("Wait before taking another reading...");
    delay(10000); //take a break

I did modify the nrf8001 library to:

  • include ble_isAdvertising() to let the Arduino sketch known that the “ACI advertisement has begun event” has occurred.  
  • set the peripheral name:

        lib_aci_set_local_data(&aci_state, PIPE_GAP_DEVICE_NAME_SET , (uint8_t *)&device_name , strlen(device_name));

 iPhone App

 The (very ugly) iPhone app picks up the advertisement packets and displays the pH and EC value.  

IMG 0044

Ugly iPhone app Running on my iPad


I used an updated BTDiscovery class library I had used in a previous prototype to receive the advertisement packets.  The swift file is BTDiscovery02072015.swift.   The BTDiscovery class includes delegates that are implemented by the View Controller (ViewController.swift) to update the pH and EC labels on the UI.  Easy Peasy.  Did I mention how much I like the Swift language?





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

Making a Prototype Board with an Other Machine

 Last Thursday was a very exciting day.  My Other Machine arrived…Oh Happy Day!!!


This is the story of how I got from here:

IMG 3373

After the dust settled:

IMG 3374

To there:

1503130146 2


I can roll my own prototype PCBs.  Ah the YIPPEE!!! moments are piling up.  FANTASTIC.

The Goal

The goal is to master making prototype PCBs on my Other Machine.  By doing so, I have added a valuable tool that will stream my design to finished product work flow.

Thanks to Those That Went Before

A HUGE thank you to Simone, the wonderful person at the other end of my endless stream of support ticket entries.  Simone is knowledgable and evolves the role of support from something that sounds like a necessary prop to what it really is – the role that makes or breaks the success of a business.  We’ll see if Other Machine Co. gets my vote as a company I fanatically hope for success for the value and happiness provided – as I do with OSH Park.  With Simone they are on the right track.  When I got frustrated Simone pulled me out with patience and spot on advice.  I also thank the creators of the Other Machine.  You have brought us a significant leap forward in our ability to prototype hardware/software efforts.

Open Source

Kicad schematic and layout files are located at this GitHub location.

My Scenario

I found out through the Ladybug Shield project that there are smaller sub-circuits that could be immediately proved out and tested.  Yes, this means there is a new schematic and layout in Kicad that needs to be done.  But on the other hand, the schematic side is simple.  Doing the layout on simplified sub-circuits is good practice in getting better laying out PCBs.

Oh yeah – I can also make PCB stencils.  There is an instructable that outlines the steps.  As the Ladybug Shield stabilizes the stencil and the reflow oven will be used more.  I tried stenciling earlier (see this post) to see what it was like.  It is definitely worthwhile if reflowing many boards.  What I just don’t understand is why the copper pads and/or the parts don’t come with sticky solder so that once they are placed they can be popped into the oven and toasted.  I mean, we have double sided tape… I assume there is a chemical reason why this is a non-starter…chemistry is fascinating but not something I have knowledge in.

There are so many reasons why I will use both the Other Mill and OSH Park.  I’ll cover this in another post.  The main reason is the quality and sophistication of the PCB layout (vias, small track widths, finishing) are far superior.

Ladybug Pump

For this effort I am creating a PCB that will talk to the Arduino running the Ladybug shield and turn on/off a pump.  In the current Ladybug Shield design, the pumps hang off one side of the Shield.  After trying out the shield, I found having both the BNC connectors for the probes and the pump cabling to be very crowded, particularly in the nutrient bath where the pumps and probes would be co-mingling.  I decided to split the pumps off the shield.  Each pump will include a small board with the circuit I use here.  The pump will have a wire running from the Ladybug shield so the Arduino controlling the shield can send pump on/off commands.  Here is an image of the schematic (kicad files available at this GitHub location):



It’s Right There on The Board

It’s simple – don’t you get it?  It’s right there on the board…

Simple Math With Cat

That “simple” statement was a defining moment in my academic career.  It happened when I went up to my professor and told him I did not understand the triple integral expression he had carefully crafted on the board.  I give him credit for being enthralled and captivated in his work.  However, I did not appreciate the annoyed look and condescending comment.

Why mention this?  Because I love learning stuff I am clueless in – particularly in the design and building of hardware and software –  and developing some level of mastery.  I arrive at this particular learning opportunity with no knowledge of its language, culture, or context.  I visit.  I learn a new language and a new skill.  I had never used a CNC machine.  I vaguely remember way (way) back in high school that when I took Home Economics and boys took metal working, there were milling machines…hmmm…but my vision was clearly focused on sugar plum cookies.

Anyways, when I first started using the Other Machine among the many oops! moments I managed to break two of the end mills:

broken End Mill

I bumbled through over 11 tries and submitted (too many to count) support tickets before I felt I had enough knowledge to feel confident I could actually create a PCB that I could populate with SMTs.

The Goal

The goal of this post is to add the Other Machine into my workflow by improving my ability to build prototype PCBs.  At the end of this post I will have gone through many trials.  Along the way, I will build and test a PCB.

The Workflow from KiCad to Other Machine Milled PCB

Loading the Gerbers and Drill File

As the web site notes in this post, Other Machine’s Otherplan software

  • can load Gerber and drill files
  • run well on my MacBook

and…wait for it…it worked!…well, good enough.  I had one challenge but it was not a showstopper.

When making plots in Kicad’s PCBNew app, I chose to plot the top copper, bottom copper, and edge cut as well as generate the drill file.


 While I could use the Other Machine to make double sided PCBs, the Ladybug Pump PCB has the circuit on the top side copper only.  So the bottom copper is not needed.  I included it because well, what the heck.  the Other Machine’s software (OtherPlan) reads it and I will probably do double sided PCBs in the future (those darn vias…).  It’s good practice to get in the habit of including the bottom copper early on.  

Kicad creates the files with the following names:


where .gbl = bottom copper, .gtl = top copper, .drl = drill file, .gbr = edge cut

Otherplan wants the file names to all be the same.  So I renamed them:


I was not able to get Otherplan to recognize the board outline (edge cut) file.  I tried renaming the .gbr to both .gko or .gm16..but the post on using Gerbers also noted:

.gtl is the top copper layer. This contains the Top, Pads, and Vias layers. It also tells Otherplan to look for the following associated files:

  • .gbl bottom copper layer. Contains the Bottom, Pads, and Vias layers.
  • .gko or .gm1-.gm16 board outline. Contains the Dimension layer.
  • .txt or .drl drills/holes. Contains the Drills and Holes layers.

I opened up LadyBugPump.gtl in a text editor but did not find any association with an outline layer…maybe that is the problem.  I do not know for sure. I forged ahead because Otherplan kindly created an outline and all the other files read in correctly.  Let me pause for a YIPPEE! moment.

Matching the Layout to the End Mills

When learning a new tool and process, my quest revolves around getting into the heads of the folks that built the tool – both hardware and software.  All of us come at a work flow from a different background with different ways of approaching getting through a process.  Given that I have never used a CNC machine before, it was logical to me the folks that built the Other Machine’s idea of an intuitive work flow in the creation of a PCB would not be initially intuitive to me.  Thanks to Simone, I now at least feel I am on the expected path.

What I needed to “get” was to think about spacing between what would become the exposed copper – the pads and tracks.  The spacing between the exposed copper parts becomes part of the layout as well as the choice of end mill(s).  When I send Gerbers to OSH Park, their constraints

  • 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


OSH Park’s minimum drill size and minimum annular ring


allow me to be very flexible and more complex in my layout.  

End Mills

I am next to clueless when it comes to picking the right end mills.  For this effort, I relied on Other Machine’s guidance:

Requires a 1/32″ or smaller end mill

  • SOT23-3 (Small-Outline Transistor)
  • SOT23-4 (Small-Outline Transistor)

Requires a 1/64″ or smaller end mill

  • 8-SOIC (Small Outline Integrated Circuit)
  • 14-SOIC (Small Outline Integrated Circuit)
  • SO-8 (Small Outline)
  • SOT23-5L (Small-Outline Transistor)
  • SOT-223-4 (Small-Outline Transistor)

Requires a 1/100″ or smaller end mill

  • SOT23-5 (Small-Outline Transistor)
  • SOT23-6 (Small-Outline Transistor)
  • TSSOP (Thin-Shrink Small Outline Package)
  • TQFP (Thin Quad Flat Package)

Not compatible

  • WLCSP (Wafer Level Chip Scale Package)
  • QFN (Quad-Flat No-Leads)
  • DFN (Dual-Flat No-Leads)
  • MSOP (Mini Small Outline Package)
  • LQFP (Low-profile Quad Flat Package)

Luckily, the “Not compatible” is above my soldering ability!

This is obvious but new to me – end mills come in all sorts of sizes and shapes.  These sites helped me get up to speed:

I had ordered the electronics bit bundle which included 2 1/32” and 2 1/64” end mills.  A challenge I had was figuring out which bit was which size.  Obviously, putting the tip under the magnifying glass would reveal the difference.  The other way (that Simone recommended) was to use a caliper.  I would have prefer the end mills to have a distinctive mark…oh, it could be something fun – similar to a pencil caps: 


that cover the cutting side of the end mills.   Besides identifying a 1/64” from a 1/32”, the caps would protect the end from breaking off. A sad moment for us, but a ca-ca-ca-chink moment for companies that sell end mills.  OK, it could be as simple as the itzy-bitzy writing on SMT resistors (although frankly, that reeks of seriousness).

Given that I will most likely be breaking more of the end mills and those that don’t will wear out, I am a bit concerned about the price of end mills.  Ah – the razor and blade business model!  Is the razor/blade model a requirement for things that shave off?

Razor And Blade

Drill bits are such a commodity that I can go to a hardware store and have a choice of high quality at a reasonable price.  End mills for us home PCB makers using a CNC machine don’t share this advantage.  Well, maybe they do but I don’t know about it.  I assume the end mills used for PCBs are used for other CNC carving efforts…

I also do not have a grasp on the features and quality of the end mill.  For example, Other Machine’s end mills range in price from $13 to $21 (link to store page).  Adafruit sells end mills for $4 (link to one of the offerings).  Why the difference?  As it was explained to me by a folk at Other Machine:

End mills go for anything from $3 to over $40+ a bit, and they are not all created equal. The ones that Adafruit carries have longer shanks, meaning they’re not meant to travel sideways. They are brittle and specifically for drilling holes. The ones we carry will last up to 2000 inches on pcb before they start to get dull. Also, we special order the 1/64th’s and 1/100th’s with shorter shanks so they will be less likely to break.

Given that the likelihood of me breaking end mills as I learn is higher, I’d probably benefit from getting Adafruit’s.  For now I will stick with Other Machine’s.  My buying habits will expand to other offerings as my skill and knowledge improve.  Perhaps asking folks what end mills they use is a good conversation question at a maker event.

Layout and Size Matter

The PCB’s layout partners with the end mill’s size to determine if there is enough spacing between the pads and tracks so that the copper areas that should not be connected are separated.

 Here is a layout I had done where the track and pads are too close together (given the end mills I had):


Pasted Image 3 13 15 8 12 AM

 Track and Pad Too Close Together With 1/64” End Mill


Here is the layout I ended up with:

Other Machine Final Layout

If I left the Otherplan software to cut this out, I end up with:


IMG 3375

I wanted to cut out the copper in the areas that do not have exposed copper so to get to this:

1503130146 2

Simone once again to the rescue.  She advised me:

  • go to Otherplan > Preferences, and click on the BitBreaker Mode box.  (yes – bit breaker – sounds like my moniker!)  Once you’ve done that, in the imported plan file window for your Gerber you will see a button called “Advanced Options”.
  • Click on “Advanced Options”, and you’ll see a line item for Trace Clearance. To make sure all your copper gets cleared, just set Trace Clearance for something huge, like 2 inches. This will get rid of pretty much all the excess copper on your board.

Keep in mind though, that depending on the tool you are using, this could take a while to cut! For example, if you have a 1/16” flat end mill selected, this will clear the big areas faster that the 1/32”. 

 That did the trick!

What’s Next

I am thrilled to add the Other Machine to my tool set.  I must say this electronics learning hobby gets expensive.  But on the other hand, it could be much worse.  I could be paying what I am for my kid’s educations :-).  

I now have multiple techniques to use to prototype circuits from break out boards on bread boards, SMT parts soldered to a SMT-to-DIP board and placed on a bread board, to the Other Mill..and finally, Osh Park.  I can see a use for each one in a continuum of prototyping needs.  

I guess that is what next, an ongoing prototyping effort that leads to useful “stuff” like the Ladybug Shield.



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

Ladybug Shield Alpha V2 – Comparison with Atlas Scientific EZO EC Stamp


, ,

And now for the exciting part….comparing EC readings between the Ladybug Shield and Atlas-Scientific’s EZO EC Stamp.  Yes, I designed the Ladybug Shield for a different use case than the EZO EC Stamp.  But I thinking of the EZO EC Stamp as a “gold standard” of Arduino EC sensors.  Also, I use an Atlas-Scientific probe so both measurements will be using the same probe.

The Goal

The goal of this post is to compare EC readings when the Atlas-Scientific EC probe (K=1) is submerged in:

  • 2000µS
  • 1413µS
calibration solutions.

Thanks to Those That Went Before

A huge thank you to Chris Gammell for mentoring and teaching his excellent Contextual Electronics courses.  A year ago I would not have dreamed I would be able to build the Ladybug Shield.  I give Chris the credit for getting the EC circuit to work in key areas – like advising to measure Vin as well as Vout.

Another giant thank you to Ryan @SparkysWidgets.  Ryan open sourced the design of the minipH and miniEC.  I absorbed and evolved these designs into the Ladybug Shield.  Ryan has been extremely helpful in my efforts.

Use a K=1 EC Prob

The protagonist of any EC measurements is the probe.

Conductivity probes that I am aware of have these dimensions:


Probes may vary in the distance between the electrodes.   EC = (the distance between electrodes/area of an electrode plate) * conductance.  The distance between electrodes/area of the electrode plate is known more commonly as the K constant, or just K. A probe with K=1 has 1cm distance between electrodes with 1 cm squared area of electrode plate.  I started with a probe with a K=.1. I figured a shorter distance between the plates would amplify the incoming signal and therefore get better readings.  I found however the design of the Ladybug Shield’s EC circuit was better suited for a K=1 probe.

Here is an image of the EC Vout when K=.1:


The gain loop is amplified to the point where the peaks are chopped.

Here is an image when K=1:



 My probe has a K of .1/cm -> .1cm distance between electrodes/1 cm squared area = .1/cm.  Since the electrodes are closer together, the probe can be used in lower conductivity solutions than a probe where the K=1.  Until I know better, a probe with either K=1 or K = .1 should work.

Tables for EC values of vegetables have a nasty habit of leaving off the distance, assuming the probe has a K of 1.  For example, a page that lists EC values for vegetables notes: Electro-Conductivity (EC) or Conductivity Factor (cF) can be expressed as… milliSiemens (mS).  This is true if K = 1.  When K = .1, EC = K *conductance. The table lists the EC value for lettuce to range from .8 to 1.2mS.  When K = .1, EC = .1*.8 to .1*1.2 = .08 to .12mS


The Ladybug Shield and the A-S EZO EC Stamp used the same K=1 EC probe.



The table below shows the µS value for the EZO and Ladybug Shield when the EC probe is in a 2000µS and then 1413µS calibrated solution:

Calibrated Solution Ladybug % difference EZO % difference
2000 2059 2.91 1875 8.42
1413 1388 1.79 1254 15.68

The results seem too good to be true.  The Ladybug results were very close to the calibrated solution value.  Talk about a YIPPEE! moment….

The biggest change in the Ladybug shield to get better results was the reading of Vin (the shrunken signal generated through the Wien Bridge Oscillator).  As I noted earlier, Since both the Vin and Vout are key variables in calculating the Gain – it makes sense to measure both.

Ladybug Calculations

In the case of the 2000 µS calibrated solution, Vin = 239mV  Vout = 731mV.   Gain = 731/239 = 3.058577406. R = 1000/(3.058577406-1) = 485.77235769 Ω EC = 1/485.77235769 = .002058577 S = 2059µS.

In the 1413µS solution, Vin = 237mV Vout = 731mV  Gain = 566/237 = 2.388185654 = R = 1000/(1.388185654-1) = 720.364741646Ω EC =  1/720.364741646 = .001388186 S = 1388µS.

That’s It For Now

The EC circuit appears to be working.  A Definite YIPPEE! moment.  



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

Ladybug Shield – A Better Understanding of The Interaction Between the MUX and FET


I recently modified the EC circuit to read both Vin and Vout of the EC gain loop.  This way the Ladybug Shield would provide the closest readings for the Gain (Vout/Vin).  Once the gain is known, the resistance of the EC probe in the nutrient bath can be measured.  Once the probe’s resistance is known it is a small skip to calculate the Conductivity of the nutrient bath.

Thanks To Those That Went Before

  • Chris Gammell advised me on how to think about and debug this challenge.  Chris is an excellent teacher/mentor.  I have learned A LOT from his Contextual Electronics courses and his mentorship.  THANK YOU.
  • Ryan (SparkysWidgets) open sourced the minipH and miniEC.  This effort has allowed me to gain a jump start in my understanding of the electronics behind pH and EC circuits.  Besides that, Ryan is an exceptionally smart, kind person who readily shares his knowledge and has provided me with excellent advice.  THANK YOU.
  • Laen and the people/company at OshPark.  I have become an advocate of OshPark.  They are a model of the most excellent service/support providing quality product at a reasonable price and turn around time.  THANK YOU.

Open Source

The kicad schematic and layout are located at this GitHub location.  The schematic to view for this post is the Rectifier schematic.

I recently started measuring both Vin and Vout of the EC gain loop.  


The Challenge

For weeks I have been poking at really understanding why I am seeing readings from the ADC start high and eventually drift down to the right value when these events occurred:

  • switch MUX to take Vout readings
  • turn FET on for around 4 ms to drain the capacitor
  • switch MUX to take Vin readings

Challenge 1: Start high, Go low

Vin readings start out high (say around 900mV) and eventually (after hundreds – say 2000 readings) stabilize at an expected value (say around 250mV).

I stumbled around mumbling what I thought was going on.  The problem was I didn’t have “the smoking gun.”  I didn’t have proof of what was going on until….until…I gained a better understanding of how to use a scope!

Chris advised me what to look for:

On channel 1, monitor the gate voltage of the FET.On channel 2, monitor the input to the buffer (the output from the rectifier circuit).
If you trigger on channel 1 going high, you can see the behavior the FET is causing (hopefully draining the cap). 

(RIGHT THERE – the cost of Contextual Electronics paid off !)

Ah yes…just like any great detective knows…figuring stuff out is about figuring out what to look for and then finding it.

After figuring out the difference between “Auto” “Normal” and “Single” triggering I realized what I wanted was to set my scope on Normal triggering.  Personally, I found (find?) how triggering works confusing at first.  But well worth learning :-).

And look at that:

FET Trigger HIGH

The blue line follows the FET as it transitions from OFF (low) to ON (high).  When the FET is on, the cap is discharging.  The yellow line starts reading the rectified Vout and then switches to Vin at about the time the FET is set to HIGH.  It turns out the cap discharges in about 25µS.  With the FET on HIGH, the cap is kept discharged.  

I then set a trigger to happen when the FET went to LOW using an Arduino sketch that executed one after each other:



The scope showed the capacitor was fully discharged within the time it took the Arduino sketch to execute the digitalWrites():


Given the small amount of time it takes to discharge the cap, a digitalWrite(FET,HIGH) immediately followed by a digitalWrite(FET,LOW) gives more than enough time to discharge the cap (about 80µS for the code to execute while it takes about 25µS for the cap to discharge).

Challenge 2: Settling Down

Another challenge I was facing with ADC readings was slightly higher readings right after turning the FET OFF.  So I took another scope measurement.  This time I ran an Arduino Sketch that:

byte S = HIGH;
Serial.println(“send VOUT for 1 seconds”);
S = LOW;
Serial.println(“Switch to VIN”);
//turn FET on and off to discharge the capacitor
Serial.println(“FET ON”);
Serial.println(“FET OFF”);
Serial.println(“send VIN for 6 seconds”);



The focus is on the reading for Vin between the two readings for Vout.  When the MUX switches to VIN, it takes about 3 seconds for VIN to stabilize.  I’ll add a delay(300); after switching to Vin and discharging the cap.


That’s It

What this post is about for me is a better understanding of how to use a scope to get a better peek into what is going on within the innards of the analog part of the circuit.  WHOA!  I am excited to have learned this…hopefully I will start applying my new found debugging/viewing skills and shorten my bumblings when it comes to  debugging what is a mysterious world for me – the analog circuit…


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


Ladybug Shield Alpha V2 – Testing the pH



Spoiler alert…wait for it…the pH circuit works!  Talk about exciting.  I truly enjoy learning all the skills and different disciplines that goes into building a working pH sensor…math, science, electronics, designing, laying out, and building a PCB, writing the software,..and most importantly – the people I learn from along the way.

Ladybug Shield V2

Here it is – a thing of beauty – a fully populated Ladybug Shield Alpha V2 hooked into an Arduino:

IMG 3326


I got to use my Zallus controlled reflow oven.  I really like the Zallus (toaster) oven controller.  Heck, I really like the idea of popping a PCB in a toaster oven after carefully placing soldering past and SMT parts.  It is so Easy Bake Oven…I can’t help but smile.

The Goal

The goal of this post is to compare the results of pH circuit tests of the Ladybug Shield with those from an Atlas-Scientific EZO pH stamp.

Thanks to Those That Went Before

Thanks to Chris Gammell and his Contextual Electronics courses I was able to get to this point where I have pretty much finished the firmware and hardware design for the pH portion of the Ladybug shield.

Thanks to Ryan @SparkysWidgets for embracing/helping us followers of his minipH open source product and project.  I find it amazing to learn so much from all that he has shared.  My hope is this effort is a positive contribution to the minipH effort.

Open Source

I will be discussing the contents of the Arduino sketches available at this GitHub location.


pH probes lose their vitality over time and eventually need to be replaced.  In the mean time, the slope of the line mapping pH mV to pH value needs to be calibrated.


I use 2 points to determine the slope of the pH mV/pH value line.  The two points come from reading the pH when the probe is in pH 4 and pH 7 calibrated solutions.  The step between pH values for an ideal probe is 59.16mV.

The calibration sketch I used is located at this GitHub location.

When the probe was in pH 4 calibration solution, the reading was 155mV averaged over 11,551 samples with a standard deviation of .49.  When the probe was in pH 7, the reading was -29mV averaged over 3,859 samples with a standard deviation of .40.  

I felt the variability between readings to be smaller than expected.  I don’t have a sound reasoning other than I expected more noise between samples. Maybe < 1standard deviation is what is expected.  The results were expected.

The pH slope = y/x = (155 – -29)/(7-4) = 61.33.

Now when pH values are calculated, a step value of 61.33mV will be used instead of 59.16mV.

Read pH

See the calcpH() function in the Arduino sketch.

(note: I evolved this part from Ryan – SparkysWidgets – minipH.ino.  Thanks Ryan!).   Converting the mV value from the ADC into a pH value involves two steps:

  • compensate for the offset of the pH 7 mV reading of the probe from the ideal of 0 mV
  • figure out how many steps away the mV reading is from pH 7.
Since figuring out how many steps away the mV value is from pH 7 assumes the ideal pH 7 = 0mV, start with adjusting the mV value to compensate for the pH 7 mV value.  From calibration, the mV value for pH 7 for the probe I used was -29mV.
When I put the probe into pH 4 calibration solution – this time to read the pH and not calibrate – the mV reading from the ADC was 153mV.  Given the offset, the mV value when pH 7 mV = 0 is 153 – -29 = 153 + 29 = 182.  Calibration provided the probe’s step value at 61.33mV.  The pH value of a 153mV reading given this probe = 7 – 182/61.33 = 4.03.  Wow!  That’s a darn good measurement.

Compare with Atlas-Scientific EZO pH Stamp

 I had an older Atlas-Scientific pH Stamp so I purchased the EZO pH Stamp.  I have to say I am very impressed with it.  With the older pH stamp I had to send a command several times to make sure it pH Stamp reacted.  This was not a challenge with the EZO ph Stamp.  Unpacking the EZO and first use is a pleasurable experience that requires no additional electronic knowledge.  In short, if you want a “high” quality pH sensor that works with an Arduino, the EZO is worth a look.

I compared the readings from the EZO pH Stamp with the Ladybug Shield for two solutions:

  • White distilled vinegar
  • Baking soda added to filtered water
  EZO Ladybug % difference
Vinegar 2.56 2.67 4.21
Baking Soda 7.94 7.85 1.14
The difference in readings is acceptable.

What’s Next

Work on the pH measurement circuit and firmware is almost done.  I have learned a lot as I traveled this journey.  From the science and math behind a pH measurement to the electronics used to detect a voltage that can then be interpreted in a pH value.  I got a lot of help from folks like Chris Gammell and Ryan @SparkysWidgets.

I haven’t added temperature adjustment.  I’ll do this in an upcoming post.


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


A Lettuce LED System – Part 2: The Constant Current Source


In my previous setup I used an LED driver, the LDD-1000H to provide 1A constant current to a series of LEDs.  Armed with knowledge gained from the latest Contextual Electronics course, I have the confidence to build a constant current source to up to 1A to the red and blue LEDs I discussed in the previous post, 

The Goal

The goal of this post is to design a circuit to provide a constant 1A current to the red and blue LEDs.

Thanks to Those That Went Before

Thanks to Chris Gammell for his Contextual Electronics course and mentoring.  Chris walked us through designing a current sink which was easy for me to see how I could modify the design to act as a current source for the two LEDs used in this project.  It was an achievement for me to take his design and evolve it into an LED current driver.

I found these two videos:

gave me a better understanding of how to think about heat transfer when watts of power need to be dissipated.

Open Source

The LTSpice IV circuit model that is discussed below is located at this GitHub location (LEDCurrentDriver.asc).

The Kicad schematic is located at this GitHub location.

Constant Current

While it is fine to use a resistor in order not to burn out one of these type of LEDs:


more powerful LEDs – like the ones used to grow plants – require a constant current.  Up until now, I have been relying on the LDD-1000H LED driver (data sheet):


Simple to use, it can drive up to 16 3W LEDs and has a PWM dimming.  However, the challenge with the dimming is it is all or nothing. Either all the LEDs are dimmed or none are.

Circuit Design

It seemed to me the power supply tester circuit we are designing in Contextual Electronics is pretty close to what is needed to provide a constant current to the royal blue and red LEDs. I discussed the project in an earlier post.

Chris has us early on in a design using LTSpice as a way to model a circuit.  Here is the model circuit I came up with in LTSpice:



I kept the design of the power tester Chris had us working on – the beautifully simple current sink that feeds a  “programmable voltage” into the non-inverting input of an op amp.  Because the op amp is configured as a voltage follower and Vin+ = Vin-, the output voltage controls how much current the MOSFET lets flow through its gate.  Given a known resistor – R1 in the image – and a known programmable voltage – V2 in the image – the current can be adjusted to a range of constant current values. 

Voltage Drop


Here is a graph of the voltage drop across the XP-E2 red LED:


The first thing it points out is how much more efficient red LEDs are to the other colors.  The voltage drop at 1A is ~ 2.65V.

Royal Blue LED

The XT-E2’s voltage drop for the royal blue:


shows the voltage drop at 1A to be ~3.25V.


When the current is at 1A, the voltage drop is tiny .1V.


The voltage drop across the MOSFET is what is left over.  Assuming 9V Wall Wart, the voltage drop across the MOSFET is 3V (9-3.25-2.65-.1)


The schematic differs from the LTSpice IV model by adding a voltage regulator and a POT:

LED Schematic

Varying the Constant Current

The amount of constant current is controlled by adjusting the voltage into the non-inverting op amp.  The load resistor = .1Ω.  When the current = 1A, the voltage = .1V (V=IR).  I’ll use a potentiometer (POT) to adjust Vin+ to the op amp (R2 in the diagram):

Pasted Image 2 21 15 2 44 AM

as the bottom leg of a voltage divider to supply 0 to .1V to the non-inverting op amp.  The top of the voltage divider (Vin) is 5V.  I want Vout to range from 0 to .1 V. The ratio (Vout/Vin) is 1/50.  I already have a POT that goes from 0 – 5K that I’d like to use.  Vout = Vin(R2/R1+R2) -> .1 =  -> 1/50 = R2/R2+R1 -> 50R2 = R2 +R1 R1 = 49R2 => R2 = 5K, R1 = 49*5000 = 245K.  Checking the math:  .1V = 5(5K/245K+5K) -> .1V = 5(5/250) = 5/50 = 1/10 = .1V.

In order for R2 to go from 0 – 5K, R1 = 245KΩ.

Picking Parts


In our Contextual Electronics course, Chris walked us through finding an N-Channel MOSFET based on:

  • Price
  • Package – TO-220 DPAK – very common for power MOSFETS.
  • SOA (Safe Operating Area) – the maximum power the MOSFET can dissipate.
  • RDS(ON) – the resistance from drain to source when enough voltage is applied to the MOSFET’s gate such that current is fully flowing.  Note: While knowing the RDS(ON) is useful, I didn’t end up using it directly since the value is taken into account by the SOA graph.
  • a VGS(th) of no more than 5V to allow 1A of current to flow.  This means a Logic Level MOSFET.  There is range from where a MOSFET starts turning on the current to when the current is fully flowing.
DigiKey Filters:
  • N-Channel MOSFET
  • buy at quantities of 1
  • Logic Level Gate
  • all the TO-220 packages
Sorting by price, the first one in the list from NXP Semiconductors (dd) can handle 41W.  The data sheet includes the SOA graph:
Pasted Image 2 24 15 4 33 AM
This MOSFET will be fine for the continuous 1A of drain current with a voltage drop of 3V (3W) 
  • Power >= 6V

Heat Sink

I found an inexpensive TO-220 heat sink on digikey To see if this heat sink would work, I followed the formula Bil Herd went over in his video about heat sinks:


I’ll start with the same ambient temperature (38˚C).  Next add the thermal resistance * 3W (amount of power needed to be dissipated).  The listing on digikey shows the thermal resistance to be 24˚C/W.  3 * 24 = 72˚C.  I’m skipping the thermal resistance of case to sink.  The junction to case of the NXP MOSFET (data sheet).  Shows a typical JC thermal resistance to be 3.1˚C/W (note: While 0˚C = 273.15˚K, 1C up/down = 1K up/down so 3K = 3C heat up for each watt).  Rounding to 3˚C/W, 3*3 = 9˚C.  Adding this up:

38+72+9=119˚C.  The data sheet states the maximum rating for this MOSFET is 175˚C.  This heat sink should work.


Looking back at the LTSpice IV simulation, I = V/R, I = .1/.1 = 1.  The resistor’s value is .1Ω.  The amount of power burned is P = IV = 1*.1 = .1W.  We need a resistor that is .1Ω and can withstand burning at least .1W.  .1W is not that high so I am choosing an inexpensive SMT 0805 package resistor (digikey link).  I like to use 0805 sized caps and resistors.

Op Amp

 I will use an MCP6241 for the op amp because I have some in stock.  According to the data sheet, the positive voltage rail can go up to 5.5V.  Other characteristics are not that important.

Voltage Regulator

I need a voltage regulator that takes 9V as input and outputs 6V.  The voltage regulator I use in the Ladybug shield should work fine.  I use a 7805 sot-89 packaged voltage regulator (data sheet).

What’s Next

I’m off to order parts so that I can build a prototype.  Thanks for reading this far.  Please find many things to smile about.


A Lettuce LED Light System – part 1: the LEDs



I showed my current hydro lettuce setup in a previous post. I want to explore setting up the optimal LED setup for growing just one leafy plant.  My current setup can hold up to 9 plants.  Most setups I have seen wish to accommodate many more than 9.  I’m interested in starting with one and adding as needs expand.  Is there an effective and efficient way to build an LED setup for leafy plants in which it starts with one and then incrementally adds on more?

In this post I explore part 1 of building an LED setup for one lettuce plant. – the LEDs.  Once I am able to test it out, I will consider a future effort that connects single LED systems together to support more lettuce plants.

The Goal

The goal of this post is to review the circuit design of a single LED setup for growing lettuce.

Let There Be Light

Blue And Red

There are several lighting technologies that I could choose from.  I choose LEDs because they are effective, efficient, becoming more and more affordable, and researched.  My current design uses a white and red LED.  For this LED setup I will use blue and red LED lights.  Blue and red lighting is known to be effective for enhancing photosynthesis.

The photosynthesis process of leafy plants respond to blue and red light at the following wavelengths:


My LED choice will be based on the wavelengths:

  • Blue: around 430-455nm range
  • Red: around 635-640nm range
I will use LEDs that are close to these wavelengths if they are good quality and easy to obtain. 

Manufacturer And Part

I chose Cree LEDs because I wanted to start with “the best” to avoid variances in results because of lower quality.


For red I will be using what I already have, the XP-E2 3w red LED (data sheet).  Since the XP-E2 comes in a variety of wavelengths, the image below shows the red along with the other LED offerings:

Red Wavelength
The red wavelength is slightly lower than idea at a little more than 630nm, but close enough.


I will be using the royal blue XT-E2 LED:
The royal blue wavelength seems to be within the ideal range.


I chose to buy in quantities of 6 from (links red and royal blue).  I have been happy with previous purchases.  While I haven’t done much research at this point on sourcing, I assume the prices paid are at the high end.  Since this is testing I am opting for time, quality, and piece of mind.

That’s it for now.  Thanks for reading this far.  Please find many things to smile about. 

Is it OK to Leave a pH Probe in the Nutrient Bath?


I was blessed to get some great questions as a result of the post I made about my latest hydro lettuce station.  I am learning as I try things out and through getting great questions and feedback like the one from gotbock.

gotbock’s question::

post replyMy Hydro setup



from gotbock via /r/hydro/ sent 5 hours ago

Do you know if you’re pH and EC probes are designed to be held in your nutrient solution for long time periods? Most meters I’ve used require at least the pH probe to be stored under storage solution (usually saturated KCl) when not in use to maintain the probe. Otherwise they will go out of calibration pretty fast.


After researching, I came across this article which helped me better understand the why of gotbock’s point and what I would do differently given the probe stays in a nutrient solution.


The article notes that if the glass membrane is kept in a solution that has plenty of sodium and potassium ions (which a nutrient solution would), these ions will penetrate the membrane along with the hydrogen ions. Now instead of measuring H+, the probe provides measurements of Na+ and K+…so the pH readings are off as you point out. The ions that are a key part of the nutrients will adhere to the glass and off go the readings.

As gotbock notes, the best way to prevent this is to clean off the glass membrane with distilled water and then store in a storage solution.

I have not done enough testing to understand the practical challenge (how inaccurate) the readings will be. Especially since I am monitoring for a range of readings. For example, I’m growing lettuce so I want the pH value to be between 5.5 and 6.5.

I would agree calibration would have to be done more often. I don’t know how much more often. Once I automate this process with the Ladybug Shield, I can choose to calibrate daily/weekly, etc. with the goal of minimizing this challenge.


Learnings from Contextual Electronics: Testing a Power Source


Contextual Electronics has started up and I’m already behind.  Chris decided to get our learning juices flowing by starting with a power source tester.  This is terrific for me since I have been assuming available power to “just work.”  

I find it is very hard for me to follow along with someone’s circuit design unless I have a pretty good grasp of what led to the thought process. It is typical for me to totally miss the point – or valuable insights – at the beginning of a project.  I understand best if I am able to treat each component in the circuit as a character in a story.  The challenge is to understand the motivations and role the character/component plays. This post is my attempt to provide my learning techniques in order to clarify any misconceptions I have regarding the power source tester circuit Chris is helping us build.

My focus has been on measuring voltage.  After all, measuring small changes in voltage is what provides insight into reactions happening in the environment.  In the case of the Ladybug Shield, measuring the change in voltage is how to figure out the pH and/or EC of a nutrient bath – necessary for the healthy growth of hydroponically grown plants. 

The need to characterize a power supply becomes clear when using batteries.  If the Ladybug shield was powered by batteries, how long can it run before the batteries need to be replaced?  How efficiently does the Ladybug shield use the battery?

To answer these questions, Chris is having us build a power supply tester.  Dave Jones’ EEVBlog #102 describes this circuit:


I can see the brilliant simplicity of this design (after :-)) Dave and Chris explain it.  A POT is hooked up to a +5V voltage source.  This is fed into Vin+ of an op amp.  The “golden rule” of op amps always applies – the op amp will do whatever it can to get Vin- to = Vin+.  Now the excitement begins.  Set up the the op amp as a voltage follower.  If 1V goes into Vin+, 1V will follow back into the op amp through Vin-.  The MOSFET controls the flow (current) since a MOSFET’s output current is controlled by the voltage at the input.  By inserting a 1Ω resistor, a constant current sink serves to flush the energy out of the power source (I noted a battery in the picture but this could be any voltage source like a DC-DC converter).

Dave has a plot that I found extremely helpful:


The Y-Axis is the amount of voltage applied to the MOSFET’s gate.  The gate stays shut until the voltage is at least 1.5V. As the voltage is increased on the gate, the MOSFET starts to let current through.  Since the current sink resistor is 1Ω and V=IR where R=1, V = I – so the X-Axis can be interpreted as the amount of constant current at a given Vin+ provided by the dummy load.

Now the question of what does a given load do on the capacity or other characteristics of a power source?  Can be measured.

OK, so all of this was obvious to you.  It wasn’t to me.  That’s one of the things I enjoy about Chris’s style.  These are useful circuits that use common components in ways that bring out the key characteristics of the components.  The circuits tell a story with characters – whose characteristics like the op amp’s golden rules or the MOSFET’s ability to act like a variable resistor to current flow – are pivotal in telling the story.

On to catching up with more of the design and what parts to use!

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


Get every new post delivered to your Inbox.