sharkyenergy
sharkyenergy

Reputation: 4173

send data from a local PC with php to a online php webpage

Following situation: a RaspberryPI is in the local network, and has a webserver on it. it contains a local webpage where the user has to log in.

This local Raspberry is connected to a sensor that reads data. Additionally the user can make some changes to the local page's settings.

When done there is a button, the user clicks and the data is transfered from the local PI to the online webserver. Obviously only if he is logged in. (Online and local have the same accounts)

problems:

Upvotes: 0

Views: 345

Answers (1)

soulseekah
soulseekah

Reputation: 9162

After a lengthy chat it became clear that the Pi devices would need to be accessed by clients using a smartphone or a web-browser.

Each Pi device would have a set of settings, and be able to read GPIO data. Each device would have to be secure (with authentication and authorization). There are several options to go about this, but using a central relay server offers a lot of advantages.

Basically, a relay server (remote, shared by everyone in the system) would maintain a list of Pi devices along with their UUIDs and owners, employees, permissions. Once booted up the device would make a persistent connection over to the server using TCP, identify itself, and be able to send and receive data (configuration, sensor data). Look into Twisted, 0MQ (zeromq), and other TCP server/client stacks.

Clients would be able to use the relay server by logging in, and reading/writing (depending on permissions) to their Pi devices. Registering devices would be simple, by adding their UUID the relay server knows who it belongs to. Discarding devices due to theft, etc. (by the way, since the Pi will contact the server, if it's reported as stolen, it can relay its IP and other data when it comes online again).

Use properly configured SSL to secure your connections.

Advantages of this approach:

  1. Works without a NAT, no need for unique IPs per device.
  2. Simple UUID-based configuration, without addresses, etc.
  3. Centralized data, secure (if properly configured)

Disadvantages:

  1. Internet connection is a must.
  2. More work required to implement than a simple decentralized stack

Upvotes: 1

Related Questions