"Space occupied" and other IRC announcements

Post Reply
drostar
Posts: 51
Joined: Wed Feb 16, 2011 9:19 am

"Space occupied" and other IRC announcements

Post by drostar » Sun Sep 16, 2012 9:11 pm

A while back, Kaldonis set up a light sensor and Arduino to tweet "occupied/unoccupied" announcements whenever it detected that the lights at the space were turned on or off. Then it died. Now, I've resurrected the idea with a UBW (http://www.schmalzhaus.com/UBW/) instead of Arduino and IRC instead of Twitter.
Light sensor hooked up to analog input of UBW
Light sensor hooked up to analog input of UBW
UBW_lightsensor_breadboard.jpg (179.08 KiB) Viewed 7436 times
The circuit is very basic. The light level sensed by the photoresistor goes into the analog input (A0) of the UBW. The UBW is connected to SpaceBox over USB (virtual com port). It's not easy to use com ports with mIRC script so I made a Windows application to control the UBW and act as a DDE Server that mIRC can communicate with. This also makes it easier to integrate with other applications or web services, if that becomes necessary. Click the "DDE Commands" button to see the DDE commands available and how to use them from mIRC.
PC Application to monitor UBW and serve IO as a DDE Server
PC Application to monitor UBW and serve IO as a DDE Server
UBWIO_application.JPG (66.98 KiB) Viewed 7436 times
The C# source code is available at https://code.google.com/p/ubw-com-net-library/

Right now, the first analog input is used by the light sensor. There are 3 more available (A1 - A3) for other sensors. With some tweaking, another 2 could be enabled for a total of 6 analog inputs. The rest of the pins default to digital inputs but can be changed to digital outputs in the application. Click the "UBW IO Diagram" button for a pin diagram of the UBW. Outputs can drive up to 25mA.

There is a beacon light that I will probably hook up as well. If anyone else has any other ideas for what to hook up to the UBW, let me know (or just go ahead and do-ocracy it yourself).

User avatar
JamesCooper
Posts: 164
Joined: Tue Jan 11, 2011 11:46 pm

Re: "Space occupied" and other IRC announcements

Post by JamesCooper » Wed Sep 19, 2012 11:08 am

Excellent write-up, drostar! You made that UBW IO Automation entirely on your own? Looks wonderful! Extra kudos for making the source available on Google Code. I was looking at having to do something very similar for my multicolor light display thing, but wasn't really sure how to get started under Windows. I totally forgot about DDE servers (mIRC, it's been too long!). Well done!

drostar
Posts: 51
Joined: Wed Feb 16, 2011 9:19 am

Re: "Space occupied" and other IRC announcements

Post by drostar » Wed Sep 19, 2012 7:08 pm

Thanks! I made use of a very old open source DDE Server library from https://ndde.codeplex.com/ but I wrote the rest. I should probably provide a link to that in my code somewhere. A warning to anyone who actually bothers to look at the source code, the UI code is pretty hackish. It was originally intended to just be a COM/NET library for the UBW and then it ballooned from there.

I used this project to experiment with the .NET TableLayoutPanel container for displaying a table of UI controls. It doesn't work that well. The TableLayoutPanel is far too slow. But it works.

One more thing I'll need to implement soon is saving the pin configurations to file and automatically loading them on startup. Otherwise, someone will have to manually change the beacon light pin type to an output anytime the application/PC is restarted.

drostar
Posts: 51
Joined: Wed Feb 16, 2011 9:19 am

Re: "Space occupied" and other IRC announcements

Post by drostar » Tue Sep 25, 2012 9:37 am

The beacon is hooked up to pin C2. Because I haven't done the pin config file yet, the pin will have to manually be set to an output any time the UBW or PC is rebooted, or even just the UBW application is restarted. If you don't, the pin defaults to an input which causes the beacon light to turn on. It won't turn off until you set the pin as an output (or you disconnect power to it).

I will probably also modify the circuit so it doesn't turn on when the pin is set as an input.

drostar
Posts: 51
Joined: Wed Feb 16, 2011 9:19 am

Re: "Space occupied" and other IRC announcements

Post by drostar » Thu Nov 22, 2012 10:46 am

So it turns out that pin C2's input mode was broken and was actually outputting a voltage. The beacon has been moved to C1. At least now the beacon doesn't get stuck on when the PC is rebooted.

User avatar
JamesCooper
Posts: 164
Joined: Tue Jan 11, 2011 11:46 pm

Re: "Space occupied" and other IRC announcements

Post by JamesCooper » Fri Nov 23, 2012 8:45 pm

Did you set a true value on PORTC.2? In input mode, the output state of the pin determines whether the internal pullups are connected. If you write true, the pullup is connected, if false, there is no pullup and it will be properly floating.

Post Reply