Who has the strongest centrifugal force?

Table of Contents
Who has the strongest centrifugal force?


Do you remember the spintop? You might have had a wooden or plastic one, but we bet it wasn't a smart one. Now you can finally make one – it will register your centrifugal force. Measure it against your friends to see who is centrifugally the strongest one! 💪

In this project, you will learn to measure the fast spinning of the box. 👈

All you need is the box with button and the USB dongle in the basic HARDWARIO Starter Kit.

Download new firmware

  1. If you haven't done it yet, put it together the Starter Kit.
  2. Upload new firmware to Core Module - bcf radio spinning game (you will find it among other firmware in the Playground). Thanks to this firmware, the box will become sensitive to rotation. 👌

Our tip: You don't know how to download firmware or what it even is? You can find out here.

  1. Pair the Core Module with the USB Dongle. Right after pairing it, you will notice that your Core Module has changed Alias to rotation-g-meter.
HARDWARIO devices list

Build in the Node-RED

  1. In the Playground, click on the Functions tab, where is the programming desktop Node-RED. 🤖
  2. Start as always: first place the MQTT node from the Input section on the desktop.

Double-click on it and copy Topic to the field. With this, the box will measure the centrifugal force:

MQTT topic

Confirm it with the Done button.

  1. Surprise. 😲 Under the first MQTT node, place a second MQTT node from the Input section. This time, save another Topic in its settings; with this one, the box will measure the rotation time:
MQTT input node
  1. To each node, place one node for javascript. You can find them in Function section, under Function (original, right? 🤡).
javascript fuction node
  1. Double-click on the upper Function node and insert this code into the large field. The code will register the record centrifugal force. 💪
var record = flow.get("record") || flow.set("record", 0.0);
var lastSpin = parseFloat(msg.payload);

if(lastSpin > flow.get("record"))
    flow.set("record", lastSpin);
    return msg;

In the Name field, name the node as Save the record.

javascript function Node-RED

Confirm it with the Done button.

  1. Into the bottom Function node, insert the code that will register the record spin time. ⏰
var record = flow.get("timeRecord") || flow.set("timeRecord", 0.0);
var lastSpinTime = parseFloat(msg.payload);

if(lastSpinTime > flow.get("timeRecord"))
    flow.set("timeRecord", lastSpinTime);
    return msg;

In the Name field, name the node as Save the record.

Javascript Funciton HARDWARIO Kit

Confirm it with the Done button.

  1. Under the upper Function node, place the text node from the Dashboard section. You can place it elsewhere, but for the sake of clarity it will be better if they are aligned vertically.
Text Node

In settings, name it Last spin. This way, it will show you the value that the box just measured.

Edit text Node
  1. Place another node under this one; thanks to the bottom one, the values will be registered into a graph. 📈 You will find it as Chart node in Dashboard section.
Chart node

In the Label field, name it as History. Into the X-asis Label field, set automatic, which means that the unit will be added automatically.

settings of chart node in Node-RED
  1. Under the second javascript, place the Text node from the Dashboard section.
Dashboard text node

You will determine in it how the length of the latest rotation is displayed: Time of last spin.

Set text node in dashboard
  1. Next to each level, place one Text node from the Dashboard section. Those will affect the way you see the record time registered in the graph. Set up the Record label and Record time, respectively.
HARDWARIO playground text nodes
  1. And then connect it all as shown in the picture. You will have two separate flows on the desktop. In the end, don’t forget to press the Deploy button to make it all work. 🚨
Deploy Node-RED flow

Give it a spin!

  1. Invite all your friends and get them worked up. Have a Coke. 😄
  2. Measure your centrifugal force! One by one, spin it. Our tip: For the best spin, make the box stand on its button.
  3. Follow the results in the Dashboard tab. So, good luck and …. spin it like you dare!
settings of chart node in Node-RED