i would like to modify this micropython code so it can read the DS1920-F5 thermometer
Code:
import machine, onewire, ds18x20, time
ds_pin = machine.Pin(16)
ds_sensor = ds18x20.DS18X20(onewire.OneWire(ds_pin))
roms = ds_sensor.scan()
print('Found a ds18x20 device')
while True:
ds_sensor.convert_temp()
time.sleep_ms(750)
for rom in roms:
print(ds_sensor.read_temp(rom))
time.sleep(2)
great! but do you think it should be alright at 3.3V? and there's no need to be connected
to a 5V device?
also the wiring how it should be done? the above example code was about a DS18B20 which
uses 3 pins (VCC, GND, GPIO16) while the ibutton needs GND and DATA and it says something
about parasitic powering, is it enough connecting GND and GPIO16 to it?
The 1820 can also use parasitic power, try it and see. It's normal for one wire devices. It just needs a longer time between transmissions, check the library, see what it's doing. Post a link to it and I may be able to explain but I've never used python.
One Wire Sensors library for Arduino. Contribute to theforest/Arduino-libOneWireSensors development by creating an account on GitHub.
github.com
Note that the device IDs / family codes are different; 18x20 is 0x28, 1920 is 0x10, so different settings would likely be needed for the two different devices - which explains the header options.
One Wire Sensors library for Arduino. Contribute to theforest/Arduino-libOneWireSensors development by creating an account on GitHub.
github.com
Note that the device IDs / family codes are different; 18x20 is 0x28, 1920 is 0x10, so different settings would likely be needed for the two different devices - which explains the header options.
problem is..this is OneWire library for arduino while i'm on pico and micropython.
what can i modify on the code i posted earlier so i can make it work with a DS1920-F5
thermometer?@Pommie said it should work, but i can only notice some short of
communication between the ibutton and the pico but there's no temperature output.
problem is..this is OneWire library for arduino while i'm on pico and micropython.
what can i modify on the code i posted earlier so i can make it work with a DS1920-F5
thermometer?@Pommie said it should work, but i can only notice some short of
communication between the ibutton and the pico but there's no temperature output.
You need to port it over, it's usually far easier to port Arduino C++ to other languages, than to write your own from scratch - mostly because datasheets tend to be fairly vague, and often wrong.
Do you know if the code in post #1 actually works? Looking at the library, you need to call start_conversion(), wait (at least) 750mS and then read the scratchpad. The DS1920 has the same device ID (0x10) as a DS18S20. The library should just work as there's no way to know if a DS1920 or a DS18S20 is connected. I suspect the code in the first post is incomplete and a further search might be more successful.
Mike.
Edit, the code on this page looks more correct.
Edit, I see that is the same code as post #1. Check your hardware (4k7 pullup etc.) against that page.
i think it's alright! the pullup resistor solved the problem i'm using 3.2k resistor for the 3.3V which i
had spare, i'm reading the current temperature.. right? though 28c seems too high for room
temperature at this period,
how can i make it read and store temperatures so i can read them later?
You could store the 8 byte scratchpad readings (or just the two byte temperature) and interpret them as needed.
I suggest you read at least one scratchpad area and convert the temperature by hand to try and work out why it's wrong - unless it really is 28°C and you're sweating a lot!!!! Note, once converted, you can read the (unchanged) temperature as many times as you like without the 750mS delay.
I assume something like,
print(ds_sensor.read_temp(roms[0]))
will read the first sensor.
Note, first as in lowest rom number - not first in line.
You could store the 8 byte scratchpad readings (or just the two byte temperature) and interpret them as needed.
I suggest you read at least one scratchpad area and convert the temperature by hand to try and work out why it's wrong - unless it really is 28°C and you're sweating a lot!!!! Note, once converted, you can read the (unchanged) temperature as many times as you like without the 750mS delay.
I assume something like,
print(ds_sensor.read_temp(roms[0]))
will read the first sensor.
Note, first as in lowest rom number - not first in line.
i think the readings i'm getting it's from my hand touching the metal case,
do you think it could somehow conveniently work as a standalone device storing the values
without being permanently connected to the Pico?
They (or it) wont. However, they do contain 2 bytes of EEPROM to hold the alarm temperature. You could read the scratch pad, copy bytes 0 and 1 to bytes 2 and 3, write back the scratchpad and issue a Copy Scratchpad command to store it in the EEPROM. This would require some programming by you. You might find an example that writes the alarm values.
I thought that scratchpad could log a value, which could transfered to internal memory and then retrieve them later.. Whats the point of these tiny devices in a metal case if they need to be constantly connected somewhere?
Features and Benefits:
• 1-wire serial interface
• Self-aligns with cup-shaped probes
• Can be affixed with self-adhesive backing, latched by it's flange and locked with a ring
• Password protection for memory and control functions • Stores 8KB of data-log memory