Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
13c5a228
Commit
13c5a228
authored
8 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
docs/esp8266: Update quickref and tutorial for OneWire/DS18X20 driver.
parent
59a95097
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/esp8266/quickref.rst
+3
-4
3 additions, 4 deletions
docs/esp8266/quickref.rst
docs/esp8266/tutorial/onewire.rst
+3
-3
3 additions, 3 deletions
docs/esp8266/tutorial/onewire.rst
with
6 additions
and
7 deletions
docs/esp8266/quickref.rst
+
3
−
4
View file @
13c5a228
...
...
@@ -253,15 +253,14 @@ The OneWire driver is implemented in software and works on all pins::
ow.scan() # return a list of devices on the bus
ow.reset() # reset the bus
ow.readbyte() # read a byte
ow.read(5) # read 5 bytes
ow.writebyte(0x12) # write a byte on the bus
ow.write('123') # write bytes on the bus
ow.select_rom(b'12345678') # select a specific device by its ROM code
There is a specific driver for DS18B20 devices::
There is a specific driver for
DS18S20 and
DS18B20 devices::
import time
ds =
onewire
.DS18
B
20(ow)
import time
, ds18x20
ds =
ds18x20
.DS18
X
20(ow)
roms = ds.scan()
ds.convert_temp()
time.sleep_ms(750)
...
...
This diff is collapsed.
Click to expand it.
docs/esp8266/tutorial/onewire.rst
+
3
−
3
View file @
13c5a228
...
...
@@ -6,19 +6,19 @@ The 1-wire bus is a serial bus that uses just a single wire for communication
is a very popular 1-wire device, and here we show how to use the onewire module
to read from such a device.
For the following code to work you need to have at least one DS18B20 temperature
For the following code to work you need to have at least one
DS18S20 or
DS18B20 temperature
sensor with its data line connected to GPIO12. You must also power the sensors
and connect a 4.7k Ohm resistor between the data pin and the power pin. ::
import time
import machine
import onewire
import onewire
, ds18x20
# the device is on GPIO12
dat = machine.Pin(12)
# create the onewire object
ds =
onewire
.DS18
B
20(onewire.OneWire(dat))
ds =
ds18x20
.DS18
X
20(onewire.OneWire(dat))
# scan for devices on the bus
roms = ds.scan()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment