ESP32 Library content....?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
ixbo
Posts: 36
Joined: Wed May 04, 2022 11:12 am
Location: France

ESP32 Library content....?

Post by ixbo » Thu May 12, 2022 10:18 am

Hello
Always beginner with Micropython on ESP32 ....
You will anderstand my question by this exemple it's a simply program that display temperature of a DS18B20 on a Oled Display SSD1306:

Code: Select all

from machine import Pin,SoftI2C
import ssd1306
import time
import machine
import onewire, ds18x20


dat = machine.Pin(12)		# the device is on GPIO12
i2c = SoftI2C(scl=Pin(5), sda=Pin(4), freq=100000)      #Init i2c
lcd=ssd1306.SSD1306_I2C(128,64,i2c)           #create LCD object,Specify col and row

ds = ds18x20.DS18X20(onewire.OneWire(dat))	   # create the onewire object
roms = ds.scan()			# scan for devices on the bus

try:
  while True:
      ds.convert_temp()
      time.sleep_ms(750)	#The reading temperature needs at least 750ms
      for rom in roms:
          lcd.fill(0)
          lcd.text("temperatures:",10,16)
          lcd.text(str(ds.read_temp(rom)),40,40)
          lcd.show()

except KeyboardInterrupt:
          pass
When I run this program in IDE THONNY the program work well
I have downloaded the SSD1306.py on the board before , this is the only file i had to download......

After that I download my program on the board and I give to it the name "main.py", I have done like that for other program and it work well

But this program do not work ? I don't know why, but it's possible that my board do not contain files like onewire.py or ds18x20.py (perhaps ?) , these files are on my computer mandatorily but where ?
My question is how to find the files usefull for my ESP32 on my computer , i will be able to transfert then after on my board if necessary ?

A great thanks for all help
best regards

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: ESP32 Library content....?

Post by davef » Thu May 12, 2022 10:34 am

Which Micropython ESP32 download image have you placed on the board?

ixbo
Posts: 36
Joined: Wed May 04, 2022 11:12 am
Location: France

Re: ESP32 Library content....?

Post by ixbo » Thu May 12, 2022 11:01 am

Hello great thanks

My board
https://www.makerfabs.com/makepython-es ... r-kit.html

and the firmware

esp32-idf3-20210202-v1.14.bin

best regards

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: ESP32 Library content....?

Post by davef » Thu May 12, 2022 8:31 pm

I am sure v1.14 will already have onewire.py and ds18x20.py builtin. At the REPL prompt type:

Code: Select all

help('modules')
Tell us what errors you see when you try to run your program.

Also upgrade to v1.18

ixbo
Posts: 36
Joined: Wed May 04, 2022 11:12 am
Location: France

Re: ESP32 Library content....?

Post by ixbo » Fri May 13, 2022 7:42 am

Hello very nice your answer

I know the command help() it's good with for example help(Pin)
but I can't list modules on my board with this commande help('module')
Obviously 'module' is a string !!!

help('module')
object module is of type str
encode -- <function>
find -- <function>
rfind -- <function>
index -- <function>
rindex -- <function>
join -- <function>
split -- <function>
splitlines -- <function>
rsplit -- <function>
startswith -- <function>
endswith -- <function>
strip -- <function>
lstrip -- <function>
rstrip -- <function>
format -- <function>
replace -- <function>
count -- <function>
partition -- <function>
rpartition -- <function>
center -- <function>
lower -- <function>
upper -- <function>
isspace -- <function>
isalpha -- <function>
isdigit -- <function>
isupper -- <function>
islower -- <function>

I try the same thing with help("module") or help(Esp) help(Esp32) ,help(ESP32), help(esp32).....
I must replace 'module' with what ?
I never found in tutorials any explanation about this commande

I have the latest version

Firmware (Compiled with IDF 3.x) <======I must use this file I don't know why !!!
Releases
v1.14 (2021-02-02) .bin [.elf] [.map] [Release notes] (latest)

NOT this one
Firmware
Releases
v1.18 (2022-01-17) .bin [.elf] [.map] [Release notes] (latest)

A very very great thanks !!!!!!
Best regards

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP32 Library content....?

Post by Roberthh » Fri May 13, 2022 8:31 am

You are clode: The right istruction is:

help('modules')

ixbo
Posts: 36
Joined: Wed May 04, 2022 11:12 am
Location: France

Re: ESP32 Library content....?

Post by ixbo » Fri May 13, 2022 10:45 am

Thanks very much I'm a donkey !!!!

>>> help('modules') ===> with s is better !!!
__main__ gc ubinascii urandom
_boot inisetup ubluetooth ure
_onewire machine ucollections urequests
_thread math ucryptolib uselect
_uasyncio micropython uctypes usocket
_webrepl neopixel uerrno ussl
apa106 network uhashlib ustruct
btree ntptime uheapq usys
builtins onewire uio utime
cmath uarray ujson utimeq
dht uasyncio/__init__ umqtt/robust uwebsocket
ds18x20 uasyncio/core umqtt/simple uzlib
esp uasyncio/event uos webrepl
esp32 uasyncio/funcs upip webrepl_setup
flashbdev uasyncio/lock upip_utarfile websocket_helper
framebuf uasyncio/stream upysh

Then i have ds18x20 and _onewire on the board.....but the program do not work alone on my board, it work well when downloaded with excecute key of IDE Thonny
There is a mystery on the board i have all the files needed , onewire, ds18x20, ssd1306 and my program is named main.py.......
Where is the problem.....
I can't wait to find a solution

Very happy to read your answer
great thanks
best regards

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: ESP32 Library content....?

Post by davef » Fri May 13, 2022 7:55 pm

Tell us what errors you see when you try to run your program.

Also upgrade to v1.18

ixbo
Posts: 36
Joined: Wed May 04, 2022 11:12 am
Location: France

Re: ESP32 Library content....?

Post by ixbo » Sat May 14, 2022 8:26 am

Hello very nice...

When i power on my board (with USB) in witch i have downloaded my program as main.py (Display temperature DS18B20 on oled displau SSD1306) I don't reveive any error message, the oled display remain black, if my IDE is open I don't receive error message also.
I know that my program is good when i run it with excecute botton on THONNY IDE

With a simple program like flashing a led there is no problem , why with this program a little more complicated it don't work ????? All the necessaries files seem to be present on my board ?????
Very greatfull thanks for you help

Best regards

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: ESP32 Library content....?

Post by davef » Sat May 14, 2022 9:26 am

If the necessary files were not there you would get an error message.

I just went back at had a look at your program. pin12 is one of the pins that you are not suppose to use.

Search <esp32 strapping pins boot pins>

Change it for pin13, pin33, pin25 or pin27

Also some GPIO as input need external pull-up resistors.

Post Reply