Connect to the RuuviTag from BASIC!

My project (just completed) is to add support for the RuuviTag device into the BASIC interpreter of my “Best Calculator, IOT edition” app. The latest update was just published on the Windows app store.

Hooking up the ruuvi was pretty easy except that the temperature data format was a surprise (the upper byte isn’t a regular 2’s complement number; it’s a sign-magnitude value). And my BASIC interpreter never had to deal with EddyStone formats before. Once I could support EddyStone in general, supporting the RuuviTag was simple.

Here’s a simple BASIC program that picks apart each Ruuvi broadcast:

Bluetooth.Watch (“RuuviTag”, “ruuvi”)
MAXTIME = 10
FOR time = 1 TO MAXTIME
    Screen.ClearLine (1)
    now = DateTime.GetNow()
    PRINT now.Time
    PAUSE 50
NEXT time

FUNCTION ruuvi (address, rssi, txpower, ↲
    temperature, pressure, humidity)

    Screen.ClearLines (3, 9)
    PRINT “Temperature”, temperature
    PRINT “Pressure”, pressure
    PRINT “Humidity”, humidity

    PRINT AT 7,1 "Address", address
    PRINT "RSSI", rssi
    PRINT "TX", txpower
END
2 Likes