Skip to content

iOS framework that enables any Apple device to interface with the TI SensorTag.

License

Notifications You must be signed in to change notification settings

AndreMuis/STGTISensorTag

Repository files navigation

STGTISensorTag

Use the STGTISensorTag framework to connect any Apple device to a TI SensorTag and read measurement data from its many sensors.

Sensors

  • Accelerometer - acceleration acting on SensorTag in g's
  • Gyroscope - angular velocity of SensorTag in rad/sec
  • Temperature Sensor - ambient temperature in ℉
  • Magnetometer - local magnetic field strength in microteslas
  • Humidity Sensor - relative humidity in %
  • Barometric Pressure Sensor - atmospheric pressure in millibars

Other readings

  • RSSI - signal strength in dB
  • Simple Keys Service - which key on SensorTag is pressed

Installation via CocoaPods

In your Podfile:

platform :ios, '9.0'
use_frameworks!

pod 'STGTISensorTag', '1.0.3'

Usage

NOTE: The easiest way to learn about and get started with the STGTISensorTag framework is to download and run the STGTISensorTagDemo project.

Import STGTISensorTag framework:

import STGTISensorTag

Create an instance of STGCentralManager:

self.centralManager = STGCentralManager(delegate: self)

If the central manager's state is found to be "powered on" then start scanning for SensorTags:

func centralManagerDidUpdateState(state: STGCentralManagerState)
{
  if (state == STGCentralManagerState.PoweredOn)
  {
    self.centralManager.startScanningForSensorTags()
  }        
}

After a SensorTag is discovered and connected create a STGSensorTag instance and start discovering the SensorTag's services:

func centralManager(central: STGCentralManager, didConnectSensorTagPeripheral peripheral: CBPeripheral)
{
  self.sensorTag = STGSensorTag(delegate: self, peripheral: peripheral)
        
  self.sensorTag!.discoverServices()
}

As characteristics are discovered for different sensors enable them as needed to read their measurement data:

func sensorTag(sensorTag: STGSensorTag, didDiscoverCharacteristicsForGyroscope gyroscope: STGGyroscope)
{
  self.sensorTag!.gyroscope.enable(measurementPeriodInMilliseconds: 300)
}

Measurement data is then ready to be used:

func sensorTag(sensorTag: STGSensorTag, didUpdateAngularVelocity angularVelocity: STGVector)
{
  print("angular velocity = \(angularVelocity) rads / sec")
}

About

iOS framework that enables any Apple device to interface with the TI SensorTag.

Resources

License

Stars

Watchers

Forks

Packages

No packages published