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}
>>>
LightSwitch
@LightSwitch
Best posts made by LightSwitch
Latest posts made by LightSwitch
-
RE: Omega2 Dash ADC EXP (Python) not connecting.
-
RE: Omega2 Dash ADC EXP (Python) not connecting.
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?
-
RE: Omega2 Dash ADC EXP (Python) not connecting.
root@Omega-C592:~/OmegaHomeControl# opkg list | grep -i relay
libonionrelayexp - 0.9-1
pyRelayExp - 0.9-1
relay-exp - 0.9-1 -
RE: Omega2 Dash ADC EXP (Python) not connecting.
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?
-
RE: Omega2 Dash ADC EXP (Python) not connecting.
@crispyoz said in Omega2 Dash ADC EXP (Python) not connecting.:
echo $PYTHONPATH
This just creates a new blank line. Nothing is returned.
-
RE: Omega2 Dash ADC EXP (Python) not connecting.
@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-1pyOmegaExpansion - 0.9-1
python3-omega-expansion - 0.9-1 -
RE: Omega2 Dash ADC EXP (Python) not connecting.
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 -
RE: Omega2 Dash ADC EXP (Python) not connecting.
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.pyThis 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'
-
RE: Omega2 Dash ADC EXP (Python) not connecting.
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: -- -- -- -- -- -- -- -- -
RE: Omega2 Dash ADC EXP (Python) not connecting.
Just out of curiosity, I changed the switch on the adc to 0x49 and I changed the code for the motion sensor to 0x49 and the sensor now triggers the relay! So perhaps there is something about 0x48 and 0x49 on the dash software?
Again, the 0x48 switch and code work on omega2+ but not on dash.
On the dash, the 0x49 works. Here is the motion sensor code for reference.from OmegaExpansion import AdcExp import time import threading class Motion: def __init__(self, station=None, threshold=None, parent=None): print('********** Motion Module Starting **********', station, threshold); if station is None: raise ValueError("An Address must be passed into the constructor argument 1."); if threshold is None: raise ValueError("A Threshold must be passed into the constructor argument 2."); if parent is None: raise ValueError("A Parent self must be passed into the constructor argument 3." self.station = station; self.threshold = threshold; self.adc = AdcExp.AdcExp(address=0x49); self.parent = parent; motionThread = threading.Thread(target=self.listen); motionThread.daemon = True; motionThread.start(); self.listen(); def listen(self): while 1: print('station: ', self.station, self.threshold); print(self.adc.read_voltage(0)); if self.adc.read_voltage(self.station) > self.threshold: self.parent.motionOn(); else: self.parent.motionOff(); time.sleep(1);
and here is the parent switch.py file that calls it.
import time from relays import Relays from motion import Motion from light import Light from temp import Temp class Switch: def __init__(self): self.motionDetected = False; self.relay = Relays(7); self.relay.setAllOff(); self.motion = Motion(0, 3, self); # self.light = Light(3, 1000, self); # self.temp = Temp(1, 85, self); self.start = time.time(); while True: print('||||| SWITCH ACTIVE |||||'); time.sleep(10); self.status = 0; def motionOn(self): self.motionDetected = True; self.relay.set(0, 1); def motionOff(self): self.motionDetected = False; self.relay.set(0, 0); def tempOn(self): self.relay.set(1, 1); def tempOff(self): self.relay.set(1, 0); def testOn(self): print('testOn'); self.status = 1 - self.relay.read(0); self.relay.set(0, self.status); def lightOn(self): if self.motionDetected and self.relay.read(0) == 0: self.relay.set(0, 1); def lightOff(self): if not self.motionDetected and self.relay.read(0) == 1: self.relay.set(0, 0); Switch()
It would be nice to know the diff. I have 4 Dash, so I can try this on the others as well, but it will take time before I can get to them.
For now, I'll focus on just getting one to work.
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
Unless I can use it with just python?