RPi3, Flask and ds18b20 temperature sensor.

If I understand your question correctly, your sensor is properly integrated with a python program to read sensor data and you just want to a way to post it to a web server/store it. Assuming you're okay with using just a basic communication protocol HTTP here's how it would go:

  1. flask program listening for get/post requests, you can do with it what you want from here. (store it in a db, display it in a web app, etc)

    from Flask import flask,request

    app = Flask(name) @app.route("/postTemperature", methods=['POST']) def getTemperature(): temperatureData = request.get_json() temperature = temperatureData["temperature"] return "got a temperature reading of %s" %(temperature)

    if name == 'main': app.run()

  2. python program to read sensor data and post it to our server

    import requests

    After reading data

    sensorData = { "temperature": 25.8 }

    post request

    temperatureRequest = requests.post("http://localhost:{your_port}/postTemperature", json = sensorData)

    print server response, make sure everything worked properly

    print temperatureRequest

Let me know if this was the info you were looking for. I'd be happy to answer any further questions you might have :)

/r/flask Thread