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}
>>>
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?
-
RE: Omega2 Dash ADC EXP (Python) not connecting.
Other working project, the adc-exp same code working fine. I don't have to do the sleep file link, the file is there.
The adc works, the sensors work and turn off and on relays depending on the sensor logic. if I run the adc-exp # I get
root@Omega-B437:~/projects# adc-exp 0
A0 Voltage: 0 V
root@Omega-B437:~/projects# adc-exp 1
A1 Voltage: 0.79 V
root@Omega-B437:~/projects# adc-exp 2
A2 Voltage: 0.58 V
root@Omega-B437:~/projects# adc-exp 3
A3 Voltage: 0.76 VI had three sensors connected on ports 0, 1, and 3. port 2 has nothing on the adc.
I have a motion sensor, temp sensor, and photo resistor. They all work and toggle the correct relays on my main project where I am not using a dash.Then I power down and change the header plug to the dash, and we get what I have described.
I also did the sleep link like you mentioned, and now I can call time.sleep(2) so that works now. Thanks. -
RE: Omega2 Dash ADC EXP (Python) not connecting.
When I run the script, and change the address in the script (not from the command line), I noted that at first I would get a value (voltage) but eventually it would fail.
0 would work, 1 did not, two worked once, and three worked through several cycles like below. 'station' first number is the address of the adc. the (-num) denotes the actual read_voltage value. This was in a while True: loop with a one second delay. So after three seconds, the error appeared for adc channel 3.
('********** Motion Module Starting **********', 3, 3)
('station: ', 3, 3)
-0.675Setting RELAY0 to OFF
('station: ', 3, 3)
-0.675
Setting RELAY0 to OFF
('station: ', 3, 3)
-0.771
Setting RELAY0 to OFF
('station: ', 3, 3)
onion-i2c:: write issue for register 0x01, errno is 6: No such device or address
Traceback (most recent call last):
File "switch.py", line 54, in <module>
Switch()
File "switch.py", line 15, in init
self.motion = Motion(3, 3, self);
File "/root/OmegaHomeControl/motion.py", line 27, in init
self.listen();
File "/root/OmegaHomeControl/motion.py", line 32, in listen
print(self.adc.read_voltage(0));
File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 230, in read_voltage
return self._convert_to_voltage(self.read_adc(channel, gain, data_rate), gain)
File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 221, in read_adc
return self._read(channel + 0x04, gain, data_rate, ADS1x15_CONFIG_MODE_SINGLE)
File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 149, in _read
self._device.writeBytes(self._devAddr, ADS1x15_POINTER_CONFIG, [(config >> & 0xFF, config & 0xFF])
IOError: I2C transaction failed. -
RE: Omega2 Dash ADC EXP (Python) not connecting.
@tjoseph1 said in Omega2 Dash ADC EXP (Python) not connecting.:
adc-exp 0
root@Omega-C592:~/OmegaHomeControl# adc-exp 0
A0 Voltage: -0.77 V
root@Omega-C592:~/OmegaHomeControl# adc-exp 1
Error: Write failed
A1 Voltage: -0.77 V
root@Omega-C592:~/OmegaHomeControl# adc-exp 2
Error: Write failed
A2 Voltage: -0.77 V
root@Omega-C592:~/OmegaHomeControl# adc-exp 3
Error: Write failed
A3 Voltage: -0.77 VThis is the error Iโm getting when running the original script. Just adding here again. I still get this.
onion-i2c:: write issue for register 0x01, errno is 6: No such device or address
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
File "/usr/lib/python2.7/threading.py", line 754, in run
File "/root/OmegaHomeControl/motion.py", line 30, in listen
if self.adc.read_voltage(self.station) > self.threshold:
File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 230, in read_voltage
return self._convert_to_voltage(self.read_adc(channel, gain, data_rate), gain)
File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 221, in read_adc
return self._read(channel + 0x04, gain, data_rate, ADS1x15_CONFIG_MODE_SINGLE)
File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 149, in _read
self._device.writeBytes(self._devAddr, ADS1x15_POINTER_CONFIG, [(config >> & 0xFF, config & 0xFF])
IOError: I2C transaction failed.I get the same results in my test file. I an read 0, but not 1, 2, or 3.
-
DASH! micropython test.py no module named 'OmegaExpansion'
root@Omega-C592:~# micropython test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
ImportError: no module named 'OmegaExpansion'but...
root@Omega-C592:~# python test.py
-0.795works 4.0.
I'm using the dash, so I want to use the lv_micropython lib to create the gui. I've had several issues so far and this is just one of them I've created a posting for. The other one is here:
https://community.onion.io/topic/4282/omega2-dash-adc-exp-python-not-connecting/3?_=1601154474163What do I have to do to get the microphython to recognize the OmegaExpansion package that is present?
I already also did this instruction: opkg install micropython-lib --nodepsThe code for test.py is below
from OmegaExpansion import AdcExp
class Test:
def init(self):
self.adc = AdcExp.AdcExp(address=0x48);
print(self.adc.read_voltage(0));Test();
-
RE: Omega2 Dash ADC EXP (Python) not connecting.
@tjoseph1 said in Omega2 Dash ADC EXP (Python) not connecting.:
opkg files python3-adc-exp
Ok, I went through the instructions provided. Here is what was displayed:
root@Omega-C592:~# omega2-ctrl gpiomux get
Group i2c - [i2c] gpio
Group uart0 - [uart] gpio
Group uart1 - [uart] gpio pwm01
Group uart2 - [uart] gpio pwm23
Group pwm0 - pwm [gpio]
Group pwm1 - pwm [gpio]
Group refclk - refclk [gpio]
Group spi_s - spi_s [gpio] pwm01_uart2
Group spi_cs1 - [spi_cs1] gpio refclk
Group i2s - i2s [gpio] pcm
Group ephy - ephy [gpio]
Group wled - wled [gpio]root@Omega-C592:~# i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] Y
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@Omega-C592:~# i2cdetect 1
Error: Could not open file/dev/i2c-1' or
/dev/i2c/1': No such file or directoryroot@Omega-C592:~# opkg files adc-exp
Package adc-exp (0.3-2) is installed on root and has the following files:
/usr/bin/adc-exp
root@Omega-C592:~# 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.pyIt appears to be present for address 48, and that is also the address I am using the code on both Omega units, the working one (which is the non dash) and the non working one (which is the dash)
Additional info commands
root@Omega-C592:~/OmegaHomeControl# adc-exp -h
ERROR: Expecting channel inputUsage: adc-exp [options] <channel>
FUNCTIONALITY:
Onion ADC Expansion: Read voltage value of an analog input channel
valid channel: 0-3, or 'all'OPTIONS:
-s <0|1> specify address switch value
-j json output
-h help: show this promptroot@Omega-C592:~/OmegaHomeControl# adc-exp 0
/usr/bin/adc-exp: line 208: /usr/bin/sleep: not found
A0 Voltage: 0 V
root@Omega-C592:~/OmegaHomeControl# adc-exp 1
Error: Write failed
/usr/bin/adc-exp: line 208: /usr/bin/sleep: not found
A1 Voltage: 0 V
root@Omega-C592:~/OmegaHomeControl# adc-exp 2
Error: Write failed
/usr/bin/adc-exp: line 208: /usr/bin/sleep: not found
A2 Voltage: 0 V
root@Omega-C592:~/OmegaHomeControl# adc-exp 3
Error: Write failed
/usr/bin/adc-exp: line 208: /usr/bin/sleep: not found
A3 Voltage: 0 VThere is no /usr/bin/sleep file.
so I created a test.py file that only uses the adcExp module.
from OmegaExpansion import AdcExp
class Test:
def init(self):
self.adc = AdcExp.AdcExp(address=0x48);
print(self.adc.read_voltage(0));Test();
At first I had import time at the top, and I had the same error. I removed import time, and now I do get the voltage value form the adcExp. So the error from above where /usr/bin/sleep not present issue is of course related to the import time.
I would like to use the sleep function of the time module as well, so not this troubleshooting why there is no time module present.
Any help on how to make sure I have access to the time module both in regular python but as well micropython which the dash is using for the GUI software.
If I isolate in the test.py file just import time, and then I create a class like so
import time
from OmegaExpansion import AdcExpclass Test:
def init(self):
print(time.time());
# self.adc = AdcExp.AdcExp(address=0x48);root@Omega-C592:~# python test.py
1601145313.58
# print(self.adc.read_voltage(0));Test();
The time is printed out like it should.
root@Omega-C592:~# python test.py
1601145313.58
And if i just leave the print commented out, all is well.
import time
from OmegaExpansion import AdcExpclass Test:
def init(self):
print(time.time());
self.adc = AdcExp.AdcExp(address=0x48);
# print(self.adc.read_voltage(0));Test();
This works as well, no bug and time is printed out.
However, when I try to read_voltage(0) I get the error from above:
root@Omega-C592:~# python test.py
1601145446.04
onion-i2c:: write issue for register 0x01, errno is 6: No such device or address
Traceback (most recent call last):
File "test.py", line 10, in <module>
Test();
File "test.py", line 8, in init
print(self.adc.read_voltage(0));
File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 230, in read_voltage
return self._convert_to_voltage(self.read_adc(channel, gain, data_rate), gain)
File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 221, in read_adc
return self._read(channel + 0x04, gain, data_rate, ADS1x15_CONFIG_MODE_SINGLE)
File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 149, in _read
self._device.writeBytes(self._devAddr, ADS1x15_POINTER_CONFIG, [(config >> & 0xFF, config & 0xFF])
IOError: I2C transaction failed.so time works as expected, the adcExp works as expected, but when combine together is it breaking on the /usr/bin/sleep file
I just went to /usr/bin/ and created a blank sleep.py file, cuz why not.
The error comes back even when I am not importing anything regarding the time module. Is there some sleep module that I need to import?
I went over to the working omega2 project I have and found that there is a file called sleep and it has contents in it. I can probably copy the file over, but it gets me thinking that the opkg should in some way do this. So I am missing a step here somewhere.
Any ideas on the getting the sleep file present in /usr/bin/sleep
[ fwtool ots tail
[[ getrandom oupgrade tee
adc-exp gpioctl passwd telnet
awk head pgrep test
base64 hexdump printf time
basename id python top
bc iwinfo python2 tr
bunzip2 jshn python2.7 traceroute
bzcat jsonfilter python3 traceroute6
clear killall python3.6 uniq
cmp ldd readlink updateHostname
console-install-tool less reset uptime
crontab logger rsync urldecode
cut md5sum scp urlencode
dbclient mkfifo seq usign
dirname mosquitto_passwd sha256sum wc
dropbearkey mosquitto_pub signify wget
du mosquitto_sub sleep wget-ssl
env nc sort which
expled node-red-install-tool spi-config wifisetup
expr nslookup spi-pipe xargs
find omega2-ctrl ssh yes
free onion strings -
RE: Omega2 Dash ADC EXP (Python) not connecting.
Found the issue is that there is a sleep binary in /usr/bin/ on my working machine, that is NOT on the dash machine. I'm not sure how it gets there as I cannot find a package called sleep available for download.
I added some comments here but I don't think they were saved as I missed the edit time.
So I'll say them here in this reply.
I created a test.py file where I can import time and use it without the adcExp, and i can use the adcExp if I don't import time as well. It is when I try to use them together that it breaks due to the lack of a sleep file or folder in the usr/bin.
I tried to copy over the binary but I have been able to do it yet. In my code I am using the import time
and time.sleep() method.I need to use this, so how do I get the package required that installs the sleep package that is avaialbe on one of my machines, but not the dash?
-
RE: Omega2 Dash ADC EXP (Python) not connecting.
@tjoseph1 said in Omega2 Dash ADC EXP (Python) not connecting.:
opkg files python3-adc-exp
Ok, I went through the instructions provided. Here is what was displayed:
root@Omega-C592:~# omega2-ctrl gpiomux get
Group i2c - [i2c] gpio
Group uart0 - [uart] gpio
Group uart1 - [uart] gpio pwm01
Group uart2 - [uart] gpio pwm23
Group pwm0 - pwm [gpio]
Group pwm1 - pwm [gpio]
Group refclk - refclk [gpio]
Group spi_s - spi_s [gpio] pwm01_uart2
Group spi_cs1 - [spi_cs1] gpio refclk
Group i2s - i2s [gpio] pcm
Group ephy - ephy [gpio]
Group wled - wled [gpio]root@Omega-C592:~# i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] Y
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@Omega-C592:~# i2cdetect 1
Error: Could not open file/dev/i2c-1' or
/dev/i2c/1': No such file or directoryroot@Omega-C592:~# opkg files adc-exp
Package adc-exp (0.3-2) is installed on root and has the following files:
/usr/bin/adc-exp
root@Omega-C592:~# 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.pyIt appears to be present for address 48, and that is also the address I am using the code on both Omega units, the working one (which is the non dash) and the non working one (which is the dash)
Additional info commands
root@Omega-C592:~/OmegaHomeControl# adc-exp -h
ERROR: Expecting channel inputUsage: adc-exp [options] <channel>
FUNCTIONALITY:
Onion ADC Expansion: Read voltage value of an analog input channel
valid channel: 0-3, or 'all'OPTIONS:
-s <0|1> specify address switch value
-j json output
-h help: show this promptroot@Omega-C592:~/OmegaHomeControl# adc-exp 0
/usr/bin/adc-exp: line 208: /usr/bin/sleep: not found
A0 Voltage: 0 V
root@Omega-C592:~/OmegaHomeControl# adc-exp 1
Error: Write failed
/usr/bin/adc-exp: line 208: /usr/bin/sleep: not found
A1 Voltage: 0 V
root@Omega-C592:~/OmegaHomeControl# adc-exp 2
Error: Write failed
/usr/bin/adc-exp: line 208: /usr/bin/sleep: not found
A2 Voltage: 0 V
root@Omega-C592:~/OmegaHomeControl# adc-exp 3
Error: Write failed
/usr/bin/adc-exp: line 208: /usr/bin/sleep: not found
A3 Voltage: 0 VThere is no /usr/bin/sleep file.
so I created a test.py file that only uses the adcExp module.
from OmegaExpansion import AdcExp
class Test:
def init(self):
self.adc = AdcExp.AdcExp(address=0x48);
print(self.adc.read_voltage(0));Test();
At first I had import time at the top, and I had the same error. I removed import time, and now I do get the voltage value form the adcExp. So the error from above where /usr/bin/sleep not present issue is of course related to the import time.
I would like to use the sleep function of the time module as well, so not this troubleshooting why there is no time module present.
Any help on how to make sure I have access to the time module both in regular python but as well micropython which the dash is using for the GUI software.
If I isolate in the test.py file just import time, and then I create a class like so
import time
from OmegaExpansion import AdcExpclass Test:
def init(self):
print(time.time());
# self.adc = AdcExp.AdcExp(address=0x48);root@Omega-C592:~# python test.py
1601145313.58
# print(self.adc.read_voltage(0));Test();
The time is printed out like it should.
root@Omega-C592:~# python test.py
1601145313.58
And if i just leave the print commented out, all is well.
import time
from OmegaExpansion import AdcExpclass Test:
def init(self):
print(time.time());
self.adc = AdcExp.AdcExp(address=0x48);
# print(self.adc.read_voltage(0));Test();
This works as well, no bug and time is printed out.
However, when I try to read_voltage(0) I get the error from above:
root@Omega-C592:~# python test.py
1601145446.04
onion-i2c:: write issue for register 0x01, errno is 6: No such device or address
Traceback (most recent call last):
File "test.py", line 10, in <module>
Test();
File "test.py", line 8, in init
print(self.adc.read_voltage(0));
File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 230, in read_voltage
return self._convert_to_voltage(self.read_adc(channel, gain, data_rate), gain)
File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 221, in read_adc
return self._read(channel + 0x04, gain, data_rate, ADS1x15_CONFIG_MODE_SINGLE)
File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 149, in _read
self._device.writeBytes(self._devAddr, ADS1x15_POINTER_CONFIG, [(config >> & 0xFF, config & 0xFF])
IOError: I2C transaction failed.so time works as expected, the adcExp works as expected, but when combine together is it breaking on the /usr/bin/sleep file
I just went to /usr/bin/ and created a blank sleep.py file, cuz why not.
The error comes back even when I am not importing anything regarding the time module. Is there some sleep module that I need to import?
I went over to the working omega2 project I have and found that there is a file called sleep and it has contents in it. I can probably copy the file over, but it gets me thinking that the opkg should in some way do this. So I am missing a step here somewhere.
Any ideas on the getting the sleep file present in /usr/bin/sleep
-
RE: Omega2 Dash ADC EXP (Python) not connecting.
I would like to add the code as well.
import time from OmegaExpansion import AdcExp import threading class Motion: def __init__(self, address=None, threshold=None, parent=None): print('********** Motion Module Starting **********'); if address 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.address = address; self.threshold = threshold; self.adc = AdcExp.AdcExp(address=0x48) self.parent = parent; motionThread = threading.Thread(target=self.listen); motionThread.daemon = True; motionThread.start(); def listen(self): while 1: if self.adc.read_voltage(self.address) > self.threshold: self.parent.motionOn(); else: self.parent.motionOff(); time.sleep(0.5);
That's the code. self.address is 0 when failure occurs, this also happens for 1, 2, and 3 of the adcexp. It's like the dash does not recognize the AdcExp channels or perhaps even the AdcExp.
My thought is that this is some library problem between the two devices. I do not have any import issues so I think the library is present. The one I test for says its there.
There are several installed:
python-adc-exp - 0.3-2
adc-exp - 0.3-2 -
Omega2 Dash ADC EXP (Python) not connecting.
I have some code up and running on an existing project for Omega2. I recently received the Dash and wanted to begin building the project with a GUI.
I have run into several issues when using Dash, most of them I think I have figured out, one of them being that using the LVGL lib through micropython requires a few more dependancies mainly the micropython-lib.
When I run the python script, I get the following issues.
...
self.adc = AdcExp.AdcExp(address=0x48)
...('station: ', 0) onion-i2c:: write issue for register 0x01, errno is 6: No such device or address Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner File "/usr/lib/python2.7/threading.py", line 754, in run File "/root/OmegaHomeControl/motion.py", line 30, in listen if self.adc.read_voltage(self.station) > self.threshold: File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 230, in read_voltage return self._convert_to_voltage(self.read_adc(channel, gain, data_rate), gain) File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 221, in read_adc return self._read(channel + 0x04, gain, data_rate, ADS1x15_CONFIG_MODE_SINGLE) File "/usr/lib/python2.7/OmegaExpansion/AdcExp.py", line 149, in _read self._device.writeBytes(self._devAddr, ADS1x15_POINTER_CONFIG, [(config >> 8) & 0xFF, config & 0xFF]) IOError: I2C transaction failed.
This code runs just fine when using the previous omega2 setup. It is only when I plug in the adc module to the dash that I get this issue.
So code is working fine on existing omega2 with same adc. Then I move the adc over to dash and the same script will not run.
-
PIR Motion Sensor
Anyone connected a PIR motion sensor to a gpio? Any links or tutorials? I have found 0.