0
\$\begingroup\$

I have need to detect when something around the house is switched on.

A simple example would be that if someone switched on a light i need to be able to track that on a computer.

It needs to be at it's very basic form, for example: simple cable connected to a USB port. if i connect a battery to the USB cable i need to be able to detect that.

I had a look at some of the USB specifications, but they all mention reading information, nothing on reading voltage input into the USB port. My next logical step, is to try and convert that voltage into something the USB might recognize, which i presume is transforming volts to bits.

Does anyone have a schematic of how to build something like this? i would prefer not to make use of a micro controller, i need the device to be as simple and cheap as possible.

\$\endgroup\$
1
  • 8
    \$\begingroup\$ USB is a fairly complex protocol, with handshakes and a set-up phase. It is not a parallel port. This isn't an area where "prefer not to make use of a micro controller" makes much sense. ... Alternatively, consider using a parallel port, if your computer has one or if it can be added as an adapter card. \$\endgroup\$ Mar 5 '13 at 22:30
2
\$\begingroup\$

Expecting to do this without a micro is unrealistic. USB is a fairly complex serial protocol that was designed from the beginning assuming there would be dedicated silicon at the other end to perform the handshaking. USB has a lot of complexity under the hood so that it can seem simple to end users. Providing all that simplicity is complex!

Fortunately, the silicon to do much of the complicated handshaking is now built into a number of microcontrollers. Take a look at the PIC 18F2550 and the like. These things are cheap and small and can be powered from the USB, so expense isn't really the issue. The average 10 foot USB cable costs more than one of these micros.

\$\endgroup\$
2
\$\begingroup\$

Updated answer:

It looks like you only want to detect the presence of voltage, not actually measure the voltage. If this is true, you can avoid a micro and use a USB to GPIO chip (such as the CP2103: http://www.silabs.com/Support%20Documents/TechnicalDocs/cp2103.pdf). The chip I listed above is actually a USB-to-GPIO chip which also has 4 GPIO inputs. You would be able to program these (from your host) as inputs and then read the 0 or 1 state of each pin.

Old answer:

If you really want to build this, what you need is a microcontroller with an analog-to-digital converter and a USB interface. You will need code running on the micro to read the value from the A/D and make it available over the the USB interface.

Examples of suitable micros would include the C8051F321 or SiM3U134, both from Silicon Labs. There are many others, from many other manufacturers.

\$\endgroup\$
1
  • \$\begingroup\$ You hit the nail there: "you only want to detect the presence of voltage". \$\endgroup\$
    – stoic
    Mar 6 '13 at 11:21
1
\$\begingroup\$

As Anindo says, USB is a complex protocol which requires a microcontroller or specific USB IC, such as the FT245, FT232 USB to parallel/serial chips. If you want to and are willing to learn, then grab a starter USB dev board from e.g. Microchip or Atmel (e.g. PIC18F, 24F or PIC32 based) a couple of basic electronics books and learn the basics (plenty of questions on here about getting started with this stuff, have a look around)

If you are not looking to learn about circuit design or microcontrollers, which from scratch would take a considerable amount of time and effort to accquire the skills you would need for Home Automation type stuff, then my advice is to purchase something like a USB I/O or logging type device or Multimeter with PC comms capability.
National Instruments do a range of USB data logging products which can deal with digital or analogue inputs, plus outputs for controlling relays, etc. Here is an example of one; a digital I/O with up to 96 lines. Another is the Compact DAQ system for sensor logging, which has various sensor modules that can be used with it. Have a browse around the main data acquisition pages to see if anything suits your needs.

For simpler and cheaper more basic devices, see the Anatrek options.

Whatever you choose, it's quite likely you will still have to build some basic circuit to interface with the logging device. We would need to know the details of exactly what you want to do to provide a specific solution, such as whether you want to use wiring or RF, whether you want to measure voltage/currents and of what levels and frequency, etc. To figure out if something is switched on or off is easy enough, if that's all you want to do then tell us what it/they is/are, and whether you want to do it wirelessly or not (plus any other details you can think of which may help)

\$\endgroup\$
0
\$\begingroup\$

Previous answers are all good. You need a microcontroller to interface with usb, but you dont need to program it yourself. Dataloggers are programmed to do that for you. A soundcard is an analog input. If you need to detect on/off, you don't need to convert analog to digital. Get a parallel port card/usb device and maybe use optocouplers or lightsensors depending on application.

Considering the question, you should be very cautious before connecting any voltage source to any input. If you don't understand it, don't connect it. Don't play with mains voltage.

If you can tolerate a very hackish approach that is quite safe and really need analog input, be creative. There are lots of computer devices that do convert analog to a digital value you can use. Think about a wireless gamepad with analog sticks. You can probably get one for cheap because it has a broken stick. My "Wireless" suggestion was added for security... if you don't know what you are doing, you won't fry your pc... only the gamepad.

And if you only need to detect light, the cheapest webcam can probably do that reliably and will be safer than trying to interface mains/AC with anything.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.