B4R Question How to Check two or more variables

Discussion in 'B4R Questions' started by AndroidMadhu, Jun 7, 2019.

Thread Status:
Not open for further replies.
  1. AndroidMadhu

    AndroidMadhu Active Member Licensed User

    Hello,
    I want to check both humid and temp received from Arduino at Esp8266.
    Below is the code

    Code:
    Private Sub Arduino_Received_Data(humid () As Byte,temp As Byte)
        
    If bc.IndexOf(humid,"80") > -1 Then  <===== Here the value "80" will be different at times
            
    Log("Received from Arduino : ",humid)
            
    'timer1_Tick
        End If
    End Sub
    How to check humid and temp all at once with different value. Or any other way to check the status whether data has been received at esp8266 side from Arduino
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    As I already told you, you should use B4RSerializator.
     
  3. AndroidMadhu

    AndroidMadhu Active Member Licensed User

    @Erel,
    yes.... I got your point. But One details I am not able to understand.
    1. I want to send humid, and temp from dht11 sensor from Arduino to esp8266
    2. Esp will receive the data from Arduino and send to Cloud server.

    Here I received the data from Arduino and it is like below at Esp8266 side...
    Code:
    Humid from Ardiono :33.3977.99  <----here both Temp & Humid are coming
    Temp from Arduino :
    33.3977.99  <----here both Temp & Humid are coming
    At Arduino the below is code to send to Esp
    Code:
    Private Sub Timer1_Tick
        
    'Dim FixedValue As String=80
        Dim humid(),temp() As Byte
        humid=
    "33.39"
        temp=
    "77.99"
        
    'Astrem.Write(ser.ConvertBytesToArray(humid,data))
        Astrem.Write(humid)
        Astrem.Write(temp)
        
    Log("Send to Esp8266 Successfully!!")
    End Sub
    At ESP receiving Side
    Code:
    Private Sub Arduino_Received_Data(buffer() As Byte)
    Log("Humid from Ardiono :",buffer)
    Log("Temp from Arduino :",buffer)
    End Sub
    I want to separate the values and send to cloud server
     
  4. AndroidMadhu

    AndroidMadhu Active Member Licensed User

    I have using B4RSerializator at ESp8266 side. And I getting the below error while compiling

    Code:
    Public Serial1 As Serial
        
    Public softser As SoftwareSerial
        
    Public bc As ByteConverter
        
    Public wifi As ESP8266WiFi
        
    'Private timer1 As Timer
        Public Astream As AsyncStreams
        
    Private ser As B4RSerializator
        
    Private BE(2As Object
    Private Sub Arduino_Received_Data(buffer() As Byte)

    Dim data() As Object=ser.ConvertBytesToArray(buffer,BE)
    'Log("Humid from Ardiono :",data(0))
    'Log("Temp from Arduino :",data(1))

    End Sub
    And I am getting the error as "Smart strings are not supported"
     
  5. AndroidMadhu

    AndroidMadhu Active Member Licensed User

    I incorporated B4RSerializator at Arduino Side
    Code:
    Private Sub Timer1_Tick
        
    'Dim FixedValue As String=80
        Dim humid(),temp() As Byte
        humid=
    "33.39"
        temp=
    "77.99"
        Astrem.Write(ser.ConvertArrayToBytes(
    Array(humid,temp)))
        
    'Astrem.Write(humid)
        'Astrem.Write(temp)
        Log("Send to Esp8266 Successfully!!")
    End Sub
    At ESP8266 Side



    Code:
    Public Serial1 As Serial
        
    Public softser As SoftwareSerial
        
    Public bc As ByteConverter
        
    Public wifi As ESP8266WiFi
        
    'Private timer1 As Timer
        Public Astream As AsyncStreams
        
    Private ser As B4RSerializator
        
    Private BE(2As Object
    Private Sub Arduino_Received_Data(buffer() As Byte)
    ser.ConvertBytesToArray(buffer,BE)
    Log("Humid from Ardiono :",BE(0))
    Log("Temp from Arduino :",BE(1)) 
    End Sub
    It is running as expected. But after 1 minute, I am getting error as "Out of bounds error. Array length = 2, Index = 65535".

    Code:
    Wifi Connected Successfully!!!
    Humid from Ardiono :
    33.39
    Temp from Arduino :
    77.99
    Humid from Ardiono :
    33.39
    Temp from Arduino :
    77.99
    Humid from Ardiono :
    33.39
    Temp from Arduino :
    77.99
    Humid from Ardiono :
    33.39
    Temp from Arduino :
    77.99
    Humid from Ardiono :
    33.39
    Temp from Arduino :
    77.99
    Humid from Ardiono :
    33.39
    Temp from Arduino :
    77.99
    Out of bounds error. 
    Array length = 2, Index = 65535
    Please advice...
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    It is impossible to help you if you make three long posts with different codes and different problems.

    Start a new thread for the last question you have.
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice