Interest Check in Android/iOS Remote for MicroPython Devices

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
painlessprototyping
Posts: 1
Joined: Fri Mar 30, 2018 6:37 pm

Interest Check in Android/iOS Remote for MicroPython Devices

Post by painlessprototyping » Fri Mar 30, 2018 6:45 pm

I've been using Arduino for about two years now and just recently discovered MicroPython. For fun I wanted to see how easy it would be to create an Android (React Native) app that could act as a remote control for MicroPython projects. It took me about 4 hours to achieve bare minimum functionality to make an LED blink. I looked on the Google Play store and didn't see anything that currently exists (unless my search abilities are terrible). I'd like to contribute to the MicroPython community and thought this would be a good way. Below I've posted a wireframe of what some of it might look like.

https://imgur.com/rezQCnJ

Would be interested to hear thoughts of if this is or isn't a good idea. Either way, I'd also like to know how else apps might help the community.

pidou46
Posts: 101
Joined: Sat May 28, 2016 7:01 pm

Re: Interest Check in Android/iOS Remote for MicroPython Devices

Post by pidou46 » Wed Apr 04, 2018 4:51 pm

Hi,

I investigate with basicaly the same idea.

My building blocks are:

On the controlling device:
- Python 3.6 - I don't want to spend time learning different languages + portability (linux, android, windows)
- UI Kivy - close links with python + portability (linux, android, windows)
Nota: On android pydroid3 app come with kivy already up and running without any effort, for prototyping its cool... Then Buildozer (kivy) will allow me to build clean Android app, when (if) needed!

On MCU side:
- ESP32 with PSRAM it's easier because of available RAM but it would be cool to get it working on ESP8266
- micropython official or Loboris depending on MCU device.
- Network communications via WLAN in AP mode for first setup, and optionally STA mode to bind to local network.
- Communication protocol: websocket because it's standard, it open communications to something else, it's fullduplex without too much overhead, and micropython library is available.
- Asynchronous task between network communication and hardware I/O (leds, servo, sensor, ect...), this is where I'm stopped until now. I would like to use asyncio version of websocket, but there is some issue with asyncio V2.0, different micropython firmware, and so on, but it seems that we will get back to a working situation soon. If asyncio doesn’t come to a stable situation across micropython firmware soon, I will forget ESP8266 and go for ESP32 + Loboris firmware because it has a working websocket threaded server build in.

Have you made some choices on your side ?

You have pushed further your app design thought than me; I think it's a good starting point.

And definitely if we both get the same idea, it means that there is a necessity for this kind of setup for the community.

I don’t have too much time to spend on this, but I can contribute if you like.
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Interest Check in Android/iOS Remote for MicroPython Devices

Post by OutoftheBOTS_ » Wed Apr 04, 2018 10:02 pm

I will follow this thread with much interest.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Interest Check in Android/iOS Remote for MicroPython Devices

Post by kevinkk525 » Wed Apr 04, 2018 11:01 pm

I like the thoughts here.
And I especially like the way pidou46 tries to do an app as for most people in this community it's probably easier to write an app in python over any other language although the process of building the app looks a bit complicated.
I only programmed one app yet for work using corona sdk which uses lua.

I don't know JavaScript so this thread was not that interesting to me as I would be unable to contribute. Didn't know about the possibility to use python for app programming.

Creating an App-Framework for controlling an ESP would be nice. But it also bares the question how it is different from using an mqtt app that provides a convenient way of adding buttons for toggling leds etc.
It could be nicer to make it differently and expose all functionality to an App.
I found the App "Controllium - ESP8266 IOT" in the PlayStore, which actually does control the GPIOs (and probably more)..
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

pidou46
Posts: 101
Joined: Sat May 28, 2016 7:01 pm

Re: Interest Check in Android/iOS Remote for MicroPython Devices

Post by pidou46 » Fri Apr 06, 2018 9:17 am

Hi,

Here is screenshoots of my proof of concept app running on Windows 7 and Android.

If somebody is interested I can share the code, but it's almost an empty shell, only the kv file have a small interest.

In current state it connect to an ESP server via socket, but as the server is blocking waiting for connection, it's completly useless.

The next step is to mature the server side (ESP) with asynchronious communication with websocket, then the server could do it's main task(s) and in the same time communicate with the GUI app, then we get something quite usefull and convenient.

I given a try to mqtt, it’s a nice protocol when the ESP device is integrated into a local Wifi network where you can make the broker running on an always running server. But if you want to build something stand alone, it’s less nice because it’s a three players protocol : you need a broker and I haven’t found a broker running on ESP (I think it’s a little bit overkill for those tiny devices)
Attachments
uPyEspGUI_Android.png
uPyEspGUI_Android.png (62.6 KiB) Viewed 6390 times
uPyEspGUI.png
uPyEspGUI.png (26.54 KiB) Viewed 6390 times
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Interest Check in Android/iOS Remote for MicroPython Devices

Post by kevinkk525 » Fri Apr 06, 2018 4:34 pm

There are Apps that provide an mqtt broker (haven't tested it yet). Then the ESP would not need to be programmed differently than in your local network where it could be controlled by mqtt.

If you use uasyncio instead of normal sockets you don't have any blocking problem. The other possibility is to use the sockets in a non-blocking way and check for new data often enough.


There are a few apps for android for controlling ESP devices. I did not test any but I think it's important to get together and build an app on top of a common base (like mqtt, maybe by including mqtt server into the app) so we don't just add another app that needs a custom implementation on the ESP. I'd prefer to keep the programming of my ESP similar if using in network or controlling by an app. Making it different is just another possibility for errors and you always have to develop different versions of your code. If another way of communications is needed then I'd prefer to make it as a replaceable module to mqtt so all other packages basically still use the same API as with mqtt.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Interest Check in Android/iOS Remote for MicroPython Devices

Post by OutoftheBOTS_ » Fri Apr 06, 2018 9:03 pm

Were u guys thinking something like this https://www.esp8266basic.com/ but more for the ESP32 and in python instead of basic

Post Reply