Sending your iPhone or iPad sensor data to Adafruit IO is a great way to visualize your sensor data and also connect to an IO project from your mobile device. Adafruit IO also provides UI elements like sliders, charts, buttons, and switches to help you with your IoT (Internet of things) projects without extra programming.
In this guide, I'll take you through the steps necessary to stream your iOS iPhone or iPad sensor data to Adafruit IO using the Swift programming language. iOS mobile devices contains a handful of sensors such as Gyroscopic sensors, a Barometer, Magnetometer and much more. In this guide we'll be sending our Accelerometer sensor data to our Adafruit IO account feed. This guide doesn't require an extensive knowledge of Swift.
For reference, this guide provides an example app called IO Connect Example. This example app sends your iPhone accelerometer sensor data to Adafruit IO.
• Setup an iOS app project in Xcode.
• Create a function that helps display accelerometer data updates and a function to stop updates.
• Learn about REST to make a POST request with the REST API.
• We'll set up labels in the main.storyboard to display your accelerometer data. We will also add a switch to start and stop updates.
Your completed project will consist of an iOS app that sends our iPhone or iPad Accelerometer sensor data to Adafruit IO using a HTTP "POST" request and JSONSerialization.
• Make sure your Xcode IDE is up-to-date (version 8.3.3 or newer)
• While in Xcode, make sure the development target is set to 10.3 or higher.
• If you haven't setup your Adafruit IO account with a Feed and Dashboard, you should do so before beginning the guide.
If you're not familiar or if you need help getting started with Adafruit IO, check out our learn guide:
Once the file is downloaded, locate and click on the IO Connect Example.xcodeproj file and it will open up the project in Xcode.
Once we have the project open, select your iOS device's scheme in Xcode.
Now just press the Run button to test the app on your iOS device.
If all goes well, the IO Connect Example app will run on your iOS device and you'll be able to use the app as a reference while you explore the guide.