Question about coding

I just built the Chatter 2.0 with my son yesterday, and want to clarify something about the coding. It seems that using the web/codeblocks/micropython environment to make and upload programs works, but in doing so we lose the main the “Chatter” functions. Also, the uploaded program works only until the device is powered off. Turning it back on, nothing happens, and the device appears broken until the USB is reconnected to the coding environment, and code is sent to the device again.

I just want to ask if I am correct about this, and if it that’s how it is meant to work. I mostly understand how we can have either the chatter code or the custom program at a time (although I’d prefer to have both), but losing the custom code when cycling power seems odd to me.

Thank you in advance for replying to this!

1 Like

Hey Daniel.

That’s correct, you can use the coded program until you restore firmware.

Also, your Chatter will have a black display until you code something on it.

Let me know if you have any further questions,
Monika

I’ve only been tinkering with these beyond Codeblocks for a few days, but I think I have a solution to have your custom code boot up when the device boots. It’s not straightforward, but works reliably for me.

You’ll need to download Thonny IDE and have some familiarity with programming through that.

Beyond that, I do the following:

  1. Flash Micropython to the device using the Codeblocks environment. Unfortunately, I haven’t found another way to put Micropython on the Chatter 2.

  2. Close the browser to disconnect the Chatter 2 from Codeblocks’ serial monitor.

  3. Open Thonny, and from the View menu, enable the settings that show files and the shell if they aren’t already enabled.

  4. If your Chatter 2 is off, turn it on. Otherwise, cycle the power off and then back on.

  5. In the bottom right corner of Thonny, you should be able to set the com port after you’ve turned the device back on. Both the “MicroPython(ESP32)” and “MicroPython(Generic)” options should be available and either one works for me.

  6. Press the stop button on the Thonny tool bar, and the shell should show a message about the soft reboot followed by a message about the Micropython version. You should also see a “boot.py” file appear on the Chatter 2.

  7. Be careful with this step or you could lose your code. I save everything to my pc first before adding it to the Chatter 2. The commented code in the boot.py file appears necessary so leave those lines in the file. Any other code you add and save to the boot.py file will run when the device is powered on. Unfortunately running code from the boot.py file makes it impossible for you to write to the file system on the device after that. If that happens, restore the stock firmware and then start back at step 1.

I should mention I’m using Windows 11, as that may be relevant to using Thonny. To test new code, I develop in separate files and run them on the device without putting any code into the boot.py file. This reliably allows me to come back to unfinished work without needing to reflash the device. When I’m done testing my code, then I either copy it into the boot.py file or I save it to the Chatter 2 as a separate file and add an import statement for it to the boot.py. I’ll need to reflash the stock firmware followed by Micropython to the Chatter 2 if I want to change the code after that.

You can log back into Circuitblocks after Thonny is connected to the Chatter 2, but you can’t use both to upload code to it at the same time. To figure out how to program the device, I’ve been using Circuitblocks as documentation for the available methods in the Chatter2 module - basically I build out something simple in Circuitblocks, like a button press, then copy the code and modify variable names, etc. in my files. Other Micropython modules like network and socket have effectively worked to use the WIFI capability of the Esp32 too, so this little device seems like it has a ton of potential to explore beyond Circuitblocks.

I hope all that helps!

I was coding one of my chatters and after I disconnected it it did not return to the home screen how do I do that without restoring firmware. Also when I connected my other chatter 2.0 I accidentally disconnected it while it was connecting and now it won’t connect and turn on. Please help!

1 Like

Hey @chris2,

you’ll have to restore it’s firmware.

Please keep in mind that this is one of the most popular requests we’ve received, and our software team is working on adding a feature that will allow you to return to the home screen without having to restore the firmware.

We expect that feature to be available in January or February 2024.

Thank you for your patience,
Monika