Home Projects AVR Programming Guides Electrical Fundamentals Insteon Saving Electricity
 AVR Programming Guides We have some nice AVR code samples to share. Lots of AVR goodies like timers, interrupts, and pin I/O for the beginner.
 Watts Tables Use these tables to help you determine how much various items in your house cost you by the day, month, and year.
 Saving Electricity A list of a variety of ways to help you save money by learning how much it costs to run things.
 What is a Kilowatt Hour Saving money on your electric bill starts with understanding what a kilowatt hour is.
 How To Measure Watts Learn a variety of ways to measure watts in your house.
 Read Your Power Meter By reading your power meter you can get a good idea of how much various electrical devices cost you.
 Electronics Fundamentals Learn some basic electronics fundamentals and see if you enjoy the field of electronics.

## Poll Insteon Devices with Visual Basic 6

You should already have the following code:

Option Explicit
Dim WithEvents sm As SDM3

' create a new instance of the SDM
Set sm = New SDM3Server.SDM3
End Sub

To get the current level of an Insteon device, you use the function GetOnLevelText(strID). Lets put in a command button, and call that function from it:

Private Sub Command1_Click()
' request device status
sm.GetOnLevelText "07.B1.12"
End Sub

When you call this function, about 1 second later you will get an Insteon Event in the callback called sm_OnText. The event you are looking for will have the following in the variable Text:

getOnLevelText=07.B1.12,OFF

You can see that it is telling me that my light is currently off. Here is a down and dirty way to process device levels. You may want to add some bounds checking code to this:

' this sub will be called when the
' PLC receives an Insteon Event

Private Sub sm_OnText(ByVal Text As String)
Dim varLevels As Variant
Dim strTemp As String

If InStr(1, Text, "getOnLevelText=") Then
' get ready to split the string
strTemp = Replace(Text, "=", ",")
varLevels = Split(strTemp, ",")

Debug.Print "The device: " & varLevels(1) & " is at level: " & varLevels(2)
End If
End Sub

There are many other Insteon events you can respond to in Visual Basic. Check out the Insteon Event Dumping code here.

#### Written by Jason Bauer

Jason Bauer is an owner and programmer for Portforward.com. He's allergic to twitter and facebook, but you can find more of his articles in the Guides section.
 Wednesday, 28-Jun-2017 15:33:57 PDT