pH/EC-983 Product Breakdown -First Post

I love watching Limor/Lady Ada take apart a Consumer Electronic device and explain to us what the chips are and what is going on.  I thought what a great learning opportunity to take something that I have some familiarity with – in this case pH and EC circuits – and find a product to take apart and figure out how the circuit works. 

pH/EC-983

The product I picked was the ph/EC-983.

NewImage

This handy tool integrates a pH and EC probe as well as gives a temperature reading.  It is inexpensive and if it is “good enough” I was thinking it would be super amazing to plunk the probe in the nutrient bath.  I would use firmware to take pH/EC measurements and use the measurements to adjust the pH and nutrients.

I was mostly interested in the bottom piece.  The bottom piece contains the pH and EC probes:

NewImage  NewImage

I was thinking if I could figure out the signals coming out of the probe:

NewImage

So that I could put the probe in the nutrient bath and connect up a pH/EC circuit to be monitored through firmware.

 Hmmm…I couldn’t pry apart the device in the nice, clean way Lady Ada is able to…so…out came the Dremel!  

NewImage

The Active Parts

To get started, I looked at the active parts.

These two images show the location of the parts:

Pasted Image 3 24 17 6 16 AM

Pasted Image 3 24 17 10 17 AM

HEF 4053BT

Two of the chips are the HEF 4053BT (data sheet):

HEF4053BT

From the data sheet: The HEF4053B is a triple single-pole double-throw (SPDT) analog switch, suitable for use as an analog or digital multiplexer/demultiplexer.   This page on Basic Electricity has a great discussion on switches including SPDT switches.

HEF 4011BT

Another is the HEF 4011BT (data sheet):

HEF4011BT

From the data sheet: The HEF4011B is a quad 2-input NAND gate.

062C

Another chip is a variant on the 062C dual op amp (data sheet):

062C DualOpAmp

ICL7106

The internal ICL7106 (data sheet):

ICL7106

From the data sheet: TheICL7106 is designed to interface with a liquid crystal display(LCD)…

HEF4030BT

Unfortunately, I got a little too aggressive with the Dremel.  I’m still able to make out this chip is a HEF4030BT (data sheet):

HEF4030B

From the data sheet: The HEF4030B is a quad 2-input EXCLUSIVE-OR gate. 

Maxim ?

Drat…the Dremel scratched the markings off this chip.  I can tell it is a Maxim and there looks to be A1601…or A1801…or…:

MaximTBD

SGM3005 XMS

The SGM3005 XMS (data sheet): 

SGM3005XMS

From the data sheet: The SGM3005 is a dual, low on-resistance, low voltage, bidirectional, single-pole/double-throw (SPDT) CMOS analog switch designed to operate from a single 1.8V to 5.5V power supply.

At this point, my eyes hurt.  Time to stop for now.

 

Adding a Flow Meter

Tags

, ,

Awhile back, the plants were not getting any water/nutrients because the pump relay stopped working.  It became clear to me after this incident that a flow meter monitoring whether the pump was working would be very beneficial to have as part of the Base section of the Leaf Spa.

This post is about incorporating the flow meter into the Leaf Spa.  

Thanks To Those That Went Before

Adafruit – Thank you for your awesome customer service.  Adafruit goes above and beyond any company I know providing sample code, tutorials, excellent forums, products I can trust to work.  Products cost a bit more…but I really want Adafruit and companies who respect their customers and employees.

The Flow Meter

I got a liquid flow meter in the mail from Adafruit yesterday.

NewImage

 

How It Works

My goal is to detect whether water is flowing through the sensor.  I’ll do this in the firmware by figuring out if the flow rate is > 0 when the pump is supposed to be on.  I haven’t used a flow meter before so I figured I should know at least a little bit on how it works.

T.K. Hareendran’s blog post, “Working with Water Flow Sensors & Arduino”, gave me great info on the basics of how this type of flow meter works.  For example, I find out the type of sensor I bought is a YF-201 Hall-Effect Water Flow Sensor.  As pointed out in the article:  This sensor sits in line with the water line and contains a pinwheel sensor to measure how much water has moved through it. There is an integrated magnetic Hall-Effect sensor that outputs an electrical pulse with every revolution… By counting the pulses from the output of the sensor, we can easily calculate the water flow rate (in litre/hour – L/hr) using a suitable conversion formula.

I’ll be looking at the flow rate of water when the Leaf Spa firmware turns on the pump relay.  If there is no water flowing, something within the pump system (the pump itself, the relay) is not working.

As usual, Adafruit has provided superior support for the flow meter by making available a sample Arduino sketch at this GitHub location.  Getting this sketch working was easy and gave me a better feel for how the flow meter works with the Arduino.

I’ll blindly take the approach of “if you say so” based on Lady Ada’s comments in her Arduino Sketch:

  // if a plastic sensor use the following calculation
  // Sensor Frequency (Hz) = 7.5 * Q (Liters/min)
  // Liters = Q * time elapsed (seconds) / 60 (seconds/minute)
  // Liters = (Frequency (Pulses/second) / 7.5) * time elapsed (seconds) / 60
  // Liters = Pulses / (7.5 * 60)
  float liters = pulses;
  liters /= 7.5;
  liters /= 60.0;

I’m interested in the flow rate, not in how much water goes through the sensor.  Given what Lady Ada tells me about the flow rate (she’s using Q to represent the flow rate in liters/minute):

Pulses (Hz)) = 7.5 * Flow rate(liters/minute)

Flow rate (liters/minute) = Pulses (HZ)/7.5

Test Code

I’m going to use an external interrupt (the attachInterrupt() API) to let the firmware know when water is flowing through the sensor.  The test sketch that seems to work – FlowMeterTest2.ino – is located at this GitHub location.

Adding Code

Simpson DOHBut first…an OOPS…I thought it would be a “good thing” to update the SD library since I was informed I didn’t have the latest…BUT I FORGOT about what I talked about in this post about SD.end().  Here is the error I got:

Multiple libraries were found for “SD.h”
Used: /Users/margaret/Documents/Arduino/libraries/SD
Not used: /Users/margaret/Documents/Arduino/libraries/SD-master
Not used: /Applications/Arduino.app/Contents/Java/libraries/SD_ORIGINAL

seems I’m not lacking SD libraries :-).

Turns out the one being used was the library that I updated yesterday…the SD library folder within my Arduino/libraries folder.  I deleted the SD folder.  Now the firmware is back to using the SD-master library…which includes the end() API.

Bummer – attachInterupt() is only available on pins 2 and 3 on the Arduino Uno.  The firmware is already using these pins (from TheLeafSpa.ino sketch located at this gitHub location (version 8767e1d):

   PIN MAP
   2 - DHT temp/humidity
   3 - SD card detect
   4 - pump relay
   5 - LED relay
   6 - CO2 relay
   7 - Software Serial
   8 - Software Serial
   10 - SDI chip select
   11 - SDI DI pin
   12 - SDI DO pin
   13 - SDI CLK pin

The firmware is using attachInterrupt() with pin 3.  This means I’m restricted with the current hardware configuration to using pin 2 for the flow meter.

It doesn’t help that Seeed’s Grove Base Shield limits the digital i/o pins further:

I’m changing the pin mappings:

   PIN MAP
   2 - Flow Meter
   3 - SD card detect
   4 - DHT temp/humidity
   5 - LED relay
   6 - CO2 relay
   7 - Software Serial
   8 - Software Serial
   9 - Pump relay
   10 - SDI chip select
   11 - SDI DI pin
   12 - SDI DO pin
   13 - SDI CLK pin
  • DHT is on pin 4 instead of pin 2.
  • pump relay is on pin 9 instead of pin 4.
  • Flow meter is on pin 2.

 Adding the Flow Meter

It took a bit of emotional effort to cut into the plumbing and insert the flow meter..but it’s done…before and after:

NewImage   NewImage 

Checking the Log File

 Below are two snippets of the log file after adding the flow meter:

1 3/22/2017 11:40:28          
0 3/22/2017 11:41:28 23.5 71.5 1097    
5 3/22/2017 11:41:28          
2 3/22/2017 11:41:28 167.33        

 

1 3/22/2017 11:55:28          
0 3/22/2017 11:55:29 24.3 70.2 1113    
5 3/22/2017 11:55:29          
6 3/22/2017 11:55:37          
2 3/22/2017 11:56:28 175.33        

1 in the first column means the pump has turned on. 2 means the pump turned off.  The row identifying the pump was turned off now includes a column with the flow rate in liters/minute.  Both are > 0 which means water has gone through the plumbing.  YIPPEE!  The first flow rate shows 167 liters/minute (~44 gallons/minute).  The second shows 175 liters/minute (~46 gallons/minute).

The pump’s data sheet (I am using the 160 GPH model) states the model I am using has a min GPH of 106 and a max of 175.

I measured a WAY HIGHER value…SO…hmmm…

The values for the flow rate ARE NOT ACCURATE however, the Leaf Spa is detecting whether the water is flowing.

So, for what I need it to do, the flow meter is doing ok.  At this point, I do not need the flow rate.  If I did, I would debug this further.

Good better best  Of course, measuring the flow rate as accurately as possible should be part of the Leaf Spa.  But since my goal at this point is to detect water flow, I will not debug now.  Future builds should accurately measure water flow.  Frankly, I am not surprised measurements are off.  I did not do any flow rate accuracy testing before putting the flow meter in.

 

ChallengesBringOpportunites Yippee!  The flow meter is in place.

Adding a Fan to the Left Side

Customer Check-In

The images show the improved (I hope!) left side with the second fan mounted as well as the plants/fan on the right side:

NewImage

NewImage

The right side of the Leaf Spa has a mounted fan blowing air down on the leaves:

NewImage

None of the plants look stressed.  However, the left side of the Leaf Spa does not.  The Stevia Leaves curl up:

NewImage

I’m exploring if this leaf stress is caused by the air temperature being too high.  I just turned down the light intensity.  Turning down the light intensity will lower the air temperature a bit.  

In this post I’m focusing on designing and 3D printing a fan  mount that will be attached on the left side of the Grow Chamber.  This way, the left side will be more balanced to the right in terms of air temperature and access to CO2.  I’ll be including a hole for a CO2 tube.  I plan to split the CO2 tubing so that both the left and right side will receive CO2 when the CO2 valve is turned on.  

The Fan Mount

I’ll start with the Fusion 360 model I made – and am using – for the right fan mount.  I will modify the model such that the bolt mounts go through the plastic and attach to the LED Shelf with a nut.  This way, the plastic doesn’t have to handle screw/bolt threading – a weakness on the right Fan mount.

NewImage

Now that I have the fan mount 3D printed, it’s time to wire up power in a way that both fans share the 12V power supply.

NewImage

 I put connectors on wires going between the Grow Chamber and the Base because I have this new idea to bling out the Leaf Spa so that I can wheel it outside during the summer.

One improvement down…many more to most likely come!

Increase CO2 -> Decrease the Cost of Lighting

Tags

, , , , , , ,

Customer Check-In

This time I used a small tri-pod to hold the camera.  Not ideal, but does show the plants ok.  The plants near the fan are getting a nice air flow.  The Stevia leaves (plants closer to the camera) are curling in. My first guess is the leaves are either getting too much light and/or the temperature is too high.  The leaves themselves are all green, so at this point I do not believe the curling is due to too much nutrients.  I’ll be adjusting the lights based on the discussion in this post.  I’ll address the temperature in a subsequent post.

Increase CO2, Decrease Light Costs

Isn’t it FANTASTIC that increasing the CO2 can decrease the cost of lighting?

I am practicing sustainability.  I am not only interested in the $ cost,  but also how much energy is currently being used by the Leaf Spa and if there are things I can tweak to minimize both costs without compromising healthy leaf growth.

The current amount of power used by the LEDs is 95.8 W.  The amount of energy used up within a 24 hour period = 95.8 W * 20 hours / 1000 = 1.9kWh. From a $ perspective, Chart 2 from the Bureau of Land Statistic’s web page notes 1kW costs us folks in Seattle around $.10. So 1.9kW $.19 per day.

I have not optimized the settings for light intensity in the presence of higher CO2 levels.  Indeed, I haven’t evaluated the current light intensity with what is considered a healthy light intensity for the leaves.

The goal of this post is to see if I can tweak the light intensity to a lower amount such that costs in both energy and money are decreased.

Thanks To Those That Went Before

Dr. Kubota – The lectures in the course –  Greenhouse Plant Physiology & Technology from Dr. Kubota (University of Arizona), inspired me to understand the how and why CO2 benefits plant growth…after all, I want to give plants a Spa experience – so ultimately, only the best for the plants! 🙂

Increasing CO2 Increases Photosynthesis

Dr. Kubota showed us this image when she gave the lecture on the effects of CO2 on plants.  What this image is saying:

NewImage

given the same amount of light, the photosynthetic response is increased when the CO2 concentration is higher than the normal (of ~400ppm).   Since CO2 level + light drives the photosynthetic response rate, we can get to the same leaf mass with less light if light is supplemented with CO2.  YIPPEE!

Dr. Kubota goes on to note the effects of higher CO2 are somewhat thwarted by the plant’s (partial) closing of stomata.  Which is a bit of a bummer.  However, I was encouraged to see this slide:

NewImage

 Given the research results for lettuce – and making a wild extrapolation…a guesstimate I most likely shouldn’t be making but will experiment with is using 30% less light. 

Photoperiod and Amount DLI

Currently, the photoperiod is 20 hours.  The DLI is much higher than what  I discussed in a previous post, of a 10 mol·m-2·d-1 target.  Now that I have had time to explore the current set up, I’m going to adjust photoperiod and DLI to accommodate the learnings discussed in the article: Managing Electrical Conductivity (EC) For Hydroponic Basil Production.  While the Leaf Spa is being designed to accommodate many leafy plants, I am assuming  for this round of exploration, basil leaves can represent the leaves of the other plants when it comes to photoperiod, DLI, and CO2 concentration. The article states:

Basil had comparable growth (fresh and dry mass, branches, nodes) across nutrient solution ECs and there were no significant differences (Figure 1).

Figure 1. Sweet basil grown with ECs ranging from 0.5 to 4 mS∙cm−1 under low (~7 mol∙m−2∙d−1) or high (~15 mol∙m−2∙d−1) daily light integrals (DLIs). This photo was taken three weeks after transplanting seedlings into hydroponic systems and treatments.

Although EC has no effect on basil growth, growth increased for all three basil species grown under ~15 mol∙m−2∙d−1 compared to those grown under 7 mol∙m−2∙d−1. There was no interaction between the EC and DLI on basil growth.

New Targets for Photoperiod and DLI

Based on the information in this article and background information that has accumulated in my brain over the past year, assuming a CO2 level of ~ 1200ppm, the new targets are:

  • photoperiod of 16 hours.
  • DLI of 70% 15 mol∙m−2∙d−1 = 10.5 , rounding up to 11 mol∙m−2∙d−1
This amount of DLI + ~1200ppm CO2 should get to the equivalent photosynthetic rate as a DLI of 15 mol·m-2·d-1 + ~ 400ppm.

Current DLI

I’ll be using the calculation for DLI I discussed in this post: DLI = PAR reading  x (3,600 * photoperiod)/1,000,000.  In this post, I gave my initial readings for the Leaf Spa PAR levels.  The readings were far from uniform, ranging from 288µmol/s at an edge to 737µmol/s at the center.

Good better best Using the COB LEDs makes for uneven PAR as shown in the table below.  COBs are perhaps best for lighting when the light source is significantly higher than the canopy.  For the small height of the leaf shelf, smaller LEDs spread uniformly across the bottom of the shelf – or other mechanism (such as using lenses, i.e.: exploring optics) to smooth out the LED’s emittance – should be explored.

I just took measurements at each plant base and then at ~the top of the Stevia plant.

Base       Average Average
  290 280 380 317  
540 680 460 300 495 391
  430 400 250 360  
           
~Top of Stevia          
540 640 780 350 578  
930 600 810 700 760 613
  540 500 460 500  

The numbers are ball park.  I did not pay attention to getting exact measurements.  Rather these were what I read holding the PAR meter “to about where” I thought was the right spot and taking a reading.  Totally unscientific and not reproducible, but for my needs, good enough.  The top of Stevia refers to the distance seen in this image: 

Pasted Image 3 18 17 7 11 AM

Calculate Current Values

Links for how to calculate DLI when the LED is constant:  

First, I’ll calculate the DLI (DLI = PAR reading (in µmol m-2 d-1) x (3,600 (seconds/hour) * photoperiod in hours )/1,000,000 µmol/mole) for:

  • the base: DLI = (391  * 3600  * 20 )/1000 000 = 28.15 moles/day
  • the top of the Stevia Leaf: DLI = (613 * 3600 * 20)/1000000 = 44.14 moles/day
Whoa!  That’s more than is required.
Good better best I didn’t have a way (or at least couldn’t figure out a way) to calculate the DLI based on the LED’s data sheets.  At best, some vendors such as Cree provide instantaneous PPF – but this tells me how much the LED emits.  It doesn’t tell me how much PPF will smack onto a leaf.  I’m seeing measurements to be in it’s infancy with debates around definitions of acronyms such as PPFD.  Growmau (during this video) came up with a calculation based on a 4’ x 4’ grow space (1.48m2), using a 650w light @ 2.2 µmol/J.  650 * 2.2 = 1,430 µmol/sec emitted. 1,430/1.48 = 966 PPFD avg (¨mol/s/m2)…
 

Calculate When DLI ~ 11 moles/Day

Currently, the COBs are being run at 100% with a constant current of 1.05A.  If I continue to run the COBs at 100%, the photoperiod – which is currently at 20 hours would be:

  • the base = (319 * 3600 * X )/1000000 = 11 moles/day -> (11 * 1000000)/ (319 * 3600) = 9.6 hours
  • the top of the Stevia Leaf: (11 * 1000000)/(613 * 3600) = 5 hours.
Given unevenness of PAR – both from a plant location within the Leaf Spa as well as how far the leaves are from the LEDs as they grow, I need to pick an approximate value for the PAR to base calculations on.  I want to use a conservative approximate PAR value.  Looking at the measured values, I’m choosing 400 PAR to base calculations at.  
  • PAR = 400 -> (11 * 1000000)/ (400 * 3600) -> ~ 8 hours
hmm….I want the lights to be on for 16 hours. 

Adjusting the LED Driver

The LED Driver I am using is the Meanwell 709-ELG100-C1050A.  I purchased this Meanwell driver from Mouser (product link).  I am very happy with this driver.  However, up until now I hadn’t thought much about lowering the light intensity.

Good better best Future LED driver designs should take into consideration how the light intensity can be adjusted.

As noted in the data sheet:

NewImage

A models can adjust the current through a built-in potentiometer.  This is the model I bought.  Perhaps a better choice would have been the B model (for about $4 more).  The B model has connections to dim the intensity.  The range the current can be adjusted to is noted within the data sheet:

NewImage

The C1050A can be adjusted from 525 – 1050mA.

Wouldn’t you know it? The drawing in the data sheet shows the current adjustment POT on the bottom of the case:

NewImage

To get to 15 moles/day on a 16 hour photoperiod, the (average) PAR should be ~ 200.  This means I can lower the current to the low end.

Amount of Energy – Down by Half

I noted earlier the current amount of power used by the LEDs is 95.8 W.  The amount of energy used up within a 24 hour period = 95.8 W * 20 hours / 1000 = 1.9kWh. $ amounts vary.  Given $.10 / kWh, the cost = $.19 per day.

Lowering the current brought the power used down to 46.7 W.  I also adjusted the photoperiod to 16 hours.  With this setup, the amount of energy used within a 24 hour period = 46.7W * 16 hours / 1000 = .75kWh at $.10 / kWh, the cost = $.08 per day, half as much.

 

I don’t know if the lower settings are too low.  I’ll keep observing.  I certainly love the idea of 1/2 the energy and have the $ amount to run the LEDs.  Also, the lower setting will have other benefits such as:

  • decreasing the temperature of the Grow Chamber.
  • increasing the lifespan of the LEDs.

That’s it for now.  Time to move on to another adventure.

Customer Check-In

Tags

, ,

This post is a reflection  on the growth of the plants that are living their lives in The Leaf Spa.  

March 18th

I came home after five days. 

NewImage NewImage

Whoa – the top leaves of the basil are getting burnt by the LEDs.  And look – I can tell that is a Kale plant…ooh – the Stevia plants grew.  That’s a relief since I just finished reading blog posts on how hard it is to grow Stevia from seed.  YIPPEE!

A couple of observations:

  • The basil plants are too tall for the current LED shelf height.  Should I move the shelf up OR should I trim the basil plants down so the other plants aren’t penalized with less PAR?
  • Perhaps I’m seeing what I want to see, however, the plants closer to the fan appear more mature.  The quality of the Leaf Spa would improve if a second fan was placed on the other side of the Leaf Spa

Good better bestRight now the Leaf Spa has one CPU fan that benefits the plants on the right side of the Leaf Spa.  Putting a fan on the other side would benefit plants on the left side.  It would also be beneficial to release CO2 from both sides.

March 1st

To put plant growth progress into perspective, the image below shows what the plants were doing on March 1st:

NewImage

I am happy with the plant growth that has occurred within the last 2 1/2 weeks.  However, there is A LOT of room for improvement.  The current results are promising.  I am eager to evolve the Leaf Spa experience into the ideal controlled environment for the plants as I learn more about (and implement) what works best.

Taking MH-Z19 CO2 Readings Using Micropython

Now that I have explored reading the CO2 sensor using PWM using an Arduino (GitHub location of Arduino sketch), I want to do the same using Micropython.  Since I got a nifty WiPy awhile back, I thought I’d start with using this hardware rich micro python platform.  Getting to the punch line, I was able to calculate what appears to be a reasonable CO2 value using Pin interrupts.  I am not sure how reasonable because I cannot test/calibrate with Leaf Spa readings for a few days.  I stumbled over several challenges including my lack of python knowledge.  But…I also became frustrated and lost time because of whimsicalities I ran into using the WiPy PyMakr IDE as well as the WiPy implementation 1.8.7 of pycom I was using.  At this point, I am not convinced micro python is ready for me to use for the Leaf Spa.  However, I plan to continue exploring micro python using Adafruit’s feather Huzzah.

PWM

I’ve used PWM for blinking lights and such.  But until the MH-Z19, I haven’t had the opportunity to read PWM high/low signals.  So I thought I’d start by making sure I understood PWM a bit more.  Here’s a nice image:

As noted in the All About Circuits article on PWM:  “a PWM signal is a sequence of periods in which the duration of the logic-high (or logic-low) voltage varies according to external conditions, and these variations can be used to transmit information.”

So the folks who designed and built the MH-Z19 encoded CO2 readings by modulating the ON/HIGH (which determines the OFF) time within a cycle.

As noted in benripley’s excellent post, Three Ways to read a PWM signal, “…what we are really looking for is the length of time the signal remains high for each cycle.  I’ll be looking at two of these to see if I can read the MH-Z19 using PWM:

  • is there an equivalent pulseIn function to the one I used to create this Arduino sketch to read the MH-Z19?  Not really.
  • is there a pin change interrupt API that fires when the pin changes state from high to low and from low to high? Yes.
 

Calculating the CO2

Now that I feel more comfortable with working with a sensor that sends values through a pwm channel, I wrote this script.  Argh!  My knowledge of python is so low!  But the micro python code running on the WiPy seems to do the trick.  The gist of the code:

  • set the Pin reading the pwm to callback to rising() when the rising part of the pulse is detected.
  • once rising() is called back, start a ms timer that once a falling edge is detected will give us the th value.  Set the Pin to callback to falling() when the rising pulse is detected.
  • once falling() is called back, stop the timer and set th.  Set the Pin to callback to rising() one last time so we can set the tl value.
  • rising() gets called back one last time.  Set tl.
  • calculate the CO2 based on the formula given in the MH-Z19 data sheet (section 7.1):
NewImage

WiPy Whimsicalities

Identifying the Pin

The way I was able to finally reference the pin I was using for PWM in was time consuming/frustrating.  This is because the documentation (to me) is confusing. 

The documentation of  Pin class within the machine module of the WiPy’s version of micro python  discusses the Pin callback:

from machine import Pin

def pin_handler(arg):
    print("got an interrupt in pin %s" % (arg.id()))

p_in = Pin('P10', mode=Pin.IN, pull=Pin.PULL_UP)
p_in.callback(Pin.IRQ_FALLING | Pin.IRQ_RISING, pin_handler)

That didn’t work for me.  I finally stumbled upon this text:

classPin.exp_board

Contains all Pin objects supported by the expansion board. Examples:

Pin.exp_board.G16
led = Pin(Pin.exp_board.G16, mode=Pin.OUT)
Pin.exp_board.G16.id()

which seems to by in the 1.8.4 WiPy documentation, but missing from the 1.8.7 documentation! ….Grrrrr…..

Figuring pin identification was exacerbated by this statement in the 1.8.7 documentation….Grrrrr…..

On the WiPy board the pins are identified by their string id:

from machine import Pin
g = machine.Pin('GP9', mode=Pin.OUT, pull=None, drive=Pin.MED_POWER, alt=-1)

Using the USB Port to Program the WiPy

I’m plugging in the expansion board into one of my Mac’s two USB ports.  It was very common for me to receive:

Connected
> Could not enter friendly repl. (click to attempt to reconnect)

Googling this obtuse message seems to mean PyMakr can’t connect to the expansion board through the USB port.….Grrrrr…..  I put my Mac away for a few hours and come back to it.  The USB port magically starts working.  Hmmm…

…..

Well…I’m stopping my exploration into measuring CO2 using the MH-Z19 connected to a WiPy for now.  When I get back home, I’ll test/calibrate within the Leaf Spa.

 

Build Log March 12th (Daylight Savings and Different CO2 Sensor)

 

Today is daylight savings.  Unfortunately, the RTC doesn’t know this and now the time is off by one hour.

Good better best The Leaf Spa needs to accommodate Daylight Savings.  How I’ll do this is TBD.

 

A Different CO2 Sensor

I recently received two Winsen MH-Z19 NDIR CO2 sensors I ordered from Alibaba.

I am exploring a different CO2 sensor because:

  • The cost is less (I paid $22 for one).
  • The interface to the micro controller does not rely on the UART.  As noted in diy_bloke’s Instructable: The MH-Z19 has 3 ways of reading the CO2 concentration. It has a Tx/Rx UART, It has an analog output and it has a PWM input.  I’m hoping this will make it possible to use with microPython on the esp8266 enabled board.

The data sheet is located here.  Here is an image of the layout:

NewImage

NewImage

According to the diagram, the pins 2 and 3 are for UART readings and pin 9 is for PWM readings.

Testing the Board

I used the information provided in this stack exchange to write an Arduino sketch (GitHub location).  Here are results from running the sketch within my work area:

Test 1
th: 166
tl: 838
2000ppm Concentration limit: 328
5000ppm Concentration limit: 820
—————————————
Test 2
th: 166888
tl: 830489
2000ppm Concentration limit: 331
5000ppm Concentration limit: 829
—————————————
Test 1
th: 166
tl: 838
2000ppm Concentration limit: 328
5000ppm Concentration limit: 820
—————————————
Test 2
th: 167489
tl: 829888
2000ppm Concentration limit: 333
5000ppm Concentration limit: 833

I then ran the tests with the sensor inside the Leaf Spa:

NewImage

Drat…i forgot to capture the results.  Tests 1 and 2 were within error range of each other.  The results were ~ 150ppm lower than the MH-Z16 sensor.  BUT I have not calibrated the MH-Z19.  I want to do that when I get back from vacation.  Note: the MH-Z19 can be read through PWM, however calibration happens through the UART.  Not a big deal…but does point out that not all functionality can be handled through digital i/o. 

My thoughts based on this initial investigation of the MH-Z19 is it is “the best” choice to be the CO2 sensor for the Leaf Spa because:

  • less expensive than the MH-Z16 with enough accuracy.
  • does not need UART to read CO2 data.
  • it is an NDIR CO2 sensor, so it is measuring CO2 instead of estimating – which is what the CCS-811as a VOC sensor does (see wminark’s comment on this blog post).
  • It is more readily available than the CCS-811.  I put an order in for a few CCS-811’s on Digikey months ago…the current estimate is a few weeks from now.  However, that date has changed before.  Perhaps if I was buying in the bulk amounts a cell phone manufacturer needs…but at the small quantities I need, I don’t feel comfortable with my ability to source the CCS-811.

Learning about the MH-Z19 was awesomely fun and useful.  I am excited to try the Leaf Spa firmware using micro python and the ESP8266…!

 

Build Log for March 10th (the Water Pump Stopped pumping)

Tags

, , ,

Customer Check-In

Um…sadly…I’m having a fight with the camera mount I put together.  This is impeding my willingness to take pictures.  Then the pump stopped working which happily this story ends with me able to fix the pump.  So…the pressure was too much to actually take a picture of the plants.  Silly.

What’s Going on with the Pump?

Although the plants look like they are getting nutrients, I’m concerned I haven’t been hearing the water pump through the system…is the pump really turning on / off?

Good better best I will install a flow meter within the path of the water like DIY hacking did on their post.  I just ordered Adafruit’s flow meter.  I did my irrational order before thoroughly checking out if it would work.  I purchased from Adafruit because I value what the company stands for and the amount of knowledge Adafruit shares with the community.

While the plants haven’t shriveled up and died, I haven’t hear the pleasant gurgle of water.  Is the pump working?  To figure this out, I’m taking the following steps:

  • Look at the log file.  Does the log file show recent records that the pump was turned on and off?  What time period is the pump supposed to be on? 
    • The log file (sheet 03102017_1245) DOES show the pump is turning on/off as expected.  The log file records the pump turning on every 15 minutes and staying on for one minute.  The pump should have turned on four times an hour at 3, 18, 33, and 48 minutes past the hour.
  • Stand by the Leaf Spa when the pump is supposed to be on.  Did I hear the relay switch?  Did I hear the pleasant gurgle of water?
    • NOPE.
  • Check if the pump works by plugging it into a power source not connected to the relay.
    • YEP.
I am left to believe the relay switch is no longer working for the pump.
Why Isn’t the Relay Switch Working?
 
I pop open the wall socket mount and …
Simpson DOHthere are drips of water inside… DRAT… I had placed the relay box at a location where water from a leak in the plumbing could hit the relay box.  A few drops entered through the wall sockets.  Now I’m concerned because of safety.  Some of the relay connections have a small amount of rust on them.
 
It turns out, the relay being used for the pump stopped working.  I rewired the relays, hooked the box back up.  
 

ChallengesBringOpportunitesNow the pump, LED, CO2 relays are working.

Changing the Nutrients

Now that the pump is back working, I decided to change the nutrients.  As I do this, I am thinking through how the Leaf Spa system can make it (no 🙂 ) dirt simple.

Right now:

  • I  drain as much of the nutrients that are in the Coleman into a bucket then dispose of the nutrients:
NewImage
Good better best I am practicing sustainability.  In the future, I will explore using organic fertilizers.  For now, I mix chemicals.  One step at a time.  
 
  • Clean out the bucket and mix fresh nutrients using my most awesome pH/EC meter to measure in the Jack’s Hydro nutes I use.  I target an EC of around 3 mS/cm and a pH of around 6.1.
Good better bestI will evolve the pH and EC circuit / probe solution I did with the Ladybug Blue Lite and Ladybug Shield (there are previous posts on these projects) to measure and then automate the injection of the nutrients as well as pH UP/DOWN as needed.
  • Get the freshly mixed nutrients into the Coleman.  This time around I tried using this siphon:

NewImage

and siphon the water from the bucket into the Coleman through one of the net pot pipes (where the plants are).  Sadly, this didn’t work.  Still, I like the idea of not having to lift the lid off the coleman….

Good better best Need to figure out a better way to get the nutrients (or in the future water) from the bucket into the coleman using a pump.

Thinking about the relay – on the one hand, WHOA – how stupid of me to put the box so close to where water could go through the plugs!  On the other hand, it is one more day that gave me the opportunity to learn and solidify my knowledge about wiring relay boxes :-).

Build Log for March 8th (Analyzing the Log File with a Python Script)

Customer Check-In

Well…I stare at the plants a lot.  However, I’ve been …um…challenged to get the camera mount working right and my mind won’t let me take a picture of the plants until I have that figured out.  I better figure this out soon! 🙂

Open Source  

This post discusses the python code located at this GitHub location.

The Question I’m Asking

I’m looking at data in the log file that goes from 3/4 4:26:60-3/7 12:54.  While the use of the data will change over time to focus more on the health of the plants, the question I’m answering in this post is:

What is the average temperature,humidity, and CO2 when the LEDs are on and when they are off?

Knowledge Provided  by the Answer

Knowing the average values of the environmental properties monitored by the Leaf Spa will give me a clear idea if these key values in the healthy growth of a plant are optimized and at expected values.

Here are the results for the log file in this spreadsheet (sheet is named 3022017_0426-0307_1254):

Average Values          
LED ON     LED OFF    
Temp Humidity CO2 Temp Humidity CO2
29.836 31.324 1147.312 None None None
29.33766088 31.41835478 1235.456072 18.20222222 51.47055556 574.2

The table is at the bottom of the sheet.  It shows there were two runs.  The first run only had values for when the LED was on.  The second run had values for when the LED was on and off.  I want to spend a little time analyzing the results.  I’ll write up my thoughts in a future post.

In this post I will focus on the Python code I wrote that appended the average values to the bottom of the log file.

Once the log file was processed by the Python code, I imported into the Google Spreadsheet.

The Python Code

The Python code (located at this GitHub location) opens the CSV file created by the firmware of the Leaf Spa, reads through it, calculates the average values as shown in the table above, then appends these values to the end of the CSV.  I called the project: Avg Temp, Humidity, and CO2.  As I discussed in a previous post, my knowledge of python requires me to wear floaties:

I run the code within the Eclipse IDE.  I show an image In this post  on how to enter arguments.  In this project the argument entered is:

-i <path to csv logfile>

In my case, the dialog box looks like this:

Pasted Image 3 9 17 10 11 AM

I’m thinking you can understand what is going on within the Python code without me explaining.

Nifty Atom Editor Feature

Since I think of myself as an advanced beginner with respect to Python coding,  I am excited to share an interactive environment that I use as a sandbox to test stuff out – the Atom editor with the script package installed. This Quora link has answers on how to install the script package.  Using Atom with script means Python scripts can run within Atom.  This makes trying stuff out much easier than using Terminal!  Yippee!!!

 

There it is:

  • (beginner level) Python code to get to the average values of the temperature, humidity, and CO2 when the LED lights are on and when they are off.
  • a new-to-me way to play around with Python using Atom + script package.
 

 

Build Log for March 4th and 5th (3D Model of Camera Mount)

Tags

, , , , ,

Customer Check-In

These images were taken at 5 minute intervals.  I tried a new way to mount the camera using…wait…for..it…that’s right DUCK TAPE!

OOPS – the duck tape quickly gave way…the camera drops…then the LED turns off.  But it does show most of the plants and what they are up to.  At this point I am not focusing on their health as much as I am on fixing any challenges with the Leaf Spa implementation.  I am fairly happy with the growth of the basil and thyme.  However, I am concerned with the health of the other plants.  I plan to research this after I get the camera mounted the way I want.

Time Lapse

Good better best  This is a late added feature – and it shows.  Challenges:

  • Did not design a mount and explore the best camera angles during the design stage of the Grow Chamber.  At this point, I will make a mount but it will not be ideal.
  • O Snap! does not automatically download the images, make a time-lapse movie, or upload to YouTube.  To do this, I have to remove the camera.
  • O Snap! has an easy way to set a time interval or to shoot during time of day.  I would like to control via when the LED is ON or OFF.  I.e.: if the LED is ON, take the shot.  If not, don’t.

What I love about O Snap! is it gives me a very good feeling for what I want out of taking pictures of plants in the Leaf Spa.  It works well enough for this prototype and I have clear ideas on how I can evolve when/if I decide to right a custom app for an iPhone or Android phone.

My next attempt at mounting the iPhone camera within the Grow Chamber is to create and 3D print a mount. I’ll do what I did with the fan and drill holes in the LED shelf.  

Designing a Mount

I’m going to design a mount for the iPhone I have in Fusion 360.  I will need

  • a Fusion 360 model of the iPhone 4S (model A1387).  
NewImage
  • Fusion 360 Design 

I’m printing out the three bodies:

NewImage

I used the iPhone 3D model done by Amit Kumar located at this web link. I decided for this attempt to go with a simple design that includes a camera grip (yellow), wedge (light blue), and fastener (purple).  I’ll glue these together after checking the wedge angle and fastener depth + bolt hole location.

To fasten the camera holder to the leaf shelf, I will draw to holes and feed these bolts through the holes and the holes on the plastic fastener:

NewImage

 I found these bolts in my husband’s toolbox:

NewImage

ummm….yah…a pretty big mess… :-).  I am ecstatic to use bolts that have been kicking around.

Note: I find fastening a 3D printed object onto the Leaf Spa to be challenging.  The simplest is to do what I’ve done here – which is to find a bolt with a nut that allows the shelf + plastic to fit the bolt and then be tightened by the nut.  This way, the plastic does not participate in the threading/tightening of bolt-to-nut.  I apologize if my terminology for this stuff is off.  I’m new to building stuff that requires bolts.

The 3d Printed fan mount + CO2 tube holder that is hanging on the other side of the Leaf Spa is fastened by screwing the bolt into holes in the plastic. This is too feeble for long term stability – although working find for now.

Here are other ways I explored to fasten a mount:

  • Heat-set threaded inserts as recommended by MatterHackers on this web post

NewImage

 

I’m still printing out the pieces…and well..with 3D printing….it takes longer than I typically expect it should….so..time to practice patience. 

Good better best Supports should be used when printing out the camera grip.