from influxdb import InfluxDBClient as influx import requests as rq import json from time import sleep as t cliente = influx(database='covid') while 1: h = rq.get( "https://api.thingspeak.com/channels/1113372/feeds.json?results=2") j = json.loads(h.content) temp = j['feeds'][0]['field1'] data = [] data.append("paciente,tag=0 val={}".format(temp)) cliente.write_points(data, database='', time_precision='s', protocol='line') print(temp, hum) t(2)
from influxdb import InfluxDBClient as influx import Adafruit_DHT as dht from time import sleep as t sensor = dht.DHT11 pin = 2 cliente = influx(database='dht11') while 1: humedad, temperatura = dht.read_retry(sensor, pin) if humedad is not None and temperatura is not None: print("""temp={0}°C humedad={1}%""".format(temperatura, humedad)) data = [] data.append("temperatura,tag1=2 temp={}".format(temperatura)) data1 = [] data1.append("humedad,tag2=2 hum={}".format(humedad)) cliente.write_points(data, database='dht11', time_precision='s', protocol='line') cliente.write_points(data1, database='dht11', time_precision='s', protocol='line') t(3)
from influxdb import InfluxDBClient as influx from statsmodels.tsa.arima_model import ARIMA from sklearn.metrics import mean_squared_error if __name__ == '__main__': opts, args = getopt.getopt(sys.argv[1:], 'hn:', ['help', 'sessionId=']) print(opts, args) # if len(args) == 0: # sys.exit() # sessionId = args[0] sessionId = "2fe617b1-8b98-4a12-bb0d-083b777d00b7" client = influx(host='localhost', port=8086) data_influx = client.query( "SELECT band7 from autogen.band_power_rel WHERE sessionId = '" + sessionId + "' ORDER BY DESC LIMIT 250 OFFSET 0", database='vr_data_test') points = data_influx.get_points() analog_list = [] time_list = [] for p in points: analog_list.append(p['band7']) yourdate = dateutil.parser.parse(p['time']) yourtime = yourdate.timestamp() time_list.append(yourtime) analog_list.reverse() time_list.reverse() data = np.array(analog_list)
from influxdb import InfluxDBClient as influx import requests as rq from time import sleep import json cliente = influx(database='PACIENTE') while 1: h=rq.get("https://api.thingspeak.com/channels/1191468/fields/1.json?api_key=3AC5EMFTJ4ZDXNFD&results=2")//OBTENER DATOS DE THINGSPEACK j=json.loads(h.content) temperatura=j["feeds"][1]["field1"] print(temperatura) data = [] data.append("sensor,tag=0 lm35={}".format(temperatura)) cliente.write_points(data, database='PACIENTE', time_precision='s', protocol='line') r = requests.get('https://maker.ifttt.com/trigger/sensor/with/key/cilbQn9_ISfxSloSJd2qe0PBo-kAtx0HCw1cjOo2c8B', params={"value1":temperatura}) sleep(30)
from w1thermsensor import W1ThermSensor as ds from time import sleep as t from influxdb import InfluxDBClient as influx from gpiozero import LED i = 1 m = 1 led = LED(18) cliente = influx(database='rack') def ds18b20(): s1 = ds(ds.THERM_SENSOR_DS18B20, "030897943b31") s2 = ds(ds.THERM_SENSOR_DS18B20, "03ff979418c9") s3 = ds(ds.THERM_SENSOR_DS18B20, "0417c45487ff") t3 = float(s1.get_temperature()) t2 = float(s2.get_temperature()) t1 = float(s3.get_temperature()) data1 = [] data2 = [] data3 = [] data1.append("ds18b20,tag=1 temp={}".format(t1)) cliente.write_points(data1, database='rack', time_precision='s', protocol='line') data2.append("ds18b20,tag=2 temp={}".format(t2)) cliente.write_points(data2, database='rack', time_precision='s', protocol='line')