tom-mi / higrow-mqtt-sender

MIT License
3 stars 3 forks source link

No kompile #2

Open Timjena opened 5 years ago

Timjena commented 5 years ago

Please update

grafoteka commented 5 years ago

Hello @tom-mi!! I found this great project! but I can't compile it as @Timjena says.

I'm using Atom and PlatformIO. This is the output when I try to compile:

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.11.1 > 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: toolchain-xtensa32 2.50200.80 (5.2.0), framework-arduinoespressif32 2.10004.191002 (1.0.4), tool-esptoolpy 1.20600.0 (2.6.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
|-- <ArduinoJson> 6.13.0
|-- <Adafruit Unified Sensor> 1.0.3
|-- <DHT sensor library> 1.3.8
|   |-- <Adafruit Unified Sensor> 1.0.3
|-- <PubSubClient> 2.7
|-- <WiFi> 1.2.7
|   |-- <SPI> 1.0
Compiling .pio\build\esp32dev\src\main.cpp.o
Compiling .pio\build\esp32dev\src\wifi.cpp.o
In file included from src\WiFi.cpp:1:0:
src/WiFi.h:4:1: error: 'boolean' does not name a type
 boolean connect_wifi();
 ^
src\main.cpp:102:11: error: DynamicJsonBuffer is a class from ArduinoJson 5. Please see arduinojson.org/upgrade to learn how to upgrade your program to ArduinoJ
son version 6
   DynamicJsonBuffer buffer;
           ^
src\WiFi.cpp: In function 'boolean connect_wifi()':
src\WiFi.cpp:10:3: error: 'WiFi' was not declared in this scope
   WiFi.mode(WIFI_STA);

   ^
src\WiFi.cpp:10:13: error: 'WIFI_STA' was not declared in this scope
   WiFi.mode(WIFI_STA);
             ^
src\WiFi.cpp:12:68: error: 'WL_CONNECTED' was not declared in this scope
   for (int i=0; i<WIFI_CONNECT_TIMEOUT_SECONDS && WiFi.status() != WL_CONNECTED; i++) {
                                                                    ^
src\WiFi.cpp:17:24: error: 'WL_CONNECTED' was not declared in this scope
   if (WiFi.status() == WL_CONNECTED) {
                        ^
src\main.cpp:34:1: error: 'WiFiClient' does not name a type
 WiFiClient wifi_client;
 ^
src\main.cpp:35:26: error: 'wifi_client' was not declared in this scope
 PubSubClient mqtt_client(wifi_client);
                          ^
src\main.cpp: In function 'void read_and_send_data()':
src\main.cpp:102:21: error: 'buffer' was not declared in this scope
   DynamicJsonBuffer buffer;
                     ^
src\main.cpp:110:8: error: 'ArduinoJson::JsonObject {aka class ArduinoJson6130_000001::ObjectRef}' has no member named 'printTo'

   root.printTo(Serial);
        ^
src\main.cpp:114:10: error: 'ArduinoJson::JsonObject {aka class ArduinoJson6130_000001::ObjectRef}' has no member named 'printTo'
     root.printTo(payload);
          ^
src\main.cpp: In function 'void loop()':
src\main.cpp:129:3: error: 'wifi_client' was not declared in this scope
   wifi_client.flush();
   ^
src\main.cpp:131:3: error: 'WiFi' was not declared in this scope
   WiFi.disconnect(true, false);
   ^
Compiling .pio\build\esp32dev\FrameworkArduino\wiring_pulse.c.o
*** [.pio\build\esp32dev\src\wifi.cpp.o] Error 1
Compiling .pio\build\esp32dev\FrameworkArduino\wiring_shift.c.o
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1
========================= [FAILED] Took 5.42 seconds =========================

I have also installed the library ArduinoJson library, but still having the same problems.

If I change boolean connect_wifi() with bool connect_wifi(), the first error disappear, but I don't know how to continue.

Also, I don't know where to define the variables: WIFI_SSID, WIFI_PASS, MQTT_BROKER_HOST, MQTT_BROKER_PORT

Please, could you help me?

Kinds regards, Jorge

tom-mi commented 4 years ago

Ok, sorry it took me so long, lots of other stuff going on.

The variables need to be defined as environment variables. for example

export WIFI_SSID=my-ssid
export WIFI_PASS=my-s3cr3t-wifi-key
export MQTT_BROKER_HOST=my.mqtt.broker
export MQTT_BROKER_PORT=1883

Then you should be able to build in the same shell, e.g

platformio run

(I've also pushed a fix for the upgraded ArduinoJson dependency)

Please let me know if that works for you.

justinatomatic commented 3 years ago

Having a similar issue PlatformIO Core, version 5.1.1, MacOS I'm confident the environment variables are set correctly.

CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.2.1) > 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.10006.210326 (1.0.6) 
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - toolchain-xtensa32 2.50200.97 (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
|-- <ArduinoJson> 6.18.0
|-- <Adafruit Unified Sensor> 1.1.4
|-- <DHT sensor library> 1.4.2
|   |-- <Adafruit Unified Sensor> 1.1.4
|-- <PubSubClient> 2.8.0
|-- <WiFi> 1.0
Building in release mode
Compiling .pio/build/esp32dev/src/main.cpp.o
Compiling .pio/build/esp32dev/src/wifi.cpp.o
In file included from src/wifi.cpp:1:0:
src/WiFi.h:4:1: error: 'boolean' does not name a type
 boolean connect_wifi();
 ^
Archiving .pio/build/esp32dev/lib1e0/libAdafruit Unified Sensor.a
Indexing .pio/build/esp32dev/lib1e0/libAdafruit Unified Sensor.a
Compiling .pio/build/esp32dev/liba85/DHT sensor library/DHT_U.cpp.o
Compiling .pio/build/esp32dev/libe53/PubSubClient/PubSubClient.cpp.o
src/wifi.cpp: In function 'boolean connect_wifi()':
src/wifi.cpp:10:3: error: 'WiFi' was not declared in this scope
   WiFi.mode(WIFI_STA);
   ^
src/wifi.cpp:10:13: error: 'WIFI_STA' was not declared in this scope
   WiFi.mode(WIFI_STA);
             ^
src/wifi.cpp:12:68: error: 'WL_CONNECTED' was not declared in this scope
   for (int i=0; i<WIFI_CONNECT_TIMEOUT_SECONDS && WiFi.status() != WL_CONNECTED; i++) {
                                                                    ^
src/wifi.cpp:17:24: error: 'WL_CONNECTED' was not declared in this scope
   if (WiFi.status() == WL_CONNECTED) {
                        ^
*** [.pio/build/esp32dev/src/wifi.cpp.o] Error 1
src/main.cpp:34:1: error: 'WiFiClient' does not name a type
 WiFiClient wifi_client;
 ^
src/main.cpp:35:26: error: 'wifi_client' was not declared in this scope
 PubSubClient mqtt_client(wifi_client);
                          ^
src/main.cpp: In function 'void loop()':
src/main.cpp:128:3: error: 'wifi_client' was not declared in this scope
   wifi_client.flush();
   ^
src/main.cpp:130:3: error: 'WiFi' was not declared in this scope
   WiFi.disconnect(true, false);
   ^
*** [.pio/build/esp32dev/src/main.cpp.o] Error 1