ESPTouch with iOS (Swift)

Integrate the Wi-Fi module config with your existing iOS project

Sikandar Khan
RudraLabs Pte Ltd
2 min readJul 22, 2019

--

ESP8266 chips have a handy little feature that allows you to configure WiFi credentials that they use without actually connecting to them.
One of the protocols it supports is called ESP Touch and to get it working under the Xcode IDE you can use the code below as a starting point.

Espressif’s ESP-TOUCH protocol implements the Smart Config technology to help users connect ESP8266EX-embedded devices to a Wi-Fi network through simple configuration on a smartphone. — ESPTouch website

Working principle

Official application available on app store : https://apps.apple.com/us/app/espressif-esptouch/id1071176700

Steps to follow :

  1. Copy esptouch source code from official GitHub repo
    https://github.com/EspressifApp/EsptouchForIOS
    This code is available in Objective-C version. So we need to create a bridge for Objective-C to Swift.
  2. Create Bridging header
    https://developer.apple.com/documentation/swift/migrating_your_objective-c_code_to_swift
    https://stackoverflow.com/questions/24002369/how-to-call-objective-c-code-from-swift
  3. Copy files from ESPTouch project to the main project
    You should copy a few supporting files from ESPTouch project cloned directory to your main swift project. Simple drag & drop works. If it is ambiguous for you, follow this link
    https://stackoverflow.com/questions/6821057/xcode-how-could-you-copy-paste-classes-files-from-one-project-into-another
  4. Adding lib file to your project
  1. Granting Wi-Fi privileges to your main project
    Before proceeding to integrate with our main project, we need to make sure we grant Wi-Fi permission from developer.apple.com
    > You should enable it in apple’s developer portal.
    > Go to “App IDs” and edit your app.
    > Check the Wireless Accessory Configuration checkbox.
    > Click Done

Now just regenerate your provisioning profile and rebuild/archive using newly generated profile.

Congratulations, you are successfully configured your project with ESPTouch.

--

--

Sikandar Khan
RudraLabs Pte Ltd

Head of Engineering | Product Management, Strategic Thinking