metriful / sensor

Sensor by Metriful | Indoor environment monitoring | Documentation and code samples
https://www.sensor.metriful.com
MIT License
110 stars 37 forks source link

Errors compiling Home_Assistant.ino #31

Closed pizzidellamaremma closed 2 years ago

pizzidellamaremma commented 2 years ago

I'm compiling Home_Assistant.ino on ESP8266 (tried different board compilers, nothing changes) and I'm getting this error:

Home_Assistant:162:28: error: 'HA_Attributes_t' does not name a type
 void sendNumericData(const HA_Attributes_t * attributes, uint32_t valueInteger, 
                            ^
Home_Assistant:162:46: error: ISO C++ forbids declaration of 'attributes' with no type [-fpermissive]
 void sendNumericData(const HA_Attributes_t * attributes, uint32_t valueInteger, 
                                              ^
Home_Assistant:182:25: error: 'HA_Attributes_t' does not name a type
 void sendTextData(const HA_Attributes_t * attributes, const char * valueText) {
                         ^
Home_Assistant:182:43: error: ISO C++ forbids declaration of 'attributes' with no type [-fpermissive]
 void sendTextData(const HA_Attributes_t * attributes, const char * valueText) {
                                           ^
Home_Assistant:189:37: error: 'HA_Attributes_t' does not name a type
 void http_POST_Home_Assistant(const HA_Attributes_t * attributes, const char * valueText) {
                                     ^
Home_Assistant:189:55: error: ISO C++ forbids declaration of 'attributes' with no type [-fpermissive]
 void http_POST_Home_Assistant(const HA_Attributes_t * attributes, const char * valueText) {
                                                       ^
C:\Users\Davide\Documents\Arduino\sketch_feb25b\Home_Assistant.ino: In function 'void setup()':
Home_Assistant:100:6: error: redefinition of 'void setup()'
 void setup() {
      ^
sketch_feb25b:1:6: error: 'void setup()' previously defined here
 void setup() {
      ^
C:\Users\Davide\Documents\Arduino\sketch_feb25b\Home_Assistant.ino: In function 'void loop()':
Home_Assistant:115:6: error: redefinition of 'void loop()'
 void loop() {
      ^
sketch_feb25b:6:6: error: 'void loop()' previously defined here
 void loop() {
      ^
Home_Assistant:146:83: error: cannot convert 'HA_Attributes_t*' to 'const int*' for argument '1' to 'void sendNumericData(const int*, uint32_t, uint8_t, bool)'
   sendNumericData(&temperature, (uint32_t) T_intPart, T_fractionalPart, isPositive);
                                                                                   ^
Home_Assistant:147:62: error: cannot convert 'HA_Attributes_t*' to 'const int*' for argument '1' to 'void sendNumericData(const int*, uint32_t, uint8_t, bool)'
   sendNumericData(&pressure, (uint32_t) airData.P_Pa, 0, true);
                                                              ^
Home_Assistant:148:84: error: cannot convert 'HA_Attributes_t*' to 'const int*' for argument '1' to 'void sendNumericData(const int*, uint32_t, uint8_t, bool)'
   sendNumericData(&humidity, (uint32_t) airData.H_pc_int, airData.H_pc_fr_1dp, true);
                                                                                    ^
Home_Assistant:149:101: error: cannot convert 'HA_Attributes_t*' to 'const int*' for argument '1' to 'void sendNumericData(const int*, uint32_t, uint8_t, bool)'
   sendNumericData(&illuminance, (uint32_t) lightData.illum_lux_int, lightData.illum_lux_fr_2dp, true);
                                                                                                     ^
Home_Assistant:150:96: error: cannot convert 'HA_Attributes_t*' to 'const int*' for argument '1' to 'void sendNumericData(const int*, uint32_t, uint8_t, bool)'
   sendNumericData(&soundLevel, (uint32_t) soundData.SPL_dBA_int, soundData.SPL_dBA_fr_1dp, true);
                                                                                                ^
Home_Assistant:152:54: error: cannot convert 'HA_Attributes_t*' to 'const int*' for argument '1' to 'void sendNumericData(const int*, uint32_t, uint8_t, bool)'
                   soundData.peak_amp_mPa_fr_2dp, true);
                                                      ^
Home_Assistant:153:91: error: cannot convert 'HA_Attributes_t*' to 'const int*' for argument '1' to 'void sendNumericData(const int*, uint32_t, uint8_t, bool)'
   sendNumericData(&AQI, (uint32_t) airQualityData.AQI_int, airQualityData.AQI_fr_1dp, true);
                                                                                           ^
Home_Assistant:156:60: error: cannot convert 'HA_Attributes_t*' to 'const int*' for argument '1' to 'void sendNumericData(const int*, uint32_t, uint8_t, bool)'
                     particleData.concentration_fr_2dp, true);
                                                            ^
Home_Assistant:158:75: error: cannot convert 'HA_Attributes_t*' to 'const int*' for argument '1' to 'void sendTextData(const int*, const char*)'
   sendTextData(&AQ_assessment, interpret_AQI_value(airQualityData.AQI_int));
                                                                           ^
C:\Users\Davide\Documents\Arduino\sketch_feb25b\Home_Assistant.ino: In function 'void sendNumericData(const HA_Attributes_t*, uint32_t, uint8_t, bool)':
Home_Assistant:178:49: error: cannot convert 'const HA_Attributes_t*' to 'const int*' for argument '1' to 'void http_POST_Home_Assistant(const int*, const char*)'
   http_POST_Home_Assistant(attributes, valueText);
                                                 ^
C:\Users\Davide\Documents\Arduino\sketch_feb25b\Home_Assistant.ino: In function 'void sendTextData(const HA_Attributes_t*, const char*)':
Home_Assistant:185:50: error: cannot convert 'const HA_Attributes_t*' to 'const int*' for argument '1' to 'void http_POST_Home_Assistant(const int*, const char*)'
   http_POST_Home_Assistant(attributes, quotedText);
                                                  ^
exit status 1
'HA_Attributes_t' does not name a type

I tried to use older version of board compiler (e.g. 2.7.4, 2.6.3).

metriful commented 2 years ago

Hi,

The error probably means the compiler can't find the definition of "HA_Attributes_t", which is in file Metriful_sensor.h

Try these 2 things:

  1. check that this line is still present at the top of the home_assistant sketch (did you remove it?):

#include <Metriful_sensor.h>

  1. Check that you have copied the folder called "Metriful_Sensor" into your computer's Arduino library folder:

Download and unzip the Sensor repository. From this, copy the folder Metriful_Sensor (located inside the repository Arduino folder) into your computer's Arduino libraries folder (probably \Documents\Arduino\libraries)

pizzidellamaremma commented 2 years ago

Found it, made a mistake importing the libraries, sorry.

Now it compiles, upload, it's not creating a wifi AP but I can't see it connected to my network. Can't see in DHCP lease and it isn't connecting to Home Assistant. Again, I'm trying to change board compiler from generic to NodeMCU ESP-12E but it isn't working.

After some checks seems the board is broken.