Python SDK for Heicon modular hardware system
Project description
Heicon SDK
Python library and firmware for Heicon modular hardware system.
Installation
pip install heicon
Or from source:
git clone https://github.com/yourname/heicon-sdk.git
cd heicon-sdk
pip install -e .
Quick Start
from heicon import IMU, Motor, Relay, RS485, Master
# Read IMU
imu = IMU()
accel = imu.read_accel()
print(f"Acceleration: {accel}")
# Control motors
with Motor('/dev/ttyS0') as motor:
motor.forward(50)
time.sleep(1)
motor.stop()
# Toggle relay
relay = Relay()
relay.on(1)
relay.off(1)
# RS485 communication
with RS485() as rs:
rs.send("Hello RS485")
response = rs.readline()
# Master board
with Master() as master:
master.wifi_connect("SSID", "password")
devices = master.i2c_scan()
CLI Tool
# Scan I2C bus
heicon scan
# Read IMU continuously
heicon imu read -c
# Control motors
heicon motor set 50 50
heicon motor stop
# Control relays
heicon relay on 1
heicon relay off 1
# RS485
heicon rs485 send "Hello" -w
# Master board
heicon master ping
heicon master wifi connect MySSID MyPassword
Modules
IMU (MPU6050)
from heicon import IMU
imu = IMU(bus=1, address=0x68)
# Set ranges
imu.set_accel_range(4) # ±4g
imu.set_gyro_range(500) # ±500°/s
# Read data
accel = imu.read_accel() # (x, y, z) in g
gyro = imu.read_gyro() # (x, y, z) in °/s
temp = imu.read_temp() # °C
# Read all at once
data = imu.read_all()
# {'accel': (x,y,z), 'gyro': (x,y,z), 'temp': t}
# Calibrate (device must be still)
offsets = imu.calibrate(samples=100)
Motor (ESP32-C3 + TB6612)
from heicon import Motor
motor = Motor('/dev/ttyS0', baudrate=115200)
# Basic control
motor.set_speed(50, 50) # -100 to 100
motor.stop()
motor.brake()
# Convenience methods
motor.forward(50)
motor.backward(50)
motor.turn_left(50)
motor.turn_right(50)
motor.curve_left(50, ratio=0.5)
# WiFi (via ESP32)
motor.wifi_connect("SSID", "password")
print(motor.wifi_ip())
motor.close()
Relay (4-channel)
from heicon import Relay
relay = Relay()
# Control individual relays (1-4)
relay.on(1)
relay.off(1)
relay.toggle(2)
relay.pulse(3, duration=0.5)
# Control all
relay.all_on()
relay.all_off()
# Check state
state = relay.get_state(1) # True/False
states = relay.get_state() # {1: T/F, 2: T/F, ...}
relay.cleanup()
RS485 (MAX485)
from heicon import RS485
rs = RS485('/dev/ttyS0', baudrate=9600)
# Basic communication
rs.send(b"Hello")
rs.send("Hello") # Auto-encodes
response = rs.receive(10)
line = rs.readline()
# Query (send + wait + receive)
response = rs.query("CMD", delay=0.1)
# Modbus RTU
data = rs.modbus_read_holding(address=1, register=0, count=2)
rs.modbus_write_single(address=1, register=0, value=100)
rs.close()
RS232 (MAX3232)
from heicon import RS232
rs = RS232('/dev/ttyS0', baudrate=9600)
rs.send("Hello")
rs.sendline("Hello") # With newline
response = rs.readline()
rs.close()
Master (ESP32-S3)
from heicon import Master
master = Master('/dev/ttyS0')
# System
master.ping()
master.version()
master.info() # Returns JSON
master.reset()
# WiFi
master.wifi_scan()
master.wifi_connect("SSID", "password")
master.wifi_status()
master.wifi_ip()
master.wifi_ap("HeIconAP", "password") # Start AP
# BLE
master.ble_name("MyDevice")
master.ble_advertise(True)
# I2C relay
devices = master.i2c_scan()
data = master.i2c_read(0x68, 0x3B, 6)
master.i2c_write(0x68, 0x6B, b'\x00')
# GPIO
master.gpio_mode(5, 'OUTPUT')
master.gpio_write(5, True)
state = master.gpio_read(5)
# MQTT
master.mqtt_connect("broker.mqtt.com", 1883)
master.mqtt_publish("topic", "message")
master.mqtt_subscribe("topic")
# OTA
master.ota_update("http://server/firmware.bin")
master.close()
Firmware
ESP32 Arduino firmware is in the firmware/ directory:
firmware/motor/motor.ino- Motor board (ESP32-C3)firmware/master/master.ino- Master board (ESP32-S3)
Building Firmware
- Install Arduino IDE
- Add ESP32 board support
- Install libraries:
PubSubClient,ArduinoJson - Open
.inofile and upload
Hardware
See heicon repository for PCB designs.
License
MIT License
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
heicon-1.0.0.tar.gz
(20.0 kB
view details)
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
heicon-1.0.0-py3-none-any.whl
(16.5 kB
view details)
File details
Details for the file heicon-1.0.0.tar.gz.
File metadata
- Download URL: heicon-1.0.0.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ca2f6b2cffa58029ea8db71dafb09a0695218a82b519c4f34c4c3654a9ca6f3
|
|
| MD5 |
d8f0151e9d1a32309858034b932a513a
|
|
| BLAKE2b-256 |
05b606c6a9b45decb9885e7c969b1f60cdb48aecad6830b4a6db808ac1f3ebbf
|
File details
Details for the file heicon-1.0.0-py3-none-any.whl.
File metadata
- Download URL: heicon-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cb893a7698adeffdc21b87a7566b02916d1d6889a4d5cdb2bba1e0096c6ab85
|
|
| MD5 |
56153b17382605f4e61817b717a752bd
|
|
| BLAKE2b-256 |
527a7eb2ab3885b52c44c77425273f9382d1ed073dc5e0305ecd885e6174e4e0
|