I have a Nano ESP32 running Python. I want to connect it to the Arduino Cloud which everything says is possible. So I have set up a cloud account and tried to run a python program called cloudSetup. I have the required device ID and secret key. cloudSetup uses a library:
"from arduino_iot_cloud import ArduinoCloudClient " which is not already installed.
The only way I know to add a new library in python is to get it from the web using the get module program demoed in the nano ESP32 python 101 doc. However, the arduino_iot_cloud.py file I need to install has so far been impossible to find. I see were the library can be downloaded, but that is not in the format required to get it directly at a web address as the get module program attempts to do.
Does anyone know how to get this library installed on the Nano ESP32?
Thanks for your reply. The Manual Setup Device procedure is exactly the process I was following when I ran into this problem. So I am still looking for the answer to my question.
I also have the same issue (import error: no module named 'arduino_iot_cloud'). Furthermore, I am unsure if there is a connection with the management of the 'secrets.py' file. The instructions, such as 'This file should be copied over to the flash drive that mounts when MicroPython boots... and so on' appear to be written for experts
I do have exactly the same issue. I tried to reproduce the tutorial Connecting to Arduino ioT cloud using Micropython. The tutorial is based on Arduino GIGA or Potenta H7. I thought that it should however work on Nano ESP32 as it is designed to use Micropython. I thoughjt that these libraries would be in the firmware. It is unfortunately not the case. My feeling is that this new board needs some documentation to justify it's existence
Hello everyone! I might be wrong, but I think there's a configuration step that was missed - you should manually install the Arduino IoT Cloud library to the board via mpremote using these instructions from the Getting started guide.
Let me know if this helps!
@lburelli mpremote and the Git hub link didn't work for me and it also loaded more on my Nano than I needed. I wasn't sure if I was giving the wrong command line arguments with mpremote so I downloaded the code from that link as a zip and extracted it to a folder on my Desktop called IOT. From within Thonny I then drilled down into the "src" folder and copied the "arduino_iot_cloud" folder and its contents to "/" on the microcontroller.
Apart from the way I loaded the library everything else in the link you provided worked perfectly, I used a file called secrets.py and called my main py file IOT.py, when I declared the led I assigned GPIO48 led = Pin(48, Pin.OUT)
I was using Thonny to program a Nano ESP32 on Windows 10
EDIT I just noticed the library name in your link is misnamed that may have been my initial problem.
EDIT #2 After everything I have just said I decided to delete all the files from the flash and try again with a clean slate, this time each time I tried to move the "arduino_iot_cloud" folder onto the Nano and run a program I kept getting an error referring to the "init.py" file, I tried many times to copy the folder over but each time it failed, I even tried mpremote a few times without success. Eventually I manually created the folder then copied the four py files one at a time into the folder and this worked. Am I missing something?
A little additional information regarding the Arduino tutorials.
After the success with micropython I moved onto the Python tutorial. I copied the tutorial sketch into Sublime and modified it to closely match my micropython sketch, I also moved a copy of secrets.py into the working directory, the final step was to run the script and connect to the same dashboard I used with micropython. Everything worked great, at times though I did get the following error **09:21:24.015 task: mqtt_task raised exception: TLS/SSL connection has been closed (EOF) (_ssl.c:2396).** after that it would reconnect and carry on as normal.
Thank you @sumguy for sharing your experience! Could you please elaborate on what you mean by "it didn't work for you"? Did you get any error message?
@sumguy Thanks for spotting! We'd like to fix this. Where exactly did you find the incorrect name?
The file transfer to the ESP32 is sometimes a bit buggy. It's not related to our tools, so there is little that we can do at the moment. Using mpremote usually works, but yes, it also happened to me that I had to execute it more than once to get all files installed.
Thank you for your feedback @gmbgnn ! We'd like to make the documentation easier to follow. In the tutorial we say
This file should be copied over to the flash drive that mounts when MicroPython boots. To do so you can use the file manager tool in Arduino Lab for MicroPython or drag & drop the file manually.
I understand that this is not very detailed. What information could we add to make this easier to follow? I think that maybe a separate tutorial on MicroPython library installation in general might be a good idea. What's your take?
@sbhklr hi, I will address your questions though maybe not in the order you asked, to ensure accuracy I erased the flash and re-installed micropython 4 times taking the same steps each time and getting exactly the same results each time.
First regarding the issue with a spelling mistake I think that is a misunderstanding on my part of how mpremote addresses and downloads the files from git hub, so we can disregard my earlier statement.
The following is my download process in terminal (administrator mode) and the error I received in Thonny. The image shows the folder arduino_iot_cloud as being empty and this was the case all 4 times.
>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
ImportError: no module named 'arduino_iot_cloud.ArduinoCloudClient'
>>>
After each mpremote failure I manually moved the 4 required files into the "lib" folder and everything worked. I have a question for you if you can answer please, are the folders and contents "cbor2" and "snml" essential because my program runs without them, I guess I'm asking what do they do?
For now I will load these files onto my nano using a desktop python script.
@sumguy Exactly this happened to me as well. However, executing mpremote a second time did install the files. This does not happen with the other Arduino boards running MicroPython so it seems something ESP32 specific. We're still investigating this.
Those modules are required, yes, but the firmware of the Nano ESP32 already has those baked in. That's why it works. You can list the available modules in the REPL using help('modules'). Thing is that mpremote has no intelligence built in to determine if those modules are already frozen in the firmware so it blindly installs them. So, long story short, if you install the Arduino cloud library by hand, it's enough to copy just those files.
@sbhklr thanks, I am ok with loading the files manually until there is a fix, it is a relatively quick task. I am fairly new to IOT especially using micropython but just in a few days I have a Python GUI controlling a led on a nano esp32 via the cloud, this is pretty exciting stuff.
B.T.W. it is ironic that the only two folders I do not require are the ones that load ok, is that a clue?
@sumguy Haha, indeed interesting Might just be the order of how they are installed. We keep investigating.
Good luck with your cool project! Let us know if you encounter any other issue.
Hello @sumguy! Sorry to dig a thread from the grave, but I wanted to let you know that we found and fixed a MicroPython issue that was corrupting file data when writing to the Nano ESP32 Flash memory. You should have no issues with file transfers anymore with the latest "nightly" Micropython builds (and all future releases after the current 1.20).
@sbhklr I did try that yesterday and there was no change, I will try again but it will be late Sunday before I can get to it and I will definitely post the results.
Thanks again.