2

I have 2 arduino pro minis sending data to my Raspberry Pi. But in order to do that I need to run the script by typing it on my Raspberry.

How can I make Raspberry run that scrpit from another device via internet?

They will not be in the same LAN or anything. I'll send the command it will run the necessary script. I don't know much about Raspberry please answer as simple as possible.

3 Answers 3

3

You can use SSH, port forwarding, and dynamic dns to acomplish this.

SSH

This gives you a 'remote command line' from any other machine to your Raspberry Pi. Read more here : https://www.raspberrypi.org/documentation/remote-access/ssh/

Port Forwarding

It is likely that your router will block incoming connections from other internet connected machines (outside your home/local network). So to allow thew connections to come in you'll likely have to configure your router to allow connections (either from a known set of IP addresses, or to a specific port - in the case of SSH that will be port 22). Essentially you'll need to tell the router that any requests it receives on port 22 should be handled by the Raspberry Pi so send those requests over to the Raspberry Pis IP address. Read more on this here : https://www.raspberrypi.org/documentation/remote-access/access-over-Internet/README.md

Dynamic DNS

Each time your router connects to the internet it gets an IP address, the address it gets usually changes semi regularly, so you cannot always be sure you should be using the same IP address. To get around this you use Dynamic DNS - this lets you configure a fully qualified domain name (FQDN, for example mypi.example.com or kenspi1.dyndns.com) and has your router (or Pi) update the domain name with the correct IP address regularly. Now, instead of have to SSH to a different IP address each time you just SSH to the fully qualified domain name.

There are lots of tutorials on each of these, and in all there (because it's a common questions/request)

1
0

what KennetRunner was writing is right. Your Router needs to have port forwarding configured and if you do not own a static IP address you have to signed up to a dyndns service.

I personally would not use SSH, I like SSL/TLS more. I've just finished a project where it is possible to communicate with an an Android app or Client PC to a Raspberry pi via SSL/TLS. An the Raspberry pi there is a Python SSL Server running. This Server can call other scripts/commands. These calls don't have to programmed these only have to be configured in a specific file. The commands how can call these scripts/commands on the raspberry can also be configured for the Android app. If you are interested look at http://iot4pi.github.io/SSLPi/ (Server – for the Raspberry pi ) and the client at http://iot4pi.github.io/SSLPiclient/.

0

I think that your question and thus the existing answers address only part of the problem you have.

I have 2 arduino pro minis sending data to my Raspberry Pi. But in order to do that I need to run the script by typing it on my Raspberry.

To me it sounds that you intend the setup of Pi and Arduinos to automatically work no matter what, e.g. after powering it up. In this case you certainly do not want to manually log into the Pi and start a script following the procedure KennetRunner has described. Instead you would want the Pi to automatically restart the script. (It goes without saying that the access provided by SSH and dyndns has still its merits as it allows access for maintenance. So this is not about either ... or but both ... and.)

To automatically start/restart scripts various techniques are described. I found supervisord an easy to configure tool to achieve this. Besides starting processes on reboot it also monitors them and restarts them if they crash.

See also: Start and run a Python script at boot and use Cron to make sure its still alive

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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