Friendship Library Update: New Writing to Serial Monitor Feature!


#1

Go update your Friendship Code Library now!
NEW feature available!

This update allows you to print in the Arduino Serial Monitor!
If you want this new feature GO UPDATE!

WHAT IS NEW?

The Jewelbot can now communicate with the Arduino’s Serial Monitor for USB Serial Output. What does all of that mean? :dizzy_face:

The Serial Monitor is a separate pop-up window that acts as a separate terminal that communicates by receiving and sending serial data, which is information transferred bit by bit.

The Serial Monitor can be found on the Arduino IDE here:

REQUIRED SET UP

  • set_run_loop_charging()
    Needed within “setup()” in order to let the Jewelbot run loop() while plugged into the charger.
void setup() {
// put your setup code here, to run once:

// Function to tell the Jewelbot to run the loop() function
// while plugged into USB power
set_run_loop_charging();
}

AVAILABLE FUNCTIONS
There are two functions available which allow for outputting messages and variable values from the Jewelbot.

  • JWB_SERIAL(string to output)
    This function prints a string message to the Serial Monitor.
JWB_SERIAL("Debugging message.\n");
  • JWB_SERIAL_PRINTF(string with formatting, variable)
    This function prints a string message and variable value to the Serial Monitor.
JWB_SERIAL_PRINTF("x = %u\n", x);

EXAMPLE
Once the Jewelbots Friendship Board is selected, there is an example sketch of this functionality under the File -> Examples -> Jewelbots_Examples called USB_output.ino.

When you upload it, click the magnifying glass icon in the top right (as shown in the picture above) to open the Serial Monitor. If you see weird characters or nothing show up, then change the Baud rate setting in the bottom right on the Serial Monitor window. Make sure 38400 baud is selected!

Check out our Github Wiki for extra information

WHY?

The primary objective of these messages is typically for debugging purposes, to learn where and how your program is running.

However, you can also code things like an official “Hello World” project.

JWB_SERIAL("Hello World!");

HOW TO UPDATE?

  1. Go to Tools > Board > Boards Manager
  2. Type in “j” to the search bar
  3. Click on the box for the Jewelbots Friendship Library and hit “Update” to automatically update you to the most recent version
  • While in Boards Manager, make sure to check and see if you have the most updated version of the “Jewelbots Firmware Update” and “Jewelbots Arduino Library” boards.

#2

@Quymbee I love this Feature! I have been looking everywhere for this but I have one question or feature request. Is there a way for the Jewel bot to store or send the debug messages/info because I often encounter bugs in the wild and I would like to know where I went wrong in my code or what my limitations are.

Thank you very much


#3

Hey David great question,

where would you like to see them?


#4

I have been thinking long and hard on this and even slept on it and I believe I have an answer/suggestion. I would like to see a library added to one of the Boards(not sure which one would be the right one) and the reason why I say library is because it could be nice to have three types(info/log, error, warning) of debug messages.
I would also like propose a name for the new library too, I think “console” would be a good name so here is some pseudocode to give an idea of what it could look like:

CONSOLE console;
Animation animation;
if(bluetooth_friend == false) {
//check if connected to phone to send message over wifi
if(phone_connect == true){
messageSend.phone;
console.log( color_group +" friend group message over sent over WiFi");
}else{
console.error( color_group +“friend group was not found either on bluetooth or WiFi and message was not sent”);
animation.flash_single_color(RED);
}

the console lib would act as a kind of array where it would store any and all errors,logs and warnings or could be stored in a class and when called upon it would loop through all of its contents in a format something like this ( [{time}:Warning] Warning Message ) to the serial Monitor by either detecting the Jewel Bots connected to the computer or creating a for/foreach statement that loops through its contains with the charging_button_press function.

I know I may not have the best example or used the right terms but I believe this will benefit the whole Community because when trying out new programmes at school with friend no kid is going to have a laptop or computer near by when something goes wrong and I doubt he/she would ask her friend to keep her Jewel bot over night to try to see where things went wrong assuming it happens again or waiting a weekend for the friend to over to debug together rather than making something new or improve what is already there. I believe the ideal thing to have is to know you got an error and then go home and connect the Jewel bot to the computer and find out what the error was that night and fix in time to show his/her friend the next school day


#5

That would be awesome, I think, to be able to see possible errors through your phone. Is that what you are thinking? I really like that. It’s convenient because your Jewelbots don’t have to be attached to anything when you’re getting the error.


#6

I was actually thinking about the Jewel bot storing the error itself but having it sent a to phone is a better idea but then I have to happens when the child doesn’t have a phone or the phone isn’t in range? will the Jewel bot have a buffer to store the errors until a phone or computer is detected? I also have a question about the Jewel bot, when the battery dies on the Jewel bot when a program is running, will the Jewel bot store what ever what was going or will the program restart resetting everything to zero again when the Jewel bot turns back on.


#7

good question about the buffer, that would have to be built.

The program stays on the bot until new code is uploaded, so even if it dies the program stays the same.

If the reset button is pressed, the code gets reset to factory defaults.