I am fairly new to Python - let alone MicroPython. I am trying to install packages in the Thonny IDE to use BMP180 sensors with a Pi Pico but I don't seem to be able to load any packages successfully. I can install with pip3 (but not pip) but then install smbus. Ideas for what could be going wrong would be appreciated. Is there a log I can look at?
Installing to temp directory
Error installing 'smbus': , packages may be partially installed
Installing to: /tmp/tmp8haza2ak/
Warning: micropython.org SSL certificate is not validated
Problem installing packages
Re: Problem installing packages
smbus?
I think in Microython it should be
https://docs.micropython.org/en/latest/ ... e.I2C.html
I think in Microython it should be
Code: Select all
from machine import I2C
- aivarannamaa
- Posts: 171
- Joined: Fri Sep 22, 2017 3:19 pm
- Location: Estonia
- Contact:
Re: Problem installing packages
Most PyPI packages are not suitable for MicroPython and it looks like smbus is one of them.
Aivar Annamaa
https://thonny.org
https://thonny.org
Re: Problem installing packages
@pjtcb Also a newbie at pi pico, but had some success on this BMP180: from github download bmp180.py, the library, and the bmp_test.py
(http://www.learnmicropython.com/esp32/a ... -esp32.php
In the example. I changed
bus = I2C(scl=Pin(22), sda=Pin(21), freq=100000) to bus = I2C(0, scl=machine.Pin(1), sda=machine.Pin(0), freq=400000)
so i2c data on gpio pin 0 (physically pin 1) and i2c clock, scl, on gpio pin 1 (physically pin 2)
in the bmp180 library I commented the line that says "self._bmp_i2c.start()" out (#). this line caused trouble...
After that all works like a charm. Thanx to all involved...
my test_code:
from bmp180 import BMP180
from machine import I2C, Pin
from time import sleep_ms
bus = I2C(0, scl=machine.Pin(1), sda=machine.Pin(0), freq=400000)
bmp180 = BMP180(bus)
bmp180.oversample_sett = 3
bmp180.baseline = 103525 #was 101325; now altitude is more realistic
print('Scan i2c bus...')
devices = bus.scan()
if len(devices) == 0:
print("\nNo i2c device !")
else:
print('\ni2c devices found:',len(devices))
for device in devices:
print("Decimal address: ",device," | Hex address: ",hex(device))
sleep_ms(2000)
while True:
temp = bmp180.temperature
p = bmp180.pressure
altitude = bmp180.altitude
print("\nTemp={:3.1f} °C - Pressure={:3.0f} hPa".format(temp,p/100))
#print(" Altitude: ", altitude)
sleep_ms(3000)
...
Always remember: old coders never die, they just start over...
(http://www.learnmicropython.com/esp32/a ... -esp32.php
In the example. I changed
bus = I2C(scl=Pin(22), sda=Pin(21), freq=100000) to bus = I2C(0, scl=machine.Pin(1), sda=machine.Pin(0), freq=400000)
so i2c data on gpio pin 0 (physically pin 1) and i2c clock, scl, on gpio pin 1 (physically pin 2)
in the bmp180 library I commented the line that says "self._bmp_i2c.start()" out (#). this line caused trouble...
After that all works like a charm. Thanx to all involved...
my test_code:
from bmp180 import BMP180
from machine import I2C, Pin
from time import sleep_ms
bus = I2C(0, scl=machine.Pin(1), sda=machine.Pin(0), freq=400000)
bmp180 = BMP180(bus)
bmp180.oversample_sett = 3
bmp180.baseline = 103525 #was 101325; now altitude is more realistic
print('Scan i2c bus...')
devices = bus.scan()
if len(devices) == 0:
print("\nNo i2c device !")
else:
print('\ni2c devices found:',len(devices))
for device in devices:
print("Decimal address: ",device," | Hex address: ",hex(device))
sleep_ms(2000)
while True:
temp = bmp180.temperature
p = bmp180.pressure
altitude = bmp180.altitude
print("\nTemp={:3.1f} °C - Pressure={:3.0f} hPa".format(temp,p/100))
#print(" Altitude: ", altitude)
sleep_ms(3000)
...
Always remember: old coders never die, they just start over...
Nostalgia isn't what it used to be...