How potential buyers could insert WIFI-parameters
-
Hi there,
we want to develop an iot-device and made our first tries with the GPY. They run ok.
One Problem what we are thinking about ist how a potential buyer, who has no ecperience with programming and u-controller stuff, will be able to insert his wifi- information into our script on the Pycom-board.We want to send the sensor-data by using MQTT. So we need connection to the internet over the wifi the customer has.
Does anyone have experience in the field? Is there a solution?
We thought of programming a mobilephone-app where you can insert this information and sending them via bluetooth to the Board. Ist this possible?
But this would be a great effort.
Does this maybe work with ne Pymate-app(Unfortunately not available for GPY)?Thanks
Andy -
Hi @andy_n,
We've been successful with this flow:
- GPy first boots in "setup mode": WiFi is in WLAN.AP with your product name as SSID
- Setup mode also starts a small micro webserver
- Users connects phone/computer to this setup SSID and opens browser to 192.168.4.1 for example
- Micro webserver scans for nearby WiFi networks and shows webpage with this list for user to select
- Corresponding WiFi password is also requested
- The SSID and Password are recorded and GPy re-initializes into main script using the new stored settings.
Bluetooth is another option but as you say you'd need to write mobile apps to support it. We don't yet have a generic app that works for this.
-
@jmarcelino Sounds interesting. Any chance for the code? ;o)
-
Sure I'll get this up ASAP.
-
@jmarcelino Thank you!
-
Hi @jmarcelino I' m developping an NFC interface with the NTAG I2C from NXP, so you can transfer the necessary informations with your phone.
-
@jiemde
i don’t think that strategy works with iPhones -
Hi @jmarcelino I thing that the new Iphone have NFC ( from NXP )
-
Hi @jmarcelino after some investigations they can read but no write NFC tag, so you're right. But it's work with Androïd without problem
-
@jmarcelino Great! I'm trying the same but I'm really novice here.. keep us posted ;)
-
I have a method that works really well, i enable bluetooth and use a standard BLE scanner app to update the wifi credentials..works really well and can share code if you like.
-
Hi @misterlisty, That can be an other way, can you also send more informations than the wifi credential ? like the Lora or Sigfox informations ?
If you could share your code I would like to test it.
Best regards Jiemde -
picotui might me another option:
https://pypi.python.org/pypi/picotui/1.0I don't have personal experience yet, however I will probably use it in my products.
-
Hi @jmarcelino,
I was thinkinkg about doing something similar as your flow, but I am having trouble to implement a micro webserver (I'm using a standard LoPy, not LoPy4). Are you capable of process GET or POST requests on your device? Any suggestion on how can I manage that?
Thanks in advance.
-
You can run a http server on the device (a good example can be found here: http://docs.micropython.org/en/v1.9.2/esp8266/esp8266/tutorial/network_tcp.html), the sockets available in micropython work just like regular sockets on Windows/Linux and you can read/write the raw GET and POST requests like strings.
-
Hi @lsoria
There's a fantastic web server already for MicroPython by Jean-Christophe Bos. Check out https://github.com/jczic/MicroWebSrv
Works perfectly on our boards.
-
Hi @jmarcelino, thank you for your reply. The troubles I have experienced were because of that repository. It seems really great because of the functionalities ot offers, but unfortunately I wasn't able to run even the example it provides. It always fails to import MicroWebSrv (even if I copy all the files to the LoPy flash). Mi theory is that my device runs out of memory, but I cannot prove it since I don't have a LoPy4 (and there is not stock nowadays, at least in Mouser). If you want I'll post the Terminal output after I run the script, to see what it throws. Perhaps there is something more I could have missed.
Actually my attempts to embed a webserver are based on the link that @seb sent. I made a rudimentary function to process GET request, but I am not having luck at detecting POST requests. But I would like to use something more "correct" and standard.
-
@lsoria
If you could post the whole error message you get, we can help you get it working. Did you copy the library intolib/microWebSrv.py.py? -
Hi @seb, here there are the captures from the filezilla client:

On the left side there is the folder clonned from the repo. on the righht side the root folder of the device. I've copied microWebSocket.py, microWebSrv.py and microWebTemplate.py inside lib/ folder as it follows:

Then I go to Visual Studio Code, and run main.py. The first time throws this message:

And the second time this:

If I check the available memory I get values similar to this:

Am I following the right steps? Or my LoPy is really out of memory?
Thank you in advance, and sorry if I'm distorting the meaning of this thread.
-
The first error is caused by your module running out of RAM, try minimising how much HTML you are presenting to lower the memory requirements.
Secondly can share your
main.pycode so I can check what you are trying to run.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login