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 to do that I added an ESP8266 based WiFi (DuinoTECH ESP13) shield to my DuinoTECH Classic (UNO).
As per ESP8266 - Getting Started in the Arduino IDE - File - Preferences I have added the URL: http://arduino.esp8266.com/stable/package_esp8266com_index.json to the Additional Boards Manager URLs field and in Arduino IDE - Tools - Board - Boards Manager installed esp8266 by ESP8266 community.
Now I want to use the ESP8266 as a shield on the UNO rather than as a standalone board because I already have interface hardware and code to collect the data. I just want the ESP8266 shield to send the serial data collected by the UNO as UDP packets via WiFi. I have already updated by B4J client code to receive the data either via USB or UDP.
To test that I can send UDP packets I tried the following simple code:
In B4R I selected the UNO board, however on compiling the code I receive the following fatal error:
While it says "
ESP8266WiFi.h: No such file or directory" ESP8266WiFi.h is at least in C:\Users\Bryon\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src but should it also be elsewhere so it can be found?
Or have I misunderstood how a shield works and in fact I can't load code based on the ESP8266 libraries onto the UNO and this is only possible by loading the code directly onto the ESP8266 based WiFi shield?
I thought given I already had a fully functioning Arduino data gathering hardware/software combination which output the serial data via USB that it would be a simple matter to add a WiFi shield and have that data sent via UDP over WiFi. I did achieve some basic functionality by using ESP8266 AT commands, but I could see limitations with that which I thought would be overcome by using features within the ESP8266 libraries.
I normally pick these things up reasonably quickly, but I seem to be struggling with the concept of shields on Arduino boards. Any pointers in the right direction would be appreciated.
As per ESP8266 - Getting Started in the Arduino IDE - File - Preferences I have added the URL: http://arduino.esp8266.com/stable/package_esp8266com_index.json to the Additional Boards Manager URLs field and in Arduino IDE - Tools - Board - Boards Manager installed esp8266 by ESP8266 community.
Now I want to use the ESP8266 as a shield on the UNO rather than as a standalone board because I already have interface hardware and code to collect the data. I just want the ESP8266 shield to send the serial data collected by the UNO as UDP packets via WiFi. I have already updated by B4J client code to receive the data either via USB or UDP.
To test that I can send UDP packets I tried the following simple code:
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
In B4R I selected the UNO board, however on compiling the code 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
While it says "
ESP8266WiFi.h: No such file or directory" ESP8266WiFi.h is at least in C:\Users\Bryon\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src but should it also be elsewhere so it can be found?
Or have I misunderstood how a shield works and in fact I can't load code based on the ESP8266 libraries onto the UNO and this is only possible by loading the code directly onto the ESP8266 based WiFi shield?
I thought given I already had a fully functioning Arduino data gathering hardware/software combination which output the serial data via USB that it would be a simple matter to add a WiFi shield and have that data sent via UDP over WiFi. I did achieve some basic functionality by using ESP8266 AT commands, but I could see limitations with that which I thought would be overcome by using features within the ESP8266 libraries.
I normally pick these things up reasonably quickly, but I seem to be struggling with the concept of shields on Arduino boards. Any pointers in the right direction would be appreciated.