Arduino based Plant LED Lighting – Iteration 1

After years of procrastination, the itch to get into hydroponics needed attention. Before jumping headfirst into the unknown, a quick experiment to see how the plants responded to neopixel LED strips was in order. As such, I’ve put the MEAN stack exploration on hold.

Objective

Can the neopixel LED strips provide enough lighting to grow herbs and other leafy vegetables?

Materials Used

Putting it Together

The following diagram illustrates the wiring.  The LM35 when used with other analog inputs leads to erratic readings. The capacitor stabilizes things.

The software is straight forward with the xbee operating using AT mode rather than API mode.  For now, I used modbus to communicate to Mango and for giggles VT-Scada. More on that in a future post as the IIoT speak I hear from certain vendors — not the two mentioned–make me cringe knowing what they have under the hood.

Software Feature List

  • set time from host via modbus  or terminal console
  • set lights on time via modbus or terminal console (default 18 hrs on)
  • set lights off time via modbus or terminal console (default 6 hrs off)
  • set duty cycle via modbus or terminal console
  • set duty cycle period via via modbus or terminal console
  • get temperature via via modbus or terminal console
  • get soil moisture via via modbus or terminal console
  • force the lights on or off via modbus or terminal console
  • save/load/restores settings to/from EEPROM

Modbus was used as I already had a SCADA host running. It could have been xbee API or bluetooth. Having done both, this is relatively easy to refactor the code later.

The code can be found at https://github.com/chrapchp/PlantLEDLighting. Not the prettiest code yet it it does the job for this experiment.

Periodically changing the red/blue ratio aka duty cycle between 70-95% red with the remaining in blue light tainted the experiment. Regardless, it is logged in the SCADA/HMI host for further analysis.  Interestingly, the research around  LED-based plant lighting is growing along with plenty of do-it-yourselfers experimenting.

Lessons Learned

On the Mega front, the Chinese knock-off ended up with causing more trouble that they’re worth. Problems included the following:

  •  voltage regulator fried
  • TX1 via the header pin did not work
  • headers were loose
  • finding a driver took extra goggling

Needless to say,  I ended up purchasing the real one.

Wiring xbees on breadboards gets old fast. The current setup consists of switches to commission/reset and  a potentiometer to vary the input voltage for testing a device. Nevertheless, I  purchased the wireless connectivity kit  (S2C) and the pro version of the xbee  to facilitate the configuration and program some custom functionality in the xbee in the future. Highly recommended if xbee development is on the radar. BTW, digikey Canadian or US site offer great service and fast delivery. I’ve ordered from them several times.

Observations

Herbs

The basil and oregano took a couple of weeks to germinate followed with a slow growth rate.  In contrast to what others are doing, the growth rate falls far short with expectation.

Leafy Vegetables

The kale and arugula germinated in 3 days and grew relatively fast. The weak stems could be attributed to the LED’s . I’ve planted some outside as well and will compare the stem sizes with the indoor ones.

Minor Changes

The addition of a fan to create a light  breeze led to stronger stems. After a couple of weeks of circulation, the arugula and kale stems seemed stronger. The basil grew and looked healthy yet remained small. When compared to their outdoor counterparts, the healthier looking indoor basil prevailed.

Next Steps

There seems to be some confusion out there between lumens and pars. I read about people only measuring lumens for plants and scratch my head.  Consequently,  I like ChilLED‘s pitch in positioning their lighting products as well an intro-101 from Lush Lighting.

Incidentally, a buzz exists stating the effects of UV could lead  to ‘certain’ plants to produce more THC. Note, I am not interested growing those plants and just want to grow edibles all year round.  At any rate,  I think the root cause revolves around the low LED pars and power rather than the effects of different soil, nutrients, and seeds.

In short, I’m considering using ChilLED for sourcing my lighting needs provided that  controlling the output of the various channels without using their controller remains feasible.  Note  growmay5 provides some interesting vlogs on this as well as other topics around LED plant lighting.

Altogether, I’m satisfied with experiment and how quickly I could mash up a solution. Hydroponics is the next step with better LED lighting and queued for later this year as a project.

 

Kale

Temporary setup

 

Slapped together hardware

 

 

Bike LED Vest Swift 3

Earth Day is is here. Tonight, organizers set up a night time a bike ride encouraging creative ways to make yourself seen.  My daughter wanted to wear my LED vest and assumed it was just a matter of lighting it up. Needless to say, the iOS app crashed. Considering I  never tested it out with iOS 10.3, it was high time to start troubleshooting.

Because of the fact I used the objective-C BLE libs, the crash precipitated the move 100% swift solutions. For the purpose of this exercise, I forked the current the swift version and patched it to use XCGLogger, compiled it for swift 3.0, and added a couple of delegates for my own app. The changes can be found  at the forked site.

Incidentally, the crash was attributed parsing JSON results from a YML query to yahoo. The service URL changed and I cleaned up the code so it would not crash in the future should it change again.

MEAN Tools Installation

Well after some thought, I figured it was time to roll up my sleeves and install some tools and frameworks to start with my minimilist IoT playground. I use macOS and will focus just on that.

Environment under macOS

I first started to go down the path provided at mean.io and felt there was too much of a heavy lift for a newbie trying to ramp up on four technologies at the same time. I opted for installing each of them by hand so I can see the type of problems can occur.

I installed the following:

Sublime Text – Nice editor and I started using it for Arduino development as well

MongoDB –  I used the homebrew approach.

Node Version Manager (NVM) – Used to manage different versions of node.js. Note I have Xcode installed and you may need the command line tools later.

If the NVM is too much of a hassle, get node directory from node.js via download
Node.js – It is already newer than the version I have (7.8.0). This is an easy install and should not pose any problems

Express Generator – another straight forward install for light weight web framework

I installed the following as well based on what I thought I needed for this learning exercise.

Package/ToolURLDescriptionInstallation
log4jslog4jslog4js based logging services for node.jsnpm install log4js -S
monkmonkwrapper to mongodb that is simpler yet not as powerful as mongoosenpm install monk -S
nodemonnodemonlistens for file changes and restarts server npm install nodemon -g
dummy-jsondummy-sontool to generate JSON files used for my testingnpm install dummy-json -g
RobomongorobomongoMongoDB managerdownload and point to mongoDB instance (default localhost:27017)
Bluebirdbluebirdpromise library implementationnpm install bluebird -S
SerialPortserial portserial port driver for node.jsnpm install serialport -S # have 4.0.7
xbee-apixbee-apixbee API for node.jsnpm install xbee-api -S

Off to learning this stuff.

Empowering the Many

Hello MEAN stack

A few years ago I had boat loads of temperature envelop data of my house and outside temperature. When I was looking for quotes to re-insulate my old house, an insulation vendor expressed interest in purchasing my before and after analysis and results. I did not proceed with a full re-insulation of my house but did end up loosing my data which was 100% my fault. I did not back up to a NAS and experiences a hard drive failure.

Fast forward today. There is lots of talk of IoT, Analytics, and cloud services. Many, I feel are putting lipstick on their outdated products so buyer beware.  That said, the various IoT ecosystems provided through services such as Microsoft Azure, etc. are making it easier to mashup, collect, aggregate, and analyze data. Alarm Management, historians may become moot at some point unless vendors provide added value services such as predictive analytics and performance management solutions.

My interests these days revolve around machine learning and visual analytics but I do like to keep on top of some technology that can be used to marry IoT with the enterprise. With the handful of XBee devices lying around, I’ve set my eyes to ramp up on the MEAN (MongoDB, ExpressJS, Node.js, AngularJS stack and see what I can come up with for my own use at home. I chose a Typescript/Javascript environment as I can get by with basic open source tools and decent editors without having to get something like visual studio.

Key System Architecture Components

 

1-configure XBee end devices to sleep and send to coordinator AI/DI data. (I’ve tested this a few years ago so I know it works) (Temperature, ambient light, etc) Mesh network using API mode.

2. 0 or more routers to relay the messages from the end devices to the coordinator

3. 1 coordinator that feeds into the system via serial port

4. Node.JS+ Express to handle the configuration of the I/O wired to the XBees. e.g. scaling, tag name, etc. MongoDB to persist the data, and angularJS to render the UI.

5. There are three IoT platforms ( GE Predix , XivelyThingSpeak, and Azure IoT )  that I have accounts with that I would like to push data to to test it out. I have two SCADA and one HMI system that I am also going to test out the IIoT readiness.

6. My home power monitoring has been running for 8 years on arduino and XBee. The next step is to push data rather than poll from the host to see what that SCADA system can do.

Further down the horizon the inclusion of some  MQTT flavour and and node.js integration.

Bike LED Vest Revisited

With Swift 3,  watchOS3, and iOS 10 released, it was time to migrate the code  from Swift 2.1 to Swift 3.0 using Xcode 8.0.  I still have use for my Myo armband but wanted to explore using Apple’s CoreMotion and HealthKit SDKs. The conversion tool in Xcode did a great job and most of it was dealing with optional chaining that required my attention. Once completed, the existing application worked as before. Although the bluetooth code migrated ok, I was left with a handful of deprecations warnings in iOS 10.0 that will need clean up so I can keep current on iOS releases.  For now, I wanted to explore how to use the iWatch Series 1 to achieve the following goals:

  • Capture Heart Rate and include with geolocation data in the  iPhone app
  • Detect and send turn signals to LED Vest
  • Display Temperature and Battery Voltage with alarm set points
  • Learn more about the Swift language, the various SDKs

Watch interface

Hats off to UIX designers. This does not come easy to me. I ended up purchasing Graphics (was iDraw) from Autodesk as it was affordable and comes with a rich feature set.  A nice bonus is that this tool can generate can generate Core Graphics “copy as” code.  Alas, my first pass works and leveraged the context menus to save on screen real estate.

bike-iwatch

 

 

 

 

Context Menu

The context menu used canned icons. The start/stop implement the obvious functionality.  The Speak functionality allows me to either send one of three messages or speak into the watch and send the resulting text to display on my LED Vest. The user interaction side was rather easy to implement using the presentTextInputController method of the WKInterfaceController class.

 

img_0052

 

img_0053

 

Observations

Extensions

Swift extensions are your friend.  One can extend classes without access to source and add additional behaviour.  For example, to quickly implement alarm functionality, WKIntefaceLabel was extended to allow a refresh a label.

HealtKit

Healthkit is a pain to get going using just Apple’s docs.  Fortunately, there are lots of tutorials out there to help get things going.  I would have liked to have more detailed information so one can track heart rate variability (HRV).  These folks are working on some cool stuff mashing technologies using HRV. It seems we are left with BPM samples at around 5 second intervals. I get why, given that there could be other apps wanting access to this information and sub second resolution in a device that was meant to tell time at first would overwhelm watchOS. I suspect one day this should be available.

Core Motion vs. Myo

I found Myo integration to detect hand signals easier to implement. It was more intuitive. On the Myo, the “home” position would be cached so relative changes in movement could be computed. e.g.  right hand turn gesture using pitch and left hand turns using yaw and roll. It works quite well.

I could not get this to function using that same approach with consistent results on the iWatch.  I ended up working with just gravity component for hand signals position. e.g. right turn detection is using the X component of the accelerometer and the Y component for the left hand turn. Initially, I used CMDeviceMotion‘s CMAttitude  component and used multiply(byInverseOf: x) method of CMAttitude to get relative changes in motion.  It worked for the right hand turn but was inconsistent for the left hand turn.

The gravity only component with a range threshold range works ok for now. I will investigate the CMAttitude further and will look at integrating (summing changes along X,Y, Z over small sample windows to detect hand signals.

 

 

Bike LEDVest

I’ve been tossing this project in my head for a few years. I signed up when the Myo Armband came out on kickstarter and figured I could make use of it one day.   When I purchased the the Apple Watch, then that got the wheels in motion to build an LEDVest.

Some of the goals I wanted to achieve included the following:

  • Learn the iOS development (Swift language)
  • Drill down on Bluetooth LE development
  • Persist information on iCloud and retrieve from different devices
  • Create something useful and provides context based information to others while riding my bicycle at night
  • Explore iOS HealthKit and MapKit

Screen Shot 2016-02-06 at 5.26.43 PM

 

Prototype

My wife did all the sewing. The LED’s are so bright that the iPhone camera does not do it justice inside. Many people commented from motorists, pedestrians, and cycles on how cool this vest was.

It took a lot of effort but it was a nice diversion from the day job. Learning a new programming language, organizing the code so that the appropriate level of abstractions exist to easily add new features, creating an application level protocol to control the LEDVest, and designing and building simple hardware bumped up the fun factor.

Using my Apple Watch, I can speak text to display and I send it to the LEDVest to display. If I am annoyed at a stop light, I tend to keep it safe. e.g. “Smog sucks”.  So far the software periodically displays the temperature from the hardware, along with the WTI price and Canadian currency via the yahoo finance API. If I loose connectivity to the iPhone, the arduino portion fails-safe and displays the stop symbol and posts the temperature every 30 seconds.

I’ll talk about the implementation details later.

Munging my “Smart” Home Data

Context

For some of you who live in older homes, the feeling of too cold in the winter and too hot during the summer comes with the package. Last year, I thought of getting spray foam installed and figured now is the time to start analyzing the some of the data I’ve been collecting over the past three years. I told the installer that I had three years of data and would do a before and after test to see what the spray foam did in terms of performance. He stated he would purchase the data analysis. Needless to say one could just look at the heating bill to see if there is difference.  With variance in unit  costs of fuel, admin, etc., I did not want to bother normalizing that info. The geek in me wants to explore data mining and inference. So off I go to explore  Linear discriminant analysis and random forests.

For this exercise, I had three in-home temperature points, one outside, and several power related measurements. So far I had close to 3 million data points. I searched the web for an open source toolset that could help me with data analytics and decent plotting capabilities. Given I used the R programming language a few months back and liked the graphing capabilities in the ggplot2 package, it became my tool of choice. Note that Python is making in-roads in the data analysis space and for now, I want to remain focused on data analysis so R it is.

Rasberry Pi + Camera

Image

The idea of setting up a surveillance system has been on the to-do list for a long time. Given there have been a few break and enters in our neighbourhood for petty stuff and the last straw was a break-in in my vehicle, I decided to set one one up.  Why make it easy and purchase a ready to go camera like a foscam? It is would not be as exciting. After some searching, I ended up with purchasing the following from Newark Element14:

  • 2x -RASPBERRY-PI-RASPBERRY-PI/8GB-USD-MODEL B – 8GB SDCard W/ NOOBS PRE-INSTALLED
  • 2x – ADAFRUIT INDUSTRIES-1012-USB WIFI MODULE, 802.11b/g/n, RASPBERRY PI & BEAGLEBONE
  • 2x – RASPBERRY-PI-RPI CAMERA BOARD-ADD-ON BRD, CAMERA MODULE, 2RASPBERRY PI
  • 1x – RASPBERRY-PI-RPI NOIR CAMERA BOARD-CAMERA BOARD, BCM2835 RASPBERRY PI

Continue reading

UDOO with SSD

I got around to set up the 120 GB SSD on the quad. I ended up making my own power cable with header wires to connect to +5 and Ground pins. I could not find a power connector that fit it J12 on the board at the local stores and didn’t want to order a small part online and pay for shipping.  What I have works.

The process was rather painless at first. I followed the procedure for creating a bootable image via OSX as described at the Udoo website. I then booted the board with the newly imaged SD card with the SSD connected to the board. I then installed gparted via

then ran

to partition the SSD and also create another partition on the SD card for backing up stuff since I had about 23 GB extra on the card to use.

ssd
Continue reading

A Distraction – UDOO Quad

I received my UDOO Quad today. I was not expecting to dust off my faithful home energy system I wrote a couple of years ago. It has been running well yet I feel guilty of having a home computer running 24×7 to act as my SCADA host. The UDOO is the board that will blend both the Arduino and Linux in a nice board and allow Solid State Drive to hold all the data. On its own without a SSD it consumes around 3.7 watts in-standby.

I currently have about three years worth of energy and temperature data that I also don’t want to lose and it has to be migrated as well. I’m hoping to analyze it using the R-Language one day.  I’m hoping that it should be a relatively easy port as everything is cross platform.

UDOO Quad