Sending data from raspberry pi to webserver - python

I have built a weather station using a raspberry pi and arduino and get readings every 10 minutes. I have built a code that saves all the readings locally in a database (mariadb) and in excel.
I have also built a webserver (using apache) on a separate raspberry pi to host a website. I have used simple scripts (html, css and php) to start building the website, but at the moment it is very basic and its only dynamic property is displaying the time. I have also installed mariadb on the webserver in case the database is required here. My goal would be to send the data from the Weather Station to the Website, but I am pretty new to this and not sure how to begin. I would appreciate any help/direction you can give me.
At the moment I have tried looking at different sources / similar projects, but I have failed to get a comprehensive list of suggestions.

Related

Send Data between EV3 and PC

I am programming a roboter, and it needs to send data between the EV3 and my laptop (Windows)
I run pybricks on the EV3, which enables me to code in python.
I already did research, but the only things that are remaining are some blogs from 2014 that don't help either.. the only thing that helped a little was the official documentation of pybrick.
I thought that running the example code on the EV3 and laptop would work, but the code only worked on the EV3. The EV3 waits until getting a message, but the laptop instantly says connected, even tough it isn't.
I thought it is maybe possible to get the laptop to act like an EV3 to connect them (because the original message function for EV3 is only made for interaction between different bricks), but my knowledge kinda ends here, even tough I tried a few things, like a virtual box.. maybe I did something wrong, but I hadn't had good results
If I understand correctly, you want to,
send a value to a remote machine
have the remote machine do some stuff
get a response from the remote machine
If that is correct, this is normally achieved by API. The remote machine serves an API, which the client calls using the requests library. For example, TheCatAPI allows you to call for pictures of cats. Your laptop and EV3 are still logically distinct, even though they are physically nearby.
You can choose to host the API on your laptop or make it available to others using services like AWS. Avoiding copypasta, Real Python has some fantastic docs on how to build an API.
You will want to connect your EV3 to WiFi then tell it to call your new API. If you set this up in AWS lambda, others will be able to do the same and it will probably be free for you.
If you want to do it purely locally, you will need to connect your EV3 and laptop via Bluetooth and establish a serial link.
Personal opinion
I would suggest that showcasing your ability to create an API and get it working on AWS would be more beneficial than going down the Bluetooth route.

Is there a way to connect to a bluetooth device by a django web app (so with python)?

I a personal project I was able to connect via Bluetooth to a device that measure body temperature with some python libraries.
I want to implement this code in a Django web app to collect data from these Bluetooth devices, is this possible?
Can you suggest me, if is it possible, how can I get this work in Django?
Thanks in advance,
Marco

How to run an android device application by inputting values from outside application using python

I am working on a module where I need to automate an application in an Android Device using Python. But here is a challenge that I am facing is that the application has visualization part which is a Machine movement. To move the machine, I need to give the inputs from another external application which has fields like North,East,Elevation etc. These values are taken from that external application and Machine gets moved in the android device.
My thoughts are like to use module
import subprocess
Can some one suggest me if my idea is correct or any other procedures to ahead....I got struck.
Till now no coding has been done and I need to project to convince the team first. We shouldn't use any APIs of the external application.

How to send data from Android/iOS app to a python script running on a raspberry pi using Bluetooth?

So me and my friend are working on this project where a raspberry pi with certain sensors collects some data and outputs it.
Now, we want certain parameters to be passed on runtime. So we were thinking of creating a react-native app which could connect with the Pi using Bluetooth. Once connected, it could then send the arguments over Bluetooth.
The python script would then intercept these arguments and then run its program and then send its output back to the app.
While searching for libraries to help me with this, I came across this library: https://github.com/Polidea/react-native-ble-plx
While going through the documentation, I came across https://github.com/Polidea/react-native-ble-plx/wiki/Characteristic-Writing, which seems to be the method used for writing some data and sending it.
In Bluetooth terms, what exactly are these services and characteristics and do I have to create my own service and characteristic while working on my project? Or can I write to any existing characteristic so that the python script can read that?
If I have wrongly understood certain concepts, please correct me. Also if there are any better ways to architect this approach please let me know
Currently, there is no official Expo Bluetooth API. I looked up the same library you are looking at and I find it a little complicated.
I found this link https://askubuntu.com/questions/838697/share-files-between-2-computers-via-bluetooth-from-terminal, where you could open up one terminal and use Bluetoothctl to connect to a specific device. Now, open up another terminal and use the bluetooth-sendto --device= MAC:ADDRESS (read that link) to send the file from Raspberry Pi to a phone (I tested on Android and it worked).
You could also send data from the phone to Raspberry Pi. Again, check out that link.

How can a desktop application installed on multiple PCs be synced?

We have developed a desktop application using Python. The scenario is:
An internet connection is not available.
The desktop application would be installed in multiple PCs
PC1 would enter data to a particular section (other PCs, (like PC2, PC3, etc.) can't input their respective sections unless PC1 enters their respective section).
When PC1 enters data on their section, we want it to be reflected on every other PC that has the desktop application installed.
How can we sync data within multiple desktop applications where there is no internet connectivity?
If we can achieve this using a local LAN, then how can we do this?
The most common solution would be to have one machine act as the server. Each other machine would pass its data back to the server machine over the local network. The other client machines would be notified by the server that changes had been made. The server would control and store all the data.
You could either write a separate server application to run on a completely different machine, or you could have one of your client machines act as the 'host' and take on the server role itself.
Alternatively, you could work on a peer-to-peer solution, where each machine has a separate but synchronised copy of the data. That sounds harder to get right, to me.
One of the answers at Python Library/Framework for writing P2P applications recommends the Twisted framework for network applications.

Categories