So I have a Raspberry Pi Model 3B+ that currently runs a script to collect temperature, humidity, and pressure values. How would I send these values from the Pi to my PC and then have my PC read the values and store them say every 60 seconds?
My end goal is to: Read data on Pi ==> Send data to PC ==> Send Data to Database ==> Display on website updating every 60s
I currently have this code on my Pi:
import bme680
import time
import socket
import sys
from struct import pack
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
host, port = '?????', 65000
server_address = (host, port)
try:
sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY)
except (RuntimeError, IOError):
sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY)
sensor.set_humidity_oversample(bme680.OS_2X)
sensor.set_pressure_oversample(bme680.OS_4X)
sensor.set_temperature_oversample(bme680,OS_8X)
sensor.set_filter(bme680.FILTER_SIZE_3)
print('Polling:')
try:
while True:
if sensor.get_sensor_data():
output = '{0:.2f} C,{1:.2f} hPa,{2:.3f} %RH'.format(
sensor.data.temperature,
sensor.data.pressure,
sensor.data.humidity)
print(output)
time.sleep(60)
except KeyboardInterrupt:
pass
This reads data and displays it fine... However, I want to send this data to my PC so that my PC can read the values and send them to a database etc.
Which IP would I send to and any other help would be greatly appreciated!!