Relay activated using Xojo (USB)

Hello. I am making my first project. There is a moment when the user must read a barcode, and depending on the code read a relay must be activated.

It is possible to do that with XOJO?

In case that the answer is YES I don’t know what relay to use… Thanks

http://www.ebay.com/itm/Brand-New-USB-Relay-1-Channel-Programmable-Computer-Control-For-Smart-Home-/171078469510?pt=LH_DefaultDomain_0&hash=item27d5124786

I found this on eBay… Maybe it is possible to use.
Thanks

No one?

This device uses HID which will probably just show up as a serial port (COM) on the computer when plugged in. Therefore you could probably use the SerialClass in XOJO to access it. You WILL need the baud rate and protocol to access and control the device, which would found in the datasheet for the device. That will tell you what commands to send to the device to turn the relay on or off.

Most of these devices use the FTDI chipset which converts the USB protocol to a serial RS232 COM protocol to easily interface with software (USB is not easy to implement).

It looks like the datasheet is downloadable and it also looks like it comes with a sample application as well for testing. Xojo should be able to interface with this device.

I have never done it with this exact hardware, but I have seen Xojo interact with an arduino (which uses serial) It can’t be too far off from what you’re trying to do. If I were a betting man, I’d bet that it can be done, if not then I’d just go with an arduino and hook up a relay to it. I have used a bar code reader before in one of my Xojo projects successfully so that will not be an issue.

A HID device will not show up as a new COM port. You will need to access the device using your OS’s APIs, or some plugin/library that will allow you to connect to the device using less code (and probably easier).

For Windows there is a free dll (mcHID.dll) that you can use. Here you have a test project using it (my coding and commenting is poor, as you will find out): https://dl.dropboxusercontent.com/u/3800071/HIDTest.zip

If you need other platforms or even something that will work on them all and are willing to pay a little money for a plugin, check the MBS USB class (Monkeybread Xojo plugin - USB).

Julen

It will if it has been designed to do so… The HID is USB interface, but many of these IO devices are designed to emulate an actual serial COM port. For example - you can plug this device into your USB port and bingo, it will create a new COM port you can use in XOJO with no problem using the standard serial class. I have used this method on multiple pieces of test equipment where XOJO is the front end. Here is the device:

link text

It is entirely possible when you plug that relay module into the USB and check for available com ports I would bet another standard serial COM port shows up.

In fact FTDI makes an entire set of chips designed specifically for that:

http://www.ftdichip.com/Products/ICs/FT232H.htm

This is what a lot of these industrial/hobby/DIY interface boards use as their chipset to allow easy implementation and access to legacy development systems, or, where the user cannot easily implement the USB serial class themselves.

True, I sometimes use a Teensy (Teensy USB Development Board), and it can be used either as HID or as a serial device, but the way you talk to it is completely different in either mode. The ebay information in the first post mentions HID, not serial/COM device, so my guess is that it will only work as HID.

If that’s the case, the possibilities are the ones I mentioned before. On the other hand, if it can also be recognized as a serial device connected to a COM port, then Xojo’s serial class can be used, as Joseph says.

It depends on the device.

Julen

hey, which barcode reader you used?

Hello, Mariah Sharpbot!

Hi julen.

Is the teensy reliable over time?
I need something to read switches and it has to run for months at a time.
Reads are every second so not very quick

Im wary of things that are so cheap, but it does look good.

Hi Russ,

I can’t tell you about that since I have only used it for small projects that never run for long times. Sorry.

Maybe you could check their forum (http://forum.pjrc.com/forum.php) or ask there.

Julen