C:\Users\conservator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Print.h:93:16: note: conversion of argument 1 would be ill-formed: C:\Users\conservator\Desktop\mqttToAliyun\mqttToAliyun.ino:128:18: error: invalid conversion from 'const char*' to 'long long int' [-fpermissive] 128 | Serial.print("%d",sensor[0]); | ^~~~ | | | const char* In file included from C:\Users\conservator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Stream.h:27, from C:\Users\conservator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/HardwareSerial.h:32, from C:\Users\conservator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Arduino.h:303, from C:\Users\conservator\AppData\Local\Temp\arduino\sketches\304EB848CF381B8A7A8E84D646752A81\sketch\mqttToAliyun.ino.cpp:1: C:\Users\conservator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Print.h:94:16: note: candidate: 'size_t Print::print(long long unsigned int, int)' (near match) 94 | size_t print(unsigned long long, int = DEC); | ^~~~~ C:\Users\conservator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Print.h:94:16: note: conversion of argument 1 would be ill-formed: C:\Users\conservator\Desktop\mqttToAliyun\mqttToAliyun.ino:128:18: error: invalid conversion from 'const char*' to 'long long unsigned int' [-fpermissive] 128 | Serial.print("%d",sensor[0]); | ^~~~ | | | const char* exit status 1 Compilation error: no matching function for call to 'print(const char [3], int&)'
时间: 2023-08-09 20:11:58 浏览: 258
conservator-cli:适用于FLIR Conservator的Python API和CLI
这个错误是因为 `Serial.print()` 函数的参数传递方式不正确。`print()` 函数的第一个参数应该是一个字符串,而你传递了一个格式化字符串。在 Arduino 中,你可以使用 `%d` 来打印整数值,但是在这里你需要使用 `Serial.print()` 函数的两个参数版本来打印传感器值。
以下是修正后的代码示例:
```cpp
Serial.print("Sensor Value: ");
Serial.println(sensor[0]);
```
这样就可以正确打印传感器值了。记得在修改完代码后重新编译和上传到你的硬件设备上。
阅读全文