LoPy4 + Exp Board: SD stops working after some time
I'm trying to build a simple data-logger using a digital sensor (I2C) as input and appending the values on a test.txt file on the SD card. I tried to reduce the power consumption as much as possible by means of machine.deepsleep(600000) to wake-up the system every 10 minutes. This works well for a while, let's say 3 to 6 hours, but then the following error occurs:
File "boot.py", line 127, in <module> OSError: the requested operation failed Traceback (most recent call last): File "main.py", line 70, in <module> OSError: [Errno 19] ENODEV
At line 127 of the boot.py file I mount the SD card
and line 70 of main.py opens the text.txt file.
f = open('/sd/test.txt', 'a')
Now, the second error is clear, but I can't figure out why the SD stops working after several loops. Can anyone help me, please? Thanks in advance
I've already tried to replace the SD card. I've also tried the code with LoPy4 + Exp.2.0 and with LoPy4 + Exp.3.0.
Thanks for the support! I'll wait for your feedback, best
No those shouldn't cause a conflict. We'll try it internally, thanks.
I'm using LoPy4 pin 'P9' for SDA, and pin 'P10' for SCL (GPIO16 and GPIO18 on Expansion board 3.0).
from machine import I2C i2c = I2C(0, I2C.MASTER, baudrate=100000)
For your information, I'm also using the analog channel P16 for the Vbatt read-out.
adc = machine.ADC() readADC = adc.channel(pin='P16', attn = adc.ATTN_11DB)
Lastly, I send the data to a nano-GW (FyPy) via Raw LoRa.
from network import LoRa uart = machine.UART(0, 115200) os.dupterm(uart) _LORA_PKG_FORMAT = "!BB%ds" _LORA_PKG_ACK_FORMAT = "BBB" lora = LoRa(mode=LoRa.LORA, tx_iq=True, region=LoRa.EU868) lora_sock = socket.socket(socket.AF_LORA, socket.SOCK_RAW) lora_sock.setblocking(True) rtc_stack = (str(DEVICE_ID) + str(temperature) + str(humidity)) rtc_pkg = struct.pack(_LORA_PKG_FORMAT % len(rtc_stack), DEVICE_ID, len(rtc_stack), rtc_stack) lora_sock.send(rtc_pkg) lora_sock.close()
Could some of these instructions conflict in your opinion?
Which pins are you using for your I2C sensor?