B4R Question How do I use the esp8266's own serial port

Cesar_Morisco

Active Member
Hey guys
How do I use the esp8266's own serial port to control the hc 12 module with a rate of 9600
I've already looked at some examples and it doesn't work, could anyone give me an example, thanks.
 

Cesar_Morisco

Active Member
You should use rSoftwareSerial with two GPIOs.
hello thanks for the answer
And this way?
B4R:
Sub Process_Globals
Public Serial1 As Serial
Public SerialCom  As SoftwareSerial
Public AstreamCom As AsyncStreams

Public SerialCom2  As SoftwareSerial
Public AstreamCom2 As AsyncStreams

Private Rx1 As  UInt = 03
Private Tx1 As  UInt = 01
Private Rx2 As  UInt = 00
Private Tx2 As  UInt = 02
End Sub

Private Sub AppStart
Serial1.Initialize(2400)
Log("AppStart")
SerialCom.Initialize(2400,Tx1,Rx1)'Saida serial
AstreamCom.Initialize(SerialCom.Stream, "astreamCom1_NewData", Null)

SerialCom.Initialize(2400,Tx2,Rx2)'Saida serial
AstreamCom.Initialize(SerialCom.Stream, "astreamCom2_NewData", Null)
End Sub

Sub AstreamCom1_NewData (Buffer() As Byte)
Log("Received: ", Buffer)
End Sub

Sub AstreamCom2_NewData (Buffer() As Byte)
Log("Received: ", Buffer)
End Sub

Sub AStream_Error
    'Log("Erro na comunicação com HC-12")
End Sub
 
Upvote 0

Cesar_Morisco

Active Member
Upvote 0
Top