A very light Python library with no dependencies for easy prototyping of projects based on Wi-Fi equipped microcontrollers (RPi Pico (2) W, ESP32, ESP8266…)
Project description
Microcontrollers unleashed
Python library for easy prototyping of assemblies based on microcontrollers such as ESP32, ESP8266, Raspberry Pico (2) W…
Online demonstrations: https://zelbinium.q37.info/en/ucuq/.
How to use it
Above link gives access to an ESP32 simulation with UCUq installed on it and can be very helpful understanding how to do this on your own microcontroller.
On the microcontroller
- Install Micropython on the microcontroller;
- create an ucuq.json file with below content;
- rename ucuq_device.py as main.py;
- put both ucuq.json and main.py on the microcontroller;
- restart the microcontroller.
Content of the ucuq.json file to put on the microcontroller:
{
"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 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>:
truewhen the led lights up when the pin level is high,falseotherwise.
The OnBoardLed entry is optional.
You can put more then one entry under the WLAN; the microcontroller will automatically connect to the first available one. For example, one can be your smartphone's access point, the second your home's WiFi.
On you computer
- Retrieve this repository;
- launch the Config app (
python3 Config/from the demos folder); - fill the fields accordingly to the content of the usuq.json file described above (
Identification/device_tokenandIdentification/device_id); - click on Save and quit the app.
As an example, to light up a LED connected to your device, create a file with below code and adapt it to your microcrocontroller:
import ucuq
ucuq.GPIO(<led_pin>).high()
Replace <led_pin> with the number corresponding of the onboard led pin number or string (or of whichever led connected to your microcontroller). With some controllers, the led lights up when the corresponding pin is at low level, so you have to replace high() with low(). Launch this program with python3.
See the above online demonstrations link for the API and examples of use.
The daemon
To simplify the use of this library, both the microcontroller and the local computer connects to a free public server.
You can use your own server by running the daemon available at: https://github.com/epeios-q37/ucuq.
Add also following entry to the ucuq.json file of the microcontroller:
{
…
"Proxy": {
"Host": "<address-of-the-server-hosting-the-deamon>",
"Port": "<port-the-deamon-listens-to>"
}
…
}
The Port entry can be omitted if you use the default port.
You have also to modify the Proxy settings in the Config app launched on the local computer.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ucuq-0.1.1.tar.gz.
File metadata
- Download URL: ucuq-0.1.1.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dcc8f73f93f8db4d5bc505ea62cff4fdd42476153c5b6e8c44fbceba46d06ac
|
|
| MD5 |
5e8dfae78f3a08aed99daf53770f63e7
|
|
| BLAKE2b-256 |
19c506e38636ee0af7939018428fd022a7349b0d614734c2cc387b7e779e9fe9
|
File details
Details for the file ucuq-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ucuq-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a77b790f5628839a47762b2c9e7d4ca2bbe4da48bcfe7070e9dbc7b20d4e8b7
|
|
| MD5 |
59057161ad8fca61d6d4d955a8697bda
|
|
| BLAKE2b-256 |
210a9009d4b9512a01b252dd2a01ae41c08527385a0abe8c2ef482684efba7a9
|