Missing Piece of Code or Inadequate External Power to Sensor? [Firmata]

Hi all.

I'm trying to connect a piece of apparatus (a hoop type thing with sensors in it for fish to swim through) to an Arduino which is connected to a Visual Basic form with Firmata. The hoop is attached to a relay shield and an external wall power source (that goes up to 24V) and the Arduino. I connected like I connected a previous sensor. I had it so when that sensor reading went below 100, it would trigger rotation of a food drum in a feeder.

I'm unsure if I'm missing some code for the relay shield or if 24V is still not enough power for this. I attached a few photos (of the hoop with sensors and then of my connections), though they might not be too helpful. It's a bit of a mess.

Here's my code. I have IN1 from the relay shield attached to digital pin 2. I'm using the analog port A1 to take sensor readings from (white wire from sensor is connected there). Some pieces of the code refer to LEDs that aren't shown in the photos (I took them out to simplify the mess until I can get this sensor business working).

Any suggestions would be fantastic. Thank you! :smiley:

Public Class Form1
    Dim analogread As Boolean = False
    Dim lightOn As Boolean

    Private arduino As New Firmata.FirmataVB
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        FirmataVB1.COMPortName = "COM7"
        FirmataVB1.Baud = "57600"
        FirmataVB1.Connect()
        FirmataVB1.PinMode(4, 9)
        FirmataVB1.DigitalWrite(2, 0)
    End Sub

    Private Sub btnOn_Click(sender As Object, e As EventArgs) Handles btnOn.Click
        analogread = True

        FirmataVB1.AnalogPinReport(1, 1)


        Do Until analogread = False
                lblReading.Text = FirmataVB1.AnalogRead(1)

                If FirmataVB1.AnalogRead(1) <= 100 And picboxCRF.Visible = True Then

                    FirmataVB1.DigitalWrite(8, 1)
                    timerFeeder.Start()

                End If

                Application.DoEvents()
            Loop


    End Sub

    Private Sub btnCRF_Click(sender As Object, e As EventArgs) Handles btnCRF.Click
        picboxCRF.Visible = True
        picboxEXT.Visible = False
        FirmataVB1.DigitalWrite(5, 0)
        FirmataVB1.DigitalWrite(7, 1)

        If lblReading.Text <= 100 Then
            timerFeeder.Enabled = True
            FirmataVB1.DigitalWrite(8, 1)

        End If
    End Sub


    Private Sub form1_formclosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
        FirmataVB1.Disconnect()
        analogread = False
        FirmataVB1.DigitalWrite(5, 0)
        FirmataVB1.DigitalWrite(7, 0)
        FirmataVB1.DigitalWrite(8, 0)
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles timerFeeder.Tick
        FirmataVB1.DigitalWrite(8, 1)
        timerFeeder.Interval = 8000 'ms
        FirmataVB1.DigitalWrite(8, 0)

    End Sub

    Private Sub btnEXT_Click(sender As Object, e As EventArgs) Handles btnEXT.Click
        picboxCRF.Visible = False
        picboxEXT.Visible = True
        FirmataVB1.DigitalWrite(5, 1)
        FirmataVB1.DigitalWrite(7, 0)
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnOff.Click
        FirmataVB1.DigitalWrite(5, 0)
        FirmataVB1.DigitalWrite(7, 0)
        FirmataVB1.DigitalWrite(8, 0)
        picboxCRF.Visible = False
        picboxEXT.Visible = False
    End Sub

    Private Sub Timer1_Tick_1(sender As Object, e As EventArgs)
        FirmataVB1.DigitalWrite(9, 1)
    End Sub

    Private Sub btnManual_Click(sender As Object, e As EventArgs) Handles btnManual.Click
        FirmataVB1.DigitalWrite(8, 1)
        timerFeeder.Start()
    End Sub
End Class

Here is what the hoop with sensor looks like.

Here's the picture I attached in the original post.

If for some reasons clearer or different photos of the wiring would help clarify any of this nonsense, please let me know!

You need to supply more details on the sensor your using. Specifically what voltage it uses (24V ?), what voltage it puts out on it's signal wire (white) and what type of signal it puts out (analogue, digital etc).

Also can you describe the process the VB.net is trying to do in more detail.

blackscorpion:
Here's the picture I attached in the original post.

Still no photos.

You need to find a different hosting service!

Also, I have no idea what Firmata is.
I have written a VB.net 2010 program to communicate with Arduino Uno in the past, and all I used was the .NET Serial Port class.

ieee488:
Still no photos.

You need to find a different hosting service!
The photos are hosted on here (arduino.cc) so maybe your browser is having problems?

Also, I have no idea what Firmata is.
I have written a VB.net 2010 program to communicate with Arduino Uno in the past, and all I used was the .NET Serial Port class.
Firmata is a system for allowing other programming languages to control and read the pins on an Arduino using a defined serial protocol.

Riva:
You need to supply more details on the sensor your using. Specifically what voltage it uses (24V ?), what voltage it puts out on it's signal wire (white) and what type of signal it puts out (analogue, digital etc).

Also can you describe the process the VB.net is trying to do in more detail.

I believe the voltage is either 20V or 28V. I got the hoop custom made from a laboratory equipment company. I had a very difficult time finding the voltage, but I was told tentatively that it would require 20V. Another lab I talked to that has this sensor said that it probably required 28V. I've gotten a lot of partial and unclear information, hence my confusion over the voltage.

I'm assuming it puts out an analog signal, but I'm honestly not for sure. It's a custom built piece and the company provided me with literally no information about it (except how to care for the plastic parts, of course!). I hooked it up like it was putting out an analog signal. I've also tried connecting it as if it would put out a digital signal.

The process in VB.NET is supposed to take continuous readings from the analog port / where the sensor is connected. I have it so it will loop and keep updating the readings.

Sorry I can't provide great information. I myself am working off very little information about this device myself. :confused: Thank you for the replies, though!

I'm assuming it puts out an analog signal, but I'm honestly not for sure. It's a custom built piece and the company provided me with literally no information about it (except how to care for the plastic parts, of course!). I hooked it up like it was putting out an analog signal. I've also tried connecting it as if it would put out a digital signal.

You really need to go back to the company and get the information you require if for no other reason than to prevent you damaging the sensor by connecting it with wrong voltages.

If you cannot supply details on the sensor then can you tell us what type of sensor it is?
I would guess it generates a small electric field that changes when a fish swims through it but only you can tell us for sure.
Does the sensor need AC or DC power and is the sensor output connected to the Arduino AC/DC and at what voltage. The Arduino pins can only handle DC voltages up to 5V so if the signal is AC and/or 20V+ then maybe something is damaged on the Arduino