Send data to Ctrl

Creating a data upload project in CtrlR

  • On your computer, create a new, empty, directory called Ctrl_signals

  • Go back to VS Code and open the project folder you have created

  • Now, we will need to modify the built-in python files: main.py.
    • main.py – This script runs directly after boot.py and should contain the main code you wish to run on your device.

 

Program the F1 Starter Kit for data upload

Add the following code to default main.py:

# Import what is necessary to create a thread
import time
import math

# Send data continuously to Ctrl
while True:
	for i in range(0,20):
		ctrl.send_signal(1, math.sin(i/10*math.pi)) #use signal #1
		print('sent signal {}'.format(i))
		time.sleep(10)

Now it’s time to test your code, use File->Save / ctrl-S to save your edit to main.py, and press the Reset button on the Starter Kit to reboot your device.

Since main.py persists on your device even after reboot. It will run forever after the device boot up, in order to stop the script, click onto the CtrlR terminal, and press ctrl-c on your keyboard.

Visualize your data on Ctrl platform

Check the raw data of your signal

  • Go back to Ctrl platform on your web browser
  • Go to Ctrl platform device page and select your F1 Starter Kit Device
  • Then go to Signals tab and you will see the last message that your device sent to this signal

  • Click on the message will pop up the historical messages of this signal

Add a widget for the signal

  • Then go to Dashboard tab and click on Add Widget

  • Select the type of visualization (e.g. bar chart or line chart)
  • Fill in the parameters (example below):
    • Name: “Test Data”
    • Chart type: “Line chart”
    • Signal: 1 (must be the same as the signal number used in main.py above)
  • Click on button “Add Widget”

  • Click on the Dashboard tab. Your widget was successfully added and you will be seeing new data being updated every 5 seconds!  [Image showing data history and timestamp]