Development and deployment environment for micrOS, the diy micropython automation OS (IoT)
Project description
micrOS
micropython based smart edge IoT platform
Thanks for , follow us on:
In case of any technical comments or requests, please use .
๐ฒ ๐ป Communication over WiFi: Generic communication API
๐ฒ Apple shortcuts compatible http REST API
ย ย โ๏ธ Expose upython module functions - telnet TCP/IP
โ๏ธ ๐ Device initialization from user config
๐งฉ Codeless end user experience via phone client
๐ช No external server or service required for client-device communication
ย ย โ ๏ธ ๐ก Works on Local Network (WiFi-WLAN)
๐ Easy to customize, create your own Load Modules:
ย ย 1. Write LM_<your_app>
.py
ย ย 2. Copy (OTA/USB) python script to your device (drap&drop)
ย ย 3. Call any function from <your_app>
module
๐ฆพ Built-in scheduling (IRQs):
ย ย - Time stamp based
ย ย - Geolocation based utc + sunset, sunrise rest features
ย ย - Simple periodic
ย ย - Async task manager
๐๐Lightweight and high performance core system that leaves you space ๐
โ Shortcuts:
- micrOS Client Application link
- micrOS Installer link
- micrOS Tutorials link
- micrOS System and features link
- Pin mapping - GPIO link
- micrOS Node configuration link
- micrOS gateway with Prometheus: link
- micrOS customization with LMs: link
micrOS Client Application
Installing micrOS with DevToolKit #ESP32 and more
macOS / Windows / Linux to install any esp32 board
End-to-End solution for deployment, update, monitor and develop micrOS boards.
I would suggest to use micrOS GUI as a primary interface for micrOS development kit, but you can use cli as well if you prefer.
Note: The main purpose of the USB deployment scripts to install micropython on the board and put all micrOS resources from
micrOs/toolkit/workspace/precompiled
to the connected board.
1. Install python3.9
Link for python 3.9 download
Note: Allow extend system path with that python version (installation parameter)
On Windows: RUN AS ADMINISTARTOR
2. Install micrOS devToolKit GUI
On macOS
ย Open command line, press: commnd+space
+ type: terminal
+ press: enter
Download and install micrOS devToolKit python package:
pip3 install --upgrade pip; pip3 install micrOSDevToolKit
Later on you can update the package with
pip3 uninstall micrOSDevToolKit; pip3 install micrOSDevToolKit
On Windows:
Download and install micrOS devToolKit python package:
Open Windows PowerShell, press windows+R
+ type: powershell
+ press enter
Copy the following lines to the PowerShell and press enter.
python -m pip install --upgrade pip
python -m pip install micrOSDevToolKit
Later on you can update the package with
python -m pip uninstall micrOSDevToolKit
python -m pip install micrOSDevToolKit
3. Start micrOS devToolKit GUI
Copy the following command to the command line and press enter to start.
devToolKit.py
It will open a graphical user interface for micrOS device management, like usb deploy, update, OTA operations, test executions, etc...
- Example
1. Select BOARD TYPE
2. Click on [Deploy (USB)] button -> presss YES
It will install your board via USB with default settings. Continue with micrOS Client app...
Note: At the first USB deployment, devToolKit will ask to install SerialUSB driver and it will open the driver installer as well, please follow the steps and install the necessary driver.
โโ โโ โโโโโโโ โโโโโ โโ โโโโโ
โโ โโ โโโโโโโ โโโโโโโโ โโโโโ
โโโโโโโโโ โโโโโโโโ โโโโโโโ โโโโโโโโ โโโ โโโโ
โโโโโโ โโ โโโโโโโโ โโโโโโโ โโโโโโโโ โโโ โโโโ
โโ โโโโโโโโโโโโโโโฃ โโโโ โโโโโโโ โโโ โโโโโโโโ
โโ โโโโโโโ โโ โโโโ โโโโ โโโโโโโ โโโ โโโโโโโโ
micrOS Projects
micrOS Video Tutorials
micrOS System, message-function visualization
Note: micrOS development kit contains command line interface for socket communication. Example:
devToolKit.py --connect
micrOS Framework Features๐ก
-
๐ฏmicrOS loader - starts micrOS or WEBREPL(update / recovery modes)
- OTA update - push update over wifi (webrepl automation) / monitor update and auto restart node
-
๐Config handling - user config - node_config.json
- โณBoot phase - preload Load Module(s)
- For pinout and last state initialization - based on node_config
boothook
- Example values:
rgb load_n_init; neopixel load_n_init
- For pinout and last state initialization - based on node_config
- ๐กNetwork handling - based on node_config
- STA / AP network modes,
nwmd
- NTP + UTC aka clock setup
- API: ip-api.com
- Static IP configuration,
devip
- dhcp hostname setup,
devfid
.local
- STA / AP network modes,
- โ๏ธScheduling / External events - Interrupt callback - based on node_config
- Time based
- โ๏ธsimple LM task pool execution
timirq
&timirqcbf
Timer(0)
- ๐cron [time stump!LM task] pool execution
cron
&crontasks
-
Timer(1)
-
timestamp:
WD:H:M:S!LM FUNC
, ranges:0-6:0-23:0-59:0-59!LM FUNC
- example:
*:8:0:0!rgb rgb r=10 g=60 b=100; etc.
, it will set rgb color on analog rgb periphery at 8am every day. WD: 0...6
0=Monday, 6=Sunday -> optional range handling: 0-2 means Monday to Wednesday
- example:
-
tag:
sunset
/sunrise
- example:
sunset!rgb rgb r=10 g=60 b=100; etc.
, it will set rgb color on analog rgb periphery at every sunset, every day. - optional minute offset (+/-): sunrise+30
- example:
-
- โ๏ธsimple LM task pool execution
- ๐ฃEvent based
- Set trigger event
irqX
- Trigger up/down/both
irqX_trig
- With LM callback function
irqX_cbf
- Trigger up/down/both
- X = 1, 2, 3 or 4
- Set trigger event
- Time based
- โณBoot phase - preload Load Module(s)
-
โ๏ธ**[L]oad [M]odule** aka application handling
- Lot of built-in functions (table below)
- Create your own module with 3 easy steps
- Create a python file, naming convention:
LM_<your_app_name>.py
- Replace
<your_app_name>
for anything you prefer!
- Replace
- Write python functions, you can call any function from that module...
- Upload modul with "drag&Drop" with help of devToolKit GUI
devToolKit.py
- Create a python file, naming convention:
-
๐จSocket interpreter - wireless communication interface with the nodes
- System commands:
help, version, reboot, webrepl, webrepl --update, etc.
- After
webrepl --update
command the micrOS system reboots and waits for ota update in webrepl mode.
- After
- Config handling SET/GET/DUMP - node_config.json
- enter configuration mode:
conf
- exit configuration mode:
noconf
- Print out all parameters and values:
dump
- enter configuration mode:
- LM - Load Module function execution (application modules)
- Example:
system info
- Example:
- System commands:
-
๐**[L]ogical [P]inout** handling - lookuptables for each board
- Predefined pinout modules for esp32, tinyPico
- Create your pinout based on
LP_esp32.py
, naming convencion:LP_<name>.py
- To activate your custom pinout set
cstmpmap
config parameter to<name>
-
๐Task manager aka Async LM jobs - Capable of execute [L]oad [M]odules in the background - Invoke with single execution
&
or loop execution&&
- Example: - In loop:system heartbeat &&
- Loop frequency conrol:system heartbeat &&1000
, it will execute every sec - Single call:system heartbeat &
- Delayed execution (ms):system heartbeat &1000
, waits 1 sec before execution. - Stop task:task kill system.heartbeat
- Show task live ouput:task show system.heartbeat
โ DevToolKit CLI feature:
- Socket client python plugin - interactive - non interactive mode
Built in periphery support
#Sensors / inputes
#Actuators / outputs
[CLICK] Show micrOS Load Module functions
Device Pinouts for wiring
Logical pin association handling
LogicalPin lookup tables:
- tinypico
- esp32
- esp32s2
- esp32s3
- raspberryPicoW ASYNC SERVER NOT STARTING ISSUE...
Note: Good idea to use costant variable for pin map declaration, check the files for more info, These files are also precompiled automatically into byte steams ->
.mpy
GENERAL CONTROLLER CONCEPT: microPLC
micrOS node configuration, parameters with description
Config keys | Default value and type | Reboot required | Description |
---|---|---|---|
devfid |
node01 <str> |
Yes | Device friendly "unique" name - also used for AccessPoint nw mode (AP name) and DHCP device IP resolve |
boostmd |
True <bool> |
Yes | boost mode - set up cpu frequency low or high 8MHz-16Mhz-24MHz (depends on boards) |
staessid |
your_wifi_name <str> |
Yes | Wifi router name (for default connection mode) |
stapwd |
your_wifi_passwd <str> |
Yes | Wifi router password (for default connection mode) |
appwd |
ADmin123 <str> |
Yes | Device system password.: Used in AP password (access point mode) + webrepl password + micrOS auth |
auth |
False <bool> |
Yes | Enables socket password authentication, password: appwd . Passwordless functions: hello , version , exit . WARNING OTA upade not supported in this mode (yet). |
utc |
60 <int> |
Yes | NTP-RTC - timezone setup (UTC in minute) - it is automatically calibrated in STA mode based on geolocation. |
boothook |
n/a <str> |
Yes | Callback function(s) list for priority Load Module(s) execution in boot sequence [before network setup!]. Add LoadModule(s) here, separator ; . Example: Set LED colors / Init custom module(s) / etc. |
aioqueue |
4 <int> |
Yes | Set asyc task queue limit, system overload protection |
timirq |
False <bool> |
Yes | Timer(0) interrupt enabler - background "subprocess" emulation, timer based infinite loop for the LoadModule execution |
timirqcbf |
n/a <str> |
Yes | if timirq enabled, calls the given Load Module(s), e.x.: module function optional_parameter(s) , task separator: ; |
timirqseq |
1000 <int> |
Yes | Timer interrupt period in ms, default: 3000 ms (for timirq infinite loop timer value) |
cron |
False <bool> |
Yes | Cron enabler, Timer(1) interrupt enabler - time stamp based task scheduler. |
crontasks |
n/a <str> |
Yes | Cron scheduler input, task format: WD:H:M:S!module function e.g.: 1:8:0:0!system heartbeat , task separator in case of multiple tasks: ; . [WD:0-6, H:0-23, M:0-59, S:0-59] in case of each use: * . Instead WD:H:M:S you can use suntime tags: sunset , sunrise , optional offset: sunset+-<minutes> , sunrise+-<minutes> , example: sunset-30!system heartbeat . Range of days: WD can be conrete day number or range like: 0-2 means Monday to Wednesday. |
irq1 |
False <bool> |
Yes | External event interrupt enabler - Triggers when desired signal state detected - button press happens / motion detection / etc |
irq1_cbf |
n/a <str> |
Yes | irq1 enabled, calls the given Load Modules, e.x.: module function optional_parameter(s) when external trigger happens |
irq1_trig |
n/a <str> |
Yes | Sets trigger mode for external irq, signal phase detection, values up (default: n/a ) or down or both . |
irq2 |
False <bool> |
Yes | External event interrupt enabler - Triggers when desired signal state detected - button press happens / motion detection / etc |
irq2_cb f |
n/a <str> |
Yes | irq2 enabled, calls the given Load Modules, e.x.: module function optional_parameter(s) when external trigger happens |
irq2_trig |
n/a <str> |
Yes | Sets trigger mode for external irq, signal phase detection, values up (default: n/a ) or down or both . |
irq3 |
False <bool> |
Yes | External event interrupt enabler - Triggers when desired signal state detected - button press happens / motion detection / etc |
irq3_cbf |
n/a <str> |
Yes | irq3 enabled, calls the given Load Modules, e.x.: module function optional_parameter(s) when external trigger happens |
irq3_trig |
n/a <str> |
Yes | Sets trigger mode for external irq, signal phase detection, values up (default: n/a ) or down or both . |
irq4 |
False <bool> |
Yes | External event interrupt enabler - Triggers when desired signal state detected - button press happens / motion detection / etc |
irq4_cbf |
n/a <str> |
Yes | irq4 enabled, calls the given Load Modules, e.x.: module function optional_parameter(s) when external trigger happens. |
irq4_trig |
n/a <str> |
Yes | Sets trigger mode for external irq, signal phase detection, values up (default: n/a ) or down or both . |
irq_prell_ms |
300 <int> |
Yes | "Prell": contact recurrence (hw property), for fake event filtering... :D Time window to ignore external IRQ events in ms. |
cstmpmap |
n/a <str> |
Yes | Default (n/a ), select pinmap automatically based on platform (LP_<platform> ). Manual control / customization of application pins, syntax: pin_map_name; pin name:pin number; etc. [1][optional] pin_map_name [L]ogical[P]in represented as LP_<pin_map_name>.py/.mpy file on device. [2+][optinal] dht:22 overwrite individual existing load module pin(s). Hint: <module> pinmap() to get app pins, example: neopixel pinmap() |
dbg |
True <bool> |
Yes | Debug mode - enable micrOS system printout, server info, etc. + progress LED (heartbeat) |
soctout |
100 <int> |
Yes | Socket server connection timeout (because single process socket interface) |
socport |
9008 <int> |
Yes | Socket server service port (should not be changed due to client and API inconpatibility) |
devip |
n/a <str> |
Yes(N/A) | Device IP address, (first stored IP in STA mode will be the device static IP on the network), you are able to provide specific static IP here. |
nwmd |
n/a <str> |
Yes | Prefered network mode - AP or STA |
hwuid |
n/a <str> |
N/A | USED BY SYSTEM (state storage) - hardware address - dev uid |
guimeta |
n/a str |
No | USED BY micrOS Client (state storage) - stores - offloaded parameter type in config. Clinet widget meta data. |
telegram |
n/a str |
No | TELEGRAM_BOT_TOKEN to enable micrOS Notifications. Hint, to create bot with botfather: click. After enabling this, send /ping to telegram chat for chat ID sync. |
webui |
False bool |
Yes | Launch http rest server on port 80 (in parallel with micrOS shell on port 9008 aka socport ). It has 2 endpoints: / aka main page (index.html) and /rest aka rest (json) interface for load module execution. Example: <devfid>.local or <devfid>.local/rest + optional parameters: /rgb/toggle . Apple shortcuts compatible |
Note: Default empty value:
n/a
in case of string parameter. Note: Cron is only available on devices with Timer(1): esp32
Networking - automatic network modes
micrOS Gateway in docker
With prometheus database. Check the micrOS Gateway docker README for details.
Resources:
modify
prometheus.yml
regarding what sensors on which endpoint do you want to scrapre data from.
cd ./env/docker
docker-compose -p gateway up -d
Official DockerHub
micrOS Customization
Aka How to write Load Modules
- Create python file with the following naming convension:
LM_
your_app.py
- You can create any function in this modul, these will be exposed by micrOS framework over tcp/ip so these can be accessable via phone client.
- drag-n-drop LM file to micrOS devToolKit GUI
- Select device
- Press upload
LM_simple.py
def hello(name="Anonimus"):
return "Hello {}!".format(name)
def add_two_numbers(a, b):
return "{}+{} = {}".format(a, b, a+b)
LM_template.py
Function naming convesions for Load Modules.
from LogicalPins import physical_pin, pinmap_dump
from machine import Pin
def load_n_init():
"""
[RECOMMENDED]
Function naming convension to create IO (Pin) objects
- function to initialize IO peripheries
physical_pin - to resolve pin on board by logical name (tag)
"""
pin_number = physical_pin('redgb')
red = Pin(pin_number)
return red
def lmdep():
"""
[OPTIONAL] [IN CASE OF LM DEPENDENCY]
Function to return Load Module dependencies (tuple)
- example: if this module uses LM_rgb.py, you should
return 'rgb'
"""
return '<module_name>'
def pinmap():
"""
[OPTIONAL]
Return list of pins
Example:
RoboArm $ rgb pinmap >json
{"rgbue": 15, "rgreenb": 12, "redgb": 14}
return: dict {pinkey: pinvalue}
pinmap_dump - logical pinmap resolver based on LP_<device_tag>.py
Example:
return pinmap_dump(['redgb', 'rgreenb', 'rgbue'])
"""
return {}
def status(lmf=None):
"""
[OPTIONAL]
Function naming convension for
module state-machine return
return: dict
Example in case of RGB color state return
return {'R': data[0], 'G': data[1], 'B': data[2], 'S': data[3]}
"""
return {'key': 'value'}
def help():
"""
[OPTIONAL]
Return help message tuple
"""
return 'load_n_init', 'pinmap', 'status', 'lmdep'
micrOS Common module
Common module with additinal features for LMs
Module responsible for collecting additional feature definitions dedicated to the micrOS framework and LoadModules. Code: micrOS/source/Common.py
socket_stream decorator
Adds an extra msgobj
to the wrapped function's argument list. The msgobj
provides a socket message interface for the open connection.
@socket_stream
def function_name(arg1, arg2, ..., msgobj=None):
# function body
msgobj("Client reply :)")
transition(from_val, to_val, step_ms, interval_sec)
Generator for color transitions.
Parameters:
- from_val: Starting value
- to_val: Target value
- step_ms: Step to reach to_val
- interval_sec: Full intervals
Returns:
- A generator that yields the intermediate values between from_val and to_val in steps of step_ms.
transition_gen(*args, interval_sec=1.0)
Create multiple transition generators.
Parameters:
- args: Pairs of from_val and to_val values for each channel
- interval_sec: Interval in seconds to calculate the optimal fade/transition effect
Returns:
- If only one transition generator is created, it returns the generator and the step size in milliseconds (gen, step_ms). If multiple transition generators are created, it returns a list of generators and the step size in milliseconds ([gen1, gen2, ...], step_ms).
class SmartADC
ADC wrapper class for reading analog values.
Methods:
- __init__(self, pin): Initializes the ADC object with the specified pin.
- get(self): Reads the analog value from the ADC and returns a dictionary with the raw value, percentage, and voltage.
- get_singleton(pin): Returns a singleton SmartADC object for the specified pin.
micro_task(tag, task=None)
Async task creation from LoadModules.
Parameters:
- tag: If None, returns the task generator object. If a taskID is provided, returns the existing task object by tag.
- task: Coroutine to execute.
Returns:
- If tag is None, returns the task generator object. If a taskID is provided, returns the existing task object by tag. If task is provided, returns the task creation state: True for success, False for failure.
data_logger(f_name, data=None, limit=12, msgobj=None)
micrOS Common Data logger solution.
Parameters:
- f_name: Log name (without extension, automatically appends .dat)
- data: Data to append to the log. If None, reads the log and returns it as a message stream.
- limit: Line limit for the log (default: 12)
- msgobj: Socket stream object (automatically set)
Returns:
- If data is None, returns the log as a message stream. If data is provided, returns True if the write operation was successful, False otherwise.
notify(text)
micrOS common notification handler (Telegram).
Parameters:
- text: Notification text
Returns:
- True if the notification was sent successfully, False otherwise.
----------------------------------------s
RELESE NOTE
VERSION (TAG) | RELEASE INFO | MICROS CORE MEMORY USAGE | SUPPORTED DEVICE(S) | APP PROFILES | Load Modules | NOTE |
---|---|---|---|---|---|---|
v0.1.0-0 | release_Info-0.1.0-0 | 78,4% 29 776 byte | esp8266 | App Profiles | LM manual | Stable Core with applications - first release |
v0.4.0-0 | release_Info-0.4.0-0 | 81,0% 30768 byte | esp8266 | App Profiles | LM manual | micrOS multi device support with finalized core and so more. OTA update feature. |
v0.4.0-0 | release_Info-0.4.0-0 | 47,1% 52 416 byte | esp32 | App Profiles | LM manual | micrOS multi device support with finalized core and advanced task scheduler based on time, and and so more. OTA update feature. |
v1.0.0-0 | release_Info-1.0.0-0 | 47,9% 53 280 byte | esp32 | App Profiles | LM manual | Release of v1 micrOS, timer and event based irqs, cron task scheduling, realtime communication, multiple device support. OTA, etc. |
v1.2.2-0 | release_Info-1.2.2-0 | 48,6% 54 032 byte | esp32 | App Profiles | LM manual | Public Release of v1 micrOS, timer and event based irqs, cron task scheduling, realtime communication, multiple device support. OTA update, thread from socket shell (beta) etc. |
v light-1.3.0-0 | - | - | esp8266 | lightweight branch | - | remove esp8266 due to memory limitation - BUT still supported with limited functionalities on lightweight branch. Hint: Change branch on github and download zip file, then start micrOSDevToolKit dashboard GUI |
v 1.5.0-1 | release_Info-1.5.0-1 | 58,2% 64 704 byte | esp32 (tinyPico) | App Profiles | LM manual | Advanced Timer IRQ based scheduling (cron & timirq), Geolocation based timing features, External IRQs with 4 channel (event filtering), finalized light controls, Device-Device comminucation support, etc. |
v 1.21.0-4 | release_Info-1.21.0-4 | 57.3% 63 728 byte | esp32 (tinyPico, esp32s2, esp32s3) | App Profiles | LM manual | Full async core system with advanced task management and device to device communication, task scheduling and much more ... with more then 30 application/pheriphery support. |
Developer Quick guide
Note:
Secure Core (OTA static modules) (GUI):
boot.py
,micrOSloader.mpy
,Network.mpy
,ConfigHandler.mpy
,Debug.mpy
Erase device & Deploy micropython & Install micrOS
Go to micrOS repo, where the devToolKit.py
located.
devToolKit.py --make
Note: Follow the steps :)
Search and Connect to the device
devToolKit.py -s -c
User commands
devToolKit.py -h
optional arguments:
-h, --help show this help message and exit
Base commands:
-m, --make Erase & Deploy & Precompile (micrOS) & Install (micrOS)
-r, --update Update/redeploy connected (usb) micrOS. - node config will be restored
-s, --search_devices Search devices on connected wifi network.
-o, --OTA OTA (OverTheArir update with webrepl)
-c, --connect Connect via socketclinet
-p CONNECT_PARAMETERS, --connect_parameters CONNECT_PARAMETERS
Parameters for connection in non-interactivve mode.
-a APPLICATIONS, --applications APPLICATIONS
List/Execute frontend applications. [list]
-stat, --node_status Show all available micrOS devices status data.
-cl, --clean Clean user connection data: device_conn_cache.json
Search devices
devToolKit.py --search_devices
or
devToolKit.py -s
List discovered devices with status updates
devToolKit.py -stat
or
devToolKit.py --node_status
Output:
[ UID ] [ FUID ] [ IP ] [ STATUS ] [ VERSION ] [COMM SEC]
__localhost__ __simulator__ 127.0.0.1 OFFLINE <n/a> n/a
micr<ID>OS TinyDevBoard 10.0.1.72 ONLINE 1.16.2-2 0.072
micr<ID>OS LivingKitchen 10.0.1.200 ONLINE 1.16.2-2 0.076
micr<ID>OS RoboArm 10.0.1.232 ONLINE 1.15.4-0 0.072
micr<ID>S Cabinet 10.0.1.204 ONLINE 1.16.2-2 0.074
micr<ID>4OS TestBird 10.0.1.179 ONLINE 1.16.2-1 0.083
micr<ID>OS RingLamp 10.0.1.75 ONLINE 1.16.2-2 0.099
micr<ID>OS CatFeeder 10.0.1.111 OFFLINE <n/a> n/a
micr<ID>OS ImpiGamePro 10.0.1.23 OFFLINE <n/a> n/a
micr<ID>S micrOSPublic02 10.0.1.47 ONLINE 1.16.2-2 0.101
micr<ID>cOS micrOSPublic01 10.0.1.197 ONLINE 1.16.2-2 0.099
micr<ID>cOS experipurple 10.0.1.94 OFFLINE <n/a> n/a
Other Developer commands
Development & Deployment & Connection:
-f, --force_update Force mode for -r/--update and -o/--OTA
-e, --erase Erase device
-d, --deploy Deploy micropython
-i, --install Install micrOS on micropython
-l, --list_devs_n_bins
List connected devices & micropython binaries.
-ls, --node_ls List micrOS node filesystem content.
-u, --connect_via_usb
Connect via serial port - usb
-b, --backup_node_config
Backup usb connected node config.
-sim, --simulate start micrOS on your computer in simulated mode
-cc, --cross_compile_micros
Cross Compile micrOS system [py -> mpy]
-gw, --gateway Start micrOS Gateway rest-api server
-v, --version Get micrOS version - repo + connected device.
Socket terminal example - non interactive
Identify device
devToolKit.py -c -p '--dev slim01 hello'
Load MicrOS device cache: /Users/bnm/Documents/NodeMcu/MicrOs/tools/device_conn_cache.json
Activate MicrOS device connection address
[i] FUID IP UID
[0] Device: slim01 - 10.0.1.73 - 0x500x20x910x680xc0xf7
Device was found: slim01
hello:slim01:0x500x20x910x680xc0xf7
Get help
devToolKit.py -c -p '--dev BedLamp help'
[MICROS] - built-in shell commands
hello - hello msg - for device identification
version - returns micrOS version
exit - exit from shell socket prompt
reboot - system soft reboot (vm), hard reboot (hw): reboot -h
webrepl - start webrepl, for file transfers use with --update
[CONF] Configure mode - built-in shell commands
conf - Enter conf mode
dump - Dump all data
key - Get value
key value - Set value
noconf - Exit conf mode
[TASK] postfix: &x - one-time, &&x - periodic, x: wait ms [x min: 20ms]
task list - list tasks with <tag>s
task kill <tag> - stop task
task show <tag> - show task output
[EXEC] Command mode (LMs):
help lm - list ALL LoadModules
cct
help
co2
help
dht22
help
intercon
help
robustness
help
system
help
Embedded config handler
devToolKit.py -c -p '--dev BedLamp conf <a> dump'
staessid : <your-wifi-passwd>
devip : 10.0.1.204
version : 1.11.0-1
devfid : BedLamp
cron : True
cronseq : 3000
soctout : 10
irq2_cbf : n/a
stapwd : <your-wifi-name>
dbg : False
irq2 : False
irq1 : False
irq1_cbf : n/a
appwd : ADmin123
irq2_trig : n/a
hwuid : micr7c9ebd623ff8OS
crontasks : sunset!cct toggle True;*:0:30:0!cct toggle False;*:5:0:0!cct toggle False
timirq : True
irq3 : False
irq3_cbf : n/a
irq4 : False
irq4_cbf : n/a
irq4_trig : n/a
nwmd : STA
timirqcbf : system ha_sta
irq_prell_ms: 300
boothook : cct load_n_init
aioqueue : 3
auth : False
timirqseq : 60000
utc : 60
boostmd : True
socport : 9008
irq3_trig : n/a
irq1_trig : n/a
guimeta : ...
cstmpmap : n/a
Load Modules - User defined functions
devToolKit.py -c -p '--dev BedLamp system info'
CPU clock: 24 [MHz]
Mem usage: 71.0 %
FS usage: 14.6 %
upython: v1.19.1 on 2022-06-18
board: ESP32 module with ESP32
mac: 7c:9e:bd:62:3f:f8
uptime: 0 1:29:19
SocketClient
Config:
micrOS/toolkit/user_data/device_conn_cache.json
{
"__devuid__": [
"192.168.4.1",
9008,
"__device_on_AP__"
],
"__localhost__": [
"127.0.0.1",
9008,
"__simulator__"
],
"micr500291863428OS": [
"10.0.1.72",
9008,
"BedLamp"
]
}
Interactive mode
devToolKit.py -c
or
devToolKit.py -connect
[i] FUID IP UID
[0] Device: __device_on_AP__ - 192.168.4.1 - __devuid__
[1] Device: __simulator__ - 127.0.0.1 - __localhost__
[2] Device: BedLamp - 10.0.1.72 - micr500291863428OS
Choose a device index: 5
Device was selected: ['10.0.1.204', 9008, 'Cabinet']
BedLamp $ help
[MICROS] - built-in shell commands
hello - hello msg - for device identification
version - returns micrOS version
exit - exit from shell socket prompt
reboot - system soft reboot (vm), hard reboot (hw): reboot -h
webrepl - start webrepl, for file transfers use with --update
[CONF] Configure mode - built-in shell commands
conf - Enter conf mode
dump - Dump all data
key - Get value
key value - Set value
noconf - Exit conf mode
[TASK] postfix: &x - one-time, &&x - periodic, x: wait ms [x min: 20ms]
task list - list tasks with <tag>s
task kill <tag> - stop task
task show <tag> - show task output
[EXEC] Command mode (LMs):
help lm - list ALL LoadModules
cct
help
co2
help
dht22
help
intercon
help
robustness
help
system
help
BedLamp $ exit
Bye!
Project structure
micrOS resources library
micrOS Core
micrOS/source/
163 Common.py
218 ConfigHandler.py
184 Debug.py
66 Hooks.py
101 InterConnect.py
270 InterpreterShell.py
152 InterruptHandler.py
48 LP_esp32.py
49 LP_esp32s2.py
51 LP_esp32s3.py
3 LP_rp2.py
56 LP_tinypico.py
133 LogicalPins.py
214 Network.py
198 Notify.py
174 Scheduler.py
278 SocketServer.py
484 TaskManager.py
166 Time.py
24 TinyPLed.py
19 main.py
69 micrOS.py
118 micrOSloader.py
9 reset.py
127 urequests.py
SUM OF CODE LINES: 3374
micrOS Load Modules
micrOS/source/
68 LM_L298N_DCmotor.py
47 LM_L9110_DCmotor.py
323 LM_VL53L0X.py
299 LM_bme280.py
240 LM_buzzer.py
60 LM_catgame.py
318 LM_cct.py
122 LM_co2.py
60 LM_demo.py
72 LM_dht11.py
72 LM_dht22.py
200 LM_dimmer.py
70 LM_distance.py
54 LM_ds18.py
44 LM_esp32.py
130 LM_genIO.py
33 LM_i2c.py
45 LM_intercon.py
65 LM_light_sensor.py
283 LM_neoeffects.py
305 LM_neopixel.py
217 LM_oled.py
280 LM_oled_sh1106.py
466 LM_oled_ui.py
64 LM_pet_feeder.py
39 LM_ph_sensor.py
208 LM_presence.py
87 LM_rencoder.py
283 LM_rgb.py
258 LM_roboarm.py
53 LM_robustness.py
124 LM_servo.py
133 LM_stepper.py
223 LM_switch.py
260 LM_system.py
65 LM_telegram.py
85 LM_tinyrgb.py
SUM OF CODE LINES: 5755
LM (Load Modules) - Application logic - accessable over socket server as a command
micrOS devToolkit resources
DevToolKit Dashboard apps
You can easly copy the
Template_app.py
, and create a new socket based app. Template_app.py
micrOS/toolkit/dashboard_apps
โย ย โโโ AirQualityBME280_app.py
โย ย โโโ AirQualityDHT22_CO2_app.py
โย ย โโโ AnalogCCT_app.py
โย ย โโโ AnalogRGB_app.py
โย ย โโโ CatGame_app.py
โย ย โโโ Dimmer_app.py
โย ย โโโ GetVersion_app.py
โย ย โโโ GetVersion_app.pyc
โย ย โโโ NeopixelTest_app.py
โย ย โโโ RoboArm_app.py
โย ย โโโ SysCheck_app.py
โย ย โโโ Template_app.py
Stored connection data and default node configs
micrOS/toolkit/user_data
โย ย โโโ device_conn_cache.json <- connection cache
โย ย โโโ node_config_archive
โย ย โโโ BigRGB-node_config.json
โย ย โโโ Chillight-node_config.json
โย ย โโโ Kapcsolo230-node_config.json
โย ย โโโ LampController-node_config.json
โย ย โโโ MeasureNode-node_config.json
โย ย โโโ MrGreen-node_config.json
โย ย โโโ RingLamp-node_config.json
โย ย โโโ test-node_config.json
Virtaulenv for development and stored USB-Serial drivers
micrOS/env/
โโโ __init__.py
โโโ driver_cp210x
โย ย โโโ CP210x_Universal_Windows_Driver
โย ย โโโ macOS_VCP_Driver
โโโ requirements.txt
โโโ venv
โโโ bin
โโโ include
โโโ lib
โโโ pyvenv.cfg
Precompiled resources for easy install
micrOS/toolkit/workspace/precompiled
โย ย โโโ BgJob.mpy
โย ย โโโ Common.mpy
โย ย โโโ ConfigHandler.mpy
โย ย โโโ Debug.mpy
โย ย โโโ Hooks.mpy
โย ย โโโ InterConnect.mpy
โย ย โโโ InterpreterCore.mpy
โย ย โโโ InterpreterShell.mpy
โย ย โโโ InterruptHandler.mpy
โย ย โโโ LM_L298N_DCmotor.mpy
โย ย โโโ LM_L9110_DCmotor.py
โย ย โโโ LM_VL53L0X.py
โย ย โโโ LM_bme280.mpy
โย ย โโโ LM_buzzer.mpy
โย ย โโโ LM_catgame.py
โย ย โโโ LM_cct.mpy
โย ย โโโ LM_co2.mpy
โย ย โโโ LM_dht11.mpy
โย ย โโโ LM_dht22.mpy
โย ย โโโ LM_dimmer.mpy
โย ย โโโ LM_distance_HCSR04.py
โย ย โโโ LM_ds18.mpy
โย ย โโโ LM_esp32.py
โย ย โโโ LM_genIO.mpy
โย ย โโโ LM_i2c.py
โย ย โโโ LM_intercon.mpy
โย ย โโโ LM_light_sensor.mpy
โย ย โโโ LM_neoeffects.mpy
โย ย โโโ LM_neopixel.mpy
โย ย โโโ LM_oled.mpy
โย ย โโโ LM_oled_ui.mpy
โย ย โโโ LM_pet_feeder.py
โย ย โโโ LM_ph_sensor.py
โย ย โโโ LM_rgb.mpy
โย ย โโโ LM_roboarm.mpy
โย ย โโโ LM_robustness.py
โย ย โโโ LM_servo.mpy
โย ย โโโ LM_stepper.mpy
โย ย โโโ LM_switch.mpy
โย ย โโโ LM_system.mpy
โย ย โโโ LM_tinyrgb.mpy
โย ย โโโ LP_esp32.mpy
โย ย โโโ LP_tinypico.mpy
โย ย โโโ LogicalPins.mpy
โย ย โโโ Network.mpy
โย ย โโโ Scheduler.mpy
โย ย โโโ SocketServer.mpy
โย ย โโโ Time.mpy
โย ย โโโ TinyPLed.mpy
โย ย โโโ boot.py
โย ย โโโ micrOS.mpy
โย ย โโโ micrOSloader.mpy
โย ย โโโ reset.mpy
Note: From the
micrOS/source/
by default the LMs are not compiling, to extend complied LM list add LM explicitly to the following file:
micrOs/toolkit/LM_to_compile.dat
HINTS
-
Save screen console buffer (output) Press
ctrl + A :
and typehardcopy -h <filename>
-
Create callgraph: pycallgraph
-
Convert PNG/JPG-s to GIF:
convert -delay 60 ./*.png mygif.gif
-
micrOS core source code lines:
core_files=($(ls -1 | grep '.py' | grep -v 'LM_')); all_line_codes=0; for coref in ${core_files[@]}; do content_lines_cnt=$(cat $coref | grep -v -e '^$' | wc -l); all_line_codes=$((all_line_codes+content_lines_cnt)); echo -e "$content_lines_cnt\t$coref"; done; echo -e "SUM OF CODE LINES: $all_line_codes"
- micrOS Load Module-s (application-s) source code lines:
core_files=($(ls -1 | grep '.py' | grep 'LM_')); all_line_codes=0; for coref in ${core_files[@]}; do content_lines_cnt=$(cat $coref | grep -v -e '^$' | wc -l); all_line_codes=$((all_line_codes+content_lines_cnt)); echo -e "$content_lines_cnt\t$coref"; done; echo -e "SUM OF CODE LINES: $all_line_codes"
micrOS gateway - Linux service template
-
Create service: micrOS gateway service
-
[1] create
micros-gw.service
file:
[Unit]
Description=micrOS gateway REST API service
After=network-online.target
[Service]
ExecStart=/bin/bash <micrOS repo root>/magic.bash gateway
WorkingDirectory=<micrOS repo root>
StandardOutput=inherit
StandardError=inherit
Restart=always
User=<raspbian user>
[Install]
WantedBy=multi-user.target
-
[2] copy service to
sudo cp micros-gw.service /lib/systemd/system/
-
[3] start service:
sudo systemctl start micros_gw.service
-
[4] enable service at bootup:
sudo systemctl enable micros_gw.service
-
[5] show service state:
sudo systemctl status micros_gw.service
GIT
-
Add git tag:
git tag -a vX.Y.Z-K -m "tag message"
-
Publish tags:
git push origin --tags
-
Pretty git view:
git log --pretty=oneline
-
File change list:
git diff --name-only fbb4875609a3c0ee088b6a118ebf9f8a500be0fd HEAD | grep 'mpy-MicrOS'
-
GitHub embed youtube link:
https://github.com/itskeshav/Add-youtube-link-in-Readme.md
-
Git history visualization with Gource
gource \
--highlight-users \
--hide filenames \
--file-idle-time 0 \
--max-files 0 \
--seconds-per-day 0.01 \
--auto-skip-seconds 1 \
--title "micrOS Evolution" \
--output-ppm-stream - \
| ffmpeg -y -r 30 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 output.mp4
git push -u origin master
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
Hashes for micrOSDevToolKit-1.40.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a45598b6da1da01a45f5ca17f25fe077ed2f43c694383a50a89222c625c6dcf |
|
MD5 | a8acf32d751065fea033e6d73e82b42c |
|
BLAKE2b-256 | b16e81123226bc0291200dcc8372cd54ce76d802cf32fad6b231af58da23097a |