I have a ESP8266 which is the version -01, not the WeMos card.
I managed to connect it to Arduino and make it connect as client to my local wifi network (using arduino sketch that implements just SoftwareSerial), following this link http://www.martyncurrey.com/arduino-esp8266/
I can send AT commands and get response accordingly.
I tried to do the same with B4R, using softserial but I only get the same string that I send. I tried to add "\n" and "\r" but it does not change the situation.
I tried to use ESP8266WiFi library but get error:
Please help.
This is the code that does not work with softserial only but I guess I need the esp8266wifi anyway to continue with connection to the server.
The logs:
The sketch that I tried to imitate is this (with the monitor set to NL&CR) :
I managed to connect it to Arduino and make it connect as client to my local wifi network (using arduino sketch that implements just SoftwareSerial), following this link http://www.martyncurrey.com/arduino-esp8266/
I can send AT commands and get response accordingly.
I tried to do the same with B4R, using softserial but I only get the same string that I send. I tried to add "\n" and "\r" but it does not change the situation.
I tried to use ESP8266WiFi library but get error:
I need to tell the device both the two pins that connect by the SoftSerial and the serverIP and port that ESP8266Wifi use.Compiling & deploying Ino project (Arduino/Genuino Uno - COM3) Error
In file included from sketch\B4RDefines.h:27:0,
from D:\B4R\WifiPir\Objects\src\src.ino:1:
sketch\rESP8266WiFi.h:3:25: fatal error: ESP8266WiFi.h: No such file or directory
#include <ESP8266WiFi.h>
^
compilation terminated.
Please help.
This is the code that does not work with softserial only but I guess I need the esp8266wifi anyway to continue with connection to the server.
B4X:
Sub Process_Globals
Public Serial1 As Serial
Private astream As AsyncStreams
Private tmr As Timer
Private txt As String = "AT" 'Array As Byte ("A","T")
Private softserial As SoftwareSerial
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
softserial.Initialize(115200, 10, 11)
astream.Initialize(softserial.Stream, "astream_newdata", Null)
tmr.Initialize("tmr_Tick",2000)
tmr.Enabled = True
End Sub
Sub Astream_NewData (Buffer() As Byte)
Log("Received: ", Buffer)
End Sub
Sub AStream_Error
Log("error")
End Sub
Sub tmr_Tick
astream.Write(txt.GetBytes)
End Sub
The logs:
AppStart
AppStart
Received: AT
The sketch that I tried to imitate is this (with the monitor set to NL&CR) :
B4X:
#include <SoftwareSerial.h>
SoftwareSerial softSerial(10,11); // RX, TX
void setup()
{
uint32_t baud = 115200;
Serial.begin(baud);
softSerial.begin(baud);
Serial.print("SETUP!! @");
Serial.println(baud);
}
void loop()
{
while(softSerial.available() > 0)
{
char a = softSerial.read();
if(a == '\0')
continue;
if(a != '\r' && a != '\n' && (a < 32))
continue;
Serial.print(a);
}
while(Serial.available() > 0)
{
char a = Serial.read();
Serial.write(a);
softSerial.write(a);
}
}
Last edited: