0

I've been working on a project where I need an app I made to be able to get scripts to run on my Raspberry Pi. The problem is I need it to work so that if anyone had the app and my pre-configured Pi they could get the scripts to run.

So far the best way I've come up with to do this is to get the Pi to run a script when it's powered on so that it creates its own wireless network, which the user can then connect to on their phone. Now that they are on the same network, the user can give the app their wifi name and password which can be sent to the Pi over SSH. The Pi can then login to the user's home wifi network and the user can reconnect to it on their phone. At this point, the Pi can start up an Apache web server which can accept requests from the app and run the scripts on the Pi.

This way seems overly-complicated to me, and if there's any easier way to just get the app to send requests to the Pi without having to plug in a keyboard and monitor into the Pi (bluetooth?), then I'd really appreciate it if you could help me.

1
  • Why connect the Pi to the local WiFi when the phone is connected to the Pi? Other ways I can think off are serial, USB, Bluetooth or even NFC. I'm voting to close as this is very vague as we do not know your restrictions or app needs.
    – user115418
    Oct 24 '20 at 1:26
2

The problem that you have is that you need some basic information on you Pi, namely the SSID and a pre-shared key. There are a number of options, beside your solution.

  • connect the Pi via Ethernet the first time. The Pi will probably get its IP via DHCP and you can service a web-page that allows the user to provide WiFi data. This also provides your user with the option to let the Pi connected (and not use WiFi at all).
  • Some access points have a WPS-button. Your Pi can be made to use this, but not all access points have such a button.
  • Bluetooth is an option; but the app would probably need some initial way of connecting too. My experiences with bluetooth on the Pi are not good, but YMMV.
  • NFC requires some additional hardware, but can be made very user-friendly.
  • You could connect your phone to USB for the initial set-up. That may be through a terminal-like app on the phone or allow the Pi to access a specific file on the phone.

So, there are plenty of options.

There are a number of points to consider:

  • How safe is it? What prevents another person to take the Pi over?
  • What happens if I change my SSID from welcome to keepout?
  • What if I change my PSK?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.