TaW: Week 9 – Gadgeteer Temperature Logger

It gets cold in our office as for reasons unknown the AC unit appears to be binary; on as cold as possible or off, heat is an unknown concept to it.  To that end, and to see how cold an erratic the temperature is in our office I threw together a .NET Gadgeteer based temperature logger.  It records the temperature and relative humidity to an SD card every thirty seconds but also hosts a simple webserver to allow for on demand readings by anyone in the office.  It was a nice break from screaming at the list of errors the TFS Integration Platform had been throwing at me for the proceeding days…

To speed things up I took examples of code from Mike Dodaro and Stephen Jonston‘s blogs, if you are fans of Gadgeteer these are two blogs you really should keep an eye on.  In fact, I’ve covered some of Stephen’s work in the past with the payload system he developed using the Gadgeteer platform.

My data logger using the temperature and humidity sensor for the obvious reason; an Ethernet module to allow for on demand readings and time synchronisation; an SD card for storing the log; and the usual USB power/GHI Spider mainboard combo.

The code can be found here and requires the latest firmware and SDK from GHI, as of the date of the post that is.

TaW: Week 9 - Temp Logger Photo
Mounted on cardboard using cable ties, quick and simple.

.Net Gadgeteer Pomodoro Timer

I’ve been looking into methods of time management that may help me be more productive, my biggest issue is getting distracted by shiny things, interesting articles or the latest topic of intense debate amongst my friends on Facebook.  Someone suggested I take a look at something called Pomodoro, the simple premise is you concentrate on your task for 25 minutes solid then have 5 minutes to do whatever you want, rinse and repeat.

I’ve been trying various tools to assist and when stuck at a set of traffic lights on the way home realised that a device that sits on my desk and changes colour may be the best bet, I’m a person who responds strongly to visual stimulus after all.  To that end I threw together a simple timer using .NET Gadgeteer that is currently sitting on my desk, I’ll try it for a few days and if it works I’ll build something more permanent.

The idea is simple and follows this logic;

  1. If in a work period the light is red
  2. If in a rest period the light is green
  3. If at the end of an interval the light flashes orange

Here is a screen grab of the modules as connected and you can find the code below.  Please note that the reason it says “GT.Colour.Purple” is because for reasons unknown that displays as Orange from my LED module.  I assume that the definition of Orange is true for displaying on the screen but that the RBG LED uses different values, this isn’t uncommon.

Pomodoro Timer

 

using Microsoft.SPOT;

using GT = Gadgeteer;
using Gadgeteer.Modules.GHIElectronics;

namespace Pomodoro
{
    public partial class Program
    {
        //  default starting state is not working
        public bool working = false;
        public GT.Timer work_timer = new GT.Timer(60000);

        // these periods give the time in minutes for each period
        public int work_period =  25;
        public int rest_period =  5;
        public int time_remaining = 0;

        void ProgramStarted()
        {
            //  Attach event handlers for the timer and button
            button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
            work_timer.Tick +=new GT.Timer.TickEventHandler(work_timer_Tick);

            //  Blink LED to get attention
            led.BlinkRepeatedly(GT.Color.Purple);

            Debug.Print("Program Started");
        }

        void button_ButtonPressed(Button sender, Button.ButtonState state)
        {
            //  Button press either starts a work interval or resets to the interim state
            if (working)
            {
                working = false;
                work_timer.Stop();
                led.BlinkRepeatedly(GT.Color.Orange);
            }
            else
            {
                working = true;
                time_remaining = work_period;
                led.TurnRed();
                work_timer.Start();
            }
        }

        void work_timer_Tick(GT.Timer timer)
        {
            //  Timer ticks onces per minute
            time_remaining -= 1;
            Debug.Print("Time remaining: " + time_remaining.ToString() +
                " intervals");

            //  If counter = zero, either enter rest or interim period
            if (time_remaining == 0)
            {
                if (working)
                {
                    working = false;
                    led.TurnGreen();
                    time_remaining = rest_period;
                }
                else
                {
                    led.BlinkRepeatedly(GT.Color.Purple);
                    work_timer.Stop();
                }
            }
        }
    }
}

 

If you build one of these and put it in an enclosure put a link in the comments and I’d be happy to update the post with details of your project.  A photo of my finished prototype sitting between my monitors can be seen below.  The stand is from an old webcam, the button is wrapped around the base and the LED tied to the top.  Not bad for the time it took and it’s already working wonders for my focus.  Simple but effective.

Pomodoro Timer Prototype

Enjoy,
Keegan

.NET Gadgeteer In Space!

The title is a little misleading, it isn’t quite space but damn close!  Got your attention though I’ll bet. 😉

A few weeks ago I gave a presentation to my peers in the UK Support organisation at Microsoft and along with the digital camera “hello world” project that is fairly standard for Gadgeteer I came up with a few ideas to give as examples and the most fun one I could think of was to make an instrument payload for a weather balloon.  I’ll be giving another presentation shortly and I thought I’d make an earth-bound prototype as a proof of concept.  On the off chance someone would see my demo and buy the parts to do it for real I thought I’d ask the Gadgeteer team if the modules would actually be fit for purpose.

About an hour later I was having a coffee with Steven Johnston from the University of Southampton who will shortly be sending a module up, great minds think alike it seems however they had a head start and plenty of experience in these matters.  By pure chance he was on site today!  He gave me these photos to share of their project in progress including a 3d printed enclosure to hold all the parts;

He has offered to keep me up to date with progress and you can be certain this wont be the last post on the topic, that fact that such activities are within our means is astonishing and the sky is no longer the limit!

Keegan