DS18B20 not working in WiPy 2.0
-
Hello There
I have copied and paste following code
from machine import Pin from ds18x20 import DS18X20 d=DS18X20(Pin((Pin.exp_board.G23, mode=Pin.OUT))) result=d.read_temps() print(result)The only difference is that I am using the WyPy expansion board. it throwing following error in Atom
Traceback (most recent call last):
File "<stdin>", line 28
SyntaxError: invalid syntaxLine 28 is
result=d.read_temps()
any ideas?
Cheers
Colombian1976 -
First thing I notice is that you are passing Pin a tuple:
(Pin.exp_board.G23, mode=Pin.OUT)I think you have used one too many pairs of parentheses.
Secondly, can you share all your code? because the code you posted is only 5 lines long but the error says line 28
-
hey mate,...
OK so all code below, but as you can notice first 24 lines are commented. Furthermore, I have deleted extra parentheses for the line
d=DS18X20(Pin.exp_board.G23, mode=Pin.OUT)
it now throws following error:
Traceback (most recent call last):
File "<stdin>", line 28, in <module>
TypeError: function does not take keyword argumentsline 28 is
result=d.read_temps()
"""
import time
from machine import Pin
import onewire, ds18x20the device is on GPIO23, expansion board
dat = Pin(Pin.exp_board.G23, mode=Pin.OUT)
create the onewire object
ds = ds18x20.DS18X20(onewire.OneWire(dat))
scan for devices on the bus
roms = ds.scan()
print('found devices:', roms)loop 10 times and print all temperatures
for i in range(10):
print('temperatures:', end=' ')
ds.convert_temp()
time.sleep_ms(750)
for rom in roms:
print(ds.read_temp(rom), end=' ')
print()
"""
from machine import Pin
from ds18x20 import DS18X20
d=DS18X20(Pin.exp_board.G23, mode=Pin.OUT)
result=d.read_temps()
print(result)Thank you for your assistance mate
Cheers
Wilson -
@colombianaus said in DS18B20 not working in WiPy 2.0:
d=DS18X20(Pin.exp_board.G23, mode=Pin.OUT)
now you miss Pin class...
d=DS18X20(Pin(Pin.exp_board.G23, mode=Pin.OUT))
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login