如何从Arduino-UNO向ESP8266-01发送浮点值

问题描述 投票:0回答:1

我正在尝试将数据从arduino发送到esp-01,但是我只能发送整数值,或者如果我正在发送浮点值,则esp-01将通过软件序列将其作为整数接收

我尝试使用软件串行发送,也尝试将浮点数类型转换为字符串,但是在将字符串传递给myserial.write(STRING)时给了我错误>

data = 0.00005146;
myserial.write(data);

我正在尝试从arduinoto esp-01发送数据,但是我只能发送整数值,或者如果我正在发送浮点值,则esp-01会通过尝试发送的软件序列将其作为整数接收...

arduino iot esp8266 arduino-uno arduino-ide
1个回答
0
投票

从发送端使用Serial.println()函数

void setup() {
  Serial.begin(9600);
}

void loop() {
  float x = 0.00005146;
  Serial.println(x, 8);
  delay(1000);
}
© www.soinside.com 2019 - 2024. All rights reserved.