help DS18x20 sensor in STM32F7DISC

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
shaoziyang
Posts: 244
Joined: Sun Apr 17, 2016 1:55 pm

help DS18x20 sensor in STM32F7DISC

Post by shaoziyang » Sun Apr 17, 2016 2:04 pm

I build micropython 1.7 with STM32F7DISC board, it works fine. When I connect a DS1820 sensor, it is not work, but Same DS1820 sensor is work in pyboard v1.0.

>>> # STM32F7DISCO
>>> from pyb import Pin
>>> Pin('D2', Pin.OUT_PP).low()
>>> Pin('D0', Pin.OUT_PP).high()
>>> pyb.delay(100)
>>>
>>> from ds18x20 import DS18X20
>>> d = DS18X20(Pin('D1'))
>>> d.read_temp()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ds18x20.py", line 55, in read_temp
IndexError: list index out of range
>>>


And I found I2C1 is not work correctly too.

shaoziyang
Posts: 244
Joined: Sun Apr 17, 2016 1:55 pm

Re: help DS18x20 sensor in STM32F7DISC

Post by shaoziyang » Tue Apr 19, 2016 2:17 am

I have solve this problem. It cause by onewire delay. Open onewire.py, and modify

self.write_delays = (1, 40, 40, 1)
self.read_delays = (1, 1, 40)

to

self.write_delays = (6, 64, 60, 10)
self.read_delays = (6, 9, 55)

then DS1820 will work in STM32F7DISC now.

Post Reply