On BLE, nobody knows if sensor readings are from an nRF51822 or an Arduino

Tags

, , ,

In my previous post, I started exploring alternatives to the Arduino + Red Bear Lab BLE shields that are currently part of the Ladybug Shield design.  I’m noticing aggressive announcements by multiple vendors for SoCs that combine a micro controller like the Cortex m0 with BLE chips, many gpio ports, SPI, and I2C interfaces.  

I am using the nRF51 DK and Arm’s Keil v5 IDE.  In this post I take on the challenge of sending and receiving pH readings over i2c.  Once I can do that, I will have crossed the most major chasm between the digital and analog circuits of the Ladybug Shield. This will give me a clear idea if I could use the nRF51822 as a replacement for the Arduino + Red Bear Lab BLE shield.  I can’t wait to tell you…talk about a YIPPEE! moment….It works!!

The Goal

The goal of this post is to transmit data over the I2C interface.  Confirmation that the data was transferred will be output of the SDA/SCL lines when my Saleae Logic Analyzer is inserted between the I2C slave (I will be using Adafruit’s ADS1015 BoB…it could be any I2C chip at this point, I just needed a destination to transmit data to).

Thanks to Those That Went Before

Adafruit played a huge role in enabling me to get this to work.  Thank you  Adafruit for your open source availability, excellent tutorials, support, and products.    I hope/wish other companies embrace this ethos into their business model.  Imagine how many makers would be empowered on the nRF51822 if there were the same level of tutorial,  support, and product availability for Arm’s Keil IDE + nRF51822 BLE module.  

The first person I wanted to tell I got this working was Chris Gammell.  Chris has been a fantastic teacher and mentor.  I highly recommend his Contextual Electronics course – which I am currently a student.

Thank you Saleae for your EXCELLENT and reasonably priced logic analyzer.  I am a fan of your product and dedication to helping us easily/intuitively analyze our circuits.

The Test Setup

I used the same setup to simulate pH voltage (b) values as I did when I first started testing the pH circuit.  The other components in the test include Adafruit’s ADS1015 BoB (a) to provide the ADC conversion of the voltage into a digital value that is read from either an Arduino (c) or nRF51 (d) DK over i2c.

i2ctest_Arduino_nRF51DK

 

  • all shared the same ground
  • the voltage divider used a separate 5V power supply.
  • the Arduino or nRF52 DK used the USB power from my Mac.
  • I took advantage of the nRF52 DK’s mapping to the Arduino pin out, mapping SCL and SDA to the equivalent pins that are on the Arduino.  This way, I was less likely to mix up the green (SCL) and yellow (SDA) cables.
  • I used:
    • the Arduino’s 5V power source to power the ADS1015.
    • I used my DMM and logic analyzer to analyze results outside of the software.
    • I used Serial.println()s to analyze the results from the Arduino sketch.
    • I used the Keil debugger to step through and analyze results from the C source used on the nRF51 DK.

Results

The output of the voltage divider supplied the voltage reading to the ADS1015’s AIN0.  I used the default i2c address of the ADS1015 – 0x48.

Arduino

This image is a screen capture of the i2c traffic when the Arduino is used to get the ADC value:

LogicAnalyzerI2CnRF51. 

nRF51822

Here are the images for the i2c write and read traffic when the nRF51 DK is used:

Arduinoi2CWrite

i2c write traffic from the nRF51822 to the ADS1015

Arduinoi2CRead

i2c read traffic from the ADS1015 to the nRF51822

Traffic Analysis

(note: for the text below “master” could be either the Arduino or the nRF51 DK)

I found this tutorial on the I2C bus to be very helpful in understanding I2C traffic.  To read the traffic, we first have to know that read/write data transfers over i2c start with the master sending a byte in which the least significant bit (LSB) is either a 0 (for a write request from the master) or 1 (for a read request).  The higher 7 bits = the slave device’s address.  In the sniffs above, the first write traffic byte is 0x90 =  b1001 0000.  Thus the i2c address = b0100 1000 = 0x48 – the address of the ADS1015.  Since this is a write request, the least  the least significant bit is a 0.

The ADS1015 sees the traffic is for it so it sends back an ACK.  The write then occurs.  The master sense 0x01, which as noted in the ADS1010 data sheet

Second byte: 0b00000001 (points to Config register)

Third byte: 0b00000100 (MSB of the Config register configuration)..in this example: 0xCE

Fourth byte: 0b10000011 (LSB of the Config register)….in this example: 0x83

While I could go on crafting packets based on the data sheet, the  Adafruit_ADS1X15 library makes writing code dramatically easier.   It provides a “cheat sheet” of the ADS1015 data sheet’s discussion of I2C packet formats.  The 0xC383 bytes are the result of a call to Adafruit’s readADC_SingleEnded() when m_gain = GAIN_ONE:

/**************************************************************************/

/*!

    @brief  Gets a single-ended ADC reading from the specified channel

*/

/**************************************************************************/

uint16_t Adafruit_ADS1015::readADC_SingleEnded(uint8_t channel) {

  if (channel > 3)

  {

    return 0;

  }

  

  // Start with default values

  uint16_t config = ADS1015_REG_CONFIG_CQUE_NONE    | // Disable the comparator (default val)

                    ADS1015_REG_CONFIG_CLAT_NONLAT  | // Non-latching (default val)

                    ADS1015_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low   (default val)

                    ADS1015_REG_CONFIG_CMODE_TRAD   | // Traditional comparator (default val)

                    ADS1015_REG_CONFIG_DR_1600SPS   | // 1600 samples per second (default)

                    ADS1015_REG_CONFIG_MODE_SINGLE;   // Single-shot mode (default)

 

  // Set PGA/voltage range

  config |= m_gain;

 

  // Set single-ended input channel

  switch (channel)

  {

    case (0):

      config |= ADS1015_REG_CONFIG_MUX_SINGLE_0;

      break;

    case (1):

      config |= ADS1015_REG_CONFIG_MUX_SINGLE_1;

      break;

    case (2):

      config |= ADS1015_REG_CONFIG_MUX_SINGLE_2;

      break;

    case (3):

      config |= ADS1015_REG_CONFIG_MUX_SINGLE_3;

      break;

  }

 

  // Set ‘start single-conversion’ bit

  config |= ADS1015_REG_CONFIG_OS_SINGLE;

 

  // Write config register to the ADC

  writeRegister(m_i2cAddress, ADS1015_REG_POINTER_CONFIG, config);

 

  // Wait for the conversion to complete

  delay(m_conversionDelay);

 

  // Read the conversion results

  // Shift 12-bit results right 4 bits for the ADS1015

  return readRegister(m_i2cAddress, ADS1015_REG_POINTER_CONVERT) >> m_bitShift;  

Now that the config register is set, the i2c traffic asks the slave for the contents of the convert register.

 

..and there it is … both the Arduino and the nRF51 DK sent equivalent i2c traffic.  My iOS app wouldn’t know whether it’s talking to an Arduino or nRF51822.

 

Coding on the nRF51822’s I2C Module

Getting I2C traffic to work with the nRF51 SDK was similar to getting most apis I have been clueless about.  Unfortunately, while Nordic provides pretty good developer support, there is not the “geez this is easy let’s do it this weekend” type of tutorials that abound for the Arduino.  Getting out of the clueless state when it came to accessing I2C took longer than it might…of course, some of the cluelessness is innate to me.  

I’ll cut out the remarks and list what I found to be the most valuable things I learned:

  • the term to use when looking up anything to do with I2C is TWI.  This makes sense given this comment:  “The name TWI was introduced by Atmel and other companies to avoid conflicts with trademark issues related to I²CExpect TWI devices to be compatible to I²C devices except for some particularities like general broadcast or 10 bit addressing.”
  • Use the latest SDK (in my case this is 8.1)
  • Stay away from using the Pack installer in Keil v5.  Packs make installing and maintaining drivers – like the TWI driver source – easy, peasy.  The challenge is a pack has a significant amount of dependencies.  Given the hours I spent trying to get my code to work by using Packs, I am not convinced the dependencies within the Nordic nRF51 DK packs are all correct.  I ended up downloading the SDK 8.1 zip (note: DO NOT download the file with Pack in its name).
  • use the nRF_drv_twi driver from the SDK.  This driver was released in SDK 8.1.  I found it simple and “just worked.” As noted in this post on the Nordic DevZone, there are previous versions.  Most of the DevZone posts relate to the previous versions (and…this tricked me up for awhile since I did not have the context on why there were three…which was the one to use…). 
  • check out the (extremely sparse :-) ) TWI documentation.   The example code snippet got me started on writing/reading over i2c.
  • it seems there was a “oops” that was caught after SDK 8.1 was distributed.  As noted in this devzone post, the following must be added to nrf_drv_config.h:
/* TWI */
#define TWI0_ENABLED 1
 
#if (TWI0_ENABLED == 1)
#define TWI0_CONFIG_FREQUENCY NRF_TWI_FREQ_100K
#define TWI0_CONFIG_SCL 6
#define TWI0_CONFIG_SDA 5
#define TWI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
 
#define TWI0_INSTANCE_INDEX 0
#endif
 
#define TWI1_ENABLED 0
 
#if (TWI1_ENABLED == 1)
#define TWI1_CONFIG_FREQUENCY NRF_TWI_FREQ_250K
#define TWI1_CONFIG_SCL 0
#define TWI1_CONFIG_SDA 1
#define TWI1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
 
#define TWI1_INSTANCE_INDEX (TWI0_ENABLED)
#endif
 
#define TWI_COUNT (TWI0_ENABLED+TWI1_ENABLED)
  • Choose between the TWI drivers, or use both.  In my case I am using the TWI0 driver.  I enabled this by setting #define TWI0_ENABLED to 1.
  • set the gpio pins for SCL and SDA.  I chose pin 0.06 for SCL and 0.05 for SDA.
  • If using Keil v5, get familiar with the (powerful) debugger.  I like taking a walk with the code…by stepping through the lines within the debugger and looking at the values within variables….I am at the n00b level of understanding this debugger.  Even with that, it is a far more pleasant debugging experience than within the Arduino IDE :-).
I ended up starting with the be_app_template_s110_pca10028 example within the SDK and added the following to main.c:
err_code = nrf_drv_twi_init(&twi,NULL,NULL);
APP_ERROR_CHECK(err_code);
nrf_drv_twi_enable(&twi);
rawADC = readADC_SingleEnded(&twi,0);
 
The function readADC_SingleEnded() is a porting of Adafruit’s function:

/**************************************************************************/

/*!

 @brief  A simple read of one of the four ADC channels.  Does not use the differential

 */

/**************************************************************************/

uint16_t readADC_SingleEnded(nrf_drv_twi_t const * const  p_instance,uint8_t channel) {

        if (channel > 3)

        {

            return 0;

        }

        m_bitShift = 4;

        // Start with default values

        uint16_t config = ADS1015_REG_CONFIG_CQUE_NONE    | // Disable the comparator (default val)

        ADS1015_REG_CONFIG_CLAT_NONLAT  | // Non-latching (default val)

        ADS1015_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low   (default val)

        ADS1015_REG_CONFIG_CMODE_TRAD   | // Traditional comparator (default val)

        ADS1015_REG_CONFIG_DR_1600SPS   | // 1600 samples per second (default)

        ADS1015_REG_CONFIG_MODE_SINGLE;   // Single-shot mode (default)

        

        // Set PGA/voltage range

        config |= m_gain;

        

        // Set single-ended input channel

        switch (channel)

        {

            case (0):

                config |= ADS1015_REG_CONFIG_MUX_SINGLE_0;

                break;

            case (1):

                config |= ADS1015_REG_CONFIG_MUX_SINGLE_1;

                break;

            case (2):

                config |= ADS1015_REG_CONFIG_MUX_SINGLE_2;

                break;

            case (3):

                config |= ADS1015_REG_CONFIG_MUX_SINGLE_3;

                break;

        }

        

        // Set ‘start single-conversion’ bit

        config |= ADS1015_REG_CONFIG_OS_SINGLE;

        

        // Write config register to the ADC

        // Note: currently block until write happens

        writeRegister(p_instance,m_i2cAddress, ADS1015_REG_POINTER_CONFIG, config);

 

        // Read the conversion results

        // Shift 12-bit results right 4 bits for the ADS1015

uint16_t valInRegister = readRegister(p_instance,m_i2cAddress, ADS1015_REG_POINTER_CONVERT);

        return valInRegister >> m_bitShift;  

}

 

/**************************************************************************/

/*!

 @brief  Writes 16-bits to an ADS1015 register

 */

/**************************************************************************/

void writeRegister(nrf_drv_twi_t const * const  p_instance,uint8_t i2cAddress, uint8_t reg, uint16_t value) {

    uint8_t tx_data[3];

uint32_t           err_code;

    tx_data[0] = (uint8_t)reg;

    tx_data[1] = (uint8_t)(value>>8);

    tx_data[2] = (uint8_t)(value & 0xFF);

 

    err_code = nrf_drv_twi_tx(p_instance, i2cAddress, tx_data, sizeof(tx_data), false);

    APP_ERROR_CHECK(err_code);

}

/**************************************************************************/

/*!

 @brief  Reads 16-bits from an ADS1015 register

 */

/**************************************************************************/

uint16_t readRegister(nrf_drv_twi_t const * const  p_instance,uint8_t i2cAddress, uint8_t reg) {

 

uint32_t           err_code;

// TBD: err_code (error handling) should be identical to all other nordic modules

          err_code = nrf_drv_twi_tx(p_instance, i2cAddress, &reg, sizeof(reg), false);

          APP_ERROR_CHECK(err_code);

 err_code =  nrf_drv_twi_rx(p_instance,i2cAddress,data,2,false);

                   

  value = (data[0] << 8) | data[1];

    return value;

}

That’s It For Now

While there were moments when my head hurt from banging it on my desk…thanks to previous efforts by Adafruit and folks on Nordic’s DevZone, I was happy to be able to get this working.  Especially given my weak coding skills and n00bness to embedded systems and their tool chains.  Having said all that, I am watching Apple’s WWDC 2015 videos…longing for a Swift playground that talks to all these SoCs /dev environments: Arduino, nRF51 DK….so that testing things out would be as easy as breadboard prototyping and looking at signals from a scope or DMM…well..now that Swift is open source…anyways…

 

 

Please find many things to smile about!

 

Evolving the Ladybug Hardware

Tags

, , ,

I think it is a combination of wanting to explore as I am becoming more experienced in electronics/embedded software, momentum behind devices using BLE to chatter amongst themselves and testing the wantcurrent Ladybug experience that got me to ask:

Does it make sense to replace the Arduino and Red Bear BLE Shield with a BLE module?  If so, which module?

Where the definition of a BLE module comes from this page on BLECentral:

…a small form factor PCB, ready to use, where not only the IC or SoC is already soldered, but also the required RF components (filters, antenna), oscillators and passive components. To top it off, many available modules also include a metal shield to prevent EMI and are certified according to the regulations in place in one or many regions of the world: Europe (CE mark), USA (FCC), Canada (IC), Japan (VCCI)… 

and the comparison of IC to SoC is:

  • SoC: (from the BLECentral page) A SoC is a single chip where the vendor has packaged all features one will usually need to address a specific market…one or more microcontrollers, static RAM memory, Flash memory, Bluetooth controller, RF transceiver, voltage regulators and tons of extra peripherals (analog to digital converters, timers, cryptographic processors…)
  • IC: the op amps, ADC, etc. that are mixed and matched…for example, all the active components of the pH and EC circuits.

The Goal

The goal of this post is to start the exploration in answering the above question.  This post will focus on the module.

Thanks to Those That Went Before

  • I am extremely grateful for Elicia White’s guidance.  I am a fan of her podcast Embedded.fm and her book “Making Embedded Systems: Design Patterns for Great Software”  as well as her element 14 blog posts, like the one she recently did “Bluetooth Low Energy, Three Ways.”  I had been getting up before the crack of dawn the last two days trying to get example apps to run on the nrf51 dk.  I asked for advice on the embedded.fm web site and WHOA…Elicia’s advice got me unstuck and running the example apps in an extremely short time.  Talk about a gracious and gifted technologist!
  • I will always be grateful to Chris Gammell for his Contextual Electronics courses and mentoring.  I would not be able to be able to design a schematic, do a PCB layout, or problem solve circuits without his guidance.
  • Adafruit continues to be an amazing resource for the maker community.  Adafruit is more than a place to buy a breakout board.  The folks there invest heavily in helping us learn about electronics, providing libraries so that writing sketches that use chips on the breakout boards extremely easy-peasy, and providing a community with tremendous support, enthusiasm.  I happily buy from Adafruit even when a breakout board might cost more because Adafruit provides not just a chunk of hardware, but a sense of quality and caring.  I recently purchased the Bluefruit which has emboldened me to jump into exploring the software/hardware around BLE – the communications method I use between the Ladybug iPhone app and device.
  • I can’t think of a company that I would rather do business with than OSH Park.  The OSH Park service, support, and team are role models on excellence other small businesses should work towards.

Current Hardware

Open Source

The Ladybug Shield Kicad schematic and layout files are located at this GitHub repository.

Block Diagram

The current hardware contains stuff that you might expect to see in a prototype:

Current Ladybug HW

The Ladybug iPhone app talks with the Ladybug device using BLE.  BLE is provided by the Red Bear BLE Shield that sits on top of an Arduino.  The Ladybug Shield sits on top of the Red Bear BLE Shield providing pH and EC voltage readings.  Many (at this point most) of the posts on this blog are about the evolution of design, testing, and implementation of the Ladybug Shield.  The The ADS1015 ADC sends voltage readings that represent pH and EC measurements over I2C.  The sketch on the Arduino sends a HIGH to one of three pumps when the control logic determines if the pH or nutrient amounts need to be adjusted within the nutrient bath. 

The Prototype Accelerated Progress

I am happy with this prototype approach.  It has allowed me to:

  • indulge my voracious appetite for learning. I am very happy with the amount I have learned this past year that would otherwise not have been possible.
  • enhance my hydroponics setups with automatic adjustment of pH and EC.  I am currently using and improving on the software as the prototype hardware is being tested in situ.
  • solidify the hardware of the protagonists – the pH and EC circuits.

Evolved Hardware Design

While I continue to evolve the Ladybug iPhone app, I want to also evolve the design of the Ladybug Device.  I do not see a current need to evolve the pH and EC circuits.  There is a great opportunity to evolve the micro controller and BLE components.  Instead of the Arduino as the micro controller and the Red Bear BLE Shield as the BLE component, I will be exploring using a BLE module like Raytac’s MDBT40 (data sheet).

New Ladybug HW The Nordic site lists several nrf51822 modules.

Potential benefits of replacing the Arduino and Red Bear BLE Shield with the BLE module module include:

  • Simplification of the Ladybug Device.  Instead of an Arduino Uno with the ATmega328  + Red Bear Lab BLE Shield with the Red Bear BLE land nrf8100 library from Notdic, the device shrinks down to be the BLE module (replacing both the Arduino and the Red Bear Shield) plus the current pH, EC, and pump circuits of the Ladybug Shield. 
  • Cost:  current costs:
  • Learning:  More YIPPEE!! moments ahead.  I’m already excited.
  • Evolved BLE: The Red Bear BLE Shield I am using uses the nrf8001 for BLE.  The nrf8001 is an earlier generation chip.  Besides correctly handling the BLE advertising packet (for example, currently I limit the name of a Ladybug to 10 characters and can’t use the advertisement packet to broadcast sensor readings), it integrates the ARM Cortex-M0.  This post provides a high level comparison between the two chips.
  • OTA-DFU (Over-The-Air Device Firmware Upgrade): From Nordic’s postThis feature allows application, protocol stack or, application and protocol stack to be updated wireless, over the air.

Testing the nRF51822

Development Board

I looked at two options:

The Bluefruit

Since I already had a Bluefruit, I started down the path of programming the nrf51822 on the Bluefruit.  Adafruit has pin outs that can be hooked up to a programmer on the back side of the Bluefruit (see Reverse Side Breakouts at this link):
Pin Outs - back of blue fruit
I’m new to all of this, so I asked on the Adafruit forum what I needed to program the nrf58122.  As usual, I got a great response:

get a Jlink  and connect to the SWD/SCK pins on the back, you’ll need the nordic SDK, available @ http://www.nordicsemi.com/
please note: we have zero support or tutorials for bare-programming the nrf58122

the plan was to solder jumper cables onto the SWC and SWD pins then plug the other end of the jumper cables into the SWD/SWC slots of the Jlink provided cable. 

The nRF51 DK

I ended up going with the nRF51 DK (link on digikey).  

nRF51 DK

Link to image

There is A LOT that comes with the development kit:

  • The Jlink is included on the board. Nothing else is needed to program or debug.
  • As noted on the Nordic site: “The kit gives access to all I/O and interfaces via connectors and has 4 LEDs and 4 buttons which are user-programmable.
  • Also from the Nordic site: The kit is hardware compatible with the Arduino Uno Revision 3 standard, making it possible to use 3rd-party shields that are compatible to this standard with the kit.  I read this to mean I can test the Ladybug Shield using the nRF51822 instead of the Arduino and Red Bear Lab BLE Shield….YIPPEE!!!
  • mbed is supported if I wanted to give mbed a twirl.  For now my focus is on the nRF51822.

Development Environment

On to the software I’ll be running on my Mac for programming and debugging.  The toolchain assumes Windows.  While native Mac support would be very welcomed, it is not a show stopper.  I already use Parallels for Windows for Kicad and Quickbooks.  I followed the steps outlined in this post to set up the development environment.  More documentation on the Nordic SDK is given on this link.  This means I am using the Keil MDK IDE from Arm.  I could have also used an ARM GCC compiler.  
 
Note: one of the software packages is the Keil MDK IDE from Arm (download link).  I plan to use the Lite version, which is free.  It’s limitations are discussed  here.  The main limitation seems to be a code imitation of <= 32K.  Noted in this post:

Most applications will actually fit inside 32k because of the architecture and SDK that Nordic provides. If you need more than 32k, there is always Eclipse and GCC.  This version of the IDE can be used in commercial products as discussed here.   While the Keil MDK IDE is not as comfortable to use as iOS’s XCode – especially since I develop on a Mac – I found it to have nice features – like the Pack Installer and symbolic debugger.

Time to Blink

Time for the HELLO WORLD app.  There are many examples that come with the Nordic SDK.  The Keil IDE includes a Pack Installer that makes it incredibly simple to get an example up and running.  Simpler than at least the previous version of the Arduino IDE where to get 3rd party examples to work means copying the libraries + examples to “the right” location with no visualization of what has been copied and no flexibility to where the examples + libraries are copied.
 
I followed the tutorial recommendation and tried out the ble_app_uart_s110_pca10028 (UART over BLE application).  I wasted some time not grasping what s110 was all about…I found it important to understand the implications of a SoftDevice.  This image allowed me to get my head around the s110.  It’s great that the s110 is in a fixed memory location and does not take away from the 32K restriction.
 
I got the example running and then installed the nRF Toolbox (for iOS) on my iPhone….and…a YIPPEE!! moment…it worked.  WHOA.
nRF Toolbox UART example
 

That’s it for Now

I need to get back to my Contextual Electronics work/study as well as the Ladybug iPhone app.  Not to mention I designed a PCB for an LED system I’m working on.  I am excited to continue exploring an nRF51822 module as a replacement for the Red Bear Lab BLE Shield and the Arduino within the Ladybug device.

 

 

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

Progress update on Ladybug Shield

Tags

,

 

A few updates….

 

I’m starting to use the Ladybug Plant Food Adjuster on a lettuce setup.  I’ll post more details on the setup in another post.

Thumb IMG 3554 1024

I’m excited to say the system is working well.  There are bugs particularly in the iOS app.  For example, the iOS app writes each reading to a CSV file.  When the app runs in the background, data collection stops.  I updated the app to support BLE background reading (and while at this updated to support state preservation and restoration in the case iOS needs to terminate the Ladybug app due to low memory…hard for me to believe the grower is running more important apps :-) – yah right!).

Change to Ladybug Shield

A change I made to the Ladybug shield was shrinking it’s size.

Size comparison of Ladybug Shield between beta 3 and beta 4

The smaller size was $9 less when ordering the 3 boards from OSH Park.  My original plan was to not force the Ladybug Shield to be the top shield by sticking out the BNC connectors.  As I was using the board, I found shields come in all shapes and sizes.  It seemed no matter how long I made the shield, there is another shield that didn’t sit well when the Ladybug shield was below.  In particular, currently I am using the Red Bear BLE shield.  This shield is a tad too long for the BNC placement.  So I shrunk the board mostly because of what I consider a significant cost savings.  I did not see a use case compelling enough to (most likely) expand the board to justify the additional cost of PCB fabrication.

Although in the process I could have handled the artwork better:

1505250731 0

oops! trace goes over OSHW logo

I’ll fix this on the next rev of the board…. 

Change to Cabling Between Enclosures

I haven’t spent much time on enclosures and cabling.  I want to focus on starting to use the plant automator and then evolve the different parts of the experience.  Initially, I had strung together some wire between the two enclosures so that the shield could send pump on/off signals to the pump box.  Moving both units around is difficult so I am trying a Molex (5.25 Male) / Molex(2X 5.25 Female) Power Splitter from monoprice.  

Thumb IMG 3552 1024

 

NewImage

So far so good on the connectors.  I hope to find them for less from a distributor that just sells the connectors.  I went this route because I am more familiar with the wiring in PCs.  I knew if I tried these the right fittings would be there.

 

 

My Light Fixture for Growing Tomatoes

Tommy (the tomato plant) is growing quite nicely.

IMG 3475

Tommy in our Kitchen

IMG 3477

Yippee!  Starting to Flower

I’ve decided the LED light I am using from LEDGroupbuy.com – the Lumia 5.1 – will work for tomatoes.  

LEDGroupBuyLumia51

This light has 5 channels, each needing a constant current of 700mA.  It also gets really hot, so it needed a heat sink.  I ended up mounting the light on a CPU heat sink

CPUFan

The CPU fan/heat sink works extremely well at a price around $25.

I used 5 MeanWell LDD-700H constant current drivers (data sheet)

Meanwell700-HConstantCurrentDriver

hooking each channel of the LED to one of the LDD-700H drivers that I mounted onto a breadboard.  Wiring it all up and putting a reflector around it got me this FrankenLED:

LEDLightReflectorLEDGroupBuy

Bwa-ha-ha …but it works…


The LED is plugged into a power supply I got from LEDGroupBuypower supply

so that’s Tommy.  On my next post I will be building a PCB for a light fixture to hold three of the Lumia 5.1s to expand the number of tomato plants I will grow in my kitchen.

 

Introducing the Ladybug Plant Food Adjuster

Tags

, , ,

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.

That’s a Wrap (for now) Ladybug Shield Beta 2

Tags

, ,

 Ladybug Shield Works – Open Source Available

Totally a YIPPEE! moment.  All circuits on the Ladybug Shield are working.  pH and EC values get reasonable measurements.  Pumping works.  WooHoo…

IMG 3409

Just back from OSH Park

IMG 3417

Check out the Awesome soldering Job Thanks to the Zallus Reflow Oven Controller

IMG 3415

Ooh—OOH – IT WORKS!—time to work on enclosures…

Open Source

Arduino and Kicad files are located at this GitHub location.

Thanks to Those That Went Before

I would not have the skills to do this without the teachings and mentoring of Chris Gammell and his Contextual Electronics courses.  There was A LOT to learn (still is of course).  Chris and his courses greatly accelerated the process.

Regarding skill, thanks to Ryan (SparkysWidgets) for open sourcing the minipH and miniEC.  The EC and pH designs of the Ladybug Shield evolved from Ryan’s work.  Besides that, Ryan has been super helpful.

A terrific company that has provided an invaluable service and EXCELLENT support – OSH Park.

A very useful reflow oven controller from Zallus.  Works GREAT!  My soldering skills skyrocketed with this addition.

 

 

 

Wow.  I think that’s a wrap for the Ladybug Shield….I’ve started using them….a total YIPPEE! moment.

 

What’s the Challenge with the Zucchinis?

I recently transplanted some Zucchini seedlings to one of the cold frames in our backyard.  It looks like the newer leaves are more yellow than they should be…or at least what I think they should be…

IMG 3404

I’m thinking there is either a difficiency in Nitrogen or Sulfur.  Since I am not sure which, I decided to fertilize with 2.3mS of magnesium sulfate.

IMG 3408

This should let me know if the yellow coloring is due to a lack of sulfur….hmmm…or magnesium.  

I have a ways to go before I can look at a plant and diagnose the deficiency…until then I will try then try again.

But…someone on reddit noted:

Liquid fertilizers burn new roots and young plants. They’re basically chemicals that “burn” until they settle in the dirt to be extracted by roots. Too much of it is a bad thing. I highly recommend earthworm casings.

 This is great stuff!  So much to learn.  In a fun way.  From observing and adjusting.  …and eating!

Ladybug Measure – Auto Nute Measuring Device

Tags

A roadblock in hydroponically growing plants is feeding the correct ingredients at the concentration preferred by the plant.  The ingredients and concentration will vary depending on plant type.  I want to build an experience that automatically measures the ingredients.  For the prototype, I will focus on leafy green plants like lettuce, cucumbers, and tomatoes.  By not trying to measure chemistry for any hydroponically grown plant I will have more time to focus on the end-end experience.

The Goal

The goal of this post is to put down initial project definitions of what I’m calling – at least for now – the Ladybug Measure.

Thanks to Those That Went Before

Thanks to Ben Krasnow for posting his work on the Cookie Perfection machine.  A lot of my design thoughts come from watching Ben’s videos.  What a fantastic project with delicious results.

Thanks to Chris Gammell for pointing me in the direction of Ben’s work.  And of course for the excellent Contextual Electronics courses.  It’s exhilarating to take his courses and feel more like an apprentice to a master.  It is a great way to learn electronics.

What Ladybug Measure Does

The Ladybug Measure device will solve the challenge of measuring out the correct chemistry to hydroponically grow different types of plants.  The home farmer enters in the type of plant – say “Lettuce”.  The Ladybug Measure measures out the different dry ingredients into a container.  “Just add water” is the next step for the home farmer (hopefully RO water! :-) ).

High Level Design

I plan to evolve the design Ben Krakow used to build his amazing cookie machine.  The Ladybug Measure will be easier because it handles only dry ingredients versus the cookie machine which deals with hard to automatically measure stuff like brown sugar and butter.

 

BensCookieMachineProject

Ben’s Cookie Machine Project

I like the “lazy susan like” approach.  So I’ll start with that design.  The Cookie Machine uses smaller quantities of dry ingredients.  I plan to use a funnel, but it will be bigger.  I’m not sure how much bigger.  The home farmer enters into a smart phone app that talks to Ladybug Measure over BLE.  I’ve started to use BLE and my iPhone for device UIs since I find the experience painless to create and use.:

  •  the plant to be fertilized. 
  • the gallons of water.
  • the smart phone app connects to an Arduino with BLE that is identified as a Ladybug Measure device.  It gives the command “please measure out ingredients for 1 gallon of fertilizer.”
  • Ladybug Measure moves one of the dispensers over the bowl.  The dispenser releases “just the right” amount of ingredient it holdsthe needed measured amount. so that the funnel will add some of the compound its holding into the bowl on the scale.

How Many Dispensers?

The short answer: 6

The longer answer…why?

Pasted Image 4 8 15 2 42 AM

Really Big Dispensers…Labels Discussed Below

As noted in Fertilizer Management for Greenhouse Vegetables (Vol 3)  there are 16 elements needed by all plants:

The 16 elements required by all plants are carbon (C), hydrogen (H), oxygen (O), phosphorus (P), potassium (K), nitrogen (N), sulfur (S), calcium (Ca), magnesium (Mg), iron (Fe), boron (B), manganese (Mn), copper (Cu), zinc (Zn), molybdenum (Mo), and chlorine (Cl).

…The nutrients N, P, K, S, Ca, and Mg are referred to as the macronutrients because they are required in larger quantities by the plant compared to the remaining elements. The other seven elements are referred to as micronutrients because they are required in small amounts, usually a few parts per million (ppm) in the plant tissue.

This would lead to a conclusion that I’ll need 16 dispensers….but wait…I’m going to cheat a bit.  MHPGardener has a youtube video on making nutrients for tomatoes.  He blends three compounds together:  CHEM-GRO TOMATO FORMULA 4-18-38Calcium Nitrate (CaNO3)Magnesium Sulfate (MgSO4).  I tried this blend and have been very pleased with results I have seen on my tomato plants.

I’ve decided I need a minimum of four dispensers one for each of the three compounds above and one other blend similar to the Chem-Gro tomato formula, but for leafy vegetables – CHEM-GRO LETTUCE FORMULA 8-15-36.

This prototype will support 6 dispensers.  Each dispenser holds at a minimum of 8 oz.  Slightly larger dispensers could be used.  I figured out the dispenser size based on a spreadsheet I made on Google docs (GitHub link) that determines the amount of ingredients needed given the type of plant and the amount of nutrient bath.

I imagine over time the amount of ingredients will grow.  For now, this should be perfect for the prototype.

 

That’s all for now.  I’m very excited to start on this project.  I am sure to learn a lot.  Also – I just got notice from OSH Park that Ladybug Sheild beta 2 boards are in the mail.  I should get them tomorrow.  YIPPEE!!

 

 

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

 

 

 

Building an LED Light Source to Grow Lettuce with the Other Mill

Time to get back to building the constant current driver for the LED set up I discussed in this previous post (LEDs) and this post (constant current circuit design).  I am going to use my Other Mill to get to a PCB that I will then solder on parts using my reflow oven.  Whoa – talk about the treasure chest of toys I have built up!

When I last discussed the Other Mill, I have evolved my learning thanks mostly to the exceptional support and care I got from Other Machine.  I was having a challenge with my machine  – the Z-axis screw seemed jammed.  This had the unfortunate consequence of making a very loud grating noise after which whatever end mill was up for use was immediately broken by the Z-axis grinding too hard.

I admit a part of the challenge was my lack of milling knowledge/experience.  Regardless of what CNC machine used, as with other sophisticated hardware that makes things (my mind goes to a sewing machine), there is a base knowledge that includes what not to do as well as what to do when making a PCB.  It is an unfortunate consequence of my lack of networking/community that I did not know anyone who would show me ropes.  I bet with enough effort I could find someone.  But then – I also like to figure stuff out as I try it.  The challenge with trying stuff when clueless is I’m exploring an expensive machine that is not easily replaced if I blow it up.

On to the PCB.

Open Source

The automator workflow I used to rename the kicad files so they work with Other mill can be found at this GitHub location.  The Kicad and Gerber files are located here.

Foot prints

Before milling, I needed to finish matching foot prints to the components on the schematic.  In kicad this means I needed to finish the netlist from within the cvpcb tool.

Heat Sink and Mosfet

The image and layout below from the heat sink’s data sheet (I am using the 5073) shows the placement of the heat sink/mosfet as well as the foot print of the heat sink:

HeatsinkwithmosfetHeatSinkFootprint

the mosfet’s has a TO-220-3 footprint.  Here is an image from it’s data sheet:

mosfetfootprint

…and here is an image of the foot print I made in Kicad’s foot print editor:

HeatSinkMosfetFootPrint

 

POT

The next one was the POT.  I am using this POT:

POTIAmUsing

The foot print is included as part images on the digikey page:

1stpartimagePOT2ndPOTPartImage

Layout

Here’s the layout I used:

LEDLayout

I tried to keep the spacing between tracks and components large enough so that the larger end mills (in this case the 1/32”) can be used.  

Feeding Files to Otherplan

The Otherplan software has native support for Eagle, but not Kicad.  This means features like the nifty DRC end mill clearance check aren’t available for Kicad.  There is one additional step I have to do which is to rename the Gerber and drill files from:

LadyBugPump-B_Cu.gbl
LadyBugPump-Edge_Cuts.gbr
LadyBugPump-F_Cu.gtl
LadyBugPump.drl

to

Ladybug.drl
Ladybug.gbl
Ladybug.gko
Ladybug.gtl

While I probably should just right a bash script, I ended up using the Mac’s Automator app to create a renameGerbers.workflow.  Unfortunately, Automator does not support wildcard matching which I use to rename the base name.  I ended up adding this Automator action to my copy of Automator.  Luckily, instead of trashing my hard disk (so far) it works as advertised – allowing me to create a workflow that uses wildcards when renaming the base name.  I also added an Automator action to rename the edge cut layer (i.e.: the outline layer) from .gbr to .gko.  AND it actually got rid of the .gbr instead of renaming the extension .gbr.gko  .  This unfortunate double extension happens when I was renaming the file using the Finder UI without File/Preferences/Advanced Show all filename extensions checked – which is not checked by default.

Setting up the End Mills

The software allows three end mills to be used during milling.  I kept running into an unfortunate bug.  Instead of figuring out what can be optimally cut out with each end mill, it will use the smallest end mill to do all the cutting.  I had an earlier attempt where I told Otherplan I had 1/100 1/64 and 1/32 end mills.  The directions Otherplan gave to Othermill was to use the 1/100 to cut out everything except the drill holes.  

Thanks to Simone, I had a way around this:

  1. Load your biggest tool by itself in Otherplan and in the mill, and run the plan. The biggest tool will take away most of the copper you want removed.

  2. Remove the larger mill from the machine, and install your next smallest tool. In Otherplan, leave the largest tool in the plan, but add the tool you just installed in the machine. The pla file window should have a 1/8” and, say, a 1/32” selected.

  3. Run the plan again. The machine will start with the 1/32”, and when the small tool is done will prompt a tool change. Click on Cancel to stop the job completely.

  4. Install your next smallest tool in the machine. in Otherplan, remove the largest tool, and add the smallest tool, so you have the 1/32” and the 1/100” in the plan file window.

  5. Run the plan again. It will run the 1/100”, then prompt the a tool change. Cancel the job completely.

This seemed to work.  Now the larger end mill cuts as much as it can before using a smaller one.  Much nicer.

Finally, the PCB

IMG 3401hmm…a bit blurry…but it shows the milling worked pretty well.  I ran into a challenge with the edge cut file.  It turns  out the edge cut Gerber I used for this milling was not a completed square.  One of the corners leaked.  This caused the Otherplan to ignore all the Gerbers and drill files.  I ended up deleting the edge cut Gerber and letting Otherplan figure out the outline.  Afterwards, I went back to see what the problem was and indeed – after deleting the outline and creating a new-and improved-outline, all files were read by Otherplan.

 

Time to solder on the components and see if the PCB works…

 

Thanks for reading this far.

Please find many things to smile about.

Ladybug Shield Beta V1 – Cleaning Up the Design

Tags

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

The Goal

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

 Thanks To Those That Went Before

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

Open Source

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

Beta 2 Changes

Changes from Alpha 2 to Beta 2 include:

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

The Power Design

The current design:

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

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

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

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

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

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

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

Temperature

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

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

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

Test Points

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

 

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

 

 

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

 

Follow

Get every new post delivered to your Inbox.