I am using an ESP32 dev board with the latest stable uPython firmware.
I am also using the latest pycharm pro IDE with the uPython plugin 1.1.2 (previously tried 1.1.1 with same results).
Please consider the following folder structure:
Code: Select all
-- Source
-- BME280.py <--- sensor module
-- __init__.py <--- self explanatory but does not seem to work
-- ota_updater.py <--- over the air update module "https://github.com/rdehuyss/micropython-ota-updater" only thing I changed was the "main" directory variable name to "source" as to not confuse or possibly conflict with `main.py` the root folder
--temp_sensor.py <--- main code
--main.py
Code: Select all
import network
from source import ota_updater
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
print('connecting to network...')
wlan.connect('<SSID>', '<PASSWORD>')
while not wlan.isconnected():
pass
print('network config:', wlan.ifconfig())
def download_and_install_update_if_available():
token = '<TOKEN>'
o = ota_updater.OTAUpdater('https://github.com/HH0718/bme_temp_sensor', headers={'Authorization': 'token {}'.format(token)})
o.download_and_install_update_if_available('<SSID>', '<PASSWORD>')
def start():
global project
from source.temp_sensor import temp_sensor
project = temp_sensor(wlan)
def boot():
download_and_install_update_if_available()
start()
project = None
boot()
The problem I get is it will not find my `source` module. This is the error:
Code: Select all
Traceback (most recent call last):
File "main.py", line 3, in <module>
ImportError: no module named 'source.ota_updater'
I kid you not I have spent the better half of my day trying to understand how to solve this and my google skills have failed me.
I understand that some forum responses say don't use folder and keep it simple, but due to the way this works, I believe I must have subfolders.
other forums say not to use Pycharm and to use REPL, but I'm unfamiliar with the CLI methods. I am willing to give it a try and learn it and I have a feeling it's a pycharm issue, but I'm not sure what else to do and I need some guidance.
Thank you all for your help.