UCUq

UCUq #

This project is under heavy development so this page is a work in progress and will be updated to reflect this project advancement.

The UCUq library is a Python library to help prototyping circuits build around microcontrollers. With this library, you can remotely test a component connected to a microcontroller without having to upload a dedicated program each time.

Thanks to Brython, you can use this library directly from a web browser, with nothing to install. This means you can pilot components connected to a microcontroller with a smartphone or a tablet, or even your connected TV.

The microcontroller must have WiFi capabilities and Micropython installed on it. This library can so be used with Raspberry Pi Pico (2) W, ESP32, ESP8266

Online demonstration #

Setting up #

  • Go to following Wokwi project: https://wokwi.com/projects/416685595189258241;
  • go to the tab corresponding to the ucuq.json file;
  • in the Identification entry, fill the 2 empty strings (token and id; please read below section about them);
  • launch the Config app;
  • fill the Token and Id fields with the value given above in the Identification entry above and click on the Save button;
  • return to the Wokwi project;
  • run it (click on the green start button);
  • wait until connected (it may takes up to 10 sec.);
  • enjoy with one of the app below.

The demonstrations #

Click on below links. The applications are automatically started. You can modify an application directly in the browser and then restart it by clicking the Run button.

About the token, the id and the ucuq.json file #

The ucuq.json file looks like this:

{
  "Identification": ["<device_token>","<device_id>"],
  "WLAN": {
    "<wlan_name>": ["<wlan_ssid>", "<wlan_key>"]
  },
  "OnBoardLed": [<led_pin>, <led_logic>],
}
  • <device_token>: token of the device ; choose one which can not be easily guessed; a token can be shared between several devices;
  • <device_id>: id of the device, must be unique among devices with the same token;
  • <wlan_name>: name of the wlan (whatever value you want);
  • <wlan_ssid>: SSID of the wlan;
  • <wlan_key>: secret key of the wlan;
  • <led_pin>: the pin of the onboard led from the microcontroller (usually an integer, but can be a string, as with the RPI pico (2) W);
  • <led_logic>: true when the led lights up when the pin level is high, false otherwise.

<device_token> and <device_id> is for the identification of your device. The token identifies your project, and the id identifies devices within same project. You can use the value you want but none shoud be empty.

Be aware that someone who knows the token and id attributed to a device will be able to remotely control this device. So choose carefully their values, at least the token one, so it can not be easily guessed.

As stated above, <<device_token> and <device_id> had to be given to the corresponding fields of the Config app in order for the UCUq library handle your device.

Don’t modify the WLAN entry for the online demonstrations, but you have to adapt it if you use the UCUq library with a true device. You can define more then one WLAN, and the device will automatically connect to the one which is available.

As long as the connection to the UCUq server is not established, the on-board LED defined in the OnBoardLed entry will blink. <led_pin> is the pin to which the on-board LED is connected. It’s usually a integer, but it has to be the "LED" string for the Raspberry pico (2) W. <led_logic> has to be set to true if the LED lights up when it’s pin is at high state, false otherwise. This entry can be ommited, but then there is no led blinking during connection establishment.

The real device #

To use this library on a real microcontroller, Micropython must be installed and the controller must have WiFi capabilities.

Create a main.py with the content of corresponding file in the simulator and create a ucuq.json file inspired from those of the simulator and adpated as described above.

You can also use the UCUq library with a regular Python environment by using he GitHub repository at: https://github.com/epeios-q37/ucuq.