"tone" for buzzer ? No acceptable?

I’m using the WeMos D1 R32.

I just tried to build it for an Uno, and ‘tone’ is still not acceptable.

According to this issue on GitHub, tone() does not exist for your board.

However, the issue is closed - someone posted code for tone() and noTone().

You must be doing something wrong here then. :frowning_face:

The core software for the uno has tone() built in. The code above works fine on my uno.

Cheers,
Norm.

1 Like

Recently added to the above GitHub issue, ther’es now a tone library available:

If anyone wants to try it out.

Cheers,
Norm.

2 Likes

Thanks!
The D1 Mini is the one I want to use for the final gadget. I’ll see if I can use this library.

1 Like

Butit still won’t upload because it refuses to see the library.

Gotta say, PIO library function sucks too often.

I’ve spent at least half the time I’ve spent with PIO losing my mind over these stupid libraries.
And this one was installed by the PIO library tool. And it’s in the project’s /lib folder.

Fails too often. It’s insanely frustrating. And these are Adafruit libraries. No reason they wouldn’t be just known.

I’m sick of restarting.

Seriously, the library frustration is roughly half my PlatformIO experience.
Arduino did libraries well.

Seriously sucks. I took the tones out of that simple script that just lights stinking LEDs, and it’s forced me to add BusIO to the /lib. and now this?
I hate it. Where did all of this new junk come from? None of that was a problem the first three thousand times I got a library to work.

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 1.12.4 > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10004.200129 (1.0.4)
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - tool-mkspiffs 2.230.0 (2.30)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 32 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Adafruit GFX Library> 1.10.0    
|   |-- <Adafruit BusIO> 1.4.1       
|   |   |-- <Wire> 1.0.1
|   |   |-- <SPI> 1.0
|   |-- <SPI> 1.0
|   |-- <Wire> 1.0.1
|-- <Adafruit SSD1306> 2.3.1
|   |-- <Adafruit GFX Library> 1.10.0
|   |   |-- <Adafruit BusIO> 1.4.1
|   |   |   |-- <Wire> 1.0.1
|   |   |   |-- <SPI> 1.0
|   |   |-- <SPI> 1.0
|   |   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|   |-- <Wire> 1.0.1
|-- <timelib>
|-- <Tone> 0.0.1
|-- <Wire> 1.0.1
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Generating partitions .pio\build\esp32dev\partitions.bin
Compiling .pio\build\esp32dev\libba3\Wire\Wire.cpp.o
Compiling .pio\build\esp32dev\lib5a1\SPI\SPI.cpp.o
Compiling .pio\build\esp32dev\lib6d3\Adafruit BusIO\Adafruit_BusIO_Register.cpp.o
Archiving .pio\build\esp32dev\lib5a1\libSPI.a
Compiling .pio\build\esp32dev\lib6d3\Adafruit BusIO\Adafruit_I2CDevice.cpp.o
Compiling .pio\build\esp32dev\lib6d3\Adafruit BusIO\Adafruit_I2CRegister.cpp.o
Archiving .pio\build\esp32dev\libba3\libWire.a
Compiling .pio\build\esp32dev\lib6d3\Adafruit BusIO\Adafruit_SPIDevice.cpp.o
Compiling .pio\build\esp32dev\libf23\Adafruit GFX Library\Adafruit_GFX.cpp.o
Compiling .pio\build\esp32dev\libf23\Adafruit GFX Library\Adafruit_GrayOLED.cpp.o
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:3:145: error: ISO C++ forbids declaration of 'Adafruit_I2CRegister' with no type [-fpermissive]
 Adafruit_I2CRegister::Adafruit_I2CRegister(Adafruit_I2CDevice *device, uint16_t reg_addr, uint8_t width, uint8_t bitorder, uint8_t address_width) {
                                                                                                                                                 ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:3:145: error: no 'int Adafruit_BusIO_Register::Adafruit_I2CRegister(Adafruit_I2CDevice*, uint16_t, uint8_t, uint8_t, uint8_t)' member function declared in class 'Adafruit_BusIO_Register'
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp: In member function 'bool Adafruit_BusIO_Register::write(uint8_t*, uint8_t)':
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:14:9: error: '_device' was not declared in this scope
   if (! _device->write(buffer, len, true, addrbuffer, _addrwidth)) {
         ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp: In member function 'bool Adafruit_BusIO_Register::write(uint32_t, uint8_t)':
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:29:9: error: '_bitorder' was not declared in this scope
     if (_bitorder == LSBFIRST) {
         ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp: In member function 'uint32_t Adafruit_BusIO_Register::read()':
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:49:10: error: '_bitorder' was not declared in this scope
      if (_bitorder == LSBFIRST) {
          ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp: In member function 'bool Adafruit_BusIO_Register::read(uint8_t*, uint8_t)':
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:62:9: error: '_device' was not declared in this scope
   if (! _device->write_then_read(_buffer, 1, buffer, len)) {
         ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp: In member function 'bool Adafruit_BusIO_Register::read(uint16_t*)':
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:73:7: error: '_bitorder' was not declared in this scope
   if (_bitorder == LSBFIRST) {
       ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp: At global scope:
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:105:106: error: ISO C++ forbids declaration of 'Adafruit_I2CRegisterBits' with no type [-fpermissive]
 Adafruit_I2CRegisterBits::Adafruit_I2CRegisterBits(Adafruit_I2CRegister *reg, uint8_t bits, uint8_t shift) {
                                                                                                          ^
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:105:106: error: no 'int Adafruit_BusIO_RegisterBits::Adafruit_I2CRegisterBits(Adafruit_I2CRegister*, uint8_t, uint8_t)' member function declared in class 'Adafruit_BusIO_RegisterBits'  
lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:117:6: error: prototype for 'void Adafruit_BusIO_RegisterBits::write(uint32_t)' does not match any in class 'Adafruit_BusIO_RegisterBits'
 void Adafruit_I2CRegisterBits::write(uint32_t data) {
      ^
In file included from lib\Adafruit BusIO/Adafruit_I2CRegister.h:1:0,
                 from lib\Adafruit BusIO\Adafruit_I2CRegister.cpp:1:
lib\Adafruit BusIO/Adafruit_BusIO_Register.h:66:8: error: candidate is: bool Adafruit_BusIO_RegisterBits::write(uint32_t)
   bool write(uint32_t value);
        ^
*** [.pio\build\esp32dev\lib6d3\Adafruit BusIO\Adafruit_I2CRegister.cpp.o] Error 1
==================================================================================================== [FAILED]

Ok, here’s how it is for me. In a project that emulates the Arduino Serial interface for a book I’m currently writing.

platform.ini
src/testAVRusart.cpp
include/
lib/cBuffer/cBuffer.h
lib/cBuffer/cBuffer.cpp
lib/AVRusart/AVRusart.h
lib/AVRusart/AVRusart.cpp
  • In src/testAVRusart.cpp I have #include "AVRusart.h".
  • In lib/cBuffer/cBuffer.cpp I have #include "cBuffer.h". That header defines a circular buffer class.
  • In lib/AVRusart/AVRusart.cpp I have #include "AVRusart.h". That header defines my USART class.
  • Finally, in lib/AVRusart/AVRusart.h I have #include "cBuffer.h". Because the USART class has a pair of cBuffer class instances internally.

pio run compiles everything in src. When it sees the #include with a header file name in double quotes, it looks in:

  • The current directory;
  • The include directory;
  • All sub-directories in lib.

The compilation works. I have nothing in platformio.ini that mentions lib_deps etc. It just works.

I do not have to restart VSCodium. I do not have to restart Linux.

In another project, migrated from the Arduino IDE, I use the “servo” library in the IDE. So, I have the option to:

  • Install it globally - not a good idea as I’m using AVR for this project, but I also have some STM32 projects, it could lead to problems. Best avoided.
  • Install it locally, just for this project. pio lib install servo
  • Install it globally (no!) Or locally, using the pio home page in VSCodium.
  • Get the compiler to install it for me, locally. lib_deps = servo.

I chose to use lib_deps.

Once again, no need to restart, pio run will find the library, or download it as required.

I do not have a “global” folder where I keep lots of useful libraries. All mine are self written so live in a subdirectory of lib, or live wherever pio run puts them if I have a lib_deps in the ini file.

  • PlatformIO version 5.0.0 - it updated itself yesterday.
  • VSCodium (not the latest) 64 bit.
  • Linux Mint 19.3 64 bit.
  • Dell Vostro 17" laptop, 8G RAM, Core duo (Yes, it’s over 10 years old!)
  • Generating code for Atmel ATmega328, Arduino Uno and/or Arduino Duemilanove, both 16MHz, or my own “design”, Normduino running at 8MHz with no crystal to free up two extra pins. (http://qdosmsq.dunbar-it.co.uk/blog/2019/02/atmega328p-8mhz-on-a-breadboard/)

With the number if problems you are having, I think there is either:

  • Something wrong with your operating system;
  • Something wrong with your PlatformIO installation;
  • Something wrong in how or where you installed the libraries;
  • Something wrong with the framework.

My advice.

  • Start simple. Try out a simple project with no libraries - blink. Get it working. So far so good!.
  • Try another project, like servo, that uses a single library. Use lib_deps = servo. Compile. Did it work? Yes, move on, No, get in touch again. Post the output from the compiler. Post your ini file. Post the structure of your project folder. Post how you installed the library etc.

Please, post everything in one post. :wink: If you need to, you can edit a post using the pencil icon at the bottom. (I have to edit my posts all the time, spelling!)

Good luck.

Right, time for breakfast! :slightly_smiling_face:

Cheers,
Norm.

1 Like

I don’t know what the cause of your latest error is - but since it didn’t happen the “first three thousand times”… and you were just making changes to the code (removing tone)… it’s probably something you changed that you shouldn’t have! :stuck_out_tongue:

tone()/noTone() does work on the AVR and ESP8266 platforms without issue - it is only missing for the ESP32 platform, with the workaround being to use the functions mentioned in that github issue, or a library.

This looks like you’re putting libraries in the /include folder. Is that better than /lib?

One of the PIO ghosts told me about Tone32. Adding that library cleared up the issue with ‘tone’.
It was ‘tone’ deaf.

I’m going to retype it.

It just doesn’t make sense that these simple lines throw up all those errors.

Does this help? Adafruit GFX lib will not build any more (PIO 5)

Cheers,
Norm.

No, it doesn’t help. Knowing others are seeing the same error, and it’s apparently in the machine, it’s still there being an error. GFX library has to be used a lot. If there’s a problem with the currently-used library, its going to mess everybody up.

And lib_deps doesn’t work.

piling .pio\build\wemos_d1_mini32\lib99d\Adafruit BusIO\Adafruit_I2CDevice.cpp.o
Compiling .pio\build\wemos_d1_mini32\lib99d\Adafruit BusIO\Adafruit_SPIDevice.cpp.o
src\main.cpp:16:29: fatal error: Adafruit_Sensor.h: No such file or directory


  • Looking for Adafruit_Sensor.h dependency? Check our library registry!

Apparently, that library has been written with a slightly broken structure. I know not what as I don’t use it.

The indtructions given on the above link, should fix things.

Cheers,
Norm.

2 Likes

From the other thread…

Yet, up above here, you have posted the dependency graph showing that it has appeared to work but failing on a completely different error:

The obvious question, why have you installed the Adafruit stuff in lib? The error shows it compiling from lib.

How did the library source code get into lib please. Tell me exactly the steps you took to install that library into this project.

If the word “download” appears, I may weep uncontrollably into my coffee! :wink: :wink: :wink:

This might help, possibly, unless the compiler is too smart and doesnt bother to compile the libraries.

I suggest, start a new project. In the main cpp file, just #include the Adafruit headers you are using now, plus any others you might need for BLE stuff. All you need is to setup the Serial monitor, and in loop(), write hello to Serial and delay 5 seconds.

Set lib_deps to list the various libraries you are currently using.

Compile.

Hopefully, it will compile, but it should install the libraries first. Did it? Look in lib - I doubt you will see anything there. Because that’s not where they live. Then live under .pio and not in the project’s lib.

Humour me, and try the above test. Let me know how you get on.

Cheers,
Norm.

1 Like

I put it in /lib, because lib_deps didn’t work. It did work- I saw it work. But it didn’t stick.
I went back to it after a while, and the none of the scripts I’d just updated to lib_deps worked for missing libraries.

I’ll do that thing, but it’s going to 100 today. Gotta get outside now.