B4R Question About the Espallexa library

Cesar_Morisco

Active Member
Hey guys, how are you?
B4R:
Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
   
    timer1.Initialize("timer1_Tick",5000)
    Timer2.Initialize("Start_1",2000)
   
    Timer3.Initialize("LoopRun",1)
    Timer3.Enabled = True
 
    onewire.Initialize(ESPin.D4)'Pino D4 DS18B20
    PinGPIO05.Initialize(d1.D1,PinGPIO05.MODE_OUTPUT)'Pino D1 Triac1
    PinGPIO04.Initialize(d1.D2,PinGPIO04.MODE_OUTPUT)'Pino D2 Triac2
    PinGPIO14.Initialize(d1.D5,PinGPIO14.MODE_OUTPUT)'Pino D5 Triac3
    PinGPIO13.Initialize(d1.D7,PinGPIO13.MODE_OUTPUT)'Pino D7 Buzzer
    PinGPIO16.Initialize(d1.D0,PinGPIO16.MODE_OUTPUT)'Pino D16 Led
    PinGPIO12.Initialize(d1.D6,PinGPIO12.MODE_OUTPUT)'Pino D12 Servo
   
    'Set Desligar Pinos ESP
    PinGPIO05.DigitalWrite(False)
    PinGPIO04.DigitalWrite(False)
    PinGPIO14.DigitalWrite(False)
    PinGPIO16.DigitalWrite(False)
    PinGPIO12.DigitalWrite(False)
   
    Pinservo.Initialize (12,Pinservo.MODE_OUTPUT)    'connect servo to pin 4 of Arduino
    ServoMotor.Attach(Pinservo.PinNumber)            'assign servo to device on pin servo
   
   
    PinGPIO13.DigitalWrite(True)
    Delay(200)
    PinGPIO13.DigitalWrite(False)
   
    WiFiServer.Start
    ConnectToNetwork(0)
   
    alexa.Initialize("DeviceChanged")
    Timer3.Initialize("LoopRun",1)
    Timer3.Enabled = True
   
    alexa.addDevice("Ventilador Auto",127)
    alexa.addDevice("Ventilador Norma",128)
    alexa.addDevice("Ventilador Baixo",129)
    alexa.setPercent(50,3)
    Delay(1000)
    For i = 0 To 9
        Log("device name: ",alexa.getName(i))
        Log("value=",alexa.getValue(i))
    Next
    Log("mac address: ",alexa.getEscapedMac)
   
    End Sub

Sub LoopRun
    alexa.RunLoop
    time = time + 1
    If time = 90000 Then
        time = 0
        Log(time)
    End If
End Sub

Sub DeviceChanged(index As Byte)
    Log("deviceindex=",index,"deviceName=",alexa.getName(index))
    Select Case index
        Case 0
            If alexa.getValue(127) = 0 Then
                PinGPIO05.DigitalWrite(Not(State))
                PinGPIO13.DigitalWrite(True)
                Delay(200)
                PinGPIO13.DigitalWrite(False)
                RS1 = (Not(State))
                If State = False Then
                    SaveRelay(0,1)
                Else
                    SaveRelay(0,0)
                End If
            Else
                PinGPIO04.DigitalWrite(Not(State))
                PinGPIO13.DigitalWrite(True)
                Delay(200)
                PinGPIO13.DigitalWrite(False)
                RS2 = (Not(State))
                If State = False Then
                    SaveRelay(1,1)
                Else
                    SaveRelay(1,0)
                End If
            End If
    End Select
End Sub
Has anyone already used it or used it? I had already posted it a while ago. I didn't get an answer, what happens to my code? Alexa can't find my device?
Alguém teve tempo para me responder? Obrigado do fundo do meu coração.

When Alexa is searching for the device it shows this here in the log
"Astream NewData startB=GET /description.xml HTTP/1.1
Accept: */*
Content-Type: application/json
web server Disconnected"
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…