0

I am building a few RPi with temperature sensors and they are all connected to the same lan by ethernet. Raspberry Pi 1 has address 172.10.16.1 Raspberry Pi 2 has address 172.10.16.2 Raspberry Pi 3 has address 172.10.16.3

The web server with a LAMP stack has IP address of 172.10.16.0 (I am inventing the IPs for explanation purpose).

How would I be able to log the data to the web server with a SQL statement from all RPis? For now I tried with one RPi that is running the server on localhost, but I would like for the server to be run on a machine different from the raspberry pi(s) and have the RPis log data to the database in SQL.

Any ideas? :)

asked Sep 21, 2016 at 13:19
6
  • which SQL server are you running? MySQL? Commented Sep 21, 2016 at 13:32
  • Yes, I installed the LAMP stack and MySQL Commented Sep 21, 2016 at 13:33
  • You need to decide on architecture first - either: 1) install a MySQL client on each Raspberry Pi and have them make run code insert the data on the remote MySQL server, or 2) send the (raw) data from the Raspberry Pis with temp sensors to the Raspberry Pi with the MySQL (for example you could use HTTP to pass the data, or MQTT, etc) and have the MySQL done by the receiving code on the DB Pi. Latter would be my preference... Commented Sep 21, 2016 at 13:56
  • @KennetRunner but this way could I just write 172.10.16.0 on a web browser from a PC connected to the same network and see the php page that has all the logs sent from the RPi(s)? Because for now I was using a simple localhost but I need all RPi(s) to be able to send data over to the 172.10.16.0 Commented Sep 21, 2016 at 14:01
  • Yes, (with either option) you could connect to a web page on the DB Server Pi and see data. BTW using .0 for the last octet of an IP address is not usually recommended - see this: serverfault.com/questions/10985/is-x-y-z-0-a-valid-ip-address Commented Sep 21, 2016 at 14:35

1 Answer 1

0

As long as the Raspberry Pi(s) are on the same private network (172, 10, 192), there are no problems between them sharing data. I had to grant privileges to private IPs from the network for them to be able to write data to the MySQL database and I did that by modifying the my.cnf file in /etc/mysql

Also, to try and ping the different Raspberry Pi(s) I had to give permission with chmod s+u aswell on each device that wanted to ping.

Thanks for your help guys!

answered Sep 23, 2016 at 13:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.