Changeset - 94cab616b578
[Not reviewed]
default
0 0 1
matthewreed - 9 years ago 2016-07-14 16:58:15

Added data simulation and influxdb logging script
1 file changed with 40 insertions and 0 deletions:
0 comments (0 inline, 0 general)
hydrobot_data_test.py
Show inline comments
 
new file 100644
 
import time
 
import random
 
from influxdb import InfluxDBClient
 
 
temp = 65.5
 
humid = 0.50
 
press = 950
 
 
while True:
 
    
 
    temp = random.randint(-1, 1)/2 + temp
 
    humid = random.randint(-1, 1)/100 + humid
 
    press = random.randint(-1, 1) + press
 
    
 
    json_body = [
 
        {
 
            "measurement": "air_temp",
 
            "fields": {
 
                "value": temp
 
            }
 
        },
 
        {
 
            "measurement": "air_humidity",
 
            "fields": {
 
                "value": humid
 
            }
 
        },
 
        {
 
            "measurement": "air_pressure",
 
            "fields": {
 
                "value": press
 
            }
 
        }
 
    ]
 
 
    client = InfluxDBClient("www.protofusion.org", 8086, 'admin', 'admin', 'hydrobot')
 
    client.write_points(json_body)
 
    print("yes!")
 
    
 
    time.sleep(60)
 
\ No newline at end of file
0 comments (0 inline, 0 general)