Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
interfaces:bmp180 [2020/08/17 00:39] – [Resources] darron | interfaces:bmp180 [2020/08/17 07:23] (current) – [Micropython] darron | ||
---|---|---|---|
Line 11: | Line 11: | ||
=== Micropython === | === Micropython === | ||
+ | |||
+ | Setup | ||
+ | < | ||
+ | sudo apt-get install picocom | ||
+ | sudo pip3 install mpfshell | ||
+ | </ | ||
Detect | Detect | ||
< | < | ||
+ | picocom -b 115200 / | ||
from machine import Pin, I2C | from machine import Pin, I2C | ||
i2c = I2C(scl=Pin(22), | i2c = I2C(scl=Pin(22), | ||
Line 21: | Line 28: | ||
</ | </ | ||
+ | Install | ||
+ | |||
+ | < | ||
+ | wget https:// | ||
+ | mpfshell --nocolor -no ttyUSB0 -c put bmp180.py | ||
+ | Connected to esp32 | ||
+ | mpfshell --nocolor -no ttyUSB0 -c ls | ||
+ | Connected to esp32 | ||
+ | |||
+ | Remote files in '/': | ||
+ | |||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Run | ||
+ | |||
+ | < | ||
+ | picocom -b 115200 / | ||
+ | from machine import Pin, I2C | ||
+ | i2c = I2C(scl=Pin(22), | ||
+ | from bmp180 import BMP180 | ||
+ | bmp180 = BMP180(i2c) | ||
+ | print (bmp180.temperature) | ||
+ | 26.95987 | ||
+ | </ | ||
+ | |||
+ | Demo (test.py) | ||
+ | |||
+ | < | ||
+ | ''' | ||
+ | No license. | ||
+ | ''' | ||
+ | |||
+ | from machine import Pin, I2C | ||
+ | from bmp180 import BMP180 | ||
+ | |||
+ | class Test(): | ||
+ | ''' | ||
+ | No comment | ||
+ | ''' | ||
+ | |||
+ | def __init__(self): | ||
+ | self.bus = I2C(scl=Pin(22), | ||
+ | self.bmp180 = BMP180(self.bus) | ||
+ | |||
+ | def print_temp(self): | ||
+ | print (self.bmp180.temperature) | ||
+ | </ | ||
+ | |||
+ | Upload | ||
+ | |||
+ | < | ||
+ | mpfshell --nocolor -no ttyUSB0 -c put test.py | ||
+ | </ | ||
+ | |||
+ | Run | ||
+ | |||
+ | < | ||
+ | picocom -b 115200 / | ||
+ | picocom v3.1 | ||
+ | |||
+ | port is : / | ||
+ | flowcontrol | ||
+ | baudrate is : 115200 | ||
+ | parity is : none | ||
+ | databits are : 8 | ||
+ | stopbits are : 1 | ||
+ | escape is : C-a | ||
+ | local echo is : no | ||
+ | noinit is : no | ||
+ | noreset is : no | ||
+ | hangup is : no | ||
+ | nolock is : no | ||
+ | send_cmd is : sz -vv | ||
+ | receive_cmd is : rz -vv -E | ||
+ | imap is : | ||
+ | omap is : | ||
+ | emap is : crcrlf, | ||
+ | logfile is : none | ||
+ | initstring | ||
+ | exit_after is : not set | ||
+ | exit is : no | ||
+ | |||
+ | Type [C-a] [C-h] to see available commands | ||
+ | Terminal ready | ||
+ | >>> | ||
+ | >>> | ||
+ | ets Jun 8 2016 00:22:57 | ||
+ | |||
+ | rst:0xc (SW_CPU_RESET), | ||
+ | configsip: 0, SPIWP:0xee | ||
+ | clk_drv: | ||
+ | mode:DIO, clock div:2 | ||
+ | load: | ||
+ | load: | ||
+ | ho 0 tail 12 room 4 | ||
+ | load: | ||
+ | ho 0 tail 12 room 4 | ||
+ | load: | ||
+ | entry 0x400806bc | ||
+ | I (548) cpu_start: Pro cpu up. | ||
+ | I (548) cpu_start: Application information: | ||
+ | I (548) cpu_start: Compile time: Aug 16 2020 00:54:20 | ||
+ | I (551) cpu_start: ELF file SHA256: | ||
+ | I (557) cpu_start: ESP-IDF: | ||
+ | I (562) cpu_start: Starting app cpu, entry point is 0x40082f30 | ||
+ | I (552) cpu_start: App cpu up. | ||
+ | I (572) heap_init: Initializing. RAM available for dynamic allocation: | ||
+ | I (579) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM | ||
+ | I (585) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM | ||
+ | I (591) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM | ||
+ | I (598) heap_init: At 3FFBDB5C len 00000004 (0 KiB): DRAM | ||
+ | I (604) heap_init: At 3FFCA9E8 len 00015618 (85 KiB): DRAM | ||
+ | I (610) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM | ||
+ | I (616) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM | ||
+ | I (623) heap_init: At 4009DE28 len 000021D8 (8 KiB): IRAM | ||
+ | I (629) cpu_start: Pro cpu start user code | ||
+ | I (312) cpu_start: Starting scheduler on PRO CPU. | ||
+ | I (0) cpu_start: Starting scheduler on APP CPU. | ||
+ | MicroPython v1.12-665-g60f5b941e on 2020-08-16; ESP32 module with ESP32 | ||
+ | Type " | ||
+ | >>> | ||
+ | >>> | ||
+ | >>> | ||
+ | 27.09271 | ||
+ | </ | ||
=== Resources === | === Resources === | ||