B4R Question UNO & ESP8266 coding

bdunkleysmith

Active Member
Licensed User
Longtime User
I've a fully functioning Arduino project which collects data and sends it to a PC in serial form via USB for processing by a B4J app. I want to move from a wired (USB) to a wireless (WiFi) connection. Should be simple I thought.

So I've added an ESP8266 based WiFi (DuinoTECH ESP13) shield to my DuinoTECH Classic (UNO). I have been able to successfully send AT commands to the ESP8266 via the UNO serial port, but that seems rather limiting and so want to code the ESP28266 directly while using the UNO serial connection to exchange any necessary data.

I'm new to the world of "shields" and confused how to upload code to the WiFi shield while it is connected to the UNO or do I have to use the DIP switches to isolate the serial physical connection and use a separate FTDI USB-to-Serial cable?

Lot's of Googling has failed to reveal the mystery for me!
 

bdunkleysmith

Active Member
Licensed User
Longtime User
Since I want use UDP to broadcast the data over the WiFi I tried the following code based on the ESP8266 + UDP + BMP180 = Simple weather station example:

B4X:
Sub Process_Globals
    Public Serial1 As Serial
    Private Timer1 As Timer
    Private usocket As WiFiUDP
    Private wifi As ESP8266WiFi
    Private ip() As Byte = Array As Byte(192, 168, 0, 255)
    Private port As UInt = 3661
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
   
    If wifi.Connect2("Telstra1943", "********") = False Then
        Log("Error connecting to network")
        Return
    Else
        Log("Connected to network")
    End If
    usocket.Initialize(51042, "usocket_PacketArrived")
    Timer1.Initialize("Timer1_Tick", 500)
    Timer1.Enabled = True
   
End Sub


Private Sub Timer1_Tick
    usocket.BeginPacket(ip, port)
    usocket.Write("T 9:35")
    usocket.SendPacket
End Sub

Private Sub usocket_PacketArrived (Data() As Byte, ip1() As Byte, port1 As UInt)
    'not used
    Log("Packet arrived")
End Sub

However on compilation I receive the following fatal error:

B4X:
Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Bryon\AppData\Local\Arduino15\packages -hardware C:\Users\Public\Documents\Bryon\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Bryon\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Public\Documents\Bryon\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10802 -build-path C:\Users\Public\DOCUME~1\Bryon\Arduino\Weather\Objects\bin -warnings=all -build-cache C:\Users\Bryon\AppData\Local\Temp\arduino_cache_252351 -prefs=build.path=C:\Users\Public\DOCUME~1\Bryon\Arduino\Weather\Objects\bin -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.avrdude.path=C:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.arduinoOTA.path=C:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -verbose C:\Users\Public\DOCUME~1\Bryon\Arduino\Weather\Objects\src\src.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Bryon\AppData\Local\Arduino15\packages -hardware C:\Users\Public\Documents\Bryon\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Bryon\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Public\Documents\Bryon\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10802 -build-path C:\Users\Public\DOCUME~1\Bryon\Arduino\Weather\Objects\bin -warnings=all -build-cache C:\Users\Bryon\AppData\Local\Temp\arduino_cache_252351 -prefs=build.path=C:\Users\Public\DOCUME~1\Bryon\Arduino\Weather\Objects\bin -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.avrdude.path=C:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.arduinoOTA.path=C:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -verbose C:\Users\Public\DOCUME~1\Bryon\Arduino\Weather\Objects\src\src.ino
Using board 'uno' from platform in folder: C:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.20
Using core 'arduino' from platform in folder: C:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.20
Detecting libraries used...
"C:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.20\cores\arduino" "-IC:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.20\variants\standard" "C:\Users\Public\DOCUME~1\Bryon\Arduino\Weather\Objects\bin\sketch\src.ino.cpp" -o "nul"
"C:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.20\cores\arduino" "-IC:\Users\Bryon\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.20\variants\standard" "C:\Users\Public\DOCUME~1\Bryon\Arduino\Weather\Objects\bin\sketch\src.ino.cpp" -o "C:\Users\Public\DOCUME~1\Bryon\Arduino\Weather\Objects\bin\preproc\ctags_target_for_gcc_minus_e.cpp"
In file included from C:\Users\Public\DOCUME~1\Bryon\Arduino\Weather\Objects\bin\sketch\B4RDefines.h:27:0,
                 from C:\Users\Public\DOCUME~1\Bryon\Arduino\Weather\Objects\src\src.ino:1:
C:\Users\Public\DOCUME~1\Bryon\Arduino\Weather\Objects\bin\sketch\rESP8266WiFi.h:7:25: fatal error: ESP8266WiFi.h: No such file or directory
#include <ESP8266WiFi.h>
                         ^
compilation terminated.
exit status 1

It appears ESP8266WiFi.h is missing. Where do I get it and where should it be? Or does the error point to a bigger problem?
 
Upvote 0
Top