Omega2 Dash ADC EXP (Python) not connecting.



  • @György-Farkas Not sure how I got dragged into this but here is the output on one of my Dash

    16298622-6dfa-468c-96cd-efd71658b84a-image.png

    PS I don't have an ADC expansion.



  • @crispyoz Because I know that you have an Omega2 DASH board.
    Thank you.



  • @György-Farkas Are you monitoring me ? 🙂



  • @crispyoz
    Omega2 Dash now available! You wrote proudly:

    I was lucky enough to join the Beta for this product.

    🙂



  • @György-Farkas I wrote "gratefully" because it was a timely release for something I had been working on for a while and Zheng administered the Beta very attentively and professionally.

    You know I'm a stickler for nomenclature.



  • @György-Farkas

    With no ADC or any board plugged into the header,
    when I run...

    root@Omega-C592:~# i2cdetect -y 0
    0 1 2 3 4 5 6 7 8 9 a b c d e f
    00: -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- --



  • @tjoseph1

    Although Micropython is preferred, it doesn't work for the dash I have. The micropython command for some reason lacks access to the same libraries that python has.

    Again, I can run python mypython.py file
    where I cannot run the same file with micropython mypython.py file.

    "
    The next part of this is getting the call micropython swtich.py to be what activates the swtich file instead of calling python switch.py

    This is so that I can use the Micropython & LVGL support of the Dash. link
    "

    but when I call micropython switch.py it dumps this error: ImportError: no module named 'OmegaExpansion'


  • administrators

    @György-Farkas said in Omega2 Dash ADC EXP (Python) not connecting.:

    If the above is correct users should be warned a possible I2C address conflict.

    Yes, this is correct, the Omega2 Dash uses an XPT7603 I2C-based touch screen controller. Didn't realize it conflicts with the ADC Expansion.

    Where is the best place to document this so users are aware?



  • @LightSwitch :
    I guess you installed micropython by uncommenting the 5th line of /etc/opkg/distfeeds.conf, followed by an "opkg update" and then "opkg install micropython"
    root@Omega-745F:/tmp# cat /etc/opkg/distfeeds.conf
    line5: src/gz openwrt_packages http://downloads.openwrt.org/releases/18.06-SNAPSHOT/packages/mipsel_24kc/packages

    root@Omega-745F:/tmp# opkg files micropython
    Package micropython (1.9.2-1f78e7a43130acfa4bedf16c1007a1b0f37c75c3-1) is installed on root and has the following files:
    /usr/bin/micropython

    There is one more package that would be required:

    root@Omega-745F:/tmp# opkg install micropython-lib

    root@Omega-745F:/tmp# opkg files micropython-lib
    Package micropython-lib (1.9-f5fe55aaef1a39d3d56f07040c0ff9f7e841fdf7-1) is installed on root and has the following files:
    /usr/lib/micropython/binhex.py
    ...(There are about 196 .py files/libs)
    /usr/lib/micropython/time.py
    (even "time" is part of micropython-lib and micropython points to the libs provided by micropython-lib)
    ...
    root@Omega-745F:/tmp# micropython
    MicroPython v1.9.2 on 2020-09-28; linux version
    Use Ctrl-D to exit, Ctrl-E for paste mode
    >>> import sys
    >>> print(sys.path)
    ['', '/root/.micropython/lib', '/usr/lib/micropython']
    >>> <Ctrl-d>
    root@Omega-745F:/tmp#

    I have not done any micropython on Omega, but on an STM32 board, using the download provided at:
    https://www.micropython.org/download/stm32/ and I guess there could be differences (v1.13-77 vs Omega's Linux port shows v1.9.2 ?). There is no Linux on STM32, micropython is the alpha and omega there.

    This:
    https://www.oreilly.com/library/view/programming-with-micropython/9781491972724/
    was very useful..

    I am not sure if "micropython-lib" contain all that you need, but micropython with out "micropython-lib", it is pretty retarded.
    It is up to you to chose.

    Thanks..



  • @tjoseph1

    I have both of those installed, however it still throws the OmegaExpansion error is missing.

    root@Omega-C592:~/OmegaHomeControl# opkg list | grep -i micropython
    lv_micropython - 1.9.2-2
    micropython-lib - 1.9-f5fe55aaef1a39d3d56f07040c0ff9f7e841fdf7-1



  • @LightSwitch :
    "opkg list-installed" gives you the list of pkgs that are already installed. Pls try opkg --help to get all the switches that opkg accepts.



  • @tjoseph1 said in Omega2 Dash ADC EXP (Python) not connecting.:

    "opkg list-installed

    This does list the installed packages. The issue I now have is that when I run "micropython script.name.py" command with the file, I get an error "ImportError: no module named 'OmegaExpansion'"

    The same file works with the non-dash omega, AND the dash when I run "python script.name.py".

    As far as I know, I have to use micropython to run the GUI library.

    This is installed:
    lv_micropython - 1.9.2-2
    micropython-lib - 1.9-f5fe55aaef1a39d3d56f07040c0ff9f7e841fdf7-1

    pyOmegaExpansion - 0.9-1
    python3-omega-expansion - 0.9-1



  • @LightSwitch try typing echo $PYTHONPATH check OmegaExpansion is accessible in your python search path.



  • @crispyoz said in Omega2 Dash ADC EXP (Python) not connecting.:

    echo $PYTHONPATH

    This just creates a new blank line. Nothing is returned.



  • @LightSwitch :
    root@Omega-745F:/tmp/tmp# opkg list | grep -i adc-exp
    adc-exp - 0.3-2 - Command line utility for ADC Expansion
    python-adc-exp - 0.3-2 - Python module to interact with Onion ADC Expansion
    python3-adc-exp - 0.3-2 - Python3 module to interact with Onion ADC Expansion

    We have two choices, python-adc-exp (python 2) and python3-adc-exp (python3)

    From https://micropython.org :
    "MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimised to run on microcontrollers and in constrained environments"

    So we shall limit ourselves to python3 libs while working with micropython. Also, python2 has reached EOL and is not advised for new projects.

    root@Omega-745F:/tmp/tmp# opkg install python3-adc-exp
    Package python3-adc-exp (0.3-2) installed in root is up to date.

    root@Omega-745F:/tmp/tmp# opkg files python3-adc-exp
    Package python3-adc-exp (0.3-2) is installed on root and has the following files:
    /usr/lib/python3.6/OmegaExpansion/AdcExp.py

    root@Omega-745F:/tmp/tmp# opkg list-installed |grep adc-exp
    adc-exp - 0.3-2
    python3-adc-exp - 0.3-2

    root@Omega-745F:/tmp/tmp# micropython
    MicroPython v1.9.2 on 2020-09-28; linux version
    Use Ctrl-D to exit, Ctrl-E for paste mode
    >>> from OmegaExpansion import AdcExp
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ImportError: no module named 'OmegaExpansion'
    >>>
    >>> import sys
    >>> sys.version
    '3.4.0' (The uPython confirms to Python3, v 3.4.0)
    >>> sys.path
    ['', '/root/.micropython/lib', '/usr/lib/micropython'] (these are the PATH python will look for libs; micropython-lib resides under "/usr/lib/micropython")
    >>> <Ctrl-d>

    Let us add non-"micropython-lib" libraries to /root/.micropython/lib which is "compiled into" micropython.

    root@Omega-745F:/tmp/tmp# mkdir -p /root/.micropython/lib (the dir is non-existant; let us create it..)
    root@Omega-745F:/tmp/tmp# ln -s /usr/lib/python3.6/OmegaExpansion /root/.micropython/lib/

    root@Omega-745F:/tmp/tmp# ls -l /root/.micropython/lib
    lrwxrwxrwx 1 root root 33 Sep 29 05:39 OmegaExpansion -> /usr/lib/python3.6/OmegaExpansion

    root@Omega-745F:/tmp/tmp# micropython
    MicroPython v1.9.2 on 2020-09-28; linux version
    Use Ctrl-D to exit, Ctrl-E for paste mode
    >>> locals()
    {'__name__': '__main__'}
    >>>
    >>> from OmegaExpansion import AdcExp (OmegaExpansion is directly "visible" under sys.path after the "ln -s", above)
    >>> import time
    >>> locals()
    {'time': <module 'time' from '/usr/lib/micropython/time.py'>, '__name__': '__main__', 'AdcExp': <module 'OmegaExpansion.AdcExp' from '/root}
    >>>

    To add another python3 lib, install it; create its link under "/root/.micropython/lib". as above..
    Again, every python3 lib might NOT be compatible with micropython.

    More info about sys lib is here:
    http://docs.micropython.org/en/v1.9.2/pyboard/library/sys.html

    Every language "author" has made certain choices while designing it. As application developers, it pays off if we understand the "under-the-hood" design. Every minute on that direction is well-spent.

    Thanks..



  • @tjoseph1

    Thank you for your assistance. Certainly, the more I know the better I will understand how this all pulls together. What you've shared so far is helping quite a bit. I'm onto the next issue now.

    root@Omega-C592:~/OmegaHomeControl# micropython dash.py
    Traceback (most recent call last):
      File "dash.py", line 5, in <module>
      File "/root/OmegaHomeControl/switch.py", line 3, in <module>
      File "/root/OmegaHomeControl/relays.py", line 1, in <module>
    ImportError: no module named 'OmegaExpansion.relayExp'
    root@Omega-C592:~/OmegaHomeControl# micropython
    MicroPython reboot-7475-ge6757b4765-dirty on 2020-07-14; linux version
    Use Ctrl-D to exit, Ctrl-E for paste mode
    >>> from OmegaExpansion import RelayExp
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: no module named 'OmegaExpansion.RelayExp'
    >>> from OmegaExpansion import relayExp
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: no module named 'OmegaExpansion.relayExp'
    >>>
    

    So now its how to add the relayExp as well. I'm working through what you shared but in the context of the relayExp. I haven't figured this one out yet.

    Any ideas here?



  • @LightSwitch

    root@Omega-C592:~/OmegaHomeControl# opkg list | grep -i relay
    libonionrelayexp - 0.9-1
    pyRelayExp - 0.9-1
    relay-exp - 0.9-1



  • @LightSwitch :

    From these two:

    https://docs.onion.io/omega2-docs/relay-expansion.html
    https://docs.onion.io/omega2-docs/relay-expansion-python-module.html#relay-expansion-python-module

    it appears that RelayExp is a python2 module.

    Pls try if it works as advertised (under python2).

    Just need to invoke the the python prompt and do the import and then type in each statement one-by-one at the prompt. See if each stmt succeeds.

    We need to worry about incorporating it into the current environment only if it does...

    Thanks..



  • @tjoseph1

    root@Omega-C592:~# python --version
    Python 2.7.18
    root@Omega-C592:~# python
    Python 2.7.18 (default, Jul 14 2020, 21:51:14)
    [GCC 7.3.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.

    from OmegaExpansion import relayExp
    import time
    locals()
    {'builtins': <module 'builtin' (built-in)>, 'relayExp': <module 'OmegaExpansion.relayExp' from '/usr/lib/python2.7/OmegaExpansion/relayExp.so'>, 'package': None, 'time': <module 'time' from '/usr/lib/python2.7/lib-dynload/time.so'>, 'name': 'main', 'doc': None}

    Is this what you meant to do above? It seams like it works.

    I already have this entire setup running on the dash and all the sensors work and all the omegaexpansion modules as well. It just does not work when I run the micropython command.

    Can this too be sym linked?



  • @LightSwitch

    root@Omega-C592:~# python --version
    Python 2.7.18
    root@Omega-C592:~# python
    Python 2.7.18 (default, Jul 14 2020, 21:51:14)
    [GCC 7.3.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from OmegaExpansion import relayExp
    >>> import time
    >>> locals()
    {'__builtins__': <module '__builtin__' (built-in)>, 'relayExp': <module 'OmegaExpansion.relayExp' from '/usr/lib/python2.7/OmegaExpansion/relayExp.so'>, '__package__': None, 'time': <module 'time' from '/usr/lib/python2.7/lib-dynload/time.so'>, '__name__': '__main__', '__doc__': None}
    >>>
    

Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.