Exemple #1
0
def get_moisture():
  i2c = i2c_bus.easyI2C(i2c_bus.PORTA, 0x36)
  i2c.write_u8(0x0f, 0x10)
  wait_ms(5)
  val = i2c.read(2)
  val = ustruct.unpack(">H", val)[0]
  return int(val)
ERR = const(2)

# ATOM PORT IO
RS485_UART = (1, 22, 19)  # TX,RX
IIC_PORTA = (26, 32)  # I2C grove port for 16BV demo
unit.PORTA = (
    26, 32
)  # seems used in the unit init!unit.get(unit.RFID, unit.PORTA) # fit ATOM?
#i2c0  = i2c_bus.easyI2C((25, 21), 0x28)
print('< Intelligent 16-BV connector with RS485 Port & NFC program v1.5b >' +
      "\r\n")
print('< Author: Ling.Zell, [email protected], 13.July.2020 >' + "\r\n")
print('#-->:i2c_bus.easyI2C(PORTA, 0x28, freq=100000)')
print('#-->:RS485_UART: TX_G22,RX_G19@ 115200')
#print('#-->: i2c_bus.easyI2C(i2c_bus.PORTA, 0x28, freq=400000)')
i2c0 = i2c_bus.easyI2C(IIC_PORTA, 0x28, freq=100000)

#sys vars
run_cnt = None
#RFID vars
RFID_ID = None
TAG_Reg0 = None
TAG_near = None


# Top Btn to write tag, send 485 test only
def buttonA_wasPressed():
    #global cntNone
    global RFID_ID, TAG_Reg0, TAG_near
    stat = None
    rgb.setBrightness(20)
Exemple #3
0
                          "23.4",
                          lcd.FONT_DejaVu40,
                          0xFFFFFF,
                          rotate=0)
s_temp_min = M5TextBox(25, 130, "12.3", lcd.FONT_DejaVu24, 0xD0D0D0, rotate=0)
s_humidity = M5TextBox(25, 170, "12", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label5 = M5TextBox(100, 170, "%", lcd.FONT_Default, 0xFFFFFF, rotate=0)
s_pressure = M5TextBox(25, 200, "1234", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label4 = M5TextBox(85, 200, "hPa", lcd.FONT_Default, 0xFFFFFF, rotate=0)

# temperature inside
s_temp_in = M5TextBox(200, 90, "12.3", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
s_hum_in = M5TextBox(200, 170, "12", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label1 = M5TextBox(260, 170, "%", lcd.FONT_Default, 0xFFFFFF, rotate=0)

i2c0 = i2c_bus.easyI2C(i2c_bus.PORTA, 0x5c)
dht12 = DHT12(i2c0.i2c)


def read_dht12():
    global dht12
    try:
        dht12.measure()
        h = dht12.humidity()
        s_hum_in.setText(str(h))
        t = dht12.temperature()
        s_temp_in.setText(str(t))
    except:
        s_hum_in.setText("Error")
        s_temp_in.setText("Error")
Exemple #4
0
 def __init__(self, port, addr=0x61):
     self.addr = addr
     self.i2c = i2c_bus.easyI2C(port, self.addr)
     self._available()
Exemple #5
0
Vbus = 0
Current = 0
Power_INA = 0
T_LM75A = 0
T_LM75B = 0
TF1 = 0
TF2 = 0
SensorA_scan_cnt = 0
SensorB_scan_cnt = 0
INA_OK = False
LM75A1_OK = False
LM75A2_OK = False
sys_cnt = 0

#i2c0 = i2c_bus.easyI2C((26, 32), LM75_ADDRESS, freq=100000)
i2c0 = i2c_bus.easyI2C(IIC_PORTA, LM75_ADDRESS2, freq=100000)
LM75_sensor = LM75
Scan_EN = True
OUT_EN = True
while (Scan_EN):
    try:
        addrList = i2c0.scan()
        Dev_cnt = len(addrList)
        print('IIC scan results:')
        #print(addrList)
        #print("0x")
        for i in range(0, Dev_cnt, 1):
            print('0x' + '%2x%%' % ((addrList[i])))
            if (INA260_ADDRESS == addrList[i]):
                rgb.setColorAll(0xEEEEBB)
                print('>:INA260 detected!')
Exemple #6
0
#ATOM IIC scan demo
#11.Jan.2021
from m5stack import *
from m5ui import *
from uiflow import *
import i2c_bus
import time

#ATOM IIC scan demo
#11.Jan.2021
print('ATOM IIC scan demo v2.0')
addrList = None
Dev_cnt = 0

#i2c0 = i2c_bus.easyI2C(i2c_bus.PORTA, 0x68, freq=100000)
i2c0 = i2c_bus.easyI2C((26, 32), 0x68, freq=100000)
while 1:
    try:
        addrList = i2c0.scan()
        Dev_cnt = len(addrList)
        print('IIC scan results:')
        #print(addrList)
        #print("0x")
        for i in range(0, Dev_cnt, 1):
            print('0x' + '%2x%%' % ((addrList[i])))

        print('Total device:' + str(Dev_cnt))
        if (Dev_cnt > 0):
            rgb.setColorAll(0x03ff13)
        else:
            rgb.setColorAll(0x101000)
from m5stack import *
from m5ui import *
from uiflow import *
import wifiCfg
import ntptime
import i2c_bus
import unit

setScreenColor(0x222222)
color0 = unit.get(unit.COLOR, unit.PORTA)

distmm = None

wifiCfg.doConnect('Name', 'Password')
label2 = M5TextBox(92, 43, "D", lcd.FONT_DejaVu56, 0xFFFFFF, rotate=0)
time = M5TextBox(34, 152, "00:00:00", lcd.FONT_DejaVu56, 0xFFFFFF, rotate=0)

ntp = ntptime.client(host='de.pool.ntp.org', timezone=1)
speaker.tone(800, 200)
i2c0 = i2c_bus.easyI2C((21, 22), 0x52, freq=4000)
while True:
    i2c0.write_u8(0x52, 0x00)
    distmm = (i2c0.read_data(1, i2c_bus.INT16BE))[-1]
    label2.setText(str((str(distmm) + str('mm'))))
    label0.setText(str(ntp.formatTime(':')))
    wait_ms(2)
Exemple #8
0
from m5stack import *
from m5ui import *
from uiflow import *
import i2c_bus
import unit
#Connect this RFID Unit toSDA G25, SCL G21 on  ATOM , IIC adress is 0x28.

# ATOM PORT IO
PORTA = (25, 21)  # I2C
i2c0 = i2c_bus.easyI2C((25, 21), 0x28)

while 1:
    try:
        print(i2c0.scan())
        print(i2c0.available())
        i2c0.write_u8(0x01, 0xAA)
        rgb.setColorAll(0x001133)
        #rfid0 = unit.get(unit.RFID, unit.PORTA) # not fit to ATOM
        rfid0 = unit.get(unit.RFID, unit.PORTA)  # fit ATOM?
        #Connect this Unit to GROVE PORTA on M5Core, IIC adress is 0x28.
        #need improve for unit disconnected case
        print('RFID module is connected!' + "\r\n")
        break
    except:
        print(
            'RFID module was not detected! Please Check! Main code will not run!!!'
            + "\r\n")
        rgb.set_screen([
            0, 0, 0xFF0000, 0, 0, 0, 0xFFFFFF, 0, 0xFF0000, 0, 0xFFFFFF, 0,
            0xFF0000, 0, 0xFFFFFF, 0, 0xFF0000, 0, 0xFFFFFF, 0, 0, 0, 0xFF0000,
            0, 0
Exemple #9
0
        #raw = self._bus.read_word_data(self._address, LM75_TEMP_REGISTER) & 0xFFFF
        raw = self._bus.read_reg(LM75_TEMP_REGISTER, 2) & 0xFFFF
        #print "raw: "
        #print raw
        #raw = ((raw << 8) & 0xFF00) + (raw >> 8)
        return self.toFah(self.regdata2float(raw))


print('ATOM LM75 Temp measurement program v2.1')
print('Author: Zell, 12.Jan.2021')
tmp_str = None
T_LM75A = 0
T_LM75B = 0

#i2c0 = i2c_bus.easyI2C((26, 32), LM75_ADDRESS, freq=100000)
i2c0 = i2c_bus.easyI2C(IIC_PORTA, LM75_ADDRESS, freq=100000)
LM75_sensor = LM75
Scan_EN = True
OUT_EN = True
while (Scan_EN):
    try:
        addrList = i2c0.scan()
        Dev_cnt = len(addrList)
        print('IIC scan results:')
        #print(addrList)
        #print("0x")
        for i in range(0, Dev_cnt, 1):
            print('0x' + '%2x%%' % ((addrList[i])))

        print('Total device:' + str(Dev_cnt))
        if (Dev_cnt > 0):
Exemple #10
0
	def getTemp(self): #not working!
		"""Reads the temp from the LM75 sensor"""
		#raw = self._bus.read_word_data(self._address, LM75_TEMP_REGISTER) & 0xFFFF
		raw = self._bus.read_reg(LM75_TEMP_REGISTER,2) & 0xFFFF
		#print "raw: "
		#print raw
		#raw = ((raw << 8) & 0xFF00) + (raw >> 8)
		return self.toFah(self.regdata2float(raw))

print('ATOM LM75 Temp measurement program v1.1')
print('Author: Zell, 12.Jan.2021')
tmp_str = None
T_LM75A = 0;
T_LM75B = 0;

i2c0 = i2c_bus.easyI2C((26, 32), LM75_ADDRESS, freq=100000)
LM75_sensor = LM75
Scan_EN = True
while (Scan_EN):
    try :
      addrList = i2c0.scan()
      Dev_cnt=len(addrList)
      print('IIC scan results:')
      #print(addrList)
      #print("0x")
      for i in range(0, Dev_cnt, 1):
        print('0x'+'%2x%%'%((addrList[i])))
        
      print('Total device:'+str(Dev_cnt))
      if (Dev_cnt>0):
        rgb.setColorAll(0x03ff13)