Extension—User Cloud Message

The User Cloud Message extension enables data to be shared across devices and projects. To use this extension, you need to sign in to mBlock 5.

 

Let's use CyberPi as an example to understand the User Cloud Message extension.

1. Sign in to mBlock 5

Click the Log in/Sign up icon on the right of the toolbar.

image.png

image.png

2. Create a new project

Choose File > New on the toolbar.

image.png

3. Add CyberPi

Note: If you have set CyberPi as your most frequently used device, CyberPi is automatically added when you create a new project, and you can skip this step. If you haven't, follow the steps to add CyberPi.

(1) Click the Devices tab, delete the added device, and click + add to add CyberPi.

3.gif

(2) Use a USB cable (Type-C) to connect CyberPi to your PC and click Connect to connect CyberPi.

image.png

(3) Set the programming mode to Upload.

image.png

4. Start programming

With mBlock 5, you can program a sprite to control CyberPi remotely.

4.1 Add the User Cloud Message extension

(1) Click the Sprites tab and click + extension at the bottom of the Blocks area.

1596678324368-09d85f7e-60ff-4c06-b35c-189b1765b5bc.png

(2) On the Extension center page that appears, click + Add at the bottom of User cloud message.

1596700230341-2cbeb562-f78e-4597-b9d0-b9dd2980ace2.png

After being added, the extension and its blocks are displayed in the Blocks area.

1596700313825-05e4bca0-0fa8-4ad4-a2ba-b20f39abf533.png

4.2 Program the sprite "Empty button1"

(1) Click × to delete the default sprite Panda on the Sprites tab.

1596698949726-8a4886ae-ba7a-4972-a777-67137c368a1f.png

(2) Click + add on the Sprites tab. In the Sprite Library dialog box that appears, search for button, choose Empty button1, and click OK.

1596698948961-ef92c5a7-5503-4be5-825e-1b5503c20d6a.png

1596698950071-d6424d10-c639-4b98-803e-f7eece35c26f.png

(3) Choose Empty button1 on the Sprites tab and drag the Events block when this sprite clicked to the Scripts area.

image.png

(4) Drag the User cloud message block send user cloud message ( ) to the Scripts area and name the message light_on.

1596698949748-99cc1e2b-7fb9-4830-80bd-900836aae0b1.png

(5) Add some effects on Empty button1 to make it look like being clicked. Drag the Motion block change y by ( ) to the Scripts area and enter -2, and then drag the Looks block set color effect to ( ) to the Scripts area and enter -10.

1596698950036-cf92127a-2a2b-4061-9afe-6dd46332c9ed.png

1596698949200-b9e52a01-7d7a-4826-a633-186c7a4918ad.png

(6) Drag the Control block wait ( ) seconds to the Scripts area and enter 0.2; drag the Motion block change y by ( ) to the Scripts area and enter 2; and drag the Looks block set color effect to ( ) to the Scripts area and enter 0.

1596698949930-f0ba1ef3-b3e2-4679-b1cb-b5bd30cc370d.gif

4.3 Program CyberPi

Now, let's program CyberPi. Ensure that the name of the message to be received by CyberPi is the same as that sent by Empty button1.

4.3.1 Connect to the network

(1) Drag the Events block when CyberPi starts up to the Scripts area.

image.png

(2) Drag the IoT block connect to Wi-Fi ( ) password ( ) to the Scripts area and enter SSID and password of an available wireless network.

image.png

(3) To ensure network connection, drag the Control block wait until ( ) to the Scripts area, and then drag the IoT block network connected? to the Scripts area.

image.png

image.png

(4) Drag the LED block display ( ) to the Scripts area and set the colors of all the LEDs to green to indicate that the network is connected.

image.png

4.3.2 Write the User Cloud Message program

When CyberPi receives the user cloud message "light_on", make all LEDs on it lit up in red and then go off.

(1) Drag the IoT block when receiving user cloud broadcast ( ) to the Scripts area and enter the name light_on.

image.png

(2) Drag the LED block display ( ) to the Scripts area and set the colors of all the LEDs to red.

image.png

(3) Drag the Control block wait ( ) seconds to the Scripts area, and then drag the LED block turn off LED ( ) to the Scripts area.

image.png

image.png

(4) Click Upload to upload the program to CyberPi.

image.png

(5) Restart CyberPi, wait until all the LEDs on it are lit up in green, click Empty button1 on the stage, and see what happens.

(6) Disconnect CyberPi from mBlock 5, click Empty button1 on the stage, and see what happens.

4.4 Save the project

Click Save on the toolbar to save the project to My Projects.

image.png

After the project is saved, you can sign in to the same mBlock 5 account on other devices to open the project from My Projects.

image.png

Restart CyberPi, wait until all the LEDs on it are lit up in green, click Empty button1 on the stage, and see what happens.

You can use the sprites on mBlock 5 to control Halocode and Codey remotely in a similar way.

Was this article helpful?
0 out of 0 found this helpful

Comments

1 comment
  • No funciona.

    Hago click en el sprite, pero el CyberPI no recibe ningún mensaje.

    Al margen de esto, me gustaria saber para que sirve i como se utiliza el "codigo de atutentificación del servicio en la nube".

     

    Gracias.

    0

Please sign in to leave a comment.