Question about using esp8266 01 as Tx with wifi, will I have any problems with communication?
Does anyone use it without any problems?
Here is an example of TX
Does anyone use it without any problems?
Here is an example of TX
B4R:
Sub Process_Globals
Public Serial1 As Serial
Private wifi As ESP8266WiFi
Private socket As WiFiSocket
Private astream As AsyncStreams
Public Botao1, Botao2 As Pin
Private Conectado As Boolean = False
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Botao1.Initialize(0, Botao1.MODE_INPUT_PULLUP)
Botao2.Initialize(2, Botao2.MODE_INPUT_PULLUP)
'sleepTimer.Initialize("sleepTimer_Tick", 1000) ' timer 1 segundo mas não ligado ainda
AddLooper("ChecarBotao") ' Faz checagem de botões periodicamente
AddLooper("VerificarConexao")
RunNative("SetSTA", Null)
wifi.Connect2("esp_server", "12345678") ' <-- SSID e senha corretos do AP
Log(wifi.LocalIp)
Connect(0)
End Sub
Sub Connect(u As Byte)
Log("Tentando conectar")
If socket.ConnectIP(Array As Byte(192,168,4,1),51042) Then
Log("Conectado")
astream.InitializePrefix(socket.Stream, False, "astream_NewData", "astream_Error")
astream.Write("Remoto")
Conectado = True
Else
CallSubPlus("Connect", 1000, 0)
End If
End Sub
Sub ChecarBotao
If astream = Null Or Conectado = False Then Return
If Botao1.DigitalRead = False Then
Log("Botão 1 pressionado")
astream.Write("CMDA")
End If
If Botao2.DigitalRead = False Then
Log("Botão 2 pressionado")
'astream.Write("CMDB")
End If
End Sub
Sub VerificarConexao
If Conectado = False Then
Log("Verificando reconexão...")
Connect(0)
End If
End Sub