This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Ruuvitag BLE integration
#1
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)
Reply


Messages In This Thread
Ruuvitag BLE integration - by Papru - 22.05.2020, 05:26
RE: Ruuvitag BLE integration - by admin - 22.05.2020, 09:56
RE: Ruuvitag BLE integration - by Papru - 22.05.2020, 11:35
RE: Ruuvitag BLE integration - by admin - 22.05.2020, 11:36
RE: Ruuvitag BLE integration - by Papru - 22.05.2020, 11:43
RE: Ruuvitag BLE integration - by admin - 22.05.2020, 11:45
RE: Ruuvitag BLE integration - by Papru - 22.05.2020, 11:48
RE: Ruuvitag BLE integration - by admin - 22.05.2020, 12:38
RE: Ruuvitag BLE integration - by Papru - 22.05.2020, 13:01
RE: Ruuvitag BLE integration - by admin - 22.05.2020, 13:25
RE: Ruuvitag BLE integration - by Papru - 22.05.2020, 13:38
RE: Ruuvitag BLE integration - by admin - 24.05.2020, 11:33

Forum Jump: