Sunday, June 26, 2011

Netduino - Temperature probe adapter

Here is my temperature probe adapter, I am using a 1% 4k7 resistor between pins 2 and 3 of the probe. This will allow me to plug my pre made probe straight in and then a 3pin header cable will go to the bread board to got in to the netduino.

Saturday, June 25, 2011

Netduino - Project update inc Temperature

I have been playing with my netduino for a few days and have done a fair bit of reading which has led to a couple of changes....

A lack of reading in the first place unfortunately led to me making a few ordering errors. I now know that the xbee wireless module is not wireless in the way I was expecting, it communicates on 2.4GHz, BUT it is 802.15 and not 802.11 making it incompatible with wifi internet devices. I also discovered I would have saved a fair bit of cash and required fewer addons if I had known about the netduino plus. The netduino plus has ethernet on the board, its not wireless but it allows for a web connection out of the box. Also it has an micro SD slot on the board, meaning I wouldn't have needed the SD shield.

Since these belated discoveries I have returned the xbee module and adapter shield. My original plan was for wireless and I have looked at this briefly, however initial reading shows that this is somewhat problematic with the netduino. The wifly has a lot of issues and has no official drivers, it also requires external power to the netduino and a bit of pin rerouting. At this time, this doesn't sound like a practical option, so I am going to leave it until I have the board sensing and controlling. One possible option is to get the netduino plus, but for now I will still with the netduino until I have learnt a little more.

So I am getting to grips with C# slowly, managed to edit a little code and made my first break through and fatality at the same time. I found some code for one wire support, again a feature not currently officially supported, and I managed to get a temperature reading eventually. I am using a DS18B20 and re-flashed the netduino with v4.1.1 beta with one wire. This was an experience and an encouraging learning curve in its self. I have now used SAMBA and MFDEPLOY which I have a feeling will become more and more necessary. This went well and I got my LED blink test running with a little help. The beta firmware can also be found on the link above.

I used the example program.cs code of the afore mentioned thread as well as the DS18B20.cs class from the example project. I need to reference the LE OneWire.dll from the zip and also the System.Threading reference to allow for degree characters.

This is my working code:

using System;
using System.Threading;
using System.Collections;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using CW.NETMF.Hardware;

namespace NetduinoApplication1
    public class Program
        public static void Main()
            var oneWire = new OneWire(Pins.GPIO_PIN_D0); // Adjust the pin if necessary
            if (oneWire.Reset())
                // DS18B20 Thermometer
                oneWire.WriteByte(OneWire.SkipRom); // Address all devices
                Thread.Sleep(750);                  // Wait Tconv (for default 12-bit resolution)


                // Read just the temperature (2 bytes)
                var tempLo = oneWire.ReadByte();
                var tempHi = oneWire.ReadByte();
                var temp = DS18B20.GetTemperature(tempLo, tempHi); // ((short)((tempHi << 8) | tempLo))/16F
                Debug.Print(temp.ToString() + " \u00b0" + "C");




// Copyright 2010 Stanislav "CW" Simicek
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

namespace CW.NETMF.Hardware

    /// DS18B20 Programmable Resolution 1-Wire Digital Thermometer

    public static class DS18B20
        public const byte FamilyCode = 0x28;

        // Commands
        public const byte ConvertT = 0x44;
        public const byte CopyScratchpad = 0x48;
        public const byte WriteScratchpad = 0x4E;
        public const byte ReadPowerSupply = 0xB4;
        public const byte RecallE2 = 0xB8;
        public const byte ReadScratchpad = 0xBE;

        // Helpers
        public static float GetTemperature(byte tempLo, byte tempHi)
            return ((short)((tempHi << 8) | tempLo)) / 16F;

This gave me single temperature read outs that seemed very accurate from my testing with a digital thermometer. What I did next was the fatality......

Eager to get this in the fish tank I went about making my submersible temperature probe as per: However I managed to snap a leg off the DS18B20. Since then I have decided to order a pre-made probe, I'm all for DIY but these look really good and safe for in the tank:

I have built a little connection device on some protoboard, essentially just some angled headers, a resistor and some normal headers, allowing me to connect the probe to the netduino easily with a resistor. I will upload a picture soon.

My next plan is to have another go at personalising the code so that I can get a reading once every 5 seconds and then will be to get this logged some how. I will also have a go at getting temperature reading to display on the the LCD.

Wednesday, June 15, 2011

Netduino shopping list

Here is a the spec of my aquarium controller and the parts I have ordered...

It will provide 3 main functions via 3 levels of control, the controller will log sensor readings, will control the parameters of the fish tank, will alert when the monitored variables go outside the 'normal' parameters.

The controller will measure temperature, PH and light initially, latter on I may measure additional environmental factors such as flow, ORP, conductivity, water level and dissolved oxygen (DO).

From the initial measurements it will control, monitor, log and report on the temperature and control the heater accordingly. Initially PH will be measure but as a means of warning only, eventually this may expand to control CO2 dosers. Light will be used to sense the ambient light and could for example turn the fish tank lights off earlier if the light level in the house is below a certain level, or turn them up if light is at a low level. Alternatively this could be used to control the intensity of the lights in the tank to follow the climate locally. Eventually dissolved oxygen reading will control the air pump and the flow meter can report on significant losses of pump power, either from air lock after feeding pump stops or blockages and control the heater and air pump accordingly.

Other features will include, 5 minute or adjustable pump and heater pauses for feeding cycles and control of an automated feeder. Control of the pump for cleaning, feeding and water changes. Control of the air pump, for cleaning, noise reduction and night time. Control of lights which will be replaced with high power RGB LEDs, these will follow lunar and solar patterns based on data from the web and can be manually controlled for ambiance. Also they will be programmed to simulate cloud cover and lightening.

Future feature possibilities, water level and auto top control. Also the ability to auto water change, pumping water out and simultaneously heating and filtering and pumping water back in (possibly using a temperature controlled sump and/or top tank and mains attached RO unit.

Control is a key aspect of the project, the device itself must be able to independently monitor and control parameters automatically, but also make it possible to manually control and interface with the device. This manual control and monitoring will be both remote, via a web interface and local using an LCD graphics display and keypad. Reading will be stored on a web server and also backed up locally on an SD card. If there are any network issues the device will revert to local backup only until a connection is re-established and at which point, the web data loss will be restored from the SD card. Via the web all aspect will be graphically viewable and can be controlled, there will also be an IP web cam for monitoring the tank (possibly pan tilt controlled). Via both the keypad and the web settings can be programmed and changed and will be stored both locally and on the web, should a problem occur with the devices memory.

Currently my shopping list comprises of the following, there are sill a few things I need.

Atlas scientific - pH-Stamp: AVR, PIC, Arduino, Parallax NEW V2.0  $20.00 + $10 postage. 

3p-3p 12X Arduino 20cm Jumper Cable Shield EQUIV SENSOR (160575951979) $1.96 + $2.43

3mm Heat Shrink 2:1 - 5 meters £0.99
13MM HIGH QUALITY BLACK HEATSHRINK / heat shrink  £1.00 + £0.79 postage
Product Model Quantity Unit Price Total
Netduino board NETDUINO 1 £25.95 £25.95
XBee Shield - Sparkfun WRL-09976 1 £16.95 £16.95
Arduino Stackable Header Kit PRT-10007 2 £1.25 £2.50
830 point Breadboard 352 1 £3.99 £3.99
140 piece Jumper Wire Kit 312 1 £4.25 £4.25
Stripboard 95 x 127mm STRIPBRD95127 1 £1.75 £1.75
Light Dependent Resistor LDR 1 £0.60 £0.60
One Wire Digital Temperature Sensor - DS18B20 SEN-00245 1 £3.25 £3.25
XBee 2mW Chip Antenna - Series 2 (ZB) XBEE2MWS2CA 1 £22.95 £22.95
Serial Graphic LCD 128x64 with Backlight LCD-09351 1 £26.00 £26.00

Arduino MicroSD Shield DEV-09802 1 £11.95 £11.95

Netduino Aquarium controller

This is my first post about my latest project, a netduino Aquarium controller.

The purpose of this project is to help me learn C# within using visual studio and to also technologicalise my fish tank up to the 21st century.

At this point I have spent a ridiculous amount of time deciding how to achieve my goal of learning a new language in a useful manner and producing a new cool toy that will help me automate my aquarium. This research has took me to phidgets, arduino, many other arm processor based solutions and finally to netduino. The hardest decision at first was on a processing power level, microcontroller or single board computer (sbc).

Finally after many rambling in various forums and a lot of Google searches, I came to the conclusion of a microcontroller to meet my requirements. There was one main sacrifice that the Phidget sbc offered that Arduino doesn't and this is the ability to plug in usb peripherals, notably a web cam. The work around for this loss will be an IP cam, but I will get to that later. After this massive dilemma, if you've seen the film, this one was much bigger, I settled on the Arduino, only after placing my order, to change my mind and go with the Netduino.

The reason behind this choice moved from wanting the most I/O to wanting to use visual studio and a language which is much more useful to work and play.

My order is in the post and arrives tomorrow, I will give a run though of what I have ordered and how I envisage it to work together tomorrow evening.