22.05.2020, 05:26
Hi,
has anyone tried to integrate these BLE temperature/humidity/pressure sensors with LM5? https://ruuvi.com/
I have BLE dongle in LM5 and it seems that it found those Ruuvitags but if I try to read response from it, it just gives *nil to log or says that error in connection.
Here is specs for ruuvitag data: Ruuvitag dataformat
This is script that I used for connecting to Ruuvi:
require('ble')
ble.up()
sock = ble.sock()
res,err=ble.settimeout(sock, 15)
res,err,errno = ble.connect(sock,"f7:14:56:d0:33:d5")
if res then
rx = ble.sockreadhnd(sock, 0x0499)
log(rx)
end
log(res,err,errno)
ble.close(sock)
Script that I used for scan BLE devices:
require('ble')
-- enable ble
ble.up()
list = {}
-- mac -> group address mapping
known = {
['f7:14:56:d0:33:d5'] = '9/1/1',
['CD:F5:C0:A2:F4:4C'] = '9/1/2',
}
ctime = os.time()
function callback(addr)
local now, delta
now = os.time()
delta = now - ctime
if addr then
if not list[ addr ] then
log('BLE found ' .. addr)
if known[ addr ] then
grp.write(known[ addr ], true, dt.bool)
end
end
list[ addr ] = now
end
-- check for missing devices each 5 seconds
if delta < 0 or delta > 5 then
for addr, time in pairs(list) do
delta = now - time
if delta < 0 or delta > 60 then
log('BLE missing ' .. addr)
list[ addr ] = nil
if known[ addr ] then
grp.write(known[ addr ], false, dt.bool)
end
end
end
ctime = now
end
end
ble.scan(callback)
has anyone tried to integrate these BLE temperature/humidity/pressure sensors with LM5? https://ruuvi.com/
I have BLE dongle in LM5 and it seems that it found those Ruuvitags but if I try to read response from it, it just gives *nil to log or says that error in connection.
Here is specs for ruuvitag data: Ruuvitag dataformat
This is script that I used for connecting to Ruuvi:
require('ble')
ble.up()
sock = ble.sock()
res,err=ble.settimeout(sock, 15)
res,err,errno = ble.connect(sock,"f7:14:56:d0:33:d5")
if res then
rx = ble.sockreadhnd(sock, 0x0499)
log(rx)
end
log(res,err,errno)
ble.close(sock)
Script that I used for scan BLE devices:
require('ble')
-- enable ble
ble.up()
list = {}
-- mac -> group address mapping
known = {
['f7:14:56:d0:33:d5'] = '9/1/1',
['CD:F5:C0:A2:F4:4C'] = '9/1/2',
}
ctime = os.time()
function callback(addr)
local now, delta
now = os.time()
delta = now - ctime
if addr then
if not list[ addr ] then
log('BLE found ' .. addr)
if known[ addr ] then
grp.write(known[ addr ], true, dt.bool)
end
end
list[ addr ] = now
end
-- check for missing devices each 5 seconds
if delta < 0 or delta > 5 then
for addr, time in pairs(list) do
delta = now - time
if delta < 0 or delta > 60 then
log('BLE missing ' .. addr)
list[ addr ] = nil
if known[ addr ] then
grp.write(known[ addr ], false, dt.bool)
end
end
end
ctime = now
end
end
ble.scan(callback)