Skip to content

neuronumcybernetics/micropython-neuronum

Repository files navigation

Neuronum

The MicroPython implementation of the Neuronum client library

Website Documentation License


About micropython-neuronum

The MicroPython implementation of the Neuronum client library — actively developed and tested on ESP32.

Firmware: MicroPython v1.25.0 on 2025-04-15; Generic ESP32 module with ESP32
Download and flash your ESP: https://micropython.org/download/ESP32_GENERIC/

Installation

Connect To Wifi

config.json file

{
  "ssid": "your_ssid",
  "password": "your_password"
}

boot.py file

import network
import time
import ujson


def connect_to_wifi(ssid, password):
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    wlan.connect(ssid, password)

    print(f"Connecting to Wi-Fi: {ssid}")
    timeout = 30
    start_time = time.time()

    while not wlan.isconnected() and (time.time() - start_time < timeout):
        print("Attempting Wi-Fi connection...")
        time.sleep(1)

    if wlan.isconnected():
        print("Connected! IP Address:", wlan.ifconfig()[0])
    else:
        print("Wi-Fi connection failed. Starting AP mode...")

try:
    with open("config.json", "r") as f:
        config = ujson.load(f)
        ssid = config.get("ssid", "not_assigned")
        password = config.get("password", "not_assigned")
        print(f"SSID: {ssid}, Password: {password}")
except Exception as e:
    print("Error loading config:", e)
    ssid, password = "not_assigned", "not_assigned"


connect_to_wifi(ssid, password)

Install the MicroPython-Neuronum Library using mip

import mip
mip.install("github:neuronumcybernetics/micropython-neuronum")

This will either create a /lib folder containing or add the following files to an existing /lib folder:

  • micropython_neuronum.py
  • /uwebsockets/client.py
  • /uwebsockets/protocol.py

Sync Stream Data in Real Time with your ESP (More Examples Here)

Create, upload, and run this sync.py file on your ESP

import micropython_neuronum as neuronum

cell = neuronum.Cell(
    host="host",                # replace with your cell host
    password="password",        # replace with your cell password
    network="neuronum.net",     # choose the network -> neuronum.net
    synapse="synapse"           # replace with your cell synapse (auth token)
)

# Sync data of a public Stream (STX) gy3w11qAEibN::stx
STX = "gy3w11qAEibN::stx"
for operation in cell.sync(STX):
    label = operation.get("label")
    data = operation.get("data")
    ts = operation.get("time")
    stxID = operation.get("stxID")
    operator = operation.get("operator")
    print(label, data, ts, stxID, operator)

About

Official MicroPython implementation of the Neuronum client library

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Languages