I want to use Raspberry Pis to communicate collected Data via Python (Modbus TCP and RTU) scripts to a Database. These scripts are constantly running on the Pi and are connected to the Products where the data is coming from.
Consequently, we have to ship the already set up Raspberry Pi to the Customer. Now the Problem occurs, that the Database Credentials are stored in the Python Scripts running on the Raspberry Pi.
Is there a possibility to overcome this Problem?
Naive solution: Store database credentials on your server (or somewhere on internet) so every time Raspberry Pi run the script, it connect to the server to get the credentials first.
My recommended solution: Create an API (may be web API) to communicate with database and Rasp Pi only work with this API. By this way, the client side doesn't know about database's credentials and some private things you want to hide also.
Related
I have a router that makes it extremely difficult to run port-forwarding through it. Plus, I would rather be able to just pretty much plug my Pi in and have my server running. Setting up a Raspberry Pi as a wireless access point is pretty easy and straight forward. I would like to have a python server, which runs on the same Raspberry Pi, that allows me to run a public server off of the access point. So basically instead of having to use port forwarding with my router, the server made with sockets in python uses the access point to be public. is this something that sounds possible?
update This is NOT for local use, I want it to be a server that I could connect to states away
I have a node.js server running on a Raspberry Pi 3 B+. (I'm using node because I need the capabilities of a bluetooth library that works well).
Once the node server picks up a message from a bluetooth device, I want it to fire off an event/command/call to a different python script running on the same device.
What is the best way to do this? I've looked into spawning child processes and running the script in them, but that seems messy... Additionally, should I set up a socket between them and stream data through it? I imagine this is done often, what is the consensus solution?
Running a child process is how you would run a python script. That's how you do it from nodejs or any other program (besides a python program).
There are dozens of options for communicating between the python script and the nodejs program. The simplest would be stdin/stdout which are automatically set up for you when you create the child process, but you could also give the nodejs app a local http server that the python script could communicate with or vice versa.
Or, set up a regular socket between the two.
If, as you now indicate in a comment, your python script is already running, then you may want to use a local http server in the nodejs app and the python script can just send an http request to that local http server whenever it has some data it wants to pass to the nodejs app. Or, if you primarily want data to flow the opposite direction, you can put the http server in the python app and have the nodejs server send data to the python app.
If you want good bidirectional capabilities, then you could also set up a socket.io connection between the two and then you can easily send messages either way at any time.
I'm currently working on a project that requires me to control a step motor using a raspberry pi. I finished the motor control part of the raspberry pi, but I am not really sure on how to continue on the tcp/ip connection part of the project.
I am meaning to connect a client through the tcp/ip connection and letting the client upload a code that lets the client control the motor, in which there should already be custom commands implemented (e.g. "clockwise ": turns the motor a number of steps clockwise. "set 1": sets the gpio pin to 1, and etc.)
I apologize because my knowledge in raspberry pi and tcp/ip connections are really limited.
Can someone point me a way in the right direction? Thanks in advance.
If you are looking for a scripting solution you can do TCP/IP part using ssh. Client can use ssh to log into the RPi and run the commands. It can use scp for pushing updated code/script.
For automating you can look into Pexpect that lets you script your steps.
I want to receive data into a local web server that I have created using Raspberry Pi. It is not connected to the internet. I want to know if it is possible to receive data from an application on a Windows PC that sends via TCP protocol. The web server is an Apache server. I can specify the web server address and port number in the application that sends the data.
I am a newbee to this and I just know what tcp, http etc means. I do not know them in detail so I am finding it hard to understand related articles on the internet. Can someone please help me with some code snippets on how to set the web server in raspberry pi so that I can receive the data? Either display it on the web server page or extract the data somewhere using Python or C#. I am also open to using a Raspberry Pi with Windows IoT image instead of Jessie to do the same.
With Windows IoT you can start with Hello blinky sample that create a simple Web Server in Python.
Also, restup create a Web server in C# you can reference. This is the tutorial help you set up the code lines. I test TCP packets receiving on Raspberry Pi 3 with this web server, it works.
Hope it is helpful for you.
We have implemented a simple DynamoDB database that is updated by a remote IoT device that does not have a user (i.e. root) constantly logged in to the device. We have experience issues in logging data as the database is not updated if a user (i.e. root) is not logged into the device (we log in via a ssh session). We are confident that the process is running in the background as we are using a Linux service that runs on bootup to execute a script. We have verified that the script runs on bootup and successfully pushes data to Dynamo upon user log in (via ssh). We have also tried to disassociate a screen session to allow for the device to publish data to Dynamo but this did not seem to fix the issue. Has anyone else experienced this issue? Does amazon AWS require a user (i.e. root) to be logged in to the device at all times in order to allow for data to be published to AWS?
No, it does not. I have done similar setup and it is working fine. Are you sure that your IoT device does not go into some kind of sleep mode after a while ?