我尝试从 Arduino 向我的 ESP 控制器发送一个值,但我没有成功读取消息... 我总是只得到一些数字。 我需要在未来发送多个读数的多个值...
Arduino 代码:
int analogPin = A0;
int val = 0;
void setup(){
Serial.begin(115200);
delay(2000);
}
void loop()
{
Serial.print('Value is: ');
if (Serial.available()) {
val = analogRead(analogPin);
Serial.println(val);
}
delay(1000);
}
ESP 代码:[在此处输入图片描述][1]
String incomingByte ;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.readStringUntil('\n');
// say what you got:
Serial.print("I received: ");
Serial.print(incomingByte);
}
}
```
[1]: https://i.stack.imgur.com/w7Eiw.png
ANy Idea how to solve this?