3

I've got 2 Raspberry Pi's:

  • 1 with a LAN cable, which serves as a webserver
  • 1 with WIFI connected to a circuit, that notices when a circuit is open. (basically a simple alarm)

I want to send data from the second one to the first when the circuit opens and make it visible on the website.

How could I do that?

2
  • Why not run the web server directly on the one that has the detection circuit?
    – Ron Beyer
    Commented Aug 22, 2016 at 20:08
  • For several reasons: 1. I installed OwnCloud on the pi and it's connected to an HDD 2. It's wired, so the connection is way more stable 3. The cables look quite ugly beside the door ^^ Commented Aug 22, 2016 at 20:15

2 Answers 2

4

As a beginner it may seem a bit taunting on how to actually transfer data, or how to ask the correct question on how to do it. The reason is because there are so many ways to do.

A popular way to be run a simple webserver on your "server". You can choose any language you like to run this simple webserver, python, node.js or C# MVC with API.

On the node, all you need to do is call the webserver on the specific URL.

You may want to use a WebAPI approach to make things simpler.

Server                                        Nodes
http://pi/alarm/on   <---WebRequest----<      Make a webrequest
http://pi/alarm/off  <---WebRequest----<      Make a webrequest   

The code behind the server and the nodes is up to you. Pick a language you would like to learn, Python being the best documented with samples for Rasbpain and C# for IoT - With tons of documentation and examples too.

Once you learn the basics, you can add data to a request. Like the name of the node, timestamps, or even post photos/video as binary.

2
  • Ok thanks, just curious: Would it also be possible to make an entry in the MySQL database of the first Pi when the door opens/the circuit opens WITHOUT having a webserver running on the second Pi? Commented Aug 22, 2016 at 22:00
  • Yea, you can run whatever you like or can on the Pi. MySQL, SQLite is good, NoSQL maybe? MySQL is a bit heavy but it will go no problem
    – Piotr Kula
    Commented Aug 22, 2016 at 22:24
1

There are dozens of ways of doing what you want. Only you can tell which are acceptable.

One possibility is to use my pigpio library.

You can write a script on the first Pi to control the GPIO on the second Pi.

The script on the first Pi can be conveniently written in Python or C.

The second Pi needs to be running the pigpio daemon.

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.