pycom / pycom-libraries

MicroPython libraries and examples that work out of the box on Pycom's IoT modules
330 stars 379 forks source link

Pysense board ADC code generates an exception #24

Closed rolandvs closed 6 years ago

rolandvs commented 6 years ago

Dear,

I have a loPy (1.7.7.b1) with a Pysense board. I changed the sense.py example into main.py with a few changes. Nothing special. However after running it, it will crash/stop.

Traceback (most recent call last):
File "main.py", line 41 in <module>
File "main.py", line 35 in <main>
File "/flash/lib/pysense.py", line 177, in read_battery_voltage
File "/flash/lib/pysense.py", line 118, in peek_memory
File "/flash/lib/pysense.py", line 85, in _write
File "/flash/lib/pysense.py", line 97, in _wait
OSError: I2C bus error
Micropython v1.8.6-715-g5fa16c2c on 2017-07-20; LoPy with ESP32

There is no I2C error but reading (peeking) the battery voltage is generating the problem.

Rebooting it by ctrl-C, ctrl-D let it tells me that the Pysense board cannot be found. Looking at the code the problem seems to be in the init part and the read_battery_voltage part of the code. Disabling the ADC init code and not using the py_read_battery_voltage() anymore keeps everything running.

Only de-powering the unit completely (no battery/no USB) will "recognise" the board again, but any use of the read_battery_voltage will raise an exception again.

danicampora commented 6 years ago

Hi,

When you read the firmware version of your Pysense, what value do you get?

rolandvs commented 6 years ago

pysense.__version__ reports 1.0.2

danicampora commented 6 years ago

@rolandvs that's not what I meant... Can you call the .read_fw_version() from the pysense library and see what it returns? I think you have an old firmware on your Pysense...

rolandvs commented 6 years ago

The read_fw-version returned 1 and I reprogrammed the pysense and pytrack boards to version 0.0.4. The code seems to be working now as expected. Thanks!

(in the mean time I almost finished decoding $GNMRC instead of $GNGLL to get date/time to set the RTC when GPS is available).