B4R Question ESP8266

Michael1968

Active Member
Licensed User
Hi Erel,

i want to upload a blink example to my ESP8266

I get this error:
B4R version: 1.00 BETA 4
Parsing code. (0.00s)
Compiling code. (0.33s)
Building project (0.24s)
Compiling & deploying Ino project (Adafruit HUZZAH ESP8266 (UploadSpeed=115200) - COM10) Error
Loading configuration...
Pakete werden initialisiert...
Boards werden vorbereitet...
Überprüfungs- und Hochladevorgang...
sketch\B4RArduino.cpp: In member function 'void B4R::Serial::Initialize2(ULong, Byte)':
B4RArduino.cpp:54: error: invalid conversion from 'Byte {aka unsigned char}' to 'SerialConfig' [-fpermissive]
hs->begin(BaudRate, Config);
^
In file included from C:\Users\Michael\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.1.0\cores\esp8266/Arduino.h:246:0,
from sketch\B4RDefines.h:8,
from sketch\B4RArduino.cpp:1:
C:\Users\Michael\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.1.0\cores\esp8266/HardwareSerial.h:77:10: error: initializing argument 2 of 'void HardwareSerial::begin(long unsigned int, SerialConfig)' [-fpermissive]
void begin(unsigned long baud, SerialConfig config)
^
exit status 1
invalid conversion from 'Byte {aka unsigned char}' to 'SerialConfig' [-fpermissive]

I use a Adafruit Huzzah and a Nodemcu V1.0

Best regards
Michael
 

positrom2

Active Member
Licensed User
Strange. Copied the new boards.txt file to the B4R folder but merely boards are listed that contain "Arduino" somewhere in the filename.
Restarted B4R a couple of times, no ESP listed.
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
Strange. Copied the new boards.txt file to the B4R folder but merely boards are listed that contain "Arduino" somewhere in the filename.
Restarted B4R a couple of times, no ESP listed.
The boards.txt file is only used if the IDE failed to fetch the list from Arduino IDE. In most cases it will succeed so the file is not used.

Have you installed the ESP boards in Arduino IDE boards manager (you need to first add a link in the preferences to: http://arduino.esp8266.com/versions/2.2.0/package_esp8266com_index.json) ?
 
Upvote 0

inakigarm

Well-Known Member
Licensed User
Upvote 0

inakigarm

Well-Known Member
Licensed User
Thanks = Done.
Steps taken:
  • Attached & selected board NodeMCU v1.0 with upload speed 115200.
  • Changed core library scheduler.cpp as stated in post #14.
  • Changed core library B4RArduino.cpp by commenting out lines 50 and 52-54.
  • Got the Blink Example working on a LED connected to pin D2 which is GPIO4 of the NodeMCU. In B4R defined as Private LEDPinNumber As Byte = 0x04

Followup question:
Is it possible to add as permanent fix in B4R, an additional conditional define for the ESP8266 for core lib B4RArduino.cpp? or any hint if this can be done via B4R code.
I am not sure, not tested yet, as the changes will also work for the Arduino boards.

Appreciated
Maybe you can create an additional rCore (rCore2 for ex) copying the folder to new name (rCore2) and modifying xml name to new name rCore2 (you'll have to edit the b4R file to load rCore2 library when opening from B4R

upload_2016-5-19_16-1-15.png
 
Upvote 0

positrom2

Active Member
Licensed User
The boards.txt file is only used if the IDE failed to fetch the list from Arduino IDE. In most cases it will succeed so the file is not used.

Have you installed the ESP boards in Arduino IDE boards manager (you need to first add a link in the preferences to: http://arduino.esp8266.com/versions/2.2.0/package_esp8266com_index.json) ?
Thank you. That helped. Now I am having a thousands of additional boards (feels like that).

To become acquainted with B4R, I am buying one shield (used in the tutorials) after the other...:oops:
I get them quickly from a German-Chinese dealer at moderate price (not just as cheap as from China directly, but have it the next day.
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Maybe you can create an additional rCore (rCore2 for ex) copying the folder to new name (rCore2) and modifying xml name to new name rCore2 (you'll have to edit the b4R file to load rCore2 library when opening from B4R

View attachment 44212
Thanks for the hint = works well: Created library rCoreESP with xml file and copied to B4R additional libraries folder. The blink example is working.

Next is to use the wifi capabilities which will need dedicated libraries.
After installing the additional boards to the Arduino IDE, ESP libraries are installed: See c:\Users\USERNAME\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\libraries\
Need to find a way how to use. Any hints appreciated --- probably better to wait till Erel gets the board.
 
Upvote 0

canalrun

Well-Known Member
Licensed User
I was not able to get the B4R Blink example running on the WeMos D1 R2 using the above mods to the B4R rcore library. I kept getting a SerialConfig not compatible with byte error.

SerialConfig is an enum defined by WeMos.

I modified the HardwareSerial.cpp and HardwareSerial.h files in the ... \Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266 (the Arduino board package for esp8266 dir) directory to change all 5 or so occurrences of SerialConfig to byte.

I also had to change pin13 to pin2 (and the gpio pin it defines from 13 to 2) to point to the pin that connects to the on-board LED.

The B4R Blink demo works on my WeMos D1 R2!

Barry.
 
Last edited:
Upvote 0

Erel

Administrator
Staff member
Licensed User
Until ESP8266 is fully supported you can test it by following these steps:

1. Download the attached zip file, unzip it and copy the files to the internal libraries folder\rCore (C:\Program Files (x86)\Anywhere Software\B4R\Libraries\rCore). These files will work properly with Arduino boards as well. This will require administrator privileges if B4R is installed under Program Files.

2. Install the ESP boards from the Arduino IDE. B4R boards selector should show them automatically. If they are not listed then you need to copy the modified boards.txt file: https://www.b4x.com/android/forum/threads/esp8266.65680/#post-424452

There are cases where the compilation appears to be completed successfully but it actually failed to deploy. The old program will run. If in doubt change the Log("AppStart") message and make sure that the new program was actually deployed.

Edit: file removed. There will be soon integrated support for ESP8266.
 
Last edited:
Upvote 0

rwblinn

Well-Known Member
Licensed User
Thanks for the update - started testing:

Simple LED blink program: worked without issues.
Ensure to use the GPIO pin number assigned to a D pin (like D0 = GPIO16 = B4R Pin Number 16)
Sub Process_Globals
Public Serial1 As Serial
Private LEDPin As Pin
Private BlinkTimer As Timer
Private BlinkTimerInterval As ULong = 2
End Sub

Private Sub AppStart
Serial1.Initialize(115200)
LEDPin.Initialize(16, LEDPin.MODE_OUTPUT)
BlinkTimer.Initialize("BlinkTimer_Tick", BlinkTimerInterval * 1000)
BlinkTimer.Enabled = True
End Sub

Private Sub BlinkTimer_Tick
Dim currentState As Boolean = LEDPin.DigitalRead
Dim NewState As Boolean = Not(currentState)
LEDPin.DigitalWrite(NewState)
End Sub

Ethernet: using the rEthernet lib received error multiple libs found.
My mistake as does not make sense to use this library.

ESP8266WiFi: What is needed is a wrapper for ESP8266WiFi.h.

DHT11: wrapped Library rDHT
Received error:
B4X:
In file included from sketch\dht.h:19:0,
from sketch\dht.cpp:42:
sketch\dht.cpp: In member function 'int8_t dht::_readSensor(uint8_t, uint8_t, uint8_t)':
C:\Users\Robert\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/Arduino.h:227:63: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in initialization
#define portInputRegister(port)     ((volatile uint32_t*) &GPI)
                                                               ^
sketch\dht.cpp:122:29: note: in expansion of macro 'portInputRegister'
     volatile uint8_t *PIR = portInputRegister(port);
Do not know how to resolve.
 
Last edited:
Upvote 0

rwblinn

Well-Known Member
Licensed User
Thanks = Confirmed working fine on a ESP-12E Module (NodeMCU) using code:
B4X:
Sub Process_Globals
    Public Serial1 As Serial
    Public DHT11sensor As dht                       
    Public DHT11pin As Pin                           
    'DHT11 signal pinnumber: D4 = GPIO2 = 2
    Public DHT11pinNumber As Byte = 0x02           
    Private MeasureTimer As Timer                     
    Private MeasureTimerInterval As ULong  = 2000
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    DHT11pin.Initialize(DHT11pinNumber, DHT11pin.MODE_INPUT)       
    MeasureTimer.Initialize("MeasureTimer_Tick", MeasureTimerInterval)
    MeasureTimer.Enabled =True
    Log("AppStart - DHT11 read every ", MeasureTimerInterval / 1000, " seconds")
End Sub

Private Sub MeasureTimer_Tick
    DHT11sensor.Read11(DHT11pin.PinNumber)           
    Log("Temperature: ",DHT11sensor.GetTemperature, "C, Humidity:",DHT11sensor.GetHumidity, "%")
End Sub
 
Upvote 0

davehouston

Member
Licensed User
I have a Home Automation application where I need to use it as a WiFi-to-Serial link to an X10 PLC interface. I would like the option of it simultaneously acting as a hub for other HA related sensors using multiple WeMos D1 minis.
 
Upvote 0
Top