Cannot save code onto microcontroller for Module 5 #159
-
I've worked on my insert.py and find.py codes, and I want to test them with pytest. The see that the top of insert.py states that I need to run it in my microcontroller. However, when I try to save insert.py onto my microcontroller, I get this backend error: **Could not write next block after having written 0 bytes to /insert.py File "", line 1, in File "", line 4, in __W OSError: 28 ] __W(b'# This file needs to be run on your microcontroller\r\nfrom netman import connectWiFi\r\n\r\nfrom my_secrets import (\r\n SSID,\r\n PASSWORD,\r\n DATABASE_NAME,\r\n COLLECTION_NAME,\r\n COURSE_ID,\r\n LAMBDA_FUNCTION_URL,\r\n)\r\n\r\n# TODO: other imports here\r\nfrom pymongo.mongo_client import MongoClient\r\nimport requests\r\nimport json\r\n\r\n# Connect to WiFi\r\nconnectWiFi(SSID, PASSWORD, country="US")\r\n\r\n\r\n# Dummy function for running a color experiment\r\ndef run_color_experiment(R, G, B):\r\n """Simulate color sensor readings"""\r\n wavelengths = [410, 440, 470, 510, 550, 583, 620, 670]\r\n rw = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.9, 1.0]\r\n gw = [0.2, 0.4, 0.6, 0.8, 1.0, 0.8, 0.4, 0.2]\r\n bw = [0.9, 1.0, 0.8, 0.6, 0.4, 0.2, 0.1, 0.0]\r\n sensor_data = {\r\n f"ch{wavelength}": rw[i] * R + gw[i] * G + bw[i] * B\r\n for i, wavelength in enumerate(wavelengths)\r\n }\r\n return sensor_data\r\n\r\n\r\n# NOTE: Even though experiment_id is hard-coded here, pretend that it was\r\n# auto-generated by the "orchestrator"'): ''). Process ended with exit code 1.** Restarting does not solve the problem. Could you shed some light on this. Do I need to delete and reinstall Thonny? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Im wondering if the insert.py is reflecting the newest version. In particular, pymongo can't be used within MicroPython. Can you commit your latest files and include a link to your assignment repo here so I can check? I haven't seen this error before, but it may be related to storage space on your microcontroller. Could you try deleting all files on it (except maybe your HiveMQ certificate so you don't have to regenerate it) and reuploading the necessary ones for module 5? If that doesn't work, could you also try reflashing MicroPython onto the microcontroller? |
Beta Was this translation helpful? Give feedback.
I've committed my latest files. Here is the link to my repo:
https://github.com/ACC-HelloWorld/5-data-logging-uznab16-1
I think space was the issue. I was able to update insert.py and save it onto my microcontroller just now after deleting some files from previous assignments.