B4R Question SIM808 + ESP8266

Ilya G.

Active Member
Licensed User
Longtime User
Good day
Please help to connect SIM808 module to ESP8266. Is that code and connection right?

B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 1000
#End Region

Sub Process_Globals
    Public Serial1 As Serial
    Public Serial2 As SoftwareSerial
    
'    Private BC As ByteConverter
    Private AStream As AsyncStreams
    Private EOL() As Byte = Array As Byte(13, 10)

    Private Timer1 As Timer
    Private pin2 As Pin
End Sub

Sub AppStart
    Serial1.Initialize(115200)
    Serial2.Initialize(115200, 3, 1)
    AStream.Initialize(Serial2.Stream, "AStream_NewData", "AStream_Error")
    AStream.WaitForMoreDataDelay = 100

    Log("AppStart")
    
    pin2.Initialize(2, pin2.MODE_OUTPUT)
    Timer1.Initialize("Timer1_Tick", 1000)
    Timer1.Enabled = True
End Sub

Sub Timer1_Tick
    AStream.Write("AT").Write(EOL)
'    AStream.Write("AT+CPIN?").Write(EOL)

    pin2.DigitalWrite(Not(pin2.DigitalRead))
End Sub

Sub AStream_NewData (Buffer() As Byte)
    Log("-> ", Buffer)
'    Log("-> ", BC.StringFromBytes(Buffer))
End Sub

Sub AStream_Error
    Log("Error")
End Sub


sim808_2.jpg ESP8266-NodeMCU-kit-12-E-pinout-gpio-pin.png photo_2019-11-29_11-51-49.jpg
 

embedded

Active Member
Licensed User
Longtime User
Power your SIM 808 From external adapter of at least 2A...then confirm the baud of both devices. It must be same. Auto baud rate may not work properly...
Please issue network related command after 20 second of power up.
 
Upvote 0
Top