Send Your Windows Server’s Disk Free Space to ThingSpeak Using PowerShell

I manage a lot of servers. One of the things that I am always curious about is how much disk space is left on my servers. I know there are a lot of ways to track this, but almost always it seems the service that I am using changes on me or breaks over time.

My super simple solution for tracking server disk space is to use Windows PowerShell and ThingSpeak. I went to the trouble to release the code to GitHub, so that you can try this out for yourself. This can be used on any Windows Server as long as you have the ability to execute PowerShell scripts. ThingSpeak gives you a place to store data from anything. In this case, I am sending my disk free space to ThingSpeak once per day by scheduling a Windows Task.

Check out the open source code on GitHub!

ThingSpeak: Building My Own Twitter (for Things)

Over the past several months I have been working on software to allow “things” to form social networks and send status updates via the Internet. At first glance this may sound very impractical. Hopefully, in a few years this will make more sense as better applications come out. Remember how ridiculous my toaster sounded three years ago? I gave that thing a voice and since has been on TV and more people are interested in it than my Twitnot not saying ter status updates. More proof? At CES 2011 there were at least 10 appliances that could send Twitter status updates. I am not saying that I created them, but I am that they didn’t know about My  Toaster and it’s 600+ followers on Twitter. With this project, I wanted to take it a few steps further and build something from the ground up that’s focused on collecting enormous amounts of data from everyday objects, allowing devices to interact with each other, and building applications to present some meaning. The ThingSpeak project is finally ready to go and open to anyone that wants to start building applications.

My Problem

One problem with the Internet of Things is the concept of “the killer app” – the app that defines a new industry. The internet connected refrigerator is our poster child. Recently, Ryan Rusnak connected a mini fridge to the iPhone via ioBridge, added a motor controlled beer selector, and strapped on an air cannon to fire beers to his couch from 25 feet away – now that’s a killer app. So, my problem was trying to find an application that highlights key features of ThingSpeak and why it’s different.

My App

What I come up with is the idea of “my_house”. “my_house” is a collection of “rooms” that all hold computers, appliances, and sensors aka things. I recently installed some light sensors in “my_room” that push light levels to the ThingSpeak API. I did this to remind me when to turn my lights on so I don’t work in the dark when I get plugged in. And an interesting side benefit was that now I can detect whether or not someone is in the room based on the light level. I will admit this could have been done other ways, but sometimes you solve problems with what you have lying around. “my_house” already keeps track of my location using Google Latitude to control my thermostat.

Eureka moment…

Now I can tell when my mom goes into my room when I am out on the town, most likely Sheetz!!!

Below is a screenshot of the demo app and how I aggregate the data collected by my light sensors. Here are a few things I want to point out:

  • “my_house” is sending the status updates via a collection of networked sensors
  • The status updates were generated by the light sensor device itself
  • The timestamps were recorded by the ThingSpeak API
  • If you click the chart icon you get what the actual light level was
  • The app works in real-time and you can check it out here

"Twitter of Things" ThingSpeak Demo App

The Technical Details

The light sensor uses a Netduino Plus that connects to my home network over Ethernet. This device uses Microsoft .NET Micro Framework and I wrote an application that interfaces with the ThingSpeak API. I also wrote a tutorial over at the ThingSpeak community site on how to use the Netduino Plus for those that want to get started with it fast.

The front-end application is written using only HTML, CSS, and jQuery. I have the fully documented source code attached and you can also see the app live in your web browser.

Light Sensor Netduino Plus

Project Files:

TouchShield Slide Two-way Communications

Over last summer, I got the GamePack from Liquidware which includes a touch screen display, joystick, microcontroller, and battery pack. With this kit you can make a GameBoy from scratch. With some blood, sweat, and tears, I was able to re-create some games like Asteroids and Tetris.

The touch screen is called the TouchShield Slide which is a 320×240 OLED and resistive touch screen. The screen also has a microcontroller that is Arduino compatible and expands your program space. Since the screen is really a microcontroller in disguise, it can be used for many types of projects. Overall I am very happy with the screen, but I realized I didn’t know how to use it very well. I set out to learn and develop a protocol / reusable library that allows the screen to talk to a microcontroller and vice-verse. So I wanted to take a moment and explain what I learned – maybe you can get going faster than I did.

The Goal

My goal is to be able to display data on the screen that has been received from another device. The data requested would be initiated by a touch on the screen. The protocol has to be consistent and reliable, while being flexible enough to be the basis for future projects.

Touch -> TouchShield Slide -> Arduino -> TouchShield Slide

Programming Tips and Tricks

I found quite a few libraries and resources on liquidware.com.  I also discovered quite a few important things through my trial and error. My biggest frustration was with programming and figuring out the IDE. Here are some tips.

  • To program the screen use the Antipasto Arduino / Aardvark IDE
  • Program the screen and Arduino separately – make sure the IDE has the proper device selected
  • To put the screen in program mode, press the switch beside the power connector – it’s in program mode when the LED on the backside is red

TouchShield Slide Serial

Serial data sent and received by the TouchShield Slide uses the hardware serial lines.

To setup the serial connection, place this line in your setup code block:

Serial.begin(9600);

Now you can read and write to and from the serial buffer. To read in a whole string, use a byte array to store bytes from the serial buffer when serial data is available. To write to the serial buffer, simply use serial print.

char charIn = 0;
byte i = 0;
char stringIn[32] = “”;

while(Serial.available()) {
charIn = Serial.read();
stringIn[i] = charIn;
i += 1;
}

Serial.print(“A”);

Arduino Serial

On the Arduino side, you have to use some form of Software Serial that sends and receives data on Pins 2/3. I have found that the Adafruit SoftSerial Library, “AFSoftSerial.h”, works the best. It seems to be reliable and produce consistent results when talking to the TouchShield Slide. Reading and writing from a software  serial buffer is about the same as a hardware one with this library.

To use software serial, follow these steps:

  • Include the “AFSoftSerial.h” library in your Arduino code header space
  • Define the RX and TX pins
  • Instantiate the software serial
  • Initiate the software serial line
#include AFSoftSerial.h

#define RX_PIN 3
#define TX_PIN 2

AFSoftSerial touchSerial = AFSoftSerial(RX_PIN, TX_PIN);

void setup() {
touchSerial.begin(9600);
}

Demo Project

I took a moment to put together all of the things that I learned into a quick demo project. This project displays a random number on the screen. The random number is being generated by an Arduino, sent via serial, and requested by a touch of the TouchShield Slide.

Random Number from Arduino Displayed after Detecting a Touch…

Visit Liquidware’s App Store to download the source code and library for this demo project.