I Need a Device that Can Tell a PC the State of Relay Contacts

Thread Starter

petec

Joined Jan 2, 2019
10
A friend of mine needs to know when his furnace turns off and on. He has installed a relay that switches state when the furnace changes.
All he needs is a USB device with two wires hanging out to place across the relay contacts (and maybe a pull-up resistor). Maybe some software to log the changes. I thought finding something like this would be easy but I can't seem to turn up anything reasonable.
I found a $260 device with no software support.
A sparkfun device for $19.99 but again no software support and requiring both Arduino coding and PC coding.

If needed I could whip up some VBA code for the PC but I don't have the time to learn Arduino. In the distant past I did a lot of assembly language for the same chip family as the Arduino but I'm not ready to restart that stuff.
Any ideas?
 

Ya’akov

Joined Jan 27, 2019
9,101
Welcome to AAC.

This device is under $5.00 and includes a Centronics Parallel Port which is the past standard for interfacing digital signals to PCs on the cheap. The parallel port has 8 data lines plus some status lines and any one of them can be used as GPI, and four of them can be used for output as well.

1704920856958.png

It should be relatively trivial to write a program that reads one of those pins, but the maximum length of the wires from the relay to the board will be relatively short. A high quality shielded cable could extend the effective distance to a few meters, possible up to 10 or so.

Potentially, you could use a wireless connection between the relay and the USB interface, but that gets complicated.

If you use a small, dirt cheap, wireless capable MCU boards like the ESP8266, the whole thing is trivial. You can write a simple program that sends a notification over the network (using Wi-Fi) to a logging program, which could be syslogd or anything you'd like.

1704921462645.png
16mm x 21.2mm x 3mm

Or, you could have the logging happen on the ESP8266 itself (or better, and ESP32 if local logging is the goal) and provide a web page interface to graph it, browse, or provide a download link—and of course for C&C as well like logging enable/disable, clear local log, configure remote logging, etc.
 

Thread Starter

petec

Joined Jan 2, 2019
10
Welcome to AAC.

This device is under $5.00 and includes a Centronics Parallel Port which is the past standard for interfacing digital signals to PCs on the cheap. The parallel port has 8 data lines plus some status lines and any one of them can be used as GPI, and four of them can be used for output as well.


It should be relatively trivial to write a program that reads one of those pins, but the maximum length of the wires from the relay to the board will be relatively short. A high quality shielded cable could extend the effective distance to a few meters, possible up to 10 or so.

Potentially, you could use a wireless connection between the relay and the USB interface, but that gets complicated.

If you use a small, dirt cheap, wireless capable MCU boards like the ESP8266, the whole thing is trivial. You can write a simple program that sends a notification over the network (using Wi-Fi) to a logging program, which could be syslogd or anything you'd like.

View attachment 312419
16mm x 21.2mm x 3mm

Or, you could have the logging happen on the ESP8266 itself (or better, and ESP32 if local logging is the goal) and provide a web page interface to graph it, browse, or provide a download link—and of course for C&C as well like logging enable/disable, clear local log, configure remote logging, etc.
This is also a possible solution. The old printer/parallel port used to be my goto solution for input/output to my PC.
But I am not sure how to communicate to this device. The AliExpress doesn't say much about that part of the problem.
I See something on github that may be a start
 

Ya’akov

Joined Jan 27, 2019
9,101
This is also a possible solution. The old printer/parallel port used to be my goto solution for input/output to my PC.
But I am not sure how to communicate to this device. The AliExpress doesn't say much about that part of the problem.
I See something on github that may be a start
I suspect that it will appear as a (virtual) parallel port and can be accessed via the normal calls to talk to a PP.
 

Danko

Joined Nov 22, 2017
1,834
A friend of mine needs to know when his furnace turns off and on. He has installed a relay that switches state when the furnace changes.
All he needs is a USB device with two wires hanging out to place across the relay contacts (and maybe a pull-up resistor). Maybe some software to log the changes. I thought finding something like this would be easy but I can't seem to turn up anything reasonable.
Maybe this solution will work for your friend...
https://forum.allaboutcircuits.com/threads/simple-event-recorder.172329/post-1544605
 

eetech00

Joined Jun 8, 2013
3,928
Hi

Google "IO interface for PC" or "GPIO interface for PC", you'll get a lot of hits.
Some are designed to communicate to the PC via USB. Others are PCI type boards.
 

Ya’akov

Joined Jan 27, 2019
9,101
Another person recommended:
https://www.amazon.com/Programmable-User-Defined-Button-Customized-Combination/dp/B08SQGWZN4?th=1

This looks like the best solution.
I will see if he wants to go with this.

Thanks everybody
To be honest, the 4471 board from Adafruit, recommended by @nsaspook above, seems to actually be your best option.

Yes, you will have to learn a little Python—but my experience is telling me that at the end of the day kludging hardware not intended for a purpose and already written software, also not specifically intended to solve a problem, is going to result in a lot of wheel spinning, compromises, and at the end of the process a fragile “solution” that will ultimately be abandoned.

The 4471 solution will let you build something that is actually simple, not just apparently so. It will also not tie up an entire computer for the sake of one task. It has an excellent side effect of getting you some experience with arguably the most popular dynamic language today in its embedded programming form.

As a bonus, you have Adafruit’s excellent documentation including a tutorial that should be all you need—and support if it isn’t. I would say, make this is as easy to do as you can, but no easier—that’s a trap.
 

ErnieM

Joined Apr 24, 2011
8,377
If you ever look into using the ESP type devices they have an inexpensive starting board called the D1-Mini. The board has an ESP-8266 (I believe) chip on board, a power regulator and USB port. You can use the USB to program the thing, get data out, and power the device too.

Not bad for a device that runs you maybe 4 bucks.

I've used that in a few tiny projects (IR transmitter running thru Alexa). I've also used the larger ESP-32 boards, similar is usage, more I/O pins, for around 10 bucks. That runs a 4 channel RGBW LED controller that lights several areas of my kitchen counters.
 

Thread Starter

petec

Joined Jan 2, 2019
10
Ya'akov, I have done my fair share of python coding. I just want something more turnkey. My friend is 700 miles away. I just want to tell him, "Here is the device you need", and maybe write him a VB program to log the contacts and write it to a text file. He should be able to import that into excel and wing it from there.

ErnieM, I have a few ESP family devices. Two are about 18 inches from my right shoulder. I need more turnkey.
 

panic mode

Joined Oct 10, 2011
2,733
for a simple on/off state, the cheap and readily available option is USB to RS232 adapter and can be obtained literally anywhere for few $. one nice thing about serial port is that it is pretty robust - short circuit among any contacts on the port is not a problem (try that with Centronics aka parallel port). and any software can access it (VBA, VB, C# python).

https://www.vbforums.com/showthread...-closed-)-from-rs232-serial-port-using-VB2010
 

Thread Starter

petec

Joined Jan 2, 2019
10
for a simple on/off state, the cheap and readily available option is USB to RS232 adapter and can be obtained literally anywhere for few $. one nice thing about serial port is that it is pretty robust - short circuit among any contacts on the port is not a problem (try that with Centronics aka parallel port). and any software can access it (VBA, VB, C# python).

https://www.vbforums.com/showthread...-closed-)-from-rs232-serial-port-using-VB2010
I will keep that in mind for my own projects if needed. But for my friend, I'll suggest it but I don't think he can deal with that.
 

Reloadron

Joined Jan 15, 2015
7,512
for a simple on/off state, the cheap and readily available option is USB to RS232 adapter and can be obtained literally anywhere for few $. one nice thing about serial port is that it is pretty robust - short circuit among any contacts on the port is not a problem (try that with Centronics aka parallel port). and any software can access it (VBA, VB, C# python).

https://www.vbforums.com/showthread...-closed-)-from-rs232-serial-port-using-VB2010
This is what I would do. A USB to RS232 adapter is inexpensive, I bought a pair for about $10 USD on Amazon. The RS232 port gives you three digital inputs and two digital outputs. Pins 1, 6, and 8 serve as digital inputs and with little effort can be used to detect about anything like a switch closure. I wrote a routine maybe 15 ~ 20 years ago using VB 6.0 to monitor the serial port and it looked like this.

Phone Home 1.png

When SMS Text is enabled it looks like this.

Phone Home 2.png

When any of the 3 pins go high it would send a text message to my phone.

The actual code looks like this:


VB 6.0 Phone Home:
Private Sub CmdCallEnable_Click() 'Set captions for Phone Home button
If CmdCallEnable.Caption = "Disabled" Then
    CmdCallEnable.Caption = "Enabled"
ElseIf CmdCallEnable.Caption = "Enabled" Then
    CmdCallEnable.Caption = "Disabled"
End If
If CmdCallEnable.Caption = "Enabled" Then 'Make lower features visible or invisible
    Label13.Visible = True
    Label14.Visible = True
    Label15.Visible = True
    Label16.Visible = True
    Label17.Visible = True
    Label18.Visible = True
    TxtFire.Visible = True
    TxtFlood.Visible = True
    TxtIntrusion.Visible = True
    cmdSmoke.Visible = True
    cmdFlood.Visible = True
    cmdIntrusion.Visible = True
    Frame3.Visible = True
    
ElseIf CmdCallEnable.Caption = "Disabled" Then
    Label13.Visible = False
    Label14.Visible = False
    Label15.Visible = False
    Label16.Visible = False
    Label17.Visible = False
    Label18.Visible = False
    TxtFire.Visible = False
    TxtFlood.Visible = False
    TxtIntrusion.Visible = False
    cmdSmoke.Visible = False
    cmdFlood.Visible = False
    cmdIntrusion.Visible = False
    Frame3.Visible = False
End If

End Sub

Private Sub cmdFlood_Click()
If CmdCallEnable.Caption = "Enabled" Then
Shell "Wscript.exe C:\Notifications\Flood.vbs", vbNormalFocus
End If
End Sub

Private Sub cmdIntrusion_Click()
If CmdCallEnable.Caption = "Enabled" Then
Shell "Wscript.exe C:\Notifications\Intruder.vbs", vbNormalFocus
End If
End Sub

Private Sub cmdSmoke_Click()
If CmdCallEnable.Caption = "Enabled" Then
Shell "Wscript.exe C:\Notifications\Fire.vbs", vbNormalFocus
End If
End Sub

Private Sub Command1_Click() 'Start
MSComm1.CommPort = Val(Combo1.Text) 'Select port from combo box
MSComm1.PortOpen = True 'Open the port
Timer1.Enabled = True
End Sub

Private Sub Command2_Click() 'Stop
MSComm1.PortOpen = False 'Close the port
Timer1.Enabled = False
End Sub

Private Sub Form_Load()
Combo1.AddItem "1"
Combo1.AddItem "2"
Combo1.AddItem "3"
Combo1.AddItem "4"
Combo1.AddItem "5"
Combo1.AddItem "6"
Combo1.AddItem "7"
Combo1.AddItem "8"
Combo1.AddItem "9"
Combo1.AddItem "10"
Combo1.AddItem "11"
Combo1.AddItem "12"
Combo1.AddItem "13"
Combo1.AddItem "14"
Combo1.AddItem "15"

Label13.Visible = False
Label14.Visible = False
Label15.Visible = False
Label16.Visible = False
Label17.Visible = False
Label18.Visible = False
TxtFire.Visible = False
TxtFlood.Visible = False
TxtIntrusion.Visible = False
cmdSmoke.Visible = False
cmdFlood.Visible = False
cmdIntrusion.Visible = False
Frame3.Visible = False

End Sub

Private Sub Text1_Change()

End Sub

Private Sub Timer1_Timer() 'Timer set for 100 mS

If MSComm1.CTSHolding = True Then
    Shape1.FillColor = &HFF&
Else: Shape1.FillColor = &HFF00&
End If
If MSComm1.DSRHolding = True Then
    Shape2.FillColor = &HFF&
Else: Shape2.FillColor = &HFF00&
End If
If MSComm1.CDHolding = True Then
    Shape3.FillColor = &HFF&
Else: Shape3.FillColor = &HFF00&
End If
If Check1.Value = 1 Then
    MSComm1.DTREnable = True
Else: MSComm1.DTREnable = False
End If
If Check2.Value = 1 Then
    MSComm1.RTSEnable = True
Else: MSComm1.RTSEnable = False
End If
If MSComm1.CTSHolding = True Then
    Label13.Caption = "ALARM"
    Label13.BackColor = &HFF&
ElseIf MSComm1.CTSHolding = False Then
    Label13.Caption = "NORMAL"
    Label13.BackColor = &HFF00&
End If
If MSComm1.DSRHolding = True Then
    Label14.Caption = "ALARM"
    Label14.BackColor = &HFF&
ElseIf MSComm1.CTSHolding = False Then
    Label14.Caption = "NORMAL"
    Label14.BackColor = &HFF00&
End If
If MSComm1.CDHolding = True Then
    Label15.Caption = "ALARM"
    Label15.BackColor = &HFF&
ElseIf MSComm1.CTSHolding = False Then
    Label15.Caption = "NORMAL"
    Label15.BackColor = &HFF00&
End If
If Label13.BackColor = &HFF& And CmdCallEnable.Caption = "Enabled" Then
    TxtFire.Text = "Sending Notification"
Else: TxtFire.Text = ""
End If
If Label14.BackColor = &HFF& And CmdCallEnable.Caption = "Enabled" Then
    TxtFlood.Text = "Sending Notification"
Else: TxtFlood.Text = ""
End If
If Label15.BackColor = &HFF& And CmdCallEnable.Caption = "Enabled" Then
    TxtIntrusion.Text = "Sending Notification"
Else: TxtIntrusion.Text = ""
End If
    



End Sub

Private Sub TxtFire_Change()
If CmdCallEnable.Caption = "Enabled" And TxtFire.Text = "Sending Notification" Then
Shell "Wscript.exe C:\Notifications\Fire.vbs", vbNormalFocus
End If
End Sub

Private Sub TxtFlood_Change()
If CmdCallEnable.Caption = "Enabled" And TxtFlood.Text = "Sending Notification" Then
Shell "Wscript.exe C:\Notifications\Flood.vbs", vbNormalFocus
End If

End Sub

Private Sub TxtIntrusion_Change()
If CmdCallEnable.Caption = "Enabled" And TxtIntrusion.Text = "Sending Notification" Then
Shell "Wscript.exe C:\Notifications\Intruder.vbs", vbNormalFocus
End If
End Sub
Today the code would be much, much easier to write considering the example link given for VB 2010. Even easier with newer versions of software available.

Ron
 

panic mode

Joined Oct 10, 2011
2,733
and easy for non technical types as no soldering is required, one can use ready made breakout boards.
simply plug an play, as mentioned it is pretty rugged and program is just few lines of code.
it is not the most versatile solution but it is readily available, low cost, and safe even for clumsiest types.
1705191867893.png
 

Reloadron

Joined Jan 15, 2015
7,512
and easy for non technical types as no soldering is required, one can use ready made breakout boards.
simply plug an play, as mentioned it is pretty rugged and program is just few lines of code.
it is not the most versatile solution but it is readily available, low cost, and safe even for clumsiest types.
View attachment 312663
I have some of those around here somewhere. :)

Ron
 
Hi, I can recommend these:
USB DAQ Device: You need to grab a USB DAQ device that can handle digital inputs. These gadgets were made just for this kind of stuff, keeping an eye on digital signal changes.
Wiring: Link the two wires from the relay contacts straight to the digital input channels on your USB DAQ device.
Software: Make use of what's already out there or whip up a basic script to record the changes in the digital signal. No need for fancy coding, there might be some simple scripts or programs ready for you to use.
VBA Code: If you're good with VBA, go for it! Just write a basic script that keeps tabs on the USB input and logs any changes.
Ready-Made Solutions: Keep an eye out for off-the-shelf software solutions that are compatible with your specific USB DAQ device. Some of these gadgets come with their own software that makes the monitoring process a breeze.
 

Thread Starter

petec

Joined Jan 2, 2019
10
Thanks, folks.
Many great ideas that would be easy for me.
But not my friend who is 700 miles away and not very technical.
I'll keep watching for an off the shelf, turnkey solution.
 
Top