Search code examples
iosswiftsphero-apisphero

How to read out battery state of sphero or ollie?


is there a way to read out the battery state of Orbotix Ollie or Sphero? I want to do this in a swift ios app, but the SDK API description is a bit brief.


Solution

  • There's an async response that you can receive in 'handleResponse' that's an instance of RKGetPowerStateResponse that'll show up every ten seconds of so. Cast it over and you can get batteryVoltage, time since last charge, number of charge cycles the robot has gone through and an enumerated value for the power state. I'm not at a computer right now for giving you exact values, but you should be able to use autocomplete to get it :)