Import Soul Wouldn’t it be nice if things just worked

14Sep/090

Arduino and MSN

Since somebody asked i have written up how to get MSN and Arduino to communicate.

Firstly, i use Windows Live Messenger Plus (Go here to find out about it if you dont have it). MSN Plus allows you to download plug-ins for MSN, and it mean you can write your own, the scripts are written in a variant of Microsoft's JScript 5.6.

From there all i had to do was find out how to connect to a serial port useing JScript, i found you could open a serial port like a file like this

com = fso.OpenTextFile("COM7:9600,N,8,1",2);

However that only seemed to work if the serial port had been opened previously so i kind of cheated and just made a Python file that opens the serial port and then disconnects.

import serial
import time

ser = serial.Serial('COM7',9600)
time.sleep(2) ## wait for the arduino to do its software reset thing
ser.close()

Now that that the msn is able to connect to the Arduino is simple to write strings to it but don't forget to close it and don't forget that when you close the serial connection the Arduino resets.

com = fso.OpenTextFile("COM7:9600,N,8,1",2);
com.Write("Something");
com.Close();

I wont post the full code here for my script to turn on msn lights unless somebody particularly wants it as i don't think it is written very well

function OnEvent_Initialize(MessengerStart)
{
fso = new ActiveXObject("Scripting.FileSystemObject");

// run the python script that wakes up the serial port
oShell = new ActiveXObject("WScript.Shell");
var command = "\"C:\\Program Files\\Python25\\python.exe\" \"C:\\Program Files\\Messenger Plus! Live\\Scripts\\wallchart\\open.py\"";
Debug.Trace(oShell.Run( command,0,true)); // wait for it to finish

// Connect to the serial port make sure you wait at least 2 seconds before writeing to it
fso = new ActiveXObject("Scripting.FileSystemObject");
com = fso.OpenTextFile("COM7:9600,N,8,1",2);
}

function OnEvent_ContactSignIn(email)
{
// Say something about who logged in to the serial
com.Write(data);
}

function OnEvent_ContactSignOut(email)
{
// Say something about who logged out to the serial
com.Write(data);
}

function OnEvent_Uninitialize(MessengerStart)
{
// Close the serial port when messenger closes
com.Close()
Debug.Trace("Closed");
}

Well that's it and i hope i managed to explain how to get MSN and arduino to talk to each other, there are many more events that would could catch data from to send to the arduino i recommend for people to read though the MSN plus developers manual here

Also this method is slightly flawed in that it is one way, i will look into a way that can read and write data to the serial port without disconnecting and reconnecting.

Good luck

EDIT: Raymond found out that this method only works with single digit COM ports e.g. COM7 as opposed to COM15

21Jun/096

MSN Wallchart V3

Got round to finishing this project up and giving it its own box and reprinting the photos, it ended up looking quite good. I also added a little buzzer for when people log in.

Finished and hung at last

Finished and hung at last

On off button, Beep switch, Computer connection

On off button, Beep switch, Computer connection

Usualy covered by a pannel, and yes my soldering is messy

Usualy covered by a pannel, and yes my soldering is messy

Doing the wiring on the the back was very frustrating, i spent a few hours doing it, and yes it is messy, very very messy

Project complete

Edit: i have since switched the arduino Decimila for a Stickduino (a cheaper bare bones arduino clone) so i can reclaim my arduino for other projects

16Jun/091

MSN Wallchart V2

Figured out how to make MSN scripts communicate directly with the audrino board removeing the python middle stage,  now the lights actualy turn off by themselves when the computer shuts down.  Instead of the more manual method off pulling the cord out.

14Jun/090

MSN Wallchart

Last weekend i finally found a good use for the Audrino Diecimila board that i got given to participate in the beta of NCSS/NICTA Embedded Challenge

The project was inspired by the wall in thunder birds where the eyes in peoples portraits light up when they are calling

My projects turns on and off LEDs depending on which people are logged into MSN. I probably have made it work in a very roundabout way going from MSN plus scripting to Python and finally Audrino which then decides which lights to turn on and off.

When i have time i am going to redo this project, give it its own board and try to remove the python midway stage on the software side of things

MSN Wallchart