Connecting Sparkfun ESP8266 Thing to Azure IoT Hub

不想你离开。 提交于 2019-12-13 02:47:06

问题


I am currently trying to connect my Sparkfun ESP8266 Thing to my Azure IoT Hub. I have successfully set up my hub, and am following this tutorial on how to connect the Thing to my Azure IoT Hub: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-sparkfun-esp8266-thing-dev-get-started

Unfortunately I keep getting the error:

'StaticJsonBuffer' was not declared in this scope

Arduino: 1.8.5 (Windows 10), Board: "SparkFun ESP8266 Thing, 80 MHz, 512K (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

Build options changed, rebuilding all C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino: In function 'bool readMessage(int, char*)':

message:46: error: 'StaticJsonBuffer' was not declared in this scope

 StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;

 ^

C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:46:5: note: suggested alternative:

In file included from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/StaticJsonDocument.hpp:8:0,

             from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson.hpp:10,

             from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson.h:9,

             from C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:2:

C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/Memory/StaticJsonBuffer.hpp:110:7: note: 'ArduinoJson::Internals::StaticJsonBuffer'

class StaticJsonBuffer : public Internals::StaticJsonBufferBase {

   ^

message:46: error: 'jsonBuffer' was not declared in this scope

 StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;

                                   ^

message:74: error: 'class ArduinoJson::JsonObject' has no member named 'printTo'

 root.printTo(payload, MESSAGE_MAX_LEN);

      ^

C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino: In function 'void parseTwinMessage(char*)':

message:80: error: 'StaticJsonBuffer' was not declared in this scope

 StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;

 ^

C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:80:5: note: suggested alternative:

In file included from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/StaticJsonDocument.hpp:8:0,

             from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson.hpp:10,

             from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson.h:9,

             from C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:2:

C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/Memory/StaticJsonBuffer.hpp:110:7: note: 'ArduinoJson::Internals::StaticJsonBuffer'

class StaticJsonBuffer : public Internals::StaticJsonBufferBase {

   ^

message:80: error: 'jsonBuffer' was not declared in this scope

 StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;

                                   ^

message:82: error: 'class ArduinoJson::JsonObject' has no member named 'success'

 if (!root.success())

           ^

message:88: error: 'ArduinoJson::Internals::enable_if >::type' has no member named 'success'

 if (root["desired"]["interval"].success())

                                 ^

exit status 1 'StaticJsonBuffer' was not declared in this scope

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

I have changed the DEVICE_ID from "SparkFun ESP8266 Thing Dev" to "SparkFun ESP8266 Thing", and am using simulated data.

Any help with this would be much appreciated!


回答1:


The reason for this error is that you install the ArduinoJson version >= 6. Default version 6.2.3-beta will be installed but from version 6 and higher JsonBuffer is replaced with JsonDocument. It is also indicate in the error message:

C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:46:5: note: suggested alternative:

In file included from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/StaticJsonDocument.hpp:8:0

To solve this issue you can roll back to the previous version. Version 5.13.2 works for me.

Reference issue on ArduinoJson repo and issue on iot-hub-feather-huzzah-client-app repo.



来源:https://stackoverflow.com/questions/51555386/connecting-sparkfun-esp8266-thing-to-azure-iot-hub

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!