Other Initial support for ESP32

Discussion in 'B4R Questions' started by Erel, Jan 8, 2017.

  1. Erel

    Erel Administrator Staff Member Licensed User

    ESP32 is the next generation of ESP8266 chips.
    It is a relatively new chip and the SDK is not very mature. There are many things that are not working yet, however it does look promising.

    [​IMG]

    You need to follow these instructions: https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/windows.md
    Make sure that you are able to run a program (empty program is good enough) with the Arduino IDE before you try it with B4R.

    I've encountered the following issues:

    - Wire / I2C didn't work. Maybe a problem with the specific board that I've used.
    - Network doesn't always connect.
    - ServerSocket cannot accept a connection (client->available errno 9).
    - EEPROM is not available.
    - Pin.AnalogWrite not available.
    - Client.Connected returns True although the connection has broken (this breaks rHttpUtils2).
     
    Last edited: Jan 7, 2018
  2. positrom2

    positrom2 Active Member Licensed User

    Do we need additional libraries like rESP8266, rESP8266WiFi,...?
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    rESP8266WiFi works with ESP32.
     
  4. positrom2

    positrom2 Active Member Licensed User

    Some success: I was able to run a simple code on the ESP32 (writing with astream).
    However, a larger code did even not compile.
    I get this error message that also randomly popped up with an ESP8266.
    Without any changes in the code it worked after some trials with the ESP8266.
    However, with the ESP32 on either the Sparkfun board or a genuine 32s board I can't come across this error:
    Code:
    #Region Project Attributes
       
    #AutoFlushLogs: True
       
    #StackBufferSize: 1200
    #End Region
    Sub Process_Globals
        
    Public Serial1 As Serial
        
    Private bmp As Adafruit_BMP280
        
    Private ssd As AdafruitSSD1306
    '    Private d1pins As D1Pins
        Private  k=0,rmax,rmin As Int,l As Int
        
    Private tmr As Timer
        
    Private p(128),p_gl(128),py,maxx,minn,c1,c2,maxx_old,minn_old As Double
    End Sub

    Private Sub AppStart
        Serial1.Initialize(
    115200)
        
    Log("AppStart")
        ssd.InitializeI2C(
    120x3c)
        bmp.Initialize
        
    If bmp.Initialize Then
            
    Log("Successful")
        
    Else
            
    Log("not")
        
    End If
        ssd.ClearDisplay
        ssd.Display
        ssd.ClearDisplay
        tmr.Initialize(
    "tmr_Tick",150)
        tmr.Enabled = 
    True
        
    Log(StackBufferUsage,"-----------")
        maxx=
    0
        minn=
    2e6

    End Sub
    Sub write_max_min
        ssd.GFX.SetCursor(
    550)
        ssd.GFX.DrawRect(
    55,0,80,10,ssd.BLACK,True)
        ssd.GFX.ConfigureText(
    1, ssd.WHITE, False)
        ssd.GFX.DrawText(
    NumberFormat(Round(maxx/100), 40))
        ssd.GFX.SetCursor(
    5553)
        ssd.GFX.DrawRect(
    55,53,80,63,ssd.BLACK,True)
    '    ssd.GFX.ConfigureText(1, ssd.WHITE, False)
        ssd.GFX.DrawText(NumberFormat(minn/10040))
        
    'ssd.ClearDisplay
        ssd.Display
    End Sub
    Private Sub tmr_Tick
        p(k)=k*
    1e3-l*1e2
    '    Log(k," ",p(k))
        'p(k)=bmp.ReadPressure'ReadTemperature
        k=k+1
        
    If k = 128  Then'ssd.GFX.Width
            k= 0
            l=l+
    1
            glatten
            normalize
            plott
            write_max_min
    '        ssd.INVERSE
        End If
    End Sub
    Sub glatten
        
    For i=0 To 4
            p_gl(i)=p(i)
        
    Next
        
    For i=124 To 127
            p_gl(i)=p(i)
        
    Next
        
    Dim acc As Long
        
    For I1 = 0 To 4                                          '5 Pkte                                   '17
            acc = acc + p(I1)
        
    Next
        p_gl(
    2) = acc / 5                              ' 17 Pkte
        For I1 = 3 To 125                                        '5 Pkte
            acc = acc + p(I1 + 2)-p(I1 -3)
            p_gl(I1) = acc / 
    5                          ' / 5
        Next
    End Sub
    Sub plott
        ssd.cleardisplay
    'GFX.DrawRect(0,0,127,63,ssd.BLACK,True)
        For i=0 To 127
            py=p_gl(i)*c1+c2
            
    'Log("I=",i," p=",p(i)," py=",py)
            If py>16 Then py=py-1
            ssd.GFX.DrawCircle(i,py, 
    0, ssd.WHITE, True)
           
        
    Next
    '    ssd.GFX.DrawCircle(4,4, 4, ssd.WHITE, True)
    '    ssd.GFX.DrawCircle(120,58, 4, ssd.WHITE, False)
        ssd.Display
    End Sub
    Sub normalize
        
    '    Log("L=",l)
        rmax=63
        rmin=
    0'y-achse
        maxx_old=maxx
        minn_old=minn
        
    '    Log("L=",l," MAXX_old=",maxx_old," minn_old=",minn_old)
        For i=2 To 125
            
    '            Log(i," ",p(i))
            If p_gl(i)>maxx Then maxx=p_gl(i)
            
    If p_gl(i)<minn Then minn=p_gl(i)
        
    Next
        
    '    Log("maxx=",maxx," minn=",minn)
        If maxx_old>maxx Then maxx=maxx_old
        
    If minn_old<minn Then minn=minn_old
        
    Log(maxx,";",minn)
        c1=(rmax-rmin)/(maxx-minn)
        
    '    Log("c1=",c1)
        c2=(rmin*maxx-rmax*minn)/(maxx-minn)
    End Sub
     
  5. Toley

    Toley Active Member Licensed User

    Did you try with arduino IDE?
     
  6. positrom2

    positrom2 Active Member Licensed User

    As I said, this works with the ESP8266 so I conclude the error is unrelated to the error message!!
    Only occasionally I got that error with the '8266, sometimes it was apparently related to a wrong com-port setting or too high speed -or whatever.
    With the ESP32 I have no success at all for that code (the simple one worked at once).
     
    Last edited: Jan 8, 2017
  7. positrom2

    positrom2 Active Member Licensed User

    Update#3: After a lot of trials:
    There is a recent Adafruit_SSD1306 library that includes the ESP32 (seen inside the .cpp file).
    When copying the cpp and .h files to the B4R Libraries folder, a lot of errors pops up upon compiling.
    So it appears to me that the B4R library needs to be updated.
     
    Last edited: Jan 8, 2017
  8. Erel

    Erel Administrator Staff Member Licensed User

    Seems to me that their GFX library was not updated to support the ESP32. Are you able to run their examples on the ESP32 with Arduino IDE?
     
  9. positrom2

    positrom2 Active Member Licensed User

    The Arduino the ssd1306_128x64_i2c example compiles.
    With B4R I get this error message:
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    Does it work on the ESP32?
     
  11. positrom2

    positrom2 Active Member Licensed User

    Update: Successfully uploaded the Arduino SSD1306 example to the Sparkfun ESP32 board.
    Of course
    (compiles without error, did not check uploading since oled is hooked up to an nodemcu).
     
    Last edited: Jan 9, 2017
  12. Erel

    Erel Administrator Staff Member Licensed User

    I'm getting errors when I try to compile this example with Arduino IDE. Using the latest versions of these libraries.

    I will leave it open for now.
     
  13. rwblinn

    rwblinn Well-Known Member Licensed User

    After (finally) receiving a ESP32, sharing first experience using B4R 1.8 BETA #2
    #Kit used
    The ESP32-DevKitC is a small-sized ESP32-based development board produced by Espressif.
    Model: ESP32-DEVKITC Core Board V2 Espressif including genuine ESP-WROOM-32
    Development PC (old) Toshiba Notebook Satellite with Windows Vista.

    #Get Started
    Followed strict the instructions as described: https://github.com/espressif/arduino-esp32/blob/master/doc/windows.md
    If there are issues with step 5, then
    * copy xtensa-esp32-elf-win32-VERSION.zip to folder <users>\documents\Arduino\hardware\espressif\esp32\tools\dist. The version used 1.22.0-59.
    * cd ~/Documents/Arduino/hardware/espressif/esp32/tools/
    * python get.py

    To test the setup OK, start the Arduino IDE 1.8.0 (or higher), select File > examples > Examples for the ESP32 Dev Module > WiFiScan and compile & run.
    If running OK (which did), close the Arduino IDE and start B4R IDE.

    #B4R 1.8 IDE
    After connecting the ESP32, determine the COM Port.
    Tools > Board Selector
    Board: ESP32 Dev Module
    Serial Port: COM12 Silicon Labs CP210x USB to UART Bridge - Note: COM port depends on system setup

    #Flashing
    For the ESP32-DevKitC, to flash programs from development environments, like Arduino IDE or B4R 1.8.0 (or higher).
    Example B4R IDE:
    * Pin IO0 (= GPIO0) to Ground
    * Compile and upload. Wait till message "waiting for download" in the B4R IDE Log Tab appears.
    * Pin IO0 (= GPIO0) NOT to Ground
    * Press BOOT button and hold down
    * Press EN button (enable) and hold down
    * Release BOOT button
    * Release EN button

    If all goes well, the B4R IDE Log shows, like (using simple LED Blink program):
    ets Jun 8 2016 00:22:57
    rst:0x1 (POWERON_RESET),boot:0x3
    (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
    waiting for download
    ets Jun 8 2016 00:22:57
    rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) flash read err, 1000 Falling back to built-in command interpreter.
    OK
    >ets Jun 8 2016 00:22:57
    rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0x00
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:1
    load:0x3ffc0008,len:4
    load:0x3ffc000c,len:1708
    load:0x40078000,len:3124
    load:0x40080000,len:256
    entry 0x40080034
    AppStart - LED Pin 2 blink every 2 seconds
    CurrentState: 0
    NewState: 1
    CurrentState: 1
    ...

    #Issues
    After the simple LED blink example, did not came any further as errors occurred as described in Post #1.
    • Tests not working, e.g. BMP180 = error network connection, after unplugging the BMP180, network got connected),
    • LED control via B4RSerialconnection = error WiFiClient.cpp:196 available(): 9
    Will stop further testing for now, till any updates available.
    Question:

    Beside B4R Beta updates, not clear how the ESP32 files (as installed following the instructions) will be updated.
     
  14. Erel

    Erel Administrator Staff Member Licensed User

  15. positrom2

    positrom2 Active Member Licensed User

    Hm. Could you post the error message?
    Here is my compilation protocoll:
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    Sure.
     

    Attached Files:

  17. positrom2

    positrom2 Active Member Licensed User

    I had posted my compilation protocoll in the previous message (via edit).
    I see that Arduino15\packages is involved in yours and my test.
    The Arduino15 is a strange folder. Occasionally, when things went wrong, I had to delete that folder. It will be cleanly rebuilt, but the preferences have to be reentered.
     
  18. positrom2

    positrom2 Active Member Licensed User

    To rwblinn:
    The easiest way to update a core (here ESP32) is to download the Git repository as a zip file,
    https://github.com/espressif/arduino-esp32
    ,to delete its contents and to copy the zip's contents to the ESP32 folder (watch what is in before and after).
     
  19. rwblinn

    rwblinn Well-Known Member Licensed User

    Thanks All - Have looked at the python script get.py (esp32\tools folder) used for step #5, which downloads and upzips the latest package as defined in the json package file. With that, indeed two options by either copy as mentioned post #18 or run python get.py from the esp32\tools folder (part of step #5).

    Looking forward to the upcoming - according to here most of the framework is done - have not seen a timeline yet for completion, so wait and see.
     
  20. positrom2

    positrom2 Active Member Licensed User

    Getting this error message with rAdafruitGFX v. 1.01:
    From the Arduino IDE it still works. Could it be that B4R looks in different locations than Arduino IDE?

    What does this mean for the path: "sketch\Adafruit_SSD1306.cpp: In ..." in the error message?

    The Arduino OLED example did not compile lastly in your system. Has that been fixed with the new GFX lib?
     
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