bitknitting

~ Stuff I Learned About Tech+Hydroponics

bitknitting

Category Archives: pH

Introducing the Ladybug Plant Food Adjuster

05 Tuesday May 2015

Posted by bitknitting in EC, Herbs, Hydroponics, Ladybug Plant Food Adjuster, Ladybug Shield, pH

≈ 4 Comments

Tags

EC, Ladybug Plant Food Adjuster, Ladybug Shield, pH

I’ve put the Ladybug Shield together with other hardware and software to implement a kitchen farmer plant food adjuster.  For now I am calling this the “Ladybug Plant Food Adjuster.”  I am currently testing/using it in my home.

The home farmer will be growing lettuce, herbs, tomatoes… within their home,  likely the kitchen.  This is in contrast to the more expert hobby or professional that has “industrial capable” pH, EC – and other probes, honking LEDs,…i.e.: knows A LOT about growing vegetables and herbs and needs super fine control of plant food adjustment.

Thanks to Those That Went Before

It is difficult for me to imagine being able to build the Ladybug Shield (see previous posts) without Chris Gammell and Ryan (@SparkysWidgets).

  • Chris Gammell runs the exceptional Contextual Electronics courses.  While I pay for the privelege, it is indeed a priviledge to feel and be treated like an apprentice.  Besides shear learning in a supportive and peer environment, Chris’s 1:1 time has been valuable/insightful/amazing in shaping the design of the electronics of the Ladybug Shield.
  • Ryan open sourced his minipH and miniEC stamps.  I poured over Ryan’s design until I understood them.  I had no idea how a pH or EC meter worked.  Ryan’s work significantly simplified what I needed to learn and my approach.  ON TOP OF THAT, Ryan is a truly great and very helpful person.  Please support Ryan!
While there are many great companies, two have made a HUGE POSITIVE impact on this project:
  • OSH Park the most excellent producers of low volume (purple!) PCBs.  OSH Park has the most amazing support and personal service.  From the CEO (Laen) to the support person who took his efforts in helping me out to the next level (Dan) – if I must part with my money, there is no better company/service/group of folks.
  • Adafruit, providers of breadboards, all sorts of circuit creation “thingies” that are too cool not to buy, exceptional tutorials, libraries for chips (like the ADS1015 ADC I used on the Ladybug Shield) that work within the Arduino IDE, and terrific support on their forums.  EVERY post I have made has got a valuable response.  What a great company.  
Then there are podcasts, videos, and a slew of web pages that have willingly shared their knowledge.  A particular shout out goes to Elicia White, co-host of the Embedded.fm podcast.  She wrote a blog post on a question I asked that was very useful for me.  Now – there have been many more.  Elicia’s insightful answer is the most recent.

What The Ladybug Plant Food Adjuster Does

The Ladybug Plant Food Adjuster automatically adjusts the nutrient and pH level of a reservoir of water (the hydro part) feeding growing plants.  It is for people like me that enjoy fresh vegetables and herbs.  We have many reasons to supplement what we buy with what we grow in our kitchen.  While I garden both indoors and out, I live in an environment that does not support growing vegetables and herbs year round.  Besides, in the winter it is rainy and cold.  During the winter I don’t want to spend time in an outdoor garden but love being surrounded by healthy growing plants in my kitchen.

The Components

The Ladybug plant food adjuster consists of:

Ladybug plant food adjuster

  • The probe box:
    •  measures the pH and EC values in the reservoir of water being used to feed the plants.
    • communicates with the iPhone app (using BLE 4.0) updating the app with pH and EC measurements.  The iPhone app controls the probe box by setting what type and stage the plant is in (in the diagram above, the type of plant is tomato and the stage is Youth.  The type and stage set the values for the set points which will be used by the pumps to figure out if they are far enough away from the set point to add a dose of either pH adjustment or EC concentration).
    • communicates with the pumps (using wires) to turn on either the pH or nutrient pump if the readings are off too much from the set points.  It knows to add nutrients before pH adjustment since additional nutrients will change the pH level.  This is an example of “working smart for you.”
  • The pump box:
    • contains a pump to add nutrients and a pump to adjust the pH level.  It is controlled by the probe box (the “brains”)
  • The iPhone app (is currently really really ugly…but works on my iPhone and iPad.  The goal is to be functional for testing.  Design will follow function):
    • connects to the probe using BLE 4.0
    • gets info from the probe on what it is monitoring (plant type and stage) and whether the pumps are currently allowed to be pumping or should be off (regardless of the pH and nutrient level in the reservoir).  It uses this info to update the display
    • lets the grower set the name of the plant as well as the plant type and stage.
    • displays the most recent readings for pH and EC as well as the set points.  This way the grower can see if current measurements need to be adjusted
    • informs the probe whether to turn off or on pumping.  If pumping is turned off, the probe will not tell the pumps to turn on even if the measurements need adjustment.
    • lets the grower export then email the readings into a CSV file.

The Ladybug Plant Food Adjuster Hardware

Hardware includes an iPhone/iPad as well as the probe box and the pump box.

The Probe Box

Inside the probe box is an Arduino Uno with a Red Bear BLE shield and Ladybug shield attached to it.

IMG 3430

The schematics and layout (Kicad) are located at this GitHub repository.  Designing and implementing the shield was my way to learn electronics, making a PCB, the math / science / electronic design of pH and EC sensors.  It was – and continues to be – a very positive experience!   Please see the many earlier posts I have done detailing what I learned/what I ended up implementing and why.

IMG 3434

A pH and EC probe are attached to the Ladybug shield using the BNC connectors.

The back end has holes carved out for:

  • cable to 12V wall wart.  A 12V Wall wart powers both the pumps as well as the Arduino
  • the USB cable used by the Arduino.  This is optional.  I use it while debugging to print out to the serial monitor.
  • the wires that attach to each pump.

The Pump Box

The pump box contains two peristaltic pumps, one for adjusting the pH level and the other to adjust the nutrient level.  

IMG 3433

Wires – originating from the Probe Box connect the pumps to the Probe.  The Ladybug Shield uses the 12V wall wart to power the pumps.

How the Ladybug Plant Food Adjuster works

At the core of the Ladybug Plant Food Adjuster is the reservoir containing water with the nutrients set at the right pH level.  We start with a bucket.  It can be any bucket.  For now I’m using Rubbermaid.

IMG 3443

 

One of the Rubbermaid Buckets I Use

 But I have bought much nicer looking reservoir/hydro systems.

IMG 3442

Nicer Looking Bucket Growing Basil on Kitchen Counter

 

 My goal is to evolve into happy designs that please the grower.  Right now I am at the “Frankenstein” phase.   While single plant setups are “easy”, each would take its own Ladybug Plant Food Adjuster.  I will start using the Adjuster to grow about 6-12 heads of lettuce.  

I fill the bucket up with filtered water.  The less minerals/salts the better since the amount of nutrients is a measurement of the conductivity of the salts in the water (discussed perhaps more than you wish in previous posts).

I add an air stone to increase the amount of dissolved oxygen.  After all, plants need to breathe.  

Next, I attach a pH and EC probe to the Probe box and place the probes into the filtered water.

It’s time to mix up the pH and nutrient concentrations that the Pump Box will add to the filtered water until the EC and pH values are at healthy levels for the plant type and stage (of life).

Plant Food

I’ll use the term “plant food” when referring to the nutrient concentration.  Once the plant food is available for pumping, the Ladybug Plant Food iPhone app sets the recommended levels for the pH and EC.  The (yah – I know – extremely ugly…) setup screen of the iPhone app uses a UIPickerView to let the grower tell the Ladybug Plant Food Adjuster what type and stage the plant(s).

Ladybug app settings screen

The Settings Display of the iPhone app

  The image shows “Tomato/Youth” – this tells the Adjuster what the pH and EC levels should be.

As an example, here is my tomato/youth plant I am growing.  We call it/him/her? Tommy.

IMG 3440

Tommy Doesn’t Know What Day it is

What the “right” food is to feed a plant is based not only on scientific reasoning  but also what works best for you and how much you are willing to pay.  I started off using liquid fertilizers like the one I linked to from Amazon (if you click on the link and buy something I get an Associates fee – what the heck, that’s why this ad prominently placed below): 

//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ss&ref=ss_til&ad_type=product_link&tracking_id=bitknittingwo-20&marketplace=amazon&region=US&placement=B0024NDVRA&asins=B0024NDVRA&linkId=KVTIJMSR3MCUUE3Q&show_border=true&link_opens_in_new_window=true

As my knowledge evolved, I started using the product and advice from Hydro-Gardens.  The site has information on food and additional chemical compounds as well as the amount for several vegetables.  For example, here is the “recipe” for growing tomatoes.  I got the dry ingredients and then mix up the amounts for whatever it is I am growing.

IMG 3441

Dry Ingredients I Mix together to Feed a Young Tomato Plant

Now that I have the mix I need for growing a young tomato, I put many (I put around 5) scoops into the container and fill the container with filtered water.  The pump’s nutrient feeder hose is stuck into the plant food.

IMG 3444

 

The Plant Food Container 

I will stick the nutrient feeder hose into.  It is challenging for me to get all the particles mixed well. I’ve tried integrating mixing into an exercise routine.  At some point I need to think of “best ways” to mix the plant food.  I’d also like a better suited container.  I had just finished the contents of a salsa container so it became the plant food container – at least for now.

pH

The Ladybug app knows to adjust the nutrient level before adjusting the pH.  The additional nutrients will change the pH of the water.  Once the nutrient level has been reached, the Probe goes through adjusting the pH level.  In all cases that I have come across, the pH of the water needs to be adjusted down.  This is why I use only one pH dosing container.  Which also happened to have held salsa…hmmm…too much salsa?  Nah…never…

IMG 3445

the pH concentrate is about a tablespoon of pH DOWN with water.  The concentration of Hydronium ions – which is what is being added to lower the pH level – is very intense.  This is why I dilute from pH down.

There’s an App for That

I decided to talk to the reservoir through an iPhone app.  I use the iPhone and have a developer’s license.  The app uses Apple’s Core Bluetooth framework to talk via BLE 4 to the Probe Box.  The probe box sends whomever it is connected to (in this case my iPhone running the Ladybug app) updated measurements as well as the ability to turn pumping on/off as well as select the plant type and stage.  I envision in most cases leaving the pump state on and letting the Probe Box determine if more dosing is needed.

Ladybug app home screen

 Settings were discussed earlier – see the settings screen shot.

I wanted to evaluate the data so I added the ability to export and then send what has currently been logged in a data base.  I then use a spreadsheet program to take a step back and see how well feedback and adjustments are going.

That’s it.  The app has two screens.  

What’s Next

It is hard to describe the sense of joy I have coming this far.  I’m setting up a reservoir for 6-12 lettuce.  I’m off to get that going and to plant lettuce seeds.

 

 

THANK YOU for reading this far.

Please find many things to smile about.

Advertisements

Share this:

  • Twitter
  • Facebook
  • Reddit
  • Google
  • Email
  • Pinterest

Like this:

Like Loading...

Getting pH readings on my iPhone from the Ladybug Shield

23 Monday Mar 2015

Posted by bitknitting in BTLE, Ladybug Shield, pH

≈ Leave a comment

Tags

BTLE, ios, iphone, Ladybug Shield, pH

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.

 

BLEPacketFormat

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:
setnrf8001bcastdata

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: ");
    DEBUG_PRINTLN(pH_value);
    uint16_t EC_value = takeECReading();
    DEBUG_PRINTF("--> EC: ");
    DEBUG_PRINTLN(EC_value); 
    setBLEAdvertisementName(pH_value,EC_value);   
    DEBUG_PRINTLNF("Wait before taking another reading...");
    delay(10000); //take a break
  }
  ble_do_events();
}

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.

Share this:

  • Twitter
  • Facebook
  • Reddit
  • Google
  • Email
  • Pinterest

Like this:

Like Loading...

Ladybug Shield Alpha V2 – Testing the pH

26 Thursday Feb 2015

Posted by bitknitting in Ladybug Shield, pH

≈ Leave a comment

Tags

Ladybug Shield, 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.

Calibrate

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.

IdealpHProbeOutput

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.

 

Share this:

  • Twitter
  • Facebook
  • Reddit
  • Google
  • Email
  • Pinterest

Like this:

Like Loading...

Testing Temperature Readings – Ladybug Shield Alpha 1

17 Saturday Jan 2015

Posted by bitknitting in Arduino, Ladybug Shield, pH

≈ 3 Comments

Tags

arduino, Ladybug Shield, pH

On to testing the temperature.

Open Source

I am using the Ladybug Shield Alpha 1 board created from the kicad files located at this GitHub repository. The Arduino Sketch I used during test is located here.

Thanks to Those That Went Before

Adafruit provides great tutorials.  I used their thermistor tutorials for this effort.

Thanks to Gerald Rectenwald for his excellent class notes on thermistors.  They were easy to read and useful.

As always – a huge thank you to Chris Gammell.  His Contextual Electronics and additional guidance has made it possible for me to even attempt this effort.

Testing the Thermistor

As noted in an earlier post,  the pH value will vary depending on the temperature.  The Ladybug Shield includes a thermistor circuit.  I detailed the thermistor circuit in this post.  I really like this circuit because it is a nice example of yet another use for a voltage divider.  Recall from this post:

CalculatingRTherm

The goal is to figure out the resistance of the thermistor – Rt.

Design

The circuit design for the thermistor is very simple.  

 

Thermistor Circuit

I labeled the known resistor (R15) on the schematic to be 1K +/- .5% Ω.  The resistor should be 10K since the thermistor’s rated resistance is 10K.  The 1K is a remnant of when I was using the MCP3901 for the ADC.

The voltage drop – Therm_AIN – is the input to the ADC.

Getting the Temperature

 

The schematic of the ADC shows the thermistor is measured off of channel AIN2 of the ADS1015.

PinsForECOnADCLadybugShieldAlpha1

 

 Arduino Sketch

The goal is to find Rt (the value for the thermistor which is acting as a variable resistor in the voltage divider circuit).  There are two knowns:

  • R – This is R15 in the schematic.  I am using a 10K resistor that is within 1% accuracy.
  • Vs – The V_Clean power.  This comes from the output of the voltage regulator.  While the voltage regulator SHOULD be 5V, I typically get a measurement of 5.06V. This is probably “close enough.”  However, the calculation for the temperature will vary by ~ 3˚ when 5V vs. 5.06V is used.  Ideally, since the ADC has a VREF and does that relative to Vs – I should be able to get Vs from the ADC.  But I can’t figure out a way to do this.  For now, I will use 5.06V for the known Vs.

 Results from Arduino

The sketch I used is located here.  I ran the sketch for awhile.  Output varied by +/- 1˚C.  Here is a typical line of output:

0:00:01 | ADC reading: 2378.00mV | Thermistor reading: 11278.39 ohms | Temperature 22.34 *C | 72.20 *F

From this small test, I have some confidence the thermistor circuit is working correctly.  The voltage reading on my DMM was within 1-2mV of the digital output I received in my Arduino sketch.  The temperature conversion was within 1˚F of a reading I made with a thermometer I had lying around.

What’s Next

It’s time to connect a probe, wrap the waterproof the thermistor and make the connecting cable from the thermistor to the shield long enough to be submersed on a nutrient bath….

Share this:

  • Twitter
  • Facebook
  • Reddit
  • Google
  • Email
  • Pinterest

Like this:

Like Loading...

The LadyBug Shield, Alpha 1 – Simplifying Hydroponics

27 Saturday Dec 2014

Posted by bitknitting in EC, Hydroponics, Ladybug Shield, pH

≈ 7 Comments

Tags

EC, hydroponics, Ladybug Shield, pH

A YIPPEE! moment…I just sent the LadyBug Shield Alpha V1 to OshPark.  

LadyBugShieldAlphaV1Layout

A new chapter – just in time for the New Year – is beginning for this project.  In the next few months, I plan to eat my own dog food.  I will use LadyBug Shields to help me hydroponically grow lettuce and herbs.

The Kicad files for the schematic and layout of the LadyBug Shield Alpha V1 is located at this Github repository.

Thanks To Those That Went Before

I am very grateful for the people and projects that have provided influence in my journey/practice with electronics.  It continues to amaze me how much learning material and learned folks are within my reach.  Thank you.

  • I continue to – and will always be – thankful to Chris Gammell.  His exceptional Contextual Electronics courses as well as his mentoring is a big part of the reason I can even put together the LadyBug Shield!
  • I have recently neglected to thank Ryan (Sparky’s Widgets) for his OSHW minipH and miniEC projects.  I spent a great deal of time learning through his schematic and discussions about his design.  Ryan has been very supportive, providing feedback and guidance when I asked for help.
  • I have used OshPark for PCB fabrications many times this past year.  Their attention to customers (me in this case 🙂 ), the quality of what I receive is a tremendously positive experience.  OshPark – you are an exceptional company built on great people and terrific customer service.  Thank you.
  • I thank Adafruit for their awesome forums and technical support, well designed breakout boards, and exceptionally well done tutorials that include everything needed to get a circuit using the BOB running – including Arduino libraries.  I’m finding when I need to meet a scenario with a chip – say an ADC like the ADS1015 or codec like the VS1053 – to check what Adafruit has chosen for their BOBs.  

Steps Taken Prior to Fabrication

Getting the Shield ready for fabrication took many steps.  I tried to apply lessons I have learned over the past year.  I realize this is probably a stretch, but my goal is to use this board without modifications within a hydro system.  This is a very aggressive goal which given my past experiences in all likelihood I will not make, but for now I stand by this goal.

The steps I took include:

  • combining the Healthy pH and EC shields onto one board.  While doing this, I changed aspects of the design that I thought needed to evolve within a sub-circuit.  
    • I had planned to use a separate power supply for the analog power.  I changed this to use Vin of the Arduino and pass the Vin signal through a voltage regulator so that circuits enjoy 5V regulated power.  This also caused me to move to the back copper GND plane layout.
    • As I got to understand the ADC – both core features and what is needed for converting the analog voltage values of the sensors to digital values – I switched ADCs.  Twice.  The first ADC I used was the MCP3901.  This is one powerful ADC!  It uses SPI to communicate with the Arduino.  Both SPI and the MCP3901’s rich feature set was more than what was needed for the shield’s scenario.  I found I was spending more time than I should on the SPI code and understanding how to use the MCP3901’s rich feature set.  I ultimately settled on the ADS1015.  I was very happy to be able to use this one chip for two differential ADC readings (pH and EC) as well as one single-in reading (thermistor).
    • I changed the diodes to a 1N448.  The packaging was a bit smaller and less expensive.
    • Instead of two separate VGNDS to handle one power supply for the op amps, I consolidated to a 2.5V VGND.  This should work for both EC and pH readings.
  • putting the BNC connectors for the pH and EC probes on the shield.  I was avoiding this because the BNC connectors take up a significant chunk of real estate on the board, and also are incredibly expensive at quantities less than 1,000.  Yet, as I tested the pH and EC circuits, I was not happy with the signal noise introduced when the BNCs is not connected to the board.  I extended the shield off the back to accommodate.  I haven’t tested this yet.
  • check the circuit design against the layout of each schematic to see if there are any D’OH moments.  The circuits include:
    • power
    • pH
    • EC
    • Thermistor
    • Digital Access (ADC)
    • Pumps
  • check the copper layer Gerber file and the drill file.  Sometimes there are traces going nowhere that error checking doesn’t pick up on.
  • send the Gerbers to freedfm to find additional errors in the layout.  I only address “potential show stoppers”
  • print out a copy of each footprint that I haven’t soldered on a board yet and overlay “the real thing” to make sure the footprint is correct for the component.  I totally messed this up in previous efforts.  The components in question are the ADS1015, SOD-123 Diode packaging, the BNC connectors, and the 6 and 2 Terminal Block connectors.  CAUGHT IT!  The footprints were off for the BNC connectors as well as the 6 and 2 terminal block connectors.  Throughout this project, I’m finding connectors to be the components that are most likely to have the wrong footprint.
Here is an image of a print out of the front copper layer:

BNCFootprintNotCorrect

I then found it easier to print out the footprint when in the library editor of PCBNew:

PrintOutOfBNCConnector

  • run the Gerbers and drill file through freedfm.  I am glad I did this.  When I changed the footprint of one of the BNC connectors, I ended up placing a via on top of a through hole.  Freedfm gave me an idea where to look.  I opened up the drill file, found exactly what to change, then went back to PCBNew and made the change.

Thanks for reading this far.  A very Happy New Year!  Please find many things to smile about.

Share this:

  • Twitter
  • Facebook
  • Reddit
  • Google
  • Email
  • Pinterest

Like this:

Like Loading...

Testing the pH Proto Board

25 Tuesday Nov 2014

Posted by bitknitting in Arduino, Healthy pH Shield, pH

≈ Leave a comment

Tags

arduino, Healthy pH Shield, pH

In a previous post, I discussed reducing prototyping time by using the services at my local hacker space, Metrix:Create.  I’m excited to discuss testing of the pH proto board that Metrix:Create fabricated for me.

The Goal

The goal of this post is to walk through the gotcha’s and successes in testing the pH proto board.  

Thanks to Those That Went Before

Each day there is much to be thankful for.  I am continually thankful for Chris Gammel.  The journey to my current skill at electronics would be monumentally more difficult without taking Chris’s Contextual Electronics course.  Chris’s guidance, knowledge is unbelievable.

Thanks to Metrix:Create for providing a space, services, and tools to do stuff like these proto boards without me having to know much about the process.  While at the same time Lauren (the person who made the proto board) walked me through each step.  I learned a lot from her discussion of the process and watching the machines in motion.

Thanks to Osh Park for the exceptional quality and service building low quantity PCBs.  

Design and Layout

Kicad files for the proto board are located in this GitHub repository.

Both the pH and EC circuit use an ADC.  To save costs, I decided to put two separate circuits on the pH proto board:

  • the pH circuit that takes in a voltage value from a probe and sends it through an op amp in preparation for the analog -> digital conversion.
  • the ADC that converts the analog voltage into a digital value so the Arduino can figure out the mapping of the voltage value with a pH value.
I am focusing on just the analog part of the circuit and the conversion to digital.  Other aspects of the Healthy pH Shield, such as the pumps and voltage regulation is not included.  These have already been tested and work as I expected.
 
Perhaps a negative aspect of using proto boards is the layout is different than what the final layout will be.  I have been focusing on both design and final layout.  I actually see this negative aspect as a huge positive. For example, I do not focus on better/best ways to handle power/ground paths.  A critical and time consuming aspect of the final board layout but not the priority when connecting the components into a test circuit.  The proto board layout is more like a bread board layout.
LayoutOfpHProto
Proto Board Layout

Difference Between an Osh Park PCB and a Proto Board

 
pHProtoPCBFromMetrix
Proto Board
 
 
A positive side effect of doing a proto board was working with the differences between this proto board and the more refined PCBs I get from OshPark was the opportunity to refine soldering skills.  With the proto board:
    • The copper wires are exposed.  It is much easier to connect two wires with solder that shouldn’t be.  I got great practice in using my DMM to test connectivity as well as in solder removal techniques.  I have been trying different temperatures for the solder iron and techniques when soldering and de-soldering.  Techniques I picked up after asking for advice:
      • (link) OOPS! I tore the copper: comment/advice:  what happens is the epoxy holding it down gets damaged, then the copper itself simply tears, as it is extremely thin – typically 35µm.The surface tension of the solder seems to be strong enough to tear it when you’re moving the iron around!
      • (link) OOPS! I melt the material around the plastic:   Counter-intuitively, this is usually caused by the iron being too cold, forcing you to take a long time to do each joint.A sufficiently hot iron can consistently do a good joint in about 1 second.I never run my iron below 350°C.  I am now setting both the reflow and iron at 360˚C and applying heat for just a second or two.  So far, this technique is working much better.
      • stay away from VIAs.  At least at this time – this process of rapid prototyping doesn’t include plating the VIAs.  VIAs require connecting copper layers, typically by soldering a piece of wire through the VIA drill hole.  This video goes through a few techniques.  

Fixing blunders early on

After making D’OH blunders on part footprints (see my embarrassing mess up with the barrel jack), moving forward I will print out the copper layer that has parts on it.  In this case, I only use the front copper.
GerberFrontCopper
Front Copper Layer
 
I can easily print out the front copper Gerber file from the version of Kicad I am running.  Armed with the print out, I then place the active parts (no need to place capacitors and resistors – I stick to an 0805 footprint).  YIPPEE!  I found a footprint that was incorrect and fixed it immediately :-).

Design Changes

ADC

I have replaced the MCP3901 ADC with the MCP3221 (data sheet).  After experimenting with the MCP3901, it became clear to me that the capabilities of this ADC far exceeds my needs.  While it is great to have 24 bit resolution and programmable op amps, the experience I seek of simply reading the pH and adjusting the pH can be handled by the MCP3221.  I chose the MCP3221 based on a query for an ADC on Parts.io, Ryan’s (Sparkys Widgets) use in the minipH, Microchip does an excellent job documenting the serial communications between its chip and a master (like the Arduino).
 
I am very glad I made this switch.  The firmware that needs to be written is far (far!!!) simpler.  Talking to the MCP3221 is simply a matter of figuring out what address the device is at.  Everything else is taken care of by Arduino’s Wire I2C library.

VREF

When I first started exploring a pH circuit, I was not sure a VREF would be needed.  Worst case, perhaps I could use Arduino’s VREF.  As my exploration and electronics practice evolved, I became convinced a VREF is important to the design.  This I feel is particularly true given the small range of pH voltage values (+/- .415V).  The MCP3901 has an internal VREF.  The MCP3221 does not.  I initially decided on a 3V VREF.  The decision was based partially on the MCP3901’s lower VREF and partly on SparkysWidgets’ minipHv3_2 schematic (GitHub location).  Alternatively, I could choose the more conventional 4.096V VREF.  This voltage works well for a 12 bit ADC since 12 bits means there are 4096 steps.  4.096/4096 makes each step a nice even 1mV (a step is also referred to as an LSB size).  I thought given the small voltage values to be converted, if a 3V VREF was used 3/4.096 provides a great granularity per step at .73mV.  Although 3/4096 does not divide evenly.
 
TBD
Simpson DOH
My D’OH moment was not paying attention that the V+ pin of the MCP3221 is also the VREF pin. Unlike the MCP3901, the MCP3221 does not separate out the VREF.  In order to use a 3V VREF, I would have to use the power supply of the Arduino for the I2C wires.  A Sparkfun article on logic levels shows the minimum/maximum values for HIGH and LOW voltages on input and output.  

 

ArduinoLogicLevels

An Arduino pin will send a 1 at a voltage greater than or equal to 4.2V.

The MCP3221 data sheet recommends a 4.096V reference.  

VREFRecommendationForMCP3221

…but then I got to thinking (which could be a mistake!) that given an voltage output HIGH from the Arduino has a minimum voltage of 4.2V, if VDD = VREF = 4.096V, isn’t the VREF/VDD too low?  I tested the VDD with my bench power supply to see how low the voltage can go before the SDA line can’t talk with the MCP3221 when the Arduino is on one power supply and the MCP3221 is on another.  This turns out to be 3.7V.  So a VDD = VREF = 4.096 will work when the MCP3221 is on a separate power supply.  I guess the circuit inside the MCP3221 differentiates between the I2C, the rails, and the analog -> digital conversion.  How?  I have no idea. 

Initial Test Results

I used a POT hooked into a voltage divider to feed in various voltage values into the pH circuit which then was sent to the ADC for conversion.

pHADCTestSetup

Luckily, the design supports removing the VREF and using the bench power supply directly as the power supply.  My DMM showed I was getting 5.06V of regulated power.  The conversion of an ADC reading to millivolts is:

float mV = (((float)adc_result/4096)*5.06)*1000;

DMM ADC (avg >= 20 values) Difference
504 502.65 1.35
41.1 34.21 6.89
809 805.69 3.31

The biggest difference , .007V happened at a very low incoming voltage.  This margin of error is small.  I assume numbers will improve once a VREF is added.

 

Off to more testing…and figuring out stuff about the circuit I have yet to comprehend because of changing the ADC…

 

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

 

 

 

Share this:

  • Twitter
  • Facebook
  • Reddit
  • Google
  • Email
  • Pinterest

Like this:

Like Loading...

Testing Healthy pH Dev-Rev3

06 Thursday Nov 2014

Posted by bitknitting in Healthy pH Shield, pH

≈ Leave a comment

Tags

Healthy pH Shield, pH

 

YIPPEE! I just received my purple package of 3 Healthy pH Dev-Rev3 Shields.  And just before that – my order after my shopping spree at Digikey arrived…time for another round of soldering, testing, and iteration on the design and layout. 

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

The Goal

The goal of this post is to walk through the testing of the Healthy pH Dev-Rev3 shield.

Thanks to Those That Went Before

I will always be extremely grateful to Chris Gammell and his Contextual Electronics course.  Prior to taking Chris’s course, I didn’t understand how wires on a bread board could be wired together into a workable circuit…even though I dabbled in doing so.  I didn’t have a conceptual model around key electronic concepts.  Thanks to Chris, I am able to push forward learning electronics and tools such as Kicad to a point where I can build – and make work – a PCB.  This to me is amazing.

Power Source

Here is an image of the chips on the shield that take the voltage from a wall wart and clean it up for the power source used by the analog circuits on the shield:

VoltageRegulatorChips

Simpson DOH

Hmmm…silly me…D’OH…now the througholes are large enough for the barrel jack…but the middle hole is backward.  Not my finest hour.  

 

 

and an image of the schematic:

Voltage Regulator Circuit

The data sheet gives characteristics based on an incoming non-regulated power source of 10V.  The range can be anywhere from 8V to a maximum of 30V.  Working back from the 5V out, the MC7805 has a dropout voltage of 1.7V.  In addition, the 4004 diode (D2) contributes a voltage drop of .64V.  5V + .64V + 1.7V = 7.34.  So I lied.  In this configuration, the absolute minimum is 7.3V.  Given the common wall wart voltage, I will recommend 9V or 12V wall warts.

Noise on Power Lines

The first test will check the level of noise on the V+_WallWart (+5V/AGND) and VGND (VGND/AGND) signals.

Using TP20 for the probe and pin 1 of P2 for AGND, turning on AC coupling on the scope, the incoming noise looks like:

ACWaveForm(Noise)FromWallWart

the Vpp ~= 4.6mV.  Chris noted less than 10mV can be considered clean.  The power coming in from the bench power supply is nicely regulated.

Noise on V+_WallWart (through pin 2 and pin 1 of P2) looks like:

ACWaveFormAfterVoltageRegulator

Incoming power is coming from my bench power supply, which is providing regulated power. 

VGND is built using a voltage divider:

VGNDVoltageDivider 

VGNDChips

The noise that comes from VGND relative to AGND looks like:

 

ACWaveFormFromVGND

The noise for VGND shows a Vpp ~= 3mV.  Close but smaller than V+_Wallwart.  I don’t understand the characteristics of decoupling capacitors well enough but assume the slightly smaller Vpp is due to the addition of C10 – a .1µF capacitor placed closed to the resistors used for the voltage divider.

Analog pH Readings

The part of the circuit to test is the op amp used to capture the voltage measurement of the pH probe:

analogPartofpHCircuit

The chips as they are soldered on the shield are shown in an earlier image.

Testing the Analog pH Voltage Value

I’ll be putting the probe’s scope in TP1 relative to VGND.

The pH Voltage Value

I pointed out in this post, the easiest way to test the pH analog values is to send in various DC voltage values representing what might be coming from a pH probe.  I do this by setting up the power source to provide 5V to the pH circuit as well as a voltage divider  with a potentiometer to adjust the DC value simulating a result from a pH probe.  

POTForpHDC

In an earlier post, I showed a table that mapped pH values to their voltage values (link).  The table shows that a pH voltage value is a function of the pH value:  pHv =  .414-pH*.05916 – where 59.16mV is the change in voltage (slope) between two pH values.

I adjusted the POT such that the incoming DC is listed in the Bread Board column.  The measurements taken after going through the op amp are pretty much the same:

Bread Board TP1/relative to VGND
0.44 0.44
0.703 0.702
0.273 0.271

YIPPEE! This part of the circuit is working.

From Analog to Digital

Moving to digital is all about the ADC and the Arduino.

MCP3901WithCH0Oops

Schematic View With Oops on CH0…

Testing SPI Traffic

The MCP3901 uses SPI to communicate with the Arduino.  Luckily, I wrote test code during my testing of the Healthy pH Dev-Rev2.  The test code I wrote is located at this GitHub location.  When I first ran it on this build, I received:

*********************************
—> Config 1: 0XFF
—> Config 2: 0XFF

from previous testing, an 0XFF means MOSI is sending out the command, but its not getting anything back on MISO…hmmm….the challenge with debugging this was where to start…the closer I start to the challenge…argh…

I got the debugging tools ready: Logic analyzer and scope.  A DMM can be used in place of a scope.  However, I like to look at the change in voltage over time.  For example, when the Arduino sets a pin to LOW or HIGH.  Immediately hook up the logic analyzer since this is a view into the MOSI, MISO, SCK, and CS lines.

SPI PIns On Arduino

SPI Pins Color Coded to Logic Analyzer UI

  • Hook up the logic analyzer.  Run the test that reads the CONFIG registers.  Is it showing the expected results?  If YES – YIPPEE!! Else, on to the next step…
  • If received 0x0: No traffic is being seen on any of the lines.  At a minimum, I would expect to see SCK beating away and MOSI sending out the command.  Potential reasons:
    • The shield is not receiving traffic from the Arduino. Verify this by pulling off the shield and checking the SPI lines with the logic analyzer.  First thing I do for this is to take off the Shield and check the SPI traffic with just the Arduino running testing reads on CONFIG register.  It could be the Arduino, the connection of the Shield, the connection of the logic analyzer wires…
  • If received 0xFF: SPI traffic is going over the bus – at least the MOSI and CLK lines – check with the logic analyzer.  The MCP3901 is not returning any data (i.e.: no data on MISO).  Check:
    • is the power supply for V+_Wallwart plugged in?  If that is the case, the green LED on the shield should be on.
    • Use the DMM to check continuity.  Is there continuity between the family and friend components?
    • Is the chip getting power?  Pin 3 is connected to V+_WallWart.  Is there a voltage drop because of the power absorbed by the MCP3901?
    • Is the crystal working?  Get out the scope and see if there is an AC Waveform.  Here’s what I measured:
CrystalACWaveform
 
The MCP3901 data sheet (link) notes (section 3.11): The typical clock frequency specified is4 MHz. However, the clock frequency can be 1 MHz to5 MHz without disturbing ADC accuracy. 
The image of the AC Waveform shoes a time period of about 250ns.  The frequency = 1/.000000250s = 4MHz.  So the crystal seems to be correctly creating the AC Waveform needed by the MCP3901’s clock. 
    • Is CS, RESET, DR set to the right pins in the test software? If yes then…
    • Is the RESET line pulled HIGH (view in scope or DMM).  The RESET pin must be high for the MCP3901 to “wake up and hear the request.” (see “Pins to Arduino” below). Make sure this happens!
 …and …and IT WORKS!  YIPPEE!

Pins to Arduino 

Simpson DOH
 
Hmmm..this took me a better part of a day to figure out.  EVEN THOUGH this exact challenge was noted by Chris Gammell in the Contextual Electronics course.  Besides the SPI lines, the MCP3901 has a RESET and DR line to the Arduino. In section 3.1 of the MCP3901 data sheet (link): This pin [RESET] is active low and places the entire chip in areset state when active.When RESET=0, all registers are reset to their defaultvalue, no communication can take place, no clock isdistributed inside the part.  
I took out my DMM and checked to see if indeed RESET is high…because, after all, I set this pin to HIGH in the code.  In the initialization method for the MCP3901 class I have:

    //RESET_N – first set config to default thent high so that communication can happen with the ADC

    digitalWrite(RESET_N,LOW);

    digitalWrite(RESET_N,HIGH);

which would work just great if indeed the pins I associated with the RESET and DR were correct.  Well wouldn’t yah know? I changed the pins for these two in Healthy pH Dev Rev 3:

MCP3901 adc_mcp3901(10,8,9);

where the initialization method is defined as:

MCP3901::MCP3901(byte cs_n, byte reset_n, byte dr_n);

In the Healthy pH Dev-Rev2 design, the RESET pin was pin 4 and the DR pin was 2.  I switched these to pins 8 and 9 in Healthy pH Dev-Rev3.

 

HealthypHDevRev2RESETandDR

Healthy pH Dev-Rev2 Arduino Pins

HealthypHDevRev3ArduinoPins

Healthy pH Dev-Rev3 Arduino Pins

 YIPPEE!!  Once I changed the RESET and DR pins to the right ones, the SPI worked correctly!  

Digital pH Voltage Readings

Finally I can move on to evaluating results from the ADC.  and…and….

 Simpson DOH
D’OH – somewhere between updating the schematic from Healthy pH Dev-Rev2 to Dev-Rev3, the inputs for the pH analog lines got switched.  
SwitchedPinsForCh0

A big OOPS here….ARGH…I am blocked from further testing of pH values. Ah well…Dev-Rev4 better be right! 

Thermistor

 

Analog Voltage Value

The thermistor is a 10K thermistor.  I changed the resistor from 10K to 1K so that readings would be less than .79V.  The temperature around my desk should point to a voltage that is 1K/11K = .45V.  The reading I got was .368V.  For testing, I am using a 5% thermistor.  The accuracy will be improved.  I am using this thermistor because it is the easiest for me to test with.

Digital Voltage Value

What’s the value seen by the Arduino once it has been transformed into a digital value by the ADC?  The first time I ran the test program, I received what appeared to be random results.  Given that I was getting CONFIG information correctly, I’m betting there is a problem with:

  • The control byte I am sending is not set up correctly.  It could have the address of the register of the read byte incorrect.
  • I am not putting the bytes I get back correctly into a data type understood by the Arduino.
  • If the data channel returned is correct, the function to go from a data channel to a voltage value is not implemented correctly.
Previously, I used the MCP3901’s higher resolution – 24 bit width.  This time, I am going to use 16 bit because the bit manipulation is simpler/easier to understand and a 16 bit accuracy is more than enough.

Address

The Thermistor is on CH1. The address of the 16 bit stored data channel value starts at register 0x03 MSB) and includes 0x04.  

MCP3901 Control Byte

MCP3901 Register Map

the control byte should be 0x03<< 1 | 1 or 0x07.

Reading CH1

 

 

 

 

RGB LED

TBD

Changes for Dev-Rev4

Remove Diode in Voltage Regulator Circuit

As noted earlier, there is no need for diode (D2).  I’ll remove from the schematic.

Barrel Jack

Fix the barrel jack footprint and pick a different barrel jack.   The barrel jack I picked has a very small hole and I want one that will work with the majority of 9V and 12V wall warts.  I should have looked on wikipedia first (link) to learn what the most common barrel jack size is for 9V and 12V Wall Warts.  The most common size is 2.1mm inside/5.5mm outside diameter.  I will use this barrel jack for the next rev.

Label Arduino Pins

I noticed this last time but didn’t think too much about it.  The Shield does not label the Arduino pins.  This makes it difficult to see which Arduino pins do what.  The next rev will include labels for each of the Arduino pins similar to what is on an Arduino Uno.  In addition, I will clean up the Arduino pin model in the schematic so that pin labels align much better to the labels on the Arduino Uno.  When I first started using this model, I was just happy I had something that worked.  Now I am seeing the value in being as clear and obvious as possible early on :-).

Switch ADC Inputs for pH

Clearly the input for CH0+ and CH01 need to be swapped!

Add in a Test Point for VGND

I was having to share the VGND on the 8 pin connector between the circuit and a probe.  Given how much testing used VGND as ground when probing, it deserves its own test point.

TBD: Green LED Indicating Arduino Plugged In

As noted earlier, there is no need for diode (D2).  I’ll remove from the schematic.

Different Thermistor

I thought the thermistor I chose would be great because it was already covered in epoxy (digikey link).  It is too delicate.  I like the thermistors that look and feel more like a big through hole resistor.

Move RGB LED

The RGB LED is in a “tight” section in the lower right side of the board.  There is a lot of clear space near the logo. Although the RGB LED chip will no longer be near an Arduino pin, the LED will be better positioned.

 

 

 

Share this:

  • Twitter
  • Facebook
  • Reddit
  • Google
  • Email
  • Pinterest

Like this:

Like Loading...

Healthy pH Dev-Rev3: Off to Fabrication

24 Friday Oct 2014

Posted by bitknitting in Healthy pH Shield, pH

≈ Leave a comment

Tags

Healthy pH Shield, pH

A YIPPEE! moment…the Healthy pH Dev-Rev3 Shield’s Gerber files were sent off to OshPark!  The kicad files are located in this GitHub location.

The Goal

The goal of this post is to discuss the changes to the design and layout of the Healthy pH Dev-Rev2 Shield that went into the Healthy pH Dev-Rev3 effort.

Thanks to Those That Went Before

Chris Gammell continues to be a major reason I am able to make progress.  I learned a lot taking his Contextual Electronics courses – and highly recommend them if you are breadboard prototyping circuits and want to take a twirl at building PCBs with SMTs.  This time around, Chris was instrumental in guiding me through the layout choices.

OshPark is a terrific fabrication service.  I am very impressed with their product and their support.  Highly recommended!

Design Changes

After running the test harness (code at this GitHub location) I had written and playing around with the Shield, I had a list of design changes to make: 

RGB LED
Remove TP19,TP10
Remove TP8
add Text and Logo
fix pin layout of voltage regulator (7805)
fix barrel jack drill holes
enlarge TB pins
remove TP17
remove TP2, TP3, TP4, TP5, TP6, TP7
connect 2nd Ard GND pin
remove TP14
move TP12 text
put ‘1’ close to 1st conn of 8 pos TB
remove TP14
remove TP12, TP 15, TP13, TP16
remove TP11
remove TP18
change R15 to 1K
.1 R15 1K
.1 Thermistor
add .1 uF near voltage divider (r3, r4)

I discussed these changes in earlier posts.  It was terrifically exciting to see the software interact with the hardware as well as view the analog signals on a scope!  This gave me a much better idea on what is going on within the circuit(s).  It also gave me insight into how far I am from using the shield in a hydroponic system.  I hope after the next rev I can use the shield…but typically I am overly optimistic…

Layout Changes

Changes to the layout caused many a stumble on my part.  I had a major D’OH NO-NO on my first attempt at the layout for the Healthy pH Dev-Rev3 Shield:

HealthypHDev-Rev3FirstAttemptDOH

I had the power line for the analog circuit going through the middle of the MCP3901.  

I got caught up in not crossing any tracks.  Layout is harder than it looks. For me, layout is like chewing gum, patting my stomach, and spinning a plate on my nose at the same time.  I bet a great video game could be made out of the puzzle and the resource constraints…but I diverge…

Here’s what I ended up with:

Healthy Dev-Rev3 Layout

Both the analog power source (V+_Wallwart) and the digital power source (V+ARD) are wide rivers running through the board and out of the way of the chips in the same way it seems rivers typically don’t run through the middle of a building.  I also placed the decoupling capacitors closer to the chip whose power line it is supposed to be cleaning up.  Other than that – tracks were thickened.  The pump circuit had minor touch ups and most of the test points were removed.

 

It is like anticipating a special gift to wait for the purple mailer from OshPark with the 3 PCBs in it.  I’ll keep busy…next on my list is…SHOPPING!…which I find shopping for parts on digikey.com to be much more fun than shopping for shoes.  But perhaps not as exciting as the impulse buys I can’t seem to stay away from on ebay.com and amazon.com.

 

 

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

Share this:

  • Twitter
  • Facebook
  • Reddit
  • Google
  • Email
  • Pinterest

Like this:

Like Loading...

Weird AC Waveform on VGND? – Healthy pH Dev-Rev2

16 Thursday Oct 2014

Posted by bitknitting in Healthy pH Shield, pH

≈ Leave a comment

Tags

Healthy pH Shield, pH

Well that was (NOT 🙂 ) exciting.  Why was I seeing this:

ACWaveForm on VGND NO probe attached

when the scope probe was in TP 18 relative to AGND?  Yuk…..

The Goal

The goal of this post is to become familiar with the characteristics of the all important VGND – used as the GND for the pH probe readings.  With a VGND, the op amp can use a single power source since all voltage readings will be positive.

Thanks to Those That Went Before

I just can’t thank Chris Gammell enough.  His Contextual Electronics courses and mentorship have given me the ability to rapidly grow my abilities in designing and building PCBs.  Something I find I have quite a passion for when applied to growing healthy food (through hydroponics).  I look back to last year…I am amazed and exceptionally grateful for all I have learned.  This would not have been possible without Chris.

Given my thirst for learning from those that went before, Ryan – of Sparky’s Widgets – is another whom I am hugely thankful for.  Ryan has made some wonderful breakout boards, like the minipH and minieC that I highly recommend.  The circuit design of the Healthy Shields are an evolution of the open source schematics and advice from Ryan.  He truly knows his stuff.  I am very grateful that Ryan open sourced the minipH and minieC hardware.  In addition, Ryan has been extremely thoughtful in response to what must be naive questions from me given his level of expertise!

Observations of VGND

As I noted earlier, I was seeing a strange sine-like waveform when the scope probe was in TP 18 relative to VGND.  Not good…

What was happening – and this took me awhile to figure out and get right (although I am not sure why!) – the probe’s GND was loosely connected AND I had too many external electrical doo-dads and wires running around, under, and above my Healthy pH Shield Dev-Rev2 I was testing.  I let out a sigh of relief after removing the excess electronics and wires, revisiting how the probe’s GND was connected to AGND and saw:

ACWaveForm on VGND  probe attached better

in this case, the Healthy pH Shield is inserted into the Arduino.

Healthy pH Shield With Probes

When the Healthy pH Shield is not plugged into the Arduino, there is (relatively much) less noise:

ACWaveForm on VGND  detached from Arduino

 

More noise occurs when the pH probe is connected through the BNC:

ACWaveFormAnotherWithArduinoAttached

 

Lessons Learned

  • Observations are important but are only as good as the method used to measure.  In this case, I was not seating the scope probe correctly.  AND…I repeatedly was not doing this.  Certainly, slowing down, triple checking is very important when using tools and observing.  Sounds obvious, but something I need to constantly remind myself to do.
  • How well the BNC/probe is attached to the Healthy pH Shield will make a significant difference in the noise picked up on VGND.
  • A capacitor should be added close to the voltage dividers (R3 and R4) to smooth out the noise – especially since the Arduino adds additional noise – even when not plugged in.

 

Well – that’s that!

 

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

Share this:

  • Twitter
  • Facebook
  • Reddit
  • Google
  • Email
  • Pinterest

Like this:

Like Loading...

Testing the Temperature Reading Using Voltage Values – Healthy pH Dev-Rev2

13 Monday Oct 2014

Posted by bitknitting in Healthy pH Shield, pH, temperature, thermistor

≈ Leave a comment

Tags

Healthy pH Shield, pH, temperature

I use a thermistor to calculate the temperature of a bath.  I started testing in a prior post, but ran into an issue because I was using a 10K resistor for R15.  See this link for more details.

The Goal

The goal of this post is to do a litmus test on the temperature that would be calculated prior to conversion of the voltage to digital through the ADC.  While I don’t expect the temperature to be spot on, I do expect the reading to be within the ballpark.  If needed, further improvements will be done to improve readings.

Thanks to Those That Went Before

Thanks to Gerald Rectenwald for his excellent class notes on thermistors.  They were easy to read and useful.

As always – a huge thank you to Chris Gammell.  His Contextual Electronics and additional guidance has made it possible for me to even attempt this effort.

Thanks to the people behind the Wikipedia entry on Thermistors.  The article was very helpful.

The Test

Due to lack of soldering skill on my part, I managed to tear off the pads from R15 – the resistor that acts with the thermistor to divide the voltage.  The kicad files are located at this GitHub location.  OshPark provides 3 boards so I was able to only solder what was needed.  This time, I used a 1K resistor for R15.  Using 1K instead of 10K should read voltage values that can be digitized by the MCP3901 – which can handle voltage values between +/-.79V.

YIPPEE! Simple:

PCBThermistorTest

Measuring Temperature

I noted in the previous post (link), going from a voltage reading to a temperature reading (either in C or F) is a three step process:

1. The thermistor (Rtherm) is a variable resistor.  What is it’s current value?

2. The temperature has a linear relationship with Rtherm.  Use the B parameter method to solve for the temperature in Kelvins.

3. Convert from Kelvins to either C and/or F.

Solving for Rtherm

From the previous post, I first solve for the value of Rtherm (plugged into holes 3 and 4 of the holes for the 8 position terminal block).  In order to do this, I need to measure Vo then use the formula:

Rtherm = R15/(Vs/Vo – 1)

I measured Vs = 5.18V and Vo = .42V relative to AGND.  Plugging into the above equation, Rtherm = 1000/(5.18/.42 – 1) = 11,333.  At least the calculated value was not completely out of range – say if it had been 113,330…

Solving for Temperature in Kelvins

Perhaps you have become friendly with formulas.  Frankly, formulas intimidate me.  But if I take it r-e-a-l SSSSSLLLLLLLOOOOWWWW …..

As noted in the Wikipedia article on thermistors:

T = B/ln(Rtherm/r∞)

It also notes r∞ to be:

r∞ = Roe^(-B/To)

Where Ro = the thermistor value that the thermistor is spec’d at.  Mine is a 10K thermistor.

To = 298.15K (25˚C in Kelvin)

B comes from the data sheet.  For the thermistor I am using (link), B  = 3977.

Plugging in, I get:

r∞ = 10000*e^(-3977/298.15) = 0.029259

T (Kelvins) = 3977/ln(11333/298.15) = 295.25

Solving for Temperature in ˚C or ˚F

To go from Kelvins to C, just subtract 273.15.  This gets to: 295.25 – 273.15 = 22.1˚C.

The formula to go from C to F is ˚C*2 – 30, 74.2˚F

While this is not extremely accurate, the temperature where I am at is about 70˚F.  This makes the reading I got with the thermistor about 4˚F higher.  I feel this is good enough to pass my litmus test.  Now I need to better understand:

  • resistor values vary.  How important is precision of R15 or the thermistor?  It seems that thermistor tutorials suggest 5% – which is what I am using.  Should I pay more for 1% precision?  How much do small changes in temperature affect the pH value measurement?
  • How accurate are the voltage measurements for Vs and Vo?  Is there enough noise to cause inaccurate results?  I need to get a better feel for the noise on the voltage line.

Next Time

For this pass, I am focusing on knowing if the results I measure are within a litmus test of expected results.  I am not as concerned with accuracy.  And in this case, I am not sure how accurate I want to be.  Because of the relationship between the pH value and temperature, accuracy will depend on the affect of a small (say 1˚F) change of temperature on the pH value.

 

 

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

Share this:

  • Twitter
  • Facebook
  • Reddit
  • Google
  • Email
  • Pinterest

Like this:

Like Loading...
← Older posts
Advertisements

Subscribe

  • Entries (RSS)
  • Comments (RSS)

Archives

  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013

Categories

  • 3D Pringint
  • 433MHZ
  • 802.11
  • A Salad A Day
  • ADC
  • Analog Circuits
  • Arduino
  • Atlas Scientific
  • Audio Recording
  • Base Station
  • BTLE
  • cc3000
  • Cloud Services
  • Conductivity
  • Contextual Electronics
  • Data Logging
  • debugging
  • DHT22
  • Diagnostic Tests
  • doxygen
  • DS18B20
  • EC
  • Eclipse
  • electronics
  • Healthy EC Shield
  • Healthy pH Shield
  • Herbs
  • Home Network
  • Hydroponics
  • indoor gardening
  • JeeLabs
  • Ladybug Blue
  • Ladybug Nutes
  • Ladybug Plant Food Adjuster
  • Ladybug Shield
  • LED
  • Lettuce
  • LTSpice
  • Moteino
  • New Category
  • New Project
  • nRF24L201
  • nRF51822
  • Nutrients
  • Othermill
  • PAR
  • PCB
  • pH
  • PHP
  • power supply
  • Prototypes
    • Building Our First LED Circuit
    • Sending Sensor Data to a Web Server
    • Wireless Communication Between Sensors
  • Readings
  • RFM12B
  • RFM69
  • Schematics and Board Layout
  • sensors
  • sling
  • soldering
  • SparkysWidgets
  • TCS34725
  • temperature
  • thermistor
  • Uncategorized
  • Vegetables
  • virtual ground
  • Voice Recording

Meta

  • Register
  • Log in

Blog at WordPress.com.

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
%d bloggers like this: