Problem installing packages

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
pjtcb
Posts: 1
Joined: Sun Jan 31, 2021 4:09 pm

Problem installing packages

Post by pjtcb » Sun Jan 31, 2021 4:18 pm

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

ThomasChr
Posts: 121
Joined: Sat Nov 25, 2017 7:50 am

Re: Problem installing packages

Post by ThomasChr » Mon Feb 01, 2021 9:07 am

smbus?
I think in Microython it should be

Code: Select all

from machine import I2C
https://docs.micropython.org/en/latest/ ... e.I2C.html

User avatar
aivarannamaa
Posts: 171
Joined: Fri Sep 22, 2017 3:19 pm
Location: Estonia
Contact:

Re: Problem installing packages

Post by aivarannamaa » Mon Feb 01, 2021 11:41 am

Most PyPI packages are not suitable for MicroPython and it looks like smbus is one of them.
Aivar Annamaa
https://thonny.org

User avatar
bouffski
Posts: 6
Joined: Tue Feb 23, 2021 7:54 pm

Re: Problem installing packages

Post by bouffski » Mon Mar 01, 2021 1:32 pm

@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...
Nostalgia isn't what it used to be...

Post Reply