Alvik: uploaded program only works if connected to pc, or reconnected and reuploaded

Hello!
I don't know if this is the right place to ask this question, but no specific Alvik category exists, so here I am.

There is something I don't understand in Alvik's usage.

(1) I turn Alvik off, I connect it to pc, I run Arduino Lab for Micropython, I establish a software connection (connection button in the Arduino Lab IDE), I type some source code into the IDE and send it to the robot, I finally turn the robot on (it is still connected both physically and electronically).
(2) My program starts running after a while (e.g. the robot runs); I physically disconnect the robot, my program continues working in the robot (e.g. Alvik continues running)
(3) Now, I turn the (disconnected) robot off, then I turn it on again: my program does not start! on the contrary, the default "three ready-to-go examples" starts: my program remains "invisible"
(4) I now turn the robot off, I connect it again to computer, I turn the robot on: nothing changes ("three ready-to-go examples" starts: again, my program is not visible)
(5) I now establish software connection (again the connection button), I reupload my program, now it works again!

It is evident there is something I don't understand: it would be normal for me to upload once and run several times without reconnecting to pc.

What am I doing wrong?
Thanks
Giorgio

Could be the code, which you forgot to post.

A common mistake is something like this:

Serial.begin(115200);
while (!Serial) yield();  //wait for connection to serial monitor.

Hello, thanks for your kind reply.
The code is quite stupid:

from arduino_alvik import ArduinoAlvik
alvik = ArduinoAlvik()
alvik.begin()
speed = 25.00
alvik.drive(speed, 0.0, linear_unit='cm/s')

The problem is systematic: I have two robots (the firmware was updated yesterday on one of them), and both do the same, so it must be something I am doing wrong.

After sending the code:

  • I turn it on (it is not clear to me if I have to turn it on before sending the code, or after doing it, but I tried both) and the robot starts running (executing my dumb code), then...
  • I detach the cable: everything looks fine, the robot continues running. Now...
  • I turn the robot off, then...
  • I turn it on again: the robot has forgotten everything and the "three option demo code" starts. I have to reconnect and resend my code.

Getting mad.
Thanks
Giorgio

I have the same problem. Even the out of the box programs do not start when turning the Alvik on. But I can launch them from the IDE.

I suspect that some loader should be installed on the Alvik to start the program when the robot is turned on. But I don’t see which one.

I have understood what happens. The mBlock app replaces the main.py file on the robot by its own program. To restore the original demo, you have to edit the main.py file and replace the code by "import demo".

To edit main.py, use the app "Arduino lab for MicroPython".

Hello, thanks for your contribution. My problem seems a bit different, because the original demo is the only thing that works after removing the connection between the robot and the pc. In my case it looks like there are two different ways of "booting", one when connected, one when detached, and it seems that transferring new code to the robot does not remove the old one (the demo).
Moreover, I am only using Arduino Lab for MicroPython.
I don't know yet how MicroPython works on Alvik, so I cannot figure out what is going on.
I am quite sure that if I start using C++ and the Arduino IDE, everything will work as normal, because in that case I will be actually wiping the MicroPython environment out and clean things, but I wish to use python.
Anyway, thanks.
I will play with the robots during Christmas vacations and be back if I find anything.
At present I am quite discouraged...
Best regards, and merry Christmas / happy Winter vacations.
Giorgio

When Alvik is turned on while disconnected from your PC it runs main.py.

What is in main.py on your Alvik?

If it contains "import demo" then it will run the demo.

If you want it to run something else you need to replace the word "demo" with the name of the code you uploaded.

Make sure you save the change.

I'm sorry if is too basic an explanation, I'm not sure how else to help you..

Dear Arduinob8on, thanks for your kind reply! Your answer explains very well what is going on! As I thought, it was something I didn't know about how Alvik works. Moreover, I did not find this information in the Web DOC pages, probably my fault.
By the "file manager" button I could load main.py, I changed it with my code, and now everything is ok!
Really, really thanks!
Best regards,
Giorgio

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.