Having issues with trying to catch "OneWireError" exception

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Having issues with trying to catch "OneWireError" exception

Post by davef » Mon Mar 29, 2021 10:50 pm

Code: Select all

def reset(self, required=False):
(line 22)        reset = _ow.reset(self.pin)
        if required and not reset:
            raise OneWireError
return reset
at https://github.com/micropython/micropyt ... onewire.py

Hmmm. I had issues with external electrical disturbance messing with my 1-wire on the RaspberryPi.

Swap sensors and see if the problem follows?

rpi_nerd
Posts: 35
Joined: Sat Jul 29, 2017 2:05 pm

Re: Having issues with trying to catch "OneWireError" exception

Post by rpi_nerd » Tue Mar 30, 2021 1:43 am

IIRC I had the same issue when using another sensor some time ago before I swapped it out for the current one (think the reason for swapping was that I wanted a longer cable.)

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Having issues with trying to catch "OneWireError" exception

Post by davef » Tue Mar 30, 2021 3:18 am

Just to clarify ... swap sensors and see if the problem moves to the other pin. Have you also tried setting up just one 1-wire pin and seeing if that specific sensor still faults?

4K7 pull-up and normal mode?

Good luck!

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Having issues with trying to catch "OneWireError" exception

Post by kevinkk525 » Tue Mar 30, 2021 5:21 am

You might need to catch "onewire.OneWireError"
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

rpi_nerd
Posts: 35
Joined: Sat Jul 29, 2017 2:05 pm

Re: Having issues with trying to catch "OneWireError" exception

Post by rpi_nerd » Tue Mar 30, 2021 11:32 am

kevinkk525 wrote:
Tue Mar 30, 2021 5:21 am
You might need to catch "onewire.OneWireError"
That works! Thanks!

rpi_nerd
Posts: 35
Joined: Sat Jul 29, 2017 2:05 pm

Re: Having issues with trying to catch "OneWireError" exception

Post by rpi_nerd » Tue Mar 30, 2021 11:37 am

davef wrote:
Tue Mar 30, 2021 3:18 am
Just to clarify ... swap sensors and see if the problem moves to the other pin. Have you also tried setting up just one 1-wire pin and seeing if that specific sensor still faults?

4K7 pull-up and normal mode?

Good luck!
Yes to both 4K7 pull-up and normal mode.
Up until recently I was just using one sensor. Now come to think about it, I've had similar issues with non 1-wire sensors such as the DHT22(on a different pin.)

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Having issues with trying to catch "OneWireError" exception

Post by davef » Tue Mar 30, 2021 6:50 pm

What specific ESP8266 board and how are you powering it? I would comment out send_data() and print-out or log any failures you get. Maybe it is a powering issue.

rpi_nerd
Posts: 35
Joined: Sat Jul 29, 2017 2:05 pm

Re: Having issues with trying to catch "OneWireError" exception

Post by rpi_nerd » Thu Apr 01, 2021 2:53 am

I'm using a D1 board with the Arduino Uno form-factor and powering it with a 12V wall wart thru the barrel jack. I've also taken to opportunity to update the firmware to the latest version.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Having issues with trying to catch "OneWireError" exception

Post by davef » Thu Apr 01, 2021 3:46 am

Current rating of the 12V Wall-mart and what 12V to 3V3 regulator chip on D1? Commenting-out the send_data() should remove any high peak current issues with the supply system.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Having issues with trying to catch "OneWireError" exception

Post by davef » Fri Apr 02, 2021 6:07 am

Hi Kevin,

Code: Select all

import onewire
import ds18x20


try:
    roms = ds.scan()
except OneWireError as error:
    try:
        with open('errors.txt', 'a') as outfile:
            outfile.write(str(error) + '\n')
    except OSError:
        pass
and

Code: Select all

try:
    roms = ds.scan()
except onewire.OneWireError as error:
    try:
        with open('errors.txt', 'a') as outfile:
            outfile.write(str(error) + '\n')
    except OSError:
        pass

Both seems to work in the sense that I don't get any
errors, but are they both gathering the same information?

Also, I have seen this example:

Code: Select all

for rom in roms:
    try:
        print (ds.read_temp (rom), end = '|')
    except CRCError:
        print("CRC error reading the temperature, unit", rom)

I don't see CRCError in onewire.py so I guess CRCError is defined
somewhere else, but where?

In ds18x20.py I see:

Code: Select all

 raise Exception("CRC error")
but still no CRCError

Thanks,
Dave

Post Reply