-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPWRPi.py3
66 lines (47 loc) · 1.96 KB
/
PWRPi.py3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from datetime import datetime
from datetime import date
from time import sleep
import numpy as np
import influxdb_client, os, time
from influxdb_client import InfluxDBClient, Point, WritePrecision
from influxdb_client.client.write_api import SYNCHRONOUS
import board
import busio
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# declaring some important variables
i2c = busio.I2C(board.SCL, board.SDA)
ads = ADS.ADS1115(i2c, data_rate = 8, address = 0x49)
dataCh0 = []
dataCh1 = []
dataCh2 = []
dataCh3 = []
timeCh0 = []
timeCh1 = []
timeCh2 = []
timeCh3 = []
initial_t = time.time()
today = date.today()
tooltip_logo = 'Developed by Bruno Gelli, Aug 2022.\nMore information at github.com/BrunoGelli/PWR32'
# token = os.environ.get("INFLUXDB_TOKEN")
# org = "3b837ab9c3c4b3e7"
# url = "http://reines.ifi.unicamp.br:8086"
# bucket="evaporadora"
# client = influxdb_client.InfluxDBClient(url=url, token=token, org=org)
# write_api =client.write_api(write_options=SYNCHRONOUS)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#functions
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# layout
ads.gain = 16
print("Here we will list the properties of the ADC")
print(" -> The possible data rates are: " + str(ads.rates))
print(" This device is currently set to: " + str(ads.data_rate) + " samples per second.")
print(" -> The dinamic range of this device is: " + str(ads.bits) + " bits.")
print(" -> The possible gains of this device are: " + str(ads.gains))
print(" This device is currently set to: " + str(ads.gain) + "x.")
while True:
chan = AnalogIn(ads, ADS.P0, ADS.P1)
print(chan.value, chan.voltage)
pass