, , ,

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.