CosmicMac / ESParkle

MQTT driven visual & audio notifier, based on ESP8266.
MIT License
85 stars 15 forks source link

Expand instructions? #6

Closed bobmarley2021 closed 4 years ago

bobmarley2021 commented 4 years ago

Hi!

I would really like to build this, but I am struggling understanding how to do so. I know next to nothing about Arduino. So far I have:

  1. Installed Arduino IDE
  2. Installed VS Code and installed the Platform IO plugin
  3. Grabbed a copy of your git files
  4. Pulled all requirements bar 1 into the Arduino Library folder - I cannot figure out where to put the MPU6050 files?
  5. I think I have edited the platformio.ini file to add board_f_cpu = 160000000L, it had a leading ; which I assume was a comment marker, so I uncommented

I know I need to rename and edit the Config.h file, which I think I can work out, but what next? Do I need to paste something into a sketch or?

Sorry if this is totally n00bish but I think your project is great and I'll really like to make it :)

bobmarley2021 commented 4 years ago

@CosmicMac I am now up and running and compiling! Managed to look at it again after some pointers and realised I had to install the Platform CLI tools and I also had to pull in some libraries myself. Looks like there's an compile error though:


Warning! `board_f_cpu` configuration option in section [env:d1_mini] is deprecated and will be removed in the next release! Please use `board_build.f_cpu` instead
Processing d1_mini (platform: espressif8266@1.6.0; board: d1_mini; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html
PLATFORM: Espressif 8266 1.6.0 > WeMos D1 R2 & mini
HARDWARE: ESP8266 160MHz, 80KB RAM, 4MB Flash
PACKAGES: 
 - framework-arduinoespressif8266 1.20400.3 (2.4.0) 
 - tool-esptool 1.409.0 (4.9) 
 - toolchain-xtensa 1.40802.0 (4.8.2)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Looking for ESP Async WebServer library in registry
Found: https://platformio.org/lib/show/306/ESP Async WebServer
LibraryManager: Installing id=306 @ 1.1.0
ESPAsyncWebServer @ 1.1.0 is already installed
Installing dependencies
LibraryManager: Installing id=305
ESPAsyncTCP @ 1.2.2 is already installed
Found 36 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ESP8266Audio> 1.0
|   |-- <ESP8266HTTPClient> 1.1
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <SD(esp8266)> 1.0.5
|   |   |-- <SPI> 1.0
|   |-- <ESP8266Spiram> 1.0
|   |   |-- <SPI> 1.0
|   |-- <SPI> 1.0
|-- <I2Cdevlib-MPU6050>
|   |-- <I2Cdevlib-Core>
|   |   |-- <Wire> 1.0
|-- <FastLED> 3.1.6
|   |-- <EspSoftwareSerial> 3.3.1
|-- <PubSubClient> 2.6
|-- <ArduinoJson> 5.8.4
|-- <ArduinoOTA> 1.0
|   |-- <ESP8266WiFi> 1.0
|   |-- <ESP8266mDNS>
|   |   |-- <ESP8266WiFi> 1.0
|-- <ESP8266Audio> 1.2
|   |-- <SPI> 1.0
|   |-- <ESP8266HTTPClient> 1.1
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <SD(esp8266)> 1.0.5
|   |   |-- <SPI> 1.0
|-- <ESP8266Spiram> 1.0
|   |-- <SPI> 1.0
|-- <ESP8266WiFi> 1.0
|-- <SD(esp8266)> 1.0.5
|   |-- <SPI> 1.0
|-- <Ticker> 1.0
Building in release mode
Compiling .pio/build/d1_mini/src/esparkle.cpp.o
In file included from src/esparkle.cpp:9:0:
.pio/libdeps/d1_mini/FastLED_ID126/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.006
 #    pragma message "FastLED version 3.001.006"
                     ^
In file included from .pio/libdeps/d1_mini/FastLED_ID126/FastLED.h:68:0,
                 from src/esparkle.cpp:9:
.pio/libdeps/d1_mini/FastLED_ID126/fastspi.h:110:23: note: #pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output
 #      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"
                       ^
In file included from src/esparkle.cpp:23:0:
src/config.h:16:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 };
 ^
src/config.h:16:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
Archiving .pio/build/d1_mini/libeb6/libESP8266mDNS.a
Indexing .pio/build/d1_mini/libeb6/libESP8266mDNS.a
Archiving .pio/build/d1_mini/lib473/libArduinoOTA.a
Indexing .pio/build/d1_mini/lib473/libArduinoOTA.a
Compiling .pio/build/d1_mini/lib42d/ESP8266Audio_ID1964/AudioFileSourceHTTPStream.cpp.o
Compiling .pio/build/d1_mini/lib42d/ESP8266Audio_ID1964/AudioFileSourceICYStream.cpp.o
Compiling .pio/build/d1_mini/lib42d/ESP8266Audio_ID1964/AudioFileSourceSD.cpp.o
Compiling .pio/build/d1_mini/lib42d/ESP8266Audio_ID1964/AudioFileSourceSPIRAMBuffer.cpp.o
Compiling .pio/build/d1_mini/lib42d/ESP8266Audio_ID1964/AudioFileSourceSTDIO.cpp.o
Compiling .pio/build/d1_mini/lib42d/ESP8266Audio_ID1964/AudioFileStream.cpp.o
Compiling .pio/build/d1_mini/lib42d/ESP8266Audio_ID1964/AudioGeneratorAAC.cpp.o
Compiling .pio/build/d1_mini/lib42d/ESP8266Audio_ID1964/AudioGeneratorFLAC.cpp.o
/Users/bob/.platformio/lib/ESP8266Audio_ID1964/src/AudioFileSourceHTTPStream.cpp: In member function 'virtual bool AudioFileSourceHTTPStream::open(const char*)':
/Users/bob/.platformio/lib/ESP8266Audio_ID1964/src/AudioFileSourceHTTPStream.cpp:40:25: error: no matching function for call to 'HTTPClient::begin(WiFiClient&, const char*&)'
   http.begin(client, url);
                         ^
/Users/bob/.platformio/lib/ESP8266Audio_ID1964/src/AudioFileSourceHTTPStream.cpp:40:25: note: candidates are:
In file included from /Users/bob/.platformio/lib/ESP8266Audio_ID1964/src/AudioFileSourceHTTPStream.h:28:0,
                 from /Users/bob/.platformio/lib/ESP8266Audio_ID1964/src/AudioFileSourceHTTPStream.cpp:21:
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:136:10: note: bool HTTPClient::begin(String)
     bool begin(String url);
          ^
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:136:10: note:   candidate expects 1 argument, 2 provided
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:137:10: note: bool HTTPClient::begin(String, String)
     bool begin(String url, String httpsFingerprint);
          ^
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:137:10: note:   no known conversion for argument 1 from 'WiFiClient' to 'String'
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:138:10: note: bool HTTPClient::begin(String, uint16_t, String)
     bool begin(String host, uint16_t port, String uri = "/");
          ^
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:138:10: note:   no known conversion for argument 1 from 'WiFiClient' to 'String'
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:139:10: note: bool HTTPClient::begin(String, uint16_t, String, String)
     bool begin(String host, uint16_t port, String uri, String httpsFingerprint);
          ^
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:139:10: note:   candidate expects 4 arguments, 2 provided
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:141:10: note: bool HTTPClient::begin(String, uint16_t, String, bool, String)
     bool begin(String host, uint16_t port, String uri, bool https, String httpsFingerprint)  __attribute__ ((deprecated));
          ^
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:141:10: note:   candidate expects 5 arguments, 2 provided
/Users/bob/.platformio/lib/ESP8266Audio_ID1964/src/AudioFileSourceICYStream.cpp: In member function 'virtual bool AudioFileSourceICYStream::open(const char*)':
/Users/bob/.platformio/lib/ESP8266Audio_ID1964/src/AudioFileSourceICYStream.cpp:43:25: error: no matching function for call to 'HTTPClient::begin(WiFiClient&, const char*&)'
   http.begin(client, url);
                         ^
/Users/bob/.platformio/lib/ESP8266Audio_ID1964/src/AudioFileSourceICYStream.cpp:43:25: note: candidates are:
In file included from /Users/bob/.platformio/lib/ESP8266Audio_ID1964/src/AudioFileSourceICYStream.h:28:0,
                 from /Users/bob/.platformio/lib/ESP8266Audio_ID1964/src/AudioFileSourceICYStream.cpp:22:
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:136:10: note: bool HTTPClient::begin(String)
     bool begin(String url);
          ^
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:136:10: note:   candidate expects 1 argument, 2 provided
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:137:10: note: bool HTTPClient::begin(String, String)
     bool begin(String url, String httpsFingerprint);
          ^
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:137:10: note:   no known conversion for argument 1 from 'WiFiClient' to 'String'
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:138:10: note: bool HTTPClient::begin(String, uint16_t, String)
     bool begin(String host, uint16_t port, String uri = "/");
          ^
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:138:10: note:   no known conversion for argument 1 from 'WiFiClient' to 'String'
*** [.pio/build/d1_mini/lib42d/ESP8266Audio_ID1964/AudioFileSourceHTTPStream.cpp.o] Error 1
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:139:10: note: bool HTTPClient::begin(String, uint16_t, String, String)
     bool begin(String host, uint16_t port, String uri, String httpsFingerprint);
          ^
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:139:10: note:   candidate expects 4 arguments, 2 provided
/Users/bob/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h:141:10: note: bool HTTPClient::begi```

Any ideas?
CosmicMac commented 4 years ago

Hi @bobmarley2021 ,

It's been a while since I've worked on this project, but I just managed to compile it successfully after making some changes in platformio.ini file.

Just follow the step-by-step guide below and let me know if it works for you.

  1. Download ESParkle repo and unzip the file
  2. Copy config.h.SAMPLE to config.h (no need to edit the file for the moment, as we only want to test compilation)
  3. Start Visual Studio Code, wait for PlatformIO home page to open (or open it manually), then select "Open project" and "ESParkle-master" directory
  4. Open the file platformio.ini and edit libdeps section:
    • change ESP826Audio@1.0 into ESP8266Audio@1.1
    • add a line with ESP8266Spiram (don't forget the 2 leading spaces)
  5. Build by clicking on the checkmark in PlatformIO toolbar (located at the bottom of VS Code)
  6. If compilation is successful, edit config.h to reflect your configuration, then upload the firmware to your ESP (click on the arrow in PIO toolbar).
bobmarley2021 commented 4 years ago

Thank you very much for replying. I am up and running now. :)

Is there a way to have the LEDs off except for a notification? Basically, I'm using this as a door bell. A Xiaomi Aqara button via zigbee2mqtt is working very nicely! Now I can have any door bell tone I can think of.

CosmicMac commented 4 years ago

Good! Using ESParkle as a door bell is a great idea. I would make the tone depend on the number of pushes in a time frame. eg. push twice in less than 2 seconds to ring the Imperial march instead of the traditional Big Ben :)

The easiest way to turn all LEDs off is to replace the content of the function ledDefault with this single line:

ledSolid(0x000000);

BTW, I did some refactoring to keep the dependencies up to date, so get a fresh download.

bobmarley2021 commented 4 years ago

@CosmicMac that's great thanks!

I pulled a fresh copy but I got his error:

Error: Invalid '/Users/bob/git/ESParkle/platformio.ini' (project configuration file): 'While reading from '/Users/bob/git/ESParkle/platformio.ini' [line 17]: option 'build_flags' in section 'env:d1_mini' already exists'

But, on my existing copy I did manage to change the LED function in esparkle.cpp as you suggested and it performs just as I would like it to. Thanks :)

May I just ask a couple of other questions?

  1. I couldn't get the RTTTL to produce any noise, at all. Even with a 3 note example, am I doing something wrong? I literally pasted your example from the git readme.
  2. Cmds don't seem to work, like: {"cmd":"list"} doesn't seem to output anything when listening to esparkle/out

It's not a massive problem as the only function I need it to perform is playing MP3 from SPIFFS and that works very well. If they still work on your end (and no doubt they do) it's my user error.

CosmicMac commented 4 years ago

Sorry, I never encountered this error. I would try to platformio update then platformio upgrade...

RTTTL... Try {"rtttl":"Beepx2:d=32,o=5,b=90:a4,p,a4,p","oncegain":"0.5"}, eventually playing with the gain value. BTW, using a terminal (my favorite is https://www.compuphase.com/software_termite.htm) may help to catch debug messages.

{"cmd":"list"} is supposed to publish the content of your ESP file system to the MQTT topic esparkle/out. On mine, it says [ "/mp3/all-eyes-on-me.mp3", "/mp3/bigben.mp3", "/mp3/bullfrog.mp3", "/mp3/droplet.mp3", "/mp3/guess-what.mp3", "/mp3/hiccup.mp3", "/mp3/hold-on.mp3", "/mp3/nasty-error-long.mp3", "/mp3/oringz-w424.mp3", "/mp3/quite-impressed.mp3", "/mp3/wet.mp3", "/mp3/you-wouldnt-believe.mp3", "/mp3/your-turn.mp3", "/mp3/youve-been-informed.mp3" ]

Obviously, you first have to upload to your ESP the content of data/mp3 (see https://docs.platformio.org/en/latest/platforms/espressif8266.html#uploading-files-to-file-system-spiffs), but it seems you already did this. Another interesting command is {"cmd":"about"}. If it does not work either, then your MQTT_MAX_PACKET_SIZE value is probably too low (default value is 128). The line build_flags = -DMQTT_MAX_PACKET_SIZE=1024 in plaformio.ini is intended to increase this value. Otherwise, you could edit the file PubSubClient.h, located in .pio\libdeps\d1_mini\PubSubClient_ID89\src.

bobmarley2021 commented 4 years ago

Brilliant that was it, the packet size. I manage to get your latest master compiling and just used the build flag in the platformio.ini file. OTA made this super easy!

I looked at the error again, and to me it seemed to be suggesting that it didn't like the double occurrence of build_flags so I changed:

build_flags = -DARDUINOJSON_ENABLE_PROGMEM=1
build_flags = -DMQTT_MAX_PACKET_SIZE=1024

to:

build_flags = -DARDUINOJSON_ENABLE_PROGMEM=1 -DMQTT_MAX_PACKET_SIZE=1024

now it compiles! With the increased packet size, RTTTL is working and so are the cmds.

Sorry to chew your ear off, but one final question (if I may) how to I define a moo box mp3? It's the only thing I cannot get working now. If I tap, it does nothing.

CosmicMac commented 4 years ago

No error on my end, that's strange. Anyway, thanks for pointing this out. I will make the change, as it makes sense to group options will multiple values.

Quoting pio Docs:

Multiple value options can be specified in two ways: Split values with “, ” (comma + space) Multi-line format, where each new line starts with at least two spaces

So I will go for

build_flags =
  -DARDUINOJSON_ENABLE_PROGMEM=1
  -DMQTT_MAX_PACKET_SIZE=1024

Concerning the moo box, just set RANDOM_STREAM_URL value in config.h to any mp3, either in SPIFFS #define RANDOM_STREAM_URL "/mp3/moo.mp3" or on line #define RANDOM_STREAM_URL "http://www.universal-soundbank.com/sounds/105.mp3"

I personally use random replicas of cult movies rather than the more traditional moo ;)

bobmarley2021 commented 4 years ago

Sorry for the delay in replying. It's been a busy week.

Great, that's all working well now. Thanks for all your help on this. :)