Answers for "micropython esp8266"

2

esp8266 micropython ds18b20

import time
import machine
import onewire

# the device is on GPIO12
dat = machine.Pin(12)

# create the onewire object
ds = onewire.DS18B20(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()
Posted by: Guest on August-24-2021
2

esp8266 micropython ds18b20

# Complete project details at https://RandomNerdTutorials.com

import machine, onewire, ds18x20, time

ds_pin = machine.Pin(4)
ds_sensor = ds18x20.DS18X20(onewire.OneWire(ds_pin))

roms = ds_sensor.scan()
print('Found DS devices: ', roms)

while True:
  ds_sensor.convert_temp()
  time.sleep_ms(750)
  for rom in roms:
    print(rom)
    print(ds_sensor.read_temp(rom))
  time.sleep(5)
Posted by: Guest on August-24-2021
1

esp8266 micropython ds18b20

from machine import Pin
import time, ds18x20
import onewire
ow = onewire.OneWire(Pin(4)) # create a OneWire bus on GPIO12
 
ds = ds18x20.DS18X20(ow)
 
roms = ds.scan()
ds.convert_temp()
time.sleep_ms(750)
 
for rom in roms:
    print(ds.read_temp(rom))
Posted by: Guest on August-24-2021

Python Answers by Framework

Browse Popular Code Answers by Language