File tree 2 files changed +6
-7
lines changed 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -253,15 +253,14 @@ The OneWire driver is implemented in software and works on all pins::
253
253
ow.scan() # return a list of devices on the bus
254
254
ow.reset() # reset the bus
255
255
ow.readbyte() # read a byte
256
- ow.read(5) # read 5 bytes
257
256
ow.writebyte(0x12) # write a byte on the bus
258
257
ow.write('123') # write bytes on the bus
259
258
ow.select_rom(b'12345678') # select a specific device by its ROM code
260
259
261
- There is a specific driver for DS18B20 devices::
260
+ There is a specific driver for DS18S20 and DS18B20 devices::
262
261
263
- import time
264
- ds = onewire.DS18B20 (ow)
262
+ import time, ds18x20
263
+ ds = ds18x20.DS18X20 (ow)
265
264
roms = ds.scan()
266
265
ds.convert_temp()
267
266
time.sleep_ms(750)
Original file line number Diff line number Diff line change @@ -6,19 +6,19 @@ The 1-wire bus is a serial bus that uses just a single wire for communication
6
6
is a very popular 1-wire device, and here we show how to use the onewire module
7
7
to read from such a device.
8
8
9
- For the following code to work you need to have at least one DS18B20 temperature
9
+ For the following code to work you need to have at least one DS18S20 or DS18B20 temperature
10
10
sensor with its data line connected to GPIO12. You must also power the sensors
11
11
and connect a 4.7k Ohm resistor between the data pin and the power pin. ::
12
12
13
13
import time
14
14
import machine
15
- import onewire
15
+ import onewire, ds18x20
16
16
17
17
# the device is on GPIO12
18
18
dat = machine.Pin(12)
19
19
20
20
# create the onewire object
21
- ds = onewire.DS18B20 (onewire.OneWire(dat))
21
+ ds = ds18x20.DS18X20 (onewire.OneWire(dat))
22
22
23
23
# scan for devices on the bus
24
24
roms = ds.scan()
You can’t perform that action at this time.
0 commit comments