求助 BMP280用Custom Sensor把气温和气压数值分开但读不到气压值
发表于 : 周二 2月 26, 2019 21:07
BMP280有气压和温度想把数值分开,ldx16是BMP280设置text,已经有读数,17和18是分开的虚拟传感器,气温已经分出来了但气压一直没有分出来,大神帮忙看看代码哪里有不对吗?
if devicechanged['BMP280'] then
local device = otherdevices_svalues["BMP280"]
print(device)
local Temperature, Pressure
_,_,Temperature, Pressure = string.find(device, "(.+);(.+)")
print(Temperature) --show temp in LOG
print(Pressure) --show Pressure in LOG,
commandArray[1] = {['UpdateDevice'] = 17 .. '|0|' .. Temperature}
commandArray[2] = {['UpdateDevice'] = 18 .. '|0|' .. Pressure}
end
return commandArray
commandArray = {}if devicechanged['BMP280'] then
local device = otherdevices_svalues["BMP280"]
print(device)
local Temperature, Pressure
_,_,Temperature, Pressure = string.find(device, "(.+);(.+)")
print(Temperature) --show temp in LOG
print(Pressure) --show Pressure in LOG,
commandArray[1] = {['UpdateDevice'] = 17 .. '|0|' .. Temperature}
commandArray[2] = {['UpdateDevice'] = 18 .. '|0|' .. Pressure}
end
return commandArray