@Lazar-Demin I checked this morning and it seemed to be working. I was looking for the sensor chart.
Frank Wiebenga
@Frank Wiebenga
Best posts made by Frank Wiebenga
-
RE: Available Apps Spinning
-
Beginner Sensor Data Chart
Hello guys, I'm new here and wanted to share a simple little start to hopefully a bigger project. This is a great start to getting used to Python and MongoDB.
Whoever wrote the starter documentation, THANK YOU! I used that here.
Requirements: Install python3-light, pip3, flask, flask-restful on the Omega. Install plotly and pymongo on the client.
The code that runs on the Omega is under
App
directory. This is a ultra simple flask api that reads the temperature. You can configure this to run on boot by addingpython3 /App/App.py
to/etc/rc.local
.You will need another computer running MongoDB. Using the other computer you can request the temp and store the data using the
App.py
script found inClient
folder. Using theGraph.py
script will generate a cool little graph.
Probably don't need 1 second intervals, but this was a really fun and cool way to get started with python. Google truly was my friend and I hope some else looking to use a DS18B20 sensor finds this useful.
Latest posts made by Frank Wiebenga
-
RE: Building API in Python
I did a very simple api here http://community.onion.io/topic/3219/beginner-sensor-data-chart
-
RE: Beginner Sensor Data Chart
@Lazar-Demin Yes the GPIO 0 was plugged into the SSR 3-32V+ and the ground was plugged into the SSR -
There was nothing connected to the SSR load side during my test.
-
RE: Beginner Sensor Data Chart
I think I broke it
I soldered up a prototype board using the same wiring diagram for the DS18B20 probe. I was dinking around with it this morning and wanted to add a SSR. I saw that tutorial on the LED control. I didn't think I needed a resistor in place because the SSR isn't voltage specific like an led is so I connected the SSR 3-32VDC to 3.3v + and ground to -. I confirmed I was able to get requests and update the GPIO value. Here is a video of it in action
from flask import Flask from flask import jsonify from flask import abort import time import datetime import onionGpio from temperatureSensor import TemperatureSensor import oneWire app = Flask(__name__) # setup onewire and polling interval oneWireGpio = 19 # set the sensor GPIO pollingInterval = 1 # seconds # Define SSR gpio0 = onionGpio.OnionGpio(0) # set to output direction with zero (LOW) being the default value gpio0.setOutputDirection(0) #Define our data structure config = [ { 'id': '1', 'name': 'Mash Heater', 'gpio': 0, 'IsOn': False }, { 'id': '2', 'name': 'Boil Heater', 'gpio': 1, 'IsOn': False } ] def start_sensor(): # check if 1-Wire is setup in the kernel if not oneWire.setupOneWire(str(oneWireGpio)): print("Kernel module could not be inserted. Please reboot and try again.") return -1 # get the address of the temperature sensor sensorAddress = oneWire.scanOneAddress() # instantiate the temperature sensor object sensor = TemperatureSensor("oneWire", {"address": sensorAddress, "gpio": oneWireGpio}) if not sensor.ready: print("Sensor was not set up correctly. Please make sure that your sensor is firmly connected to the GPIO specified above and try again.") return -1 return sensor sensor = start_sensor() def get_temp(): value = sensor.readValue() return value @app.route('/') def hello_world(): tempval = get_temp() return jsonify( temp=tempval, datetime=datetime.datetime.now() ) @app.route('/heat/<heat_id>', methods=['GET']) def heat_get(heat_id): task = [task for task in config if task['id'] == heat_id] if len(task) == 0: abort(404) return jsonify({'heat': task[0]}) @app.route('/heat/<heat_id>', methods=['PUT']) def heat_post(heat_id): task = [task for task in config if task['id'] == heat_id] if len(task) == 0: abort(404) print(task[0]) # Toggle bool task[0]['IsOn'] = not task[0]['IsOn'] if task[0]['IsOn'] is True: gpio0.setValue(1) else: gpio0.setValue(0) return jsonify({'heat': task[0]}) if __name__ == "__main__": app.run(host="0.0.0.0", port="8080")
However after 167 requests it stopped working. I did get data up until it stopped. Now my Omega2 won't boot, it just gets really really warm. Even with nothing plugged into the usb dock the Omega2 get's so hot you wouldn't want to touch it with your hand. Did I break it for good? What did I connect wrong?
-
Beginner Sensor Data Chart
Hello guys, I'm new here and wanted to share a simple little start to hopefully a bigger project. This is a great start to getting used to Python and MongoDB.
Whoever wrote the starter documentation, THANK YOU! I used that here.
Requirements: Install python3-light, pip3, flask, flask-restful on the Omega. Install plotly and pymongo on the client.
The code that runs on the Omega is under
App
directory. This is a ultra simple flask api that reads the temperature. You can configure this to run on boot by addingpython3 /App/App.py
to/etc/rc.local
.You will need another computer running MongoDB. Using the other computer you can request the temp and store the data using the
App.py
script found inClient
folder. Using theGraph.py
script will generate a cool little graph.
Probably don't need 1 second intervals, but this was a really fun and cool way to get started with python. Google truly was my friend and I hope some else looking to use a DS18B20 sensor finds this useful.
-
RE: Available Apps Spinning
@Lazar-Demin I checked this morning and it seemed to be working. I was looking for the sensor chart.
-
RE: [Project] Temperature controlled chest freezer
Very nice, I'm planning something similar for a herms system. If I may suggest some improvements to your script.
- Add a timeout. Cycling the compressor too often without time in between will shorten the life of your fridge/freezer.
- Have you looked at PID control? Perhaps this could be integrated: https://github.com/ivmech/ivPID
Great start!