├── .gitignore ├── 1.BLE ├── README.md └── TLS01 │ ├── README.md │ ├── Wire(接线图) │ ├── WeBee TLS-02.png │ └── Wire.jpg │ ├── main.py │ └── tls01.py ├── 2.WiFi └── README.md ├── 3.ZigBee └── README.md ├── 4.LORA ├── E22-400T22S │ ├── README.md │ ├── Wire(接线图) │ │ ├── E22-400T22S.jpg │ │ └── Wire.jpg │ ├── lora.py │ └── main.py └── README.md ├── 5.NBIOT └── README.md ├── 6.4G └── README.md ├── 7.GPS(北斗) ├── ATGM336H │ ├── README.md │ ├── Wire(接线图) │ │ ├── Result.png │ │ └── Wire.jpg │ └── main.py └── README.md ├── LICENSE ├── Partner ├── EBYTE.png ├── WeBee.png └── 杭州中科微.png └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /1.BLE/README.md: -------------------------------------------------------------------------------- 1 | # BLE 2 | MicroPython for BLE UART Modules. -------------------------------------------------------------------------------- /1.BLE/TLS01/README.md: -------------------------------------------------------------------------------- 1 | # TLS-01 2 | 3 | 说明:模块厂商 WeBee,型号:TLS-01,购买链接:https://item.taobao.com/item.htm?id=621274021271 4 | 5 | 出厂参数:广播名称:BLE SPS; 波特率:9600; 广播间隔:100ms 6 | ![WeBee TLS-01](https://github.com/01studio-lab/MicroPython-Examples/blob/master/1.pyBoard%20v1.1(STM32)/4.%E7%89%A9%E8%81%94%E7%BD%91%E6%A8%A1%E5%9D%97/1.%E8%93%9D%E7%89%99(BLE)/TLS-02/Wire%20picture/WeBee%20TLS-02.png) 7 | ![Wire](https://github.com/01studio-lab/MicroPython-Examples/blob/master/1.pyBoard%20v1.1(STM32)/4.%E7%89%A9%E8%81%94%E7%BD%91%E6%A8%A1%E5%9D%97/1.%E8%93%9D%E7%89%99(BLE)/TLS-02/Wire%20picture/Wire.jpg) 8 | 9 | ## 构造对象 10 | ` ` ` 11 | from tls01 import TLS01 12 | ` ` ` 13 | 14 | ` ` ` 15 | BLE= TLS01(3,9600) #构造蓝牙对象,pyboard串口号,波特率9600 16 | ` ` ` 17 | 18 | ## 使用方法 19 | ### 查看广播名字 20 | ` ` ` 21 | BLE.Name_Check() 22 | ` ` ` 23 | ### 设置广播名字 24 | ` ` ` 25 | BLE.Name_Set("01Studio") #设置成01Studio 26 | ` ` ` 27 | 28 | ### 查看广播间隔,单位ms 29 | ` ` ` 30 | BLE.BI_Check() 31 | ` ` ` 32 | ### 设置广播间隔,单位ms 33 | ` ` ` 34 | BLE.BI_Set(200) 35 | ` ` ` 36 | 37 | ### 查看波特率 38 | ` ` ` 39 | BLE.Baudrate_Check() 40 | ` ` ` 41 | ### 设置波特率 42 | ` ` ` 43 | BLE.Baudrate_Set(9600) #设置完成后需要复位,以及重置开发板UART波特率 44 | ` ` ` 45 | ### 模块复位 46 | ` ` ` 47 | BLE.RST() #复位后需要延时600ms等待重新启动 48 | ` ` ` 49 | 50 | ### 模块重置,恢复出厂设置 51 | ` ` ` 52 | BLE.RESET() #模块重置后会自动复位,复位后需要延时600ms等待重新启动 53 | ` ` ` 54 | 55 | -------------------------------------------------------------------------------- /1.BLE/TLS01/Wire(接线图)/WeBee TLS-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/01studio-lab/pyIOT/8db96e3940ae657d18badd195dcb622fcc753a0e/1.BLE/TLS01/Wire(接线图)/WeBee TLS-02.png -------------------------------------------------------------------------------- /1.BLE/TLS01/Wire(接线图)/Wire.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/01studio-lab/pyIOT/8db96e3940ae657d18badd195dcb622fcc753a0e/1.BLE/TLS01/Wire(接线图)/Wire.jpg -------------------------------------------------------------------------------- /1.BLE/TLS01/main.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 实验名称:串口蓝牙模块通信(WeBee TLS-02 BLE模块) 3 | 版本:v1.0 4 | 日期:2020-4-10 5 | 作者:01Studio 6 | 说明:通过编程实现串口通信,跟电脑串口助手实现数据收发。 7 | ''' 8 | 9 | #导入串口模块 10 | from tls01 import TLS01 11 | import time 12 | 13 | #构建蓝牙模块对象(串口) 14 | BLE=TLS01(3,9600) #设置串口号3和波特率,TX--Y9,RX--Y10 15 | 16 | ###############信息透传################ 17 | BLE.uart.write('Hello 01Studio!')#发送一条数据 18 | 19 | #接收信息 20 | while True: 21 | if BLE.uart.any(): #查询是否有信息 22 | text = BLE.uart.read(128) #默认单次最多接收128字节''' 23 | print(text) 24 | 25 | #查看广播名字 26 | #print(BLE.Name_Check()) 27 | 28 | #查看广播间隔,ms 29 | #print(BLE.BI_Check()) 30 | 31 | #查看模块波特率 32 | #print(BLE.Baudrate_Check()) 33 | 34 | #设置名字 35 | #print(BLE.Name_Set("01Studio")) 36 | 37 | #设置广播间隔,单位ms 38 | #BLE.BI_Set(200) 39 | 40 | #设置波特率,设置完成后需要复位,以及重置开发板UART波特率 41 | #BLE.Baudrate_Set(9600) 42 | 43 | #模块复位 44 | #BLE.RST() 45 | 46 | #模块重置,重置完会自动复位,复位后延时 47 | #BLE.RESET() 48 | #time.sleep_ms(600) 49 | -------------------------------------------------------------------------------- /1.BLE/TLS01/tls01.py: -------------------------------------------------------------------------------- 1 | # use WeBee TLS-01 BLE Module 2 | 3 | from machine import UART 4 | 5 | class TLS01(): 6 | def __init__(self, uart=3, baud_rate=9600): 7 | self.uart = UART(uart, baud_rate) 8 | 9 | ################################ 10 | ########### 参数查看 ############ 11 | ################################ 12 | 13 | #查看模块名字,返回字符 14 | def Name_Check(self): 15 | name_check="AT+NAME" 16 | self.uart.write(name_check) 17 | while not self.uart.any(): 18 | pass 19 | return self.uart.read(128).strip() #strip()去掉\r\n 20 | 21 | #查看模块广播间隔,返回int 22 | def BI_Check(self): 23 | BI_check="AT+ADV" 24 | self.uart.write(BI_check) 25 | while not self.uart.any(): 26 | pass 27 | return int(self.uart.read(128).strip())*0.625 #例 160*0.625=100ms 28 | 29 | #查看模块波特率 30 | def Baudrate_Check(self): 31 | Baudrate_check="AT+UART" 32 | self.uart.write(Baudrate_check)#发送一条数据 33 | while not self.uart.any(): 34 | pass 35 | return int(self.uart.read(128).strip()) 36 | 37 | 38 | ############################ 39 | ######## 参数设置 ########### 40 | ############################ 41 | 42 | #设置模块名字,例如 name='01Studio',18byte以内 43 | def Name_Set(self,name): 44 | 45 | name_set="AT+NAME="+name 46 | print(name_set) 47 | self.uart.write(name_set)#发送一条数据 48 | while not self.uart.any(): 49 | pass 50 | return self.uart.read(128).strip() 51 | 52 | #设置广播间隔,例BI=200 ,单位ms,广播间隔越大,功耗越低,出厂默认100ms 53 | def BI_Set(self,BI): 54 | 55 | BI_set="AT+ADV="+str(int(BI/0.625)) 56 | self.uart.write(BI_set)#发送一条数据 57 | while not self.uart.any(): 58 | pass 59 | return self.uart.read(128).strip() 60 | 61 | #设置波特率,设置完后修改开发板波特率以适应;默认出厂是9600 62 | def Baudrate_Set(self,Baudrate): 63 | 64 | Baudrate_set="AT+UART="+str(Baudrate) 65 | self.uart.write(Baudrate_set)#发送一条数据 66 | while not self.uart.any(): 67 | pass 68 | return self.uart.read(128).strip() 69 | 70 | #重启,复位 71 | def RST(self): 72 | rst="AT+RST" 73 | self.uart.write(rst)#发送一条数据 74 | while not self.uart.any(): 75 | pass 76 | return self.uart.read(128).strip() 77 | 78 | #恢复出厂设置 79 | def RESET(self): 80 | 81 | reset="AT+RESTORE" 82 | self.uart.write(reset)#发送一条数据 83 | while not self.uart.any(): 84 | pass 85 | return self.uart.read(128).strip() 86 | -------------------------------------------------------------------------------- /2.WiFi/README.md: -------------------------------------------------------------------------------- 1 | # WiFi 2 | MicroPython for WiFi UART Modules. 3 | -------------------------------------------------------------------------------- /3.ZigBee/README.md: -------------------------------------------------------------------------------- 1 | # ZigBee 2 | MicroPython for ZigBee UART Modules. 3 | -------------------------------------------------------------------------------- /4.LORA/E22-400T22S/README.md: -------------------------------------------------------------------------------- 1 | # E22-400T22S 2 | 3 | 说明:模块厂商 EBYTE,型号:E22-400T22S,购买链接:https://item.taobao.com/item.htm?id=621274729063 4 | 5 | 出厂参数:工作方式:透传; 波特率:9600 6 | 7 | ## 构造对象 8 | ` ` ` 9 | from lora import E22_400T22S 10 | ` ` ` 11 | 12 | ` ` ` 13 | #构建Lora对象,pybaord串口3,波特率9600, M0和M1为工作模式 14 | Lora=E22_400T22S(3,9600,M0='Y3',M1='Y4') 15 | 16 | ` ` ` 17 | 18 | ## 使用方法 19 | ### 工作模式 20 | ` ` ` 21 | #工作模式 0:一般模式;1:WOR模式; 2:配置模式;3:深度睡眠模式。 22 | Lora.work_mode(0) #设置工作模式为模式0 23 | ` ` ` 24 | 25 | ### 发送数据 26 | ` ` ` 27 | Lora.uart.write('Hello 01Studio!') #发送数据 28 | ` ` ` 29 | ### 接收数据 30 | ` ` ` 31 | Lora.uart.read(512) #接收数据,最多512字节 32 | ` ` ` 33 | 34 | ### 查看模块地址 35 | ` ` ` 36 | Lora.Add_Check() 37 | ` ` ` 38 | ### 设置模块地址 39 | ` ` ` 40 | Lora.Add_Set(ADDH=0x00,ADDL=0x02) #ADDH:高字节;ADDL:低字节 41 | ` ` ` 42 | 43 | ### 查看网络地址 NetID 44 | ` ` ` 45 | Lora.NetID_Check() 46 | ` ` ` 47 | ### 设置网络地址 NetID 48 | ` ` ` 49 | Lora.NetID_Set(NETID=0x00) 50 | ` ` ` 51 | 52 | ### 查看信道 53 | ` ` ` 54 | Lora.Channel_Check() 55 | ` ` ` 56 | ### 设置信道 57 | ` ` ` 58 | Lora.Channel_Set(CH=0x17) #配置信道,0-83,实际频率=410.125+CH*1M, 默认0x17即23 59 | ` ` ` 60 | 61 | ### 查看传输方式 62 | ` ` ` 63 | #查看透明传输:0x03;定点传输:0x43;中继传输:0x63(中继默认和定点传输搭配); 64 | Lora.Transfer_Check() 65 | ` ` ` 66 | ### 设置传输方式 67 | ` ` ` 68 | #设置传输方式,透明传输:0x03;定点传输:0x43;中继传输:0x63(中继默认和定点传输搭配); 69 | Lora.Transfer_Set(MODE=0x43) 70 | ` ` ` 71 | 72 | ### 查看波特率 73 | ` ` ` 74 | #查看波特率,9600:0x62; 115200:0xE3; 75 | Lora.Baudrate_Check() 76 | ` ` ` 77 | ### 设置波特率 78 | ` ` ` 79 | #设置波特率,9600:0x62; 115200:0xE2;设置完后记得修改开发板波特率以适应 80 | Lora.Baudrate_Set(MODE=0x62) 81 | ` ` ` 82 | 83 | ### 模块重置,恢复出厂设置 84 | ` ` ` 85 | Lora.RESET() 86 | ` ` ` 87 | 88 | -------------------------------------------------------------------------------- /4.LORA/E22-400T22S/Wire(接线图)/E22-400T22S.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/01studio-lab/pyIOT/8db96e3940ae657d18badd195dcb622fcc753a0e/4.LORA/E22-400T22S/Wire(接线图)/E22-400T22S.jpg -------------------------------------------------------------------------------- /4.LORA/E22-400T22S/Wire(接线图)/Wire.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/01studio-lab/pyIOT/8db96e3940ae657d18badd195dcb622fcc753a0e/4.LORA/E22-400T22S/Wire(接线图)/Wire.jpg -------------------------------------------------------------------------------- /4.LORA/E22-400T22S/lora.py: -------------------------------------------------------------------------------- 1 | # use EBYTE E22-400T22S uart lora Module 2 | 3 | from machine import UART,Pin 4 | import time,struct 5 | 6 | class E22_400T22S(): 7 | def __init__(self, uart=3, baud_rate=9600,M0='Y3',M1='Y4'): 8 | self.uart = UART(uart, baud_rate) 9 | self.M0=Pin(M0,Pin.OUT,value=0) 10 | self.M1=Pin(M1,Pin.OUT,value=0) 11 | 12 | 13 | #工作模式 0:一般模式;1:WOR模式; 2:配置模式;3:深度睡眠模式。 14 | def work_mode(self,mode): 15 | 16 | if 0<= mode <= 3: 17 | self.M1.value(int(mode/2)) 18 | self.M0.value(int(mode%2)) 19 | time.sleep_ms(50) 20 | 21 | ################################ 22 | ########### 参数查看 ############ 23 | ################################ 24 | 25 | #查看模块地址 26 | def Add_Check(self): 27 | 28 | self.work_mode(2) #配置模式 29 | 30 | Add_Check=[0xC1,0x00,0x02] 31 | Add_Check_hex=struct.pack("%dB"%(len(Add_Check)),*Add_Check) 32 | self.uart.write(Add_Check_hex)#发送一条数据 33 | while not self.uart.any(): 34 | pass 35 | 36 | self.work_mode(0) #恢复一般模式 37 | 38 | return self.uart.read(128) 39 | 40 | #查看网络ID 41 | def NetID_Check(self): 42 | 43 | self.work_mode(2) #配置模式 44 | 45 | NetID_Check=[0xC1,0x02,0x01] 46 | NetID_Check_hex=struct.pack("%dB"%(len(NetID_Check)),*NetID_Check) 47 | self.uart.write(NetID_Check_hex)#发送一条数据 48 | while not self.uart.any(): 49 | pass 50 | 51 | self.work_mode(0) #恢复一般模式 52 | 53 | return self.uart.read(128) 54 | 55 | #查看信道 56 | def Channel_Check(self): 57 | 58 | self.work_mode(2) #配置模式 59 | 60 | Channel_Check=[0xC1,0x05,0x01] 61 | Channel_Check_hex=struct.pack("%dB"%(len(Channel_Check)),*Channel_Check) 62 | self.uart.write(Channel_Check_hex)#发送一条数据 63 | while not self.uart.any(): 64 | pass 65 | 66 | self.work_mode(0) #恢复一般模式 67 | 68 | return self.uart.read(128) 69 | 70 | #查看传输方式,透明传输:0x03;定点传输:0x43;中继传输:0x63(中继默认和定点传输搭配); 71 | def Transfer_Check(self): 72 | 73 | self.work_mode(2) #配置模式 74 | 75 | Transfer_Check=[0xC1,0x06,0x01] 76 | Transfer_Check_hex=struct.pack("%dB"%(len(Transfer_Check)),*Transfer_Check) 77 | self.uart.write(Transfer_Check_hex)#发送一条数据 78 | while not self.uart.any(): 79 | pass 80 | 81 | self.work_mode(0) #恢复一般模式 82 | 83 | return self.uart.read(128) 84 | 85 | #查看波特率,9600:0x62; 115200:0xE3; 86 | def Baudrate_Check(self): 87 | 88 | self.work_mode(2) #配置模式 89 | 90 | Baudrate_Check=[0xC1,0x03,0x01] 91 | Baudrate_Check_hex=struct.pack("%dB"%(len(Baudrate_Check)),*Baudrate_Check) 92 | self.uart.write(Baudrate_Check_hex)#发送一条数据 93 | while not self.uart.any(): 94 | pass 95 | 96 | self.work_mode(0) #恢复一般模式 97 | 98 | return self.uart.read(128) 99 | 100 | 101 | #查看模块全部参数 102 | def Module_Check(self): 103 | 104 | self.work_mode(2) #配置模式 105 | 106 | Module_Check=[0xC1,0x00,0x09] 107 | Module_Check_hex=struct.pack("%dB"%(len(Module_Check)),*Module_Check) 108 | self.uart.write(Module_Check_hex)#发送一条数据 109 | while not self.uart.any(): 110 | pass 111 | 112 | self.work_mode(0) #恢复一般模式 113 | 114 | return self.uart.read(128) 115 | 116 | 117 | ############################ 118 | ######## 参数设置 ########### 119 | ############################ 120 | 121 | #设置模块地址 122 | def Add_Set(self,ADDH=0x00,ADDL=0x00): 123 | 124 | self.work_mode(2) #配置模式 125 | 126 | Add_Set=[0xC0,0x00,0x02,ADDH,ADDL] 127 | Add_Set_hex=struct.pack("%dB"%(len(Add_Set)),*Add_Set) 128 | self.uart.write(Add_Set_hex)#发送一条数据 129 | while not self.uart.any(): 130 | pass 131 | 132 | self.work_mode(0) #恢复一般模式 133 | 134 | return self.uart.read(128) 135 | 136 | #设置网络地址,NetID 137 | def NetID_Set(self,NETID=0x00): 138 | 139 | self.work_mode(2) #配置模式 140 | 141 | NetID_Set=[0xC0,0x02,0x01,NETID] 142 | NetID_Set_hex=struct.pack("%dB"%(len(NetID_Set)),*NetID_Set) 143 | self.uart.write(NetID_Set_hex)#发送一条数据 144 | while not self.uart.any(): 145 | pass 146 | 147 | self.work_mode(0) #恢复一般模式 148 | 149 | return self.uart.read(128) 150 | 151 | #设置信道,0-83,实际频率=410.125+CH*1M 152 | def Channel_Set(self,CH=0x17): 153 | 154 | self.work_mode(2) #配置模式 155 | 156 | Channel_Set=[0xC0,0x05,0x01,CH] 157 | Channel_Set_hex=struct.pack("%dB"%(len(Channel_Set)),*Channel_Set) 158 | self.uart.write(Channel_Set_hex)#发送一条数据 159 | while not self.uart.any(): 160 | pass 161 | 162 | self.work_mode(0) #恢复一般模式 163 | 164 | return self.uart.read(128) 165 | 166 | #设置传输方式,透明传输:0x03;定点传输:0x43;中继传输:0x63(中继默认和定点传输搭配); 167 | def Transfer_Set(self,MODE=0x03): 168 | 169 | self.work_mode(2) #配置模式 170 | 171 | Transfer_Set=[0xC0,0x06,0x01,MODE] 172 | Transfer_Set_hex=struct.pack("%dB"%(len(Transfer_Set)),*Transfer_Set) 173 | self.uart.write(Transfer_Set_hex)#发送一条数据 174 | while not self.uart.any(): 175 | pass 176 | 177 | self.work_mode(0) #恢复一般模式 178 | 179 | return self.uart.read(128) 180 | 181 | #设置波特率,9600:0x62; 115200:0xE3; 182 | def Baudrate_Set(self,MODE=0x62): 183 | 184 | self.work_mode(2) #配置模式 185 | 186 | Baudrate_Set=[0xC0,0x03,0x01,MODE] 187 | Baudrate_Set_hex=struct.pack("%dB"%(len(Baudrate_Set)),*Baudrate_Set) 188 | self.uart.write(Baudrate_Set_hex)#发送一条数据 189 | while not self.uart.any(): 190 | pass 191 | 192 | self.work_mode(0) #恢复一般模式 193 | 194 | return self.uart.read(128) 195 | 196 | #恢复出厂设置 197 | #频率:433.125MHz;地址:0x0000;信道0x17;空中速率:2.4kbps;波特率:9600;串口格式:8N1;发射功率:22dbm 198 | def RESET(self): 199 | 200 | self.work_mode(2) #配置模式 201 | 202 | RESET=[0xC0,0x00,0x09,0x00,0x00,0x00,0x62,0x00,0x17,0x03,0x00,0x00] 203 | RESET_hex=struct.pack("%dB"%(len(RESET)),*RESET) 204 | self.uart.write(RESET_hex)#发送一条数据 205 | while not self.uart.any(): 206 | pass 207 | 208 | self.work_mode(0) #恢复一般模式 209 | 210 | return self.uart.read(128) 211 | -------------------------------------------------------------------------------- /4.LORA/E22-400T22S/main.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 实验名称:串口LORA模块通信(WeBee TLS-02 BLE模块) 3 | 版本:v1.0 4 | 日期:2020-5-27 5 | 作者:01Studio 6 | 说明:通过编程实现串口通信,跟电脑串口助手实现数据收发。 7 | ''' 8 | 9 | #导入串口模块 10 | from lora import E22_400T22S 11 | from machine import Pin 12 | import time 13 | 14 | #构建Lora模块对象(串口),M0&M1为GPIO配置工作模式 15 | Lora=E22_400T22S(3,9600,M0='Y3',M1='Y4') #设置串口号3和波特率,TX--Y9,RX--Y10 16 | 17 | ################################################ 18 | #####################数据收发#################### 19 | ################################################ 20 | 21 | #模式0,默认透传;工作模式 0:一般模式;1:WOR模式; 2:配置模式;3:深度睡眠模式。 22 | Lora.work_mode(0) 23 | 24 | ###############信息发送################ 25 | Lora.uart.write('Hello 01Studio!')#发送一条数据 26 | 27 | ###############信息接收################ 28 | while True: 29 | if Lora.uart.any(): #查询是否有信息 30 | text = Lora.uart.read(512) #默认单次最多接收128字节 31 | print(text) 32 | 33 | #################参数查看###################### 34 | 35 | #查看模块地址 36 | #print(Lora.Add_Check()) 37 | 38 | #查看网络地址 NetID 39 | #print(Lora.NetID_Check()) 40 | 41 | #查看信道 42 | #print(Lora.Channel_Check()) 43 | 44 | #查看传输方式,透明传输:0x03;定点传输:0x43;中继传输:0x63(中继默认和定点传输搭配); 45 | #print(Lora.Transfer_Check()) 46 | 47 | #查看波特率,9600:0x62; 115200:0xE3; 48 | #print(Lora.Baudrate_Check()) 49 | 50 | #查看模块全部参数 51 | #print(Lora.Module_Check()) 52 | 53 | #################参数设置###################### 54 | 55 | #配置模块地址,ADDH:高字节;ADDL:低字节 56 | #print(Lora.Add_Set(ADDH=0x00,ADDL=0x02)) 57 | 58 | #配置网络ID,NetID 59 | #print(Lora.NetID_Set(NETID=0x00)) 60 | 61 | #配置信道,0-83,实际频率=410.125+CH*1M, 默认0x17即23 62 | #print(Lora.Channel_Set(CH=0x17)) 63 | 64 | #设置传输方式,透明传输:0x03;定点传输:0x43;中继传输:0x63(中继默认和定点传输搭配); 65 | #print(Lora.Transfer_Set(MODE=0x43)) 66 | 67 | #设置波特率,9600:0x62; 115200:0xE2;设置完后需要修改开发板波特率以适应 68 | #print(Lora.Baudrate_Set(MODE=0x62)) 69 | 70 | #恢复出厂设置 71 | #print(Lora.RESET()) 72 | 73 | #查看传输方式,透明传输:0x03;定点传输:0x43;中继传输:0x63(中继默认和定点传输搭配); 74 | #print(Lora.Baudrate_Check()) 75 | -------------------------------------------------------------------------------- /4.LORA/README.md: -------------------------------------------------------------------------------- 1 | # LORA 2 | MicroPython for LORA UART Modules. 3 | -------------------------------------------------------------------------------- /5.NBIOT/README.md: -------------------------------------------------------------------------------- 1 | # NBIOT 2 | MicroPython for NBIOT UART Modules. 3 | -------------------------------------------------------------------------------- /6.4G/README.md: -------------------------------------------------------------------------------- 1 | # 4G 2 | MicroPython for 4G UART Modules. 3 | -------------------------------------------------------------------------------- /7.GPS(北斗)/ATGM336H/README.md: -------------------------------------------------------------------------------- 1 | # ATGM336H 2 | 3 | 说明:中科微电子 ,型号:ATGM336H,购买链接:https://item.taobao.com/item.htm?id=621817171984 4 | 5 | 出厂参数:波特率:9600; 6 | ![ATGM336H](https://github.com/01studio-lab/pyIOT/blob/master/7.GPS(%E5%8C%97%E6%96%97)/ATGM336H/Wire(%E6%8E%A5%E7%BA%BF%E5%9B%BE)/Result.png) 7 | ![Wire](https://github.com/01studio-lab/pyIOT/blob/master/7.GPS(%E5%8C%97%E6%96%97)/ATGM336H/Wire(%E6%8E%A5%E7%BA%BF%E5%9B%BE)/Wire.jpg) 8 | 9 | #GPS数据说明 10 | #消息ID:$GNGGA,双模GPS 11 | #[0]定位点UTC时间 12 | #[1]纬度 13 | #[2]纬度方向 14 | #[3]经度 15 | #[4]经度方向 16 | #[5]GPS定位状态 17 | #[6]卫星数量 18 | #[7]水平精度衰减因子 19 | #[8]海平面高度 20 | #[9]高度单位 21 | 22 | -------------------------------------------------------------------------------- /7.GPS(北斗)/ATGM336H/Wire(接线图)/Result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/01studio-lab/pyIOT/8db96e3940ae657d18badd195dcb622fcc753a0e/7.GPS(北斗)/ATGM336H/Wire(接线图)/Result.png -------------------------------------------------------------------------------- /7.GPS(北斗)/ATGM336H/Wire(接线图)/Wire.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/01studio-lab/pyIOT/8db96e3940ae657d18badd195dcb622fcc753a0e/7.GPS(北斗)/ATGM336H/Wire(接线图)/Wire.jpg -------------------------------------------------------------------------------- /7.GPS(北斗)/ATGM336H/main.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 实验名称:GPS模块(中科微 ATGM336H GPS模块) 3 | 版本:v1.0 4 | 日期:2020-5-20 5 | 作者:01Studio 6 | 说明:编程实现串口获取GPS数据并显示 7 | ''' 8 | 9 | #导入串口模块 10 | from machine import UART 11 | import time 12 | 13 | #GPS数据说明 14 | #消息ID:$GNGGA,双模GPS 15 | #[0]定位点UTC时间 16 | #[1]纬度[2]纬度方向[3]经度[4]经度方向 17 | #[5]GPS定位状态 18 | #[6]卫星数量 19 | #[7]水平精度衰减因子 20 | #[8]海平面高度[9]高度单位 21 | GPS_INFO=['','','','','','','','','','','','','',''] #14个数据 22 | k1='$GNGGA,' #关键词,双模GPS数据 23 | 24 | #构建蓝牙模块对象(串口) 25 | GPS=UART(3,9600) #设置串口号3和波特率,TX--Y9,RX--Y10 26 | 27 | #接收信息 28 | while True: 29 | 30 | if GPS.any(): #查询是否有信息 31 | text0 = GPS.read(1024) #默认单次最多接收128字节''' 32 | #print(text0) #原始数据 33 | 34 | text=str(text0) #将数据转成字符 35 | 36 | #找到双模定位 37 | if text.find(k1) != -1 : 38 | begin_num=text.find(k1)+7 #起始字符 39 | for i in range(14): 40 | while text[begin_num]!=',' : 41 | GPS_INFO[i] = GPS_INFO[i]+str(text[begin_num]) 42 | begin_num=begin_num+1 43 | begin_num=begin_num+1 44 | 45 | print(GPS_INFO) #双模GPS数据 46 | 47 | #时间 48 | time=GPS_INFO[0].split('.') 49 | hh=int(int(time[0])/10000)+8 #北京时间东八区 50 | mm=int(int(time[0])%10000/100) 51 | ss=int(int(time[0])%100) 52 | print('Time: '+str(hh)+':'+str(mm)+':'+str(ss)) 53 | 54 | #经纬度 55 | print(GPS_INFO[1]+' '+GPS_INFO[2]) 56 | print(GPS_INFO[3]+' '+GPS_INFO[4]) 57 | 58 | #定位状态,1为定位成功 59 | print('GPS State: '+GPS_INFO[5]) 60 | 61 | #卫星数量 62 | print('Satellites: '+GPS_INFO[6]) 63 | 64 | #水平精度衰减因子 65 | 66 | print('Horizontal precision attenuation factor: '+GPS_INFO[7]) 67 | 68 | #海拔高度 69 | print('altitude: '+GPS_INFO[8]+GPS_INFO[9]) 70 | 71 | #清空数据 72 | for i in range(14): 73 | GPS_INFO[i]='' 74 | 75 | -------------------------------------------------------------------------------- /7.GPS(北斗)/README.md: -------------------------------------------------------------------------------- 1 | # GPS(北斗) 2 | MicroPython for GPS/北斗 UART Modules. 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 01Studio 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Partner/EBYTE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/01studio-lab/pyIOT/8db96e3940ae657d18badd195dcb622fcc753a0e/Partner/EBYTE.png -------------------------------------------------------------------------------- /Partner/WeBee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/01studio-lab/pyIOT/8db96e3940ae657d18badd195dcb622fcc753a0e/Partner/WeBee.png -------------------------------------------------------------------------------- /Partner/杭州中科微.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/01studio-lab/pyIOT/8db96e3940ae657d18badd195dcb622fcc753a0e/Partner/杭州中科微.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pyIOT 2 | MicroPython for UART IOT Modules 3 | 4 | ## 项目简介 5 | Micropython是指使用python做各类嵌入式硬件设备编程。MicroPython发展势头强劲,但在IOT上支持的SOC芯片还不多, 6 | 而市面上已经拥有非常成熟的串口物联网模块,本项目旨在为市面上成熟的串口物联网模块开发micropython库,让用户可以快速 7 | 实现各类物联网相关应用。 8 | 本项目推荐使用MicroPython兼容性最好的pyboard(基于STM32)开发板。 9 | https://item.taobao.com/item.htm?&id=602426184690 10 | 11 | 12 | ## 代码贡献说明 13 | 项目预设WiFi、BLE、ZigBee、LORA、NBIOT、4G、GPS(北斗) 分类。请在对应分类新建代码,并以模块名称命名。为了保证项目的易用性,本项目代码贡献者必须要求指定格式,至少需包含以下文件: 14 | 15 | ### 1.example例程 16 | 如 main.py 17 | ### 2.py库文件 18 | 如 tls02.py 19 | ### 3.Wire接线图 20 | 模块接线说明 21 | ### 4.README文件 22 | 模块简介,购买链接,基于micropython的构造函数和使用方法。 23 | ### 5.其它 24 | 模块手册、特别说明等其它相关资料 25 | 26 | 请参考范例:https://github.com/01studio-lab/pyIOT/tree/master/BLE/TLS-02 27 | 28 | ## 合作伙伴 29 | 如果你的产品或者服务正在本项目被使用,请提交logo图片到主目录-Parter文件夹,图片宽度应小于300像素。 30 | ![WeBee](https://github.com/01studio-lab/pyIOT/blob/master/Partner/WeBee.png) 31 | ![中科微](https://github.com/01studio-lab/pyIOT/blob/master/Partner/%E6%9D%AD%E5%B7%9E%E4%B8%AD%E7%A7%91%E5%BE%AE.png) 32 | ![EBYTE](https://github.com/01studio-lab/pyIOT/blob/master/Partner/EBYTE.png) 33 | 34 | ## 联系方式 35 | Jackey@01studio.org --------------------------------------------------------------------------------