-->
Page 1 of 1

Controlling the ESP8266 with a mobile app?

PostPosted: Thu Oct 11, 2018 5:14 am
by hatahet
I recently bought a NodeMCU ESP8266, and after watching enough videos I was able to make it run a simple webpage and made it act as an Access Point to do so.

Question is, how do I control it with a mobile app without bluetooth and wifi, but possibly through it acting as an access point? (I know it sounds silly)

I have seen videos where people make apps to control their microcontroller (mainly arduino) via bluetooth. I was wondering whether I could do the same by utilizing the capabilities of the ESP without the need for bluetooth.

I know that you can control it wirelessly through things like MQTT, and even make apps send requests via MQTT, but that requires WiFi.

Under the hypothetical scenario that my wifi is down, how would I control my ESP with the use of an app?
I was thinking if I could send data to it when it was acting as an access point (again without wifi or bluetooth).

Thank you.

Re: Controlling the ESP8266 with a mobile app?

PostPosted: Thu Oct 11, 2018 4:50 pm
by btidey
By 'without wifi' I assume you mean without a local wifi network that both your phone/tablet and the esp8266 connect to. Obviously you have to use wifi as the medium of communicating.

If the esp8266 is put into AP mode then it produces a new wifi network that other devices can connect to. So for example the AP may be set to use a network with a name like esp8266AP with an address of 192.168.4.1 and a wifi access password. The phone or tablet can then connect to this network using the normal wifi set up on the phone / tablet.

Once connected then the phone or tablet can access any web server functions on the esp8266 via its IP address of 192.168.4.1

If you look at WifiManager then you can see how this is exploited to allow connecting to a normal external wifi in STA mode but revert to AP mode if this is not accessible. WifiManager then uses this to allow a phone or tablet to access a web page on the ESP8266 and allow selection and entry of network passwords for first time setup purposes. You can use the same methodology to revert when STA mode doesn't work and access web pages in AP mode.

Re: Controlling the ESP8266 with a mobile app?

PostPosted: Fri Oct 12, 2018 8:20 am
by hatahet
btidey wrote:By 'without wifi' I assume you mean without a local wifi network that both your phone/tablet and the esp8266 connect to. Obviously you have to use wifi as the medium of communicating.

If the esp8266 is put into AP mode then it produces a new wifi network that other devices can connect to. So for example the AP may be set to use a network with a name like esp8266AP with an address of 192.168.4.1 and a wifi access password. The phone or tablet can then connect to this network using the normal wifi set up on the phone / tablet.

Once connected then the phone or tablet can access any web server functions on the esp8266 via its IP address of 192.168.4.1

If you look at WifiManager then you can see how this is exploited to allow connecting to a normal external wifi in STA mode but revert to AP mode if this is not accessible. WifiManager then uses this to allow a phone or tablet to access a web page on the ESP8266 and allow selection and entry of network passwords for first time setup purposes. You can use the same methodology to revert when STA mode doesn't work and access web pages in AP mode.


Thank you for your reply.

While this is a function that I intend to add later on, I was wondering whether app control is possible via the "web server functions" that you mentioned.

Apologies for the improper explanation I had provided earlier, but I would like to have app control (not via a webpage running on the esp) without connecting the esp to any external network. Is that possible?

Thank you for your time .

Re: Controlling the ESP8266 with a mobile app?

PostPosted: Mon Oct 15, 2018 4:20 am
by QuickFix
Although it still isn't clear to me why you want to do things in a (as it seems) pretty awkward way:
  • Make up some raw protocol
  • Write an app for your mobile device that contains a user interface and speaks that protocol
  • Implement that protocol inside firmware for the ESP
  • Set up the ESP to be an AP and let your mobile device connect to it
Simply put, it's exactly like using a browser and HTML, but now your using your own interface (analog to "Browser") and protocol (analog to "HTML").