Using FastLED and SharpIR Libraries with Generic ESP8266 Board

36 Views Asked by At

I recently followed a tutorial (link to the tutorial) to connect my Arduino UNO with an ESP8266 WiFi module. However, to integrate the ESP8266, I had to select a different board in my Arduino IDE. Since then, I've encountered issues with my existing code that uses the FastLED and SharpIR libraries.

Before the change in board selection, I successfully utilized both libraries with my Arduino UNO. However, after switching to the Generic ESP8266 board, the libraries don't seem to work as expected.

I really want to use this libaries with the ESP8266 wifi module on my Arduino UNO, but i can't get them work.

#include <SharpIR.h>
#include <FastLED.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

Both libraries (SharpIR and FastLED) are download with the default libraries manager.

Board selection:

Selected board

Error message:

In file included from /home/aleks/Arduino/libraries/FastLED/src/FastLED.h:75,
                 from /home/aleks/Arduino/sample_program/sample_program.ino:2:
/home/aleks/Arduino/libraries/FastLED/src/fastspi.h:157:23: note: '#pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output'
  157 | #      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/aleks/Arduino/libraries/SharpIR/src/SharpIR.cpp: In member function 'uint8_t SharpIR::getDistance(bool)':
/home/aleks/Arduino/libraries/SharpIR/src/SharpIR.cpp:41:2: error: control reaches end of non-void function [-Werror=return-type]
   41 |  }
      |  ^
cc1plus: some warnings being treated as errors
exit status 1
Error compiling for Arduino board
1

There are 1 best solutions below

0
Lee-xp On

If you really want to use an Arduino Uno with an ESP8266 wifi board, you must run your Arduino code on the Uno, and set it to the Uno in the IDE (the ESP8266 libraries will never work on the Uno - they are totally board and processor specific). Also you must use a voltage converter to convert between the 5 volts of the Uno and the 3.3 volts of the ESP8266, or there is a good chance that you will fry the 8266. Then to communicate between the Uno and the 8266 you will need to use AT commands (not the best way to go).

An alternative, suggested in the article you reference, is to program the 8266 directly (and ignore the Uno completely), but this is not the easiest route to take. A much better option is to buy an ESP8266 Arduino development board. These have built-in wifi (provided by the ESP8266 chip itself). Even better is to use the more recent and more powerful ESP32. You can get an ESP32 Arduino development board from e-bay for around $7. There are masses of example code to help you get it working.

I have used both ESP8266 and ESP32 Arduino boards for wifi applications, and both types of board perform well.