diff --git a/boards/default_src/micropython/origin/build/lib/gnss.py b/boards/default_src/micropython/origin/build/lib/gnss.py index dd4786c3..a9395dc3 100644 --- a/boards/default_src/micropython/origin/build/lib/gnss.py +++ b/boards/default_src/micropython/origin/build/lib/gnss.py @@ -14,7 +14,7 @@ class NMEA0183: self._uart.init(baudrate=baudrate, timeout=timeout, rxbuf=1024) self.time=[None, None, None, None, None, None] self.locate=['', None, '', None, None, None, None] #0'1经度,2'3纬度,4海拔m,5速度m/s,6航向° - self.status=[False, ' ', 0] #有效标注,定位模式,卫星量 + self.status=[False, ' ', 0] #有效标注,定位模式,卫星量 if not self._chip_id(): raise AttributeError("Cannot find a GNSS device") @@ -29,11 +29,11 @@ class NMEA0183: for _ in range(10): sleep_ms(300) if self.any(): - self._uart.write(("$PCAS02,1000*2E\r\n").encode()) #更新频率1HZ + self._uart.write(("$PCAS02,1000*2E\r\n").encode()) #更新频率1HZ self._uart.write("$PCAS03,1,0,0,0,1,0,0,0,0,0,,,0,0*02\r\n".encode()) #只加载GNGGA和GNRMC return True - def _judge(self, buffer, dlen): + def _judge(self, buffer, dlen): try: data=buffer.strip().decode().split(',') if len(data) == dlen: diff --git a/boards/default_src/micropython/origin/build/lib/sht20.py b/boards/default_src/micropython/origin/build/lib/sht20.py new file mode 100644 index 00000000..28a4ab89 --- /dev/null +++ b/boards/default_src/micropython/origin/build/lib/sht20.py @@ -0,0 +1,31 @@ +from struct import unpack as unp +from time import sleep_ms + +# SHT20 default address +SHT20_I2CADDR = 64 +TRI_T_MEASURE_NO_HOLD = b'\xf3' +TRI_RH_MEASURE_NO_HOLD = b'\xf5' +READ_USER_REG = b'\xe7' +WRITE_USER_REG = b'\xe6' +SOFT_RESET = b'\xfe' + +class SHT20(object): + def __init__(self, i2c_bus): + self._address = SHT20_I2CADDR + self._bus = i2c_bus + + def get_SHT_temperature(self): + self._bus.writeto(self._address, TRI_T_MEASURE_NO_HOLD) + sleep_ms(150) + origin_data = self._bus.readfrom(self._address, 2) + origin_value = unp('>h', origin_data)[0] + value = -46.85 + 175.72 * (origin_value / 65536) + return value + + def get_SHT_relative_humidity(self): + self._bus.writeto(self._address, TRI_RH_MEASURE_NO_HOLD) + sleep_ms(150) + origin_data = self._bus.readfrom(self._address, 2) + origin_value = unp('>H', origin_data)[0] + value = -6 + 125 * (origin_value / 65536) + return value diff --git a/boards/default_src/micropython/origin/build/lib/ucs12071.py b/boards/default_src/micropython/origin/build/lib/ucs12071.py index ddca328d..303b94ef 100644 --- a/boards/default_src/micropython/origin/build/lib/ucs12071.py +++ b/boards/default_src/micropython/origin/build/lib/ucs12071.py @@ -17,7 +17,7 @@ UCS_CLS_DATA = const(0x1C) _GAINS_X = (1, 4, 8, 32, 96, 192) -class UCS1207: +class UCS12071: def __init__(self, i2c_bus, addr=0x38, gain=2): self._device = i2c_bus self._address = addr