Ejemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     super(ConnectBot, self).__init__(*args, **kwargs)
     self.credentials = credentials
     r.set_loop_type('gevent')
     self.rethink = r.connect(host=self.credentials['rethink_db']['ip'], port=self.credentials['rethink_db']['port'],
                              password=self.credentials['rethink_db']['password'], db='connect')
     self.connect_py = connect.Client()
     self.up_time = datetime.datetime.utcnow()
     self.process = psutil.Process()
Ejemplo n.º 2
0
 def setUp(self):
     self.connect = connect.Client()
Ejemplo n.º 3
0
import time
import connect
from decimal import Decimal
from datetime import datetime, timedelta, timezone
from lcd_i2c import LcdSerialDisplay
from ADC import ADC
import json
import time

arn = "arn:aws:iot:us-east-1:422446087002:thing/EMonPi"
print("Connecting IoT client")
# Retry forever so that if connect fails app will retry
while True:
    try:
        client = connect.Client(arn)
        rate = Decimal('0.1326')/Decimal(1000) # 13 cents per KWh

        try:
            with ADC(gain=2/3) as adc:

                #print('Reading ADS1x15 values, press Ctrl-C to quit...')
                # Print nice channel column headers.
                #print('| {0:>9} | {1:>9} | {2:>9} | {3:>9} |'.format(*range(4)))
                #print('-' * 49)

                
                with LcdSerialDisplay() as display:
                    # Take a reading each second - at the next minute, average and send to cloud
                    currentReadings = []
                    prevMinute = ""
                    print("Starting main loop")