Cupid 发表于 2012-10-24 21:49:29

【求助】读取DS18B20温度通过315Mhz模块发射

现在报错 cannot convert 'float' to 'char*' in initialization,应该如何解决。

char *msg = sensors.getTempCByIndex(0);这段代码报错。

#include <OneWire.h>
#include <DallasTemperature.h>
#include <VirtualWire.h>

#define ONE_WIRE_BUS 8

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup(void)
{
// 初始库
sensors.begin();
vw_set_ptt_inverted(true);
vw_setup(2000);
}

void loop(void)
{
sensors.requestTemperatures(); // 发送命令获取温度
      
char *msg = sensors.getTempCByIndex(0);
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
delay(5000);
}

lyili 发表于 2012-10-25 03:11:11

不是char*字符串型,应该用float 浮点型。。

Cupid 发表于 2012-10-25 14:46:09

lyili 发表于 2012-10-25 03:11 static/image/common/back.gif
不是char*字符串型,应该用float 浮点型。。

应该怎么改?

lyili 发表于 2012-10-25 22:12:48

自己理解和尝试,总不能让老让别人帮你写程序。

guangliang825 发表于 2013-12-23 16:49:37

指针只能是赋值地址。
页: [1]
查看完整版本: 【求助】读取DS18B20温度通过315Mhz模块发射