robert-hh / Onewire_DS18X20

Classes for driving the DS18x20 sensor with the onewire protocol for Pycom MicroPython
11 stars 6 forks source link

Problems with LoPy4 v1.20.2.r6, worked well with v1.20.2.r4 #22

Open danalvarez opened 10 months ago

danalvarez commented 10 months ago

Dear Robert,

I know this might not be the exact place to post this, but since the Pycom forum has a lot less traffic nowadays, I was wondering if you could help me here.

I'd been using this library and it's worked great up to pycom's v1.20.2.r4 firmware. I recently updated to 1.20.2.r6, just to test, and I've noticed a weird issue I cannot seem to wrap my head around.

My setup:

  1. LoPy4 with v1.20.2.r4 and v1.20.2.r6, LittleFS firmware
  2. Your example code, but with the temp.resolution(roms[0], 9) line commented out.
  3. Not using parasitic power mode, providing 3.3 V from the LoPy4 output to the DS18X20 sensor.
  4. 4.7 kOhm pullup resistor on the OW line.

In v1.20.2.r4, the output from your example code is working OK:

Powermode =  0
Resolution 12
26.75
26.8125
26.8125
26.8125

But in v1.20.2.r6, the readings all return None (I assume due to a CRC check error). See:

Powermode =  0
Resolution 12
None
None
None
None

However, and here is the weird part, if I simply run the following code in the REPL, with v1.20.2.r6, I DO get readings:

>>> temp.convert_temp()
>>> temp.read_temp(roms[0])
27.0625

It doesn't make sense to me that the code would work well in the REPL, but not when running from main.py. I think this means the problem is not your library, but something weird in pycom's new FW version. Have you seen this behaviour or could you maybe reproduce it? Any ideas? Thanks!

robert-hh commented 10 months ago

I tested that here with a LOPy4 and v1.20.2.r6 with the code from the repository, and it works as it should, even without the additional pull-up resistor.

`Pycom MicroPython 1.20.2.r6 [v1.20.1.r2-403-g01403a704] on 2023-02-08

danalvarez commented 10 months ago

Could you point me towards the firmware you are using? When I update my firmware to 1.20.2.r6 with the Pycom Firmware Updater GUI tool, I get:

Pycom MicroPython 1.20.2.r6 [v1.11-c5a0a97] on 2021-10-28; LoPy4 with ESP32

And, if I call os.uname(), I get:

(sysname='LoPy4', nodename='LoPy4', release='1.20.2.r6', version='v1.11-c5a0a97 on 2021-10-28', machine='LoPy4 with ESP32', lorawan='1.0.2', sigfox='1.0.1', pybytes='1.7.1')

I think we might not be using the same firmware...

robert-hh commented 10 months ago

We definitely do not use the same firmware, because I built mine myself. To be sure, I created a new one 1.20.2.r7, which you can find here: https://github.com/robert-hh/Shared-Stuff I tested it with a ds18x20 with the code from the ds18x20 repository https://github.com/robert-hh/Onewire_DS18X20 and it works.

danalvarez commented 10 months ago

Then, I think the problem is Pycom's 1.20.2.r6 firmware. Here are some tests I conducted:

Test 1

  1. Update the firmware using the latest (1.16.6) Pycom Firmware Updater GUI tool: image
  2. Test with ds18x20_example.py from this repository.
  3. The output of the temperature readings is None.

Test 2

Repeat test 1, but instead of using the GUI tool, use the pycom-fwtool-cli and the 1.20.2.r6 firmware available here. The result is the same as in test 1.

Test 3

  1. Just to test, use the pygate version of the 1.20.2.r6 firmware available here. Update it also with the pycom-fwtool-cli. The command is: pycom-fwtool-cli.exe -p COM3 flash --tar LoPy4-1.20.2.r6.tar.gz
  2. Test with ds18x20_example.py again.
  3. Temperature readings work OK. image

Test 4

  1. Uploading your firmware image (1.20.2.r7), again with the pycom-fwtool-cli.
  2. I can confirm the installed firmware is: Pycom MicroPython 1.20.2.r7 [v1.20.1.r2-435-gbf9d3a698] on 2023-08-21; LoPy4 with ESP32
  3. Test with ds18x20_example.py again.
  4. Same results as in test 3, temperature readings work fine!

Any chance you could try to reproduce test 1 or 2?

robert-hh commented 10 months ago

With test 2 it works as well.

Pycom MicroPython 1.20.2.r6 [v1.11-c5a0a97] on 2021-10-28; LoPy4 with ESP32