Skip to content

For easy prototyping of projects based on Wi-Fi-equipped microcontrollers (RPi Pico (2) W, ESP32, ESP8266...).

License

Notifications You must be signed in to change notification settings

epeios-q37/ucuq-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microcontrolers 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

On the microcontroller

  1. Install Micropython on the microcontroller;
  2. create an ucuq.json file with below content;
  3. rename ucuq_device.py as main.py;
  4. put both ucuq.json and main.py on the microcontroller;
  5. 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>: true when the led lights up when the pin level is high, false otherwise.

The OnBoardLed entry can be omitted.

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

  1. Retrieve this repository;
  2. launch the Config app (python3 Config/ from the demos folder);
  3. fill the fields accordingly to the content of the usuq.json file described above (Identification/device_token and Identification/device_id);
  4. 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()

ucuq.commit()

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 controller, 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.

About

For easy prototyping of projects based on Wi-Fi-equipped microcontrollers (RPi Pico (2) W, ESP32, ESP8266...).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages