-1

I got 2 of these USB Relay modules off ebay, very little (none) in the way of software.

[http://cgi.ebay.ie/ws/eBayISAPI.dll?ViewItem&item=181279336378]

As it says;

Open the USB switch: A0 01 01 A2

Close USB switch: A0 01 00 A1

I have been using a program called "RS232 Monitor" (the only one I could find that will let me send HEX values and works just happens to be a 30 day trial, I know you shouldn't have to pay for stuff like that), and it will turn the relay on and off. Nice. But that's not much fun.

I would like to schedule scripts, trigger them remotely etc

If anybody could help me come up with a .vbs script or batch file to turn it on and off I would be most grateful.

Thanks for reading...

Eric Brown
  • 13,774
  • 7
  • 30
  • 71
user3133275
  • 41
  • 1
  • 8

1 Answers1

0

You could make some batch files and then use the Windows task scheduler to do your bidding. To be honest though, you're going to find yourself limited with vb or batch scripts.

Anyways, to send this data to a serial port from a batch file:

  1. You must have a valid comm num, e.g. COM1
  2. Load your data into a binary file because (NOT plain text, but raw binary file)
  3. copy /B yourdata.bin COM1

The binary file is important because

    echo data > com1

will only send ASCII. You must use the copy command and the /B flag to send these bytes to your Arduino. See how hard we're making this already?

I'd go on with the list but really, just read up on some .NET or Python (heck even Chrome serial API) and you'll be much better off.

Best of luck

cory.todd
  • 516
  • 5
  • 14
  • Thanks for getting back to me. Unfortunately the device won't accept binary commands when I convert them from HEX, tried sending them with the utility I have been using (I of course set it to binary mode). I still tried what you suggested and it just created a file called COM11 on my harddrive which says "The file cannot be copied onto itself"... – user3133275 Feb 12 '14 at 20:14
  • How did you create this file? I feel that's where things are going wrong. Did you setup the com port to match your baud rate? Here is what I tested successfully mode COM7 BAUD=19200 Parity=n DATA=8 copy /B sample.bin COM7 I created my binary file with a hex editor (not notepad). – cory.todd Feb 12 '14 at 20:38
  • Thanks Man, I had just been using an online conversion tool and saving with notepad. Downloaded a hex editor and exported the files and it works! Nicely too, will write some batch files etc now that I can schedule. Nice one... – user3133275 Feb 13 '14 at 06:06
  • Thanks! Sorry last question, no worries if there's no easy answer, I can work with what I've got. But, do you know how I can copy the on.bin and off.bin files from within a .vbs script. Preferably silently (ie, it doesn't pop the CMD window for a sec) so then I can use form buttons etc to change the state. If you don't know offhand, or its too much hassle, don't worry. You've been more than helpful!! – user3133275 Feb 13 '14 at 17:59
  • http://stackoverflow.com/questions/4919573/vbscript-code-to-capture-stdout-without-showing-console-window – cory.todd Feb 13 '14 at 19:17
  • Thanks again! Time to start scheduling. I have a DD-WRT Router that reboots at 0500 every morning, unfortunately our cable modem has no such feature and after being on a couple of weeks gets really warm/crashes limiting my remote access if I'm mobile. Now I can cut it's power lead, run it through the relay and schedule a reboot (Off for 10secs and back on!) Thanks for all your help... – user3133275 Feb 14 '14 at 00:42