Sharc hardware, firmware, and software related support and discussions.
- sharc-support
- Table of Contents
- Links
- MQTT Namespace
- MQTT EVENTS
- MQTT COMMANDS
- Self-hosting Sharc Studio
Topic structure: sharc/{{sharc_id}}/evt/{{name}}
Availability, published upon connection.
Topic: sharc/{{sharc_id}}/evt/avail
Retain: true
Payload:
{
"seq": 0,
"v": true
}
Device disconnect message is published by MQTT broker LWT mechanism.
Topic: sharc/{{sharc_id}}/evt/avail
Retain: true
Payload:
{
"seq": -1,
"v": false
}
Reboot causes and counters, published upon connection.
Topic: sharc/{{sharc_id}}/evt/rc
Retain: true
Payload:
{
"seq": 1,
"v": {
"power_on": 0,
"hard_reset": 0,
"watchdog_reset": 0,
"deep_sleep": 0,
"soft_reset": 0
}
}
$.v.power_on
- [int] Power_On count.
$.v.hard_reset
- [int] Hard count.
$.v.watchdog_reset
- [int] WDT count.
$.v.deep_sleep
- [int] Deep_Sleep count.
$.v.soft_reset
- [int] Soft count.
Current network interface values, published upon connection.
Topic: sharc/{{sharc_id}}/evt/net
Retain: true
Payload:
{
"seq": 1,
"v": {
"type": "WLAN",
"static": false,
"ip": "0.0.0.0",
"gw": "0.0.0.0",
"mask": "0.0.0.0",
"dns": "0.0.0.0",
"mac": "deadbeef",
"quality": 100,
"ssid": "wifi-name",
"lan_fallback_s": 120
}
}
$.v.type
- [string] Current network type of WLAN or LAN.
$.v.static
- [bool] Whether the IP configuration is static or dynamic.
$.v.ip
- [string] Device IP Address.
$.v.gw
- [string] Gateway IP Address.
$.v.mask
- [string] Subnet mask.
$.v.dns
- [string] DNS Server IP Address.
$.v.mac
- [string] Device Hardware Address.
$.v.quality
- [int] Connection quality.
$.v.ssid
- [string] (WLAN only) Wifi network name.
$.v.lan_fallback
- [int] (WLAN only) Seconds to wait for Wifi connection before rebooting into LAN. Zero to disable this feature.
Device information, published upon connection.
Topic: sharc/{{sharc_id}}/evt/ver
Retain: true
Payload:
{
"seq": 1,
"v": {
"mfg": "MRIIOT",
"model": "SHARC",
"serial": "{chip-id}",
"hw": "105",
"fw": "{git-head}",
"sw": "RTM/FROZEN"
}
}
$.v.mfg
- [string] Hardware manufacturer.
$.v.model
- [string] Hardware model.
$.v.serial
- [string] Hardware serial number.
$.v.hw
- [string] Hardware version.
$.v.fw
- [string] Firmware version.
$.v.sw
- [string] Software version.
MQTT connection information, published upon connection.
Topic: sharc/{{sharc_id}}/evt/mqtt
Retain: true
Payload:
{
"seq": 1,
"v": {
"address": "192.168.5.5",
"port": 1883,
"user": "",
"anonymous": true
}
}
$.v.address
- [string] Broker address.
$.v.port
- [int] Broker port.
$.v.user
- [string] Username.
$.v.anonymous
- [bool] Is connection anonymous.
Values read from sensors.
Settings and their effects:
sensor.aggregate
:true
: all sensors published on a single topic, packed into a single JSON object.false
: each sensor published on its own topic.
sensor.calibrate
:true
: each sensor'scalibrate
property is evaluated before publishing.false
: evaluation ofcalibrate
property is omitted.
sensor.convert
:true
: each sensor'sconvert
property is evaluated before publishing.false
: evaluation ofconvert
property is omitted.
Setting: sensor.aggregate = true
and sensor.calibrate = false|true
and sensor.convert = false
.
Description: All sensors published on a single topic, uncalibrated and unconverted values.
Topic: sharc/{{sharc_id}}/evt/io
Retain: false
Payload:
{
"seq": 1,
"v": {
"s0": 0,
"s1": 0,
"s2": 0,
"s3": 0
}
}
$.v.s0
- [int] PNP sensor state.
   0
- off
   1
- on
$.v.s1
- [int] NPN sensor state.
   0
- off
   1
- on
$.v.s2
- [decimal] Voltage sensor value.
   0
- minimum bits
   32767
- maximum bits
$.v.s3
- [decimal] Ampere sensor value.
   0
- minimum bits
   32767
- maximum bits
Setting: sensor.aggregate = false
and sensor.calibrate = false
and sensor.convert = false
.
Description: Each sensor published on its own topic, uncalibrated and unconverted values.
Topic: sharc/{{sharc_id}}/evt/io/{{sensor_name}}
Retain: false
Payload:
{
"seq": 1,
"v": 0
}
Setting: sensor.aggregate = true
and sensor.calibrate = true
and sensor.convert = true
.
Description: All sensors published to a single topic, calibrated and converted values. Units defined in RFC8428.
Topic: sharc/{{sharc_id}}/evt/io
Retain: false
Payload:
{
"seq": 1,
"v": {
"s0": {
"v": 0.0,
"u": "/"
},
"s1": {
"v": 1.0,
"u": "/"
},
"s2": {
"v": 10,
"u": "V"
},
"s3": {
"v": 100,
"u": "Cel"
}
}
}
$.v.s0
- [any] PNP sensor.
   v
- value
   u
- units
$.v.s1
- [any] NPN sensor state.
   v
- value
   u
- units
$.v.s2
- [any] Voltage sensor value.
   v
- value
   u
- units
$.v.s3
- [any] Ampere sensor value.
   v
- value
   u
- units
Acknowledgement of command execution.
Topic: sharc/{{sharc_id}}/evt/ack
Retain: false
Payload:
{
"seq": 1,
"v": {
"id": "abc123",
"rc": 0
}
}
$.v.id
- [string] Correlation to command.
$.v.rc
- [int] Command execution result code.
   0
- success
   non-zero
- failure code
Data published from user script.
Topic: sharc/{{sharc_id}}/evt/user
Retain: false
Payload:
{
"seq": 1,
"v": {
"user": "object"
}
}
$.v
- [any] User data.
Topic structure: sharc/{{sharc_id}}/cmd/{{name}}
Each command payload must include a unique id
attribute.
This value is published back as an acknowledgement of command execution status.
Commands with the id
attribute are dropped.
Initiates over-the-air updates over WIFI or Ethernet.
Once the device receives this message, it will:
- Reboot into update mode.
- Download the new firmware binary.
- Install the new firmware binary.
- Reboot into first-run mode.
- Reboot into production mode.
Topic: sharc/{{sharc_id}}/cmd/action
Retain: false
Payload:
{
"id": "abc123",
"v": {
"device.ota": {
"bin": "direct-download-uri-to-binary"
}
}
}
Select between WLAN and LAN network. Device reset is required to take effect.
Topic: sharc/{{sharc_id}}/cmd/action
Retain: false
Payload:
{
"id": "abc123",
"v": {
"device.network.wlan" : true
}
}
{
"id": "abc123",
"v": {
"device.network.lan" : true
}
}
Discard configuration changes and reset device into MQTT.
Topic: sharc/{{sharc_id}}/cmd/action
Retain: false
Payload:
{
"id": "abc123",
"v": {
"device.reset" : true
}
}
{
"id": "abc123",
"v": {
"device.reset.mqtt" : true
}
}
Discard configuration changes and reset device into BLE.
Topic: sharc/{{sharc_id}}/cmd/action
Retain: false
Payload:
{
"id": "abc123",
"v": {
"device.reset.ble" : true
}
}
Save configuration and reset device into MQTT.
Topic: sharc/{{sharc_id}}/cmd/action
Retain: false
Payload:
{
"id": "abc123",
"v": {
"device.save" : true
}
}
{
"id": "abc123",
"v": {
"device.save.mqtt" : true
}
}
Save configuration and reset device into BLE.
Topic: sharc/{{sharc_id}}/cmd/action
Retain: false
Payload:
{
"id": "abc123",
"v": {
"device.save.ble" : true
}
}
Reset digital input counters.
Topic: sharc/{{sharc_id}}/cmd/action
Retain: false
Payload:
{
"id": "abc123",
"v": {
"di.counter.reset" : true
}
}
Request IO data publish.
Topic: sharc/{{sharc_id}}/cmd/action
Retain: false
Payload:
{
"id": "abc123",
"v": {
"io.publish" : true
}
}
Set user data in user script.
Topic: sharc/{{sharc_id}}/cmd/action
Retain: false
Payload:
{
"id": "abc123",
"v": {
"ud.set" : {
"user": "object"
}
}
}
Changes value in configuration.
cfg.save
action required to persist changes to flash.
Topic: sharc/{{sharc_id}}/cmd/cfg
Retain: false
Payload:
{
"id": "abc123",
"v": {
"config.key1": "value",
"config.key2": "value"
}
}
$.v.<path>
- [bool|number|string|null] Configuration value. path
can be any valid path within the configuration file.
Changes sensor modes via the configuration topic.
cfg.save
action required to persist changes to flash.
Topic: sharc/{{sharc_id}}/cmd/cfg
Retain: false
Payload:
{
"id": "abc123",
"v": {
"sensor.aggregate": true
}
}
Topic: sharc/{{sharc_id}}/cmd/cfg
Retain: false
Payload:
{
"id": "abc123",
"v": {
"sensor.aggregate": false
}
}
Topic: sharc/{{sharc_id}}/cmd/cfg
Retain: false
Payload:
{
"id": "abc123",
"v": {
"sensor.s0.mode": "switch",
"sensor.s0.calibrate": "(v, False)",
"sensor.s0.convert": "(v, '/', False)"
}
}
Topic: sharc/{{sharc_id}}/cmd/cfg
Retain: false
Payload:
{
"id": "abc123",
"v": {
"sensor.s0.mode": "counter",
"sensor.s0.edge": "rising",
"sensor.s0.persist": true,
"sensor.s0.calibrate": "(v, False)",
"sensor.s0.convert": "(v, 'count', False)"
}
}
Topic: sharc/{{sharc_id}}/cmd/cfg
Retain: false
Payload:
{
"id": "abc123",
"v": {
"sensor.s0.mode": "accumulator",
"sensor.s0.edge": "falling",
"sensor.s0.period": 1000,
"sensor.s0.calibrate": "(v, False)",
"sensor.s0.convert": "(v, 'count', False)"
}
}
Topic: sharc/{{sharc_id}}/cmd/cfg
Retain: false
Payload:
{
"id": "abc123",
"v": {
"sensor.s3.convert": "(({v} - 4) * (100 - 0) / (20 - 4) + 0, 'Cel', False)"
}
}
Network configuration. Reset required.
Topic: sharc/{{sharc_id}}/cmd/cfg
Retain: false
Payload - Enforcing static IP assignment.
{
"id": "abc123",
"v": {
"lan.static_ip": 1,
"lan.ip_config.ip": "192.168.1.55",
"lan.ip_config.gw": "192.168.1.1",
"lan.ip_config.mask": "255.255.255.0",
"lan.ip_config.dns": "8.8.8.8"
}
}
Payload - Enforcing DHCP.
{
"id": "abc123",
"v": {
"lan.static_ip": 0
}
}
Payload - Wait for IP address on boot before continuing.
{
"id": "abc123",
"v": {
"lan.wait_for_ip": 1
}
}
Payload - Do not wait for IP address on boot before continuing. Instead, wait for a specific duration in milliseconds.
{
"id": "abc123",
"v": {
"lan.wait_for_ip": 0,
"lan.timeout": 1000
}
}
Broker configuration. Reset required.
Topic: sharc/{{sharc_id}}/cmd/cfg
Retain: false
Payload - Set broker options.
{
"id": "abc123",
"v": {
"mqtt.broker.address": "broker.xyz",
"mqtt.broker.port": 1883,
"mqtt.broker.user": "",
"mqtt.broker.pass": "",
"mqtt.broker.ka": 60,
"mqtt.broker.ping": 5
}
}
Section | Item | Legend | Description | Access | Value Type | Default | Notes | |
---|---|---|---|---|---|---|---|---|
lan | Ethernet Configuration. | object | ||||||
lan.static_ip | Static configuration or DHCP. | RW | boolean | false | ||||
lan.wait_for_ip | Wait for IP address before completing boot process. | RW | boolean | false | ||||
lan.timeout_ms | Milliseconds to wait for network, if wait_for_ip is false. | RW | integer | 1000 | milliseconds | |||
lan.ip_config.ip | Statically assigned device IP address. | RW | string | 192.168.5.5 | four octet | |||
lan.ip_config.mask | Statically assigned network mask. | RW | string | 255.255.255.0 | four octet | |||
lan.ip_config.gw | Statically assigned gateway IP address. | RW | string | 192.168.5.1 | four octet | |||
lan.ip_config.dns | Statically assigned DNS server IP address. | RW | string | 8.8.8.8 | four octet | |||
wlan | n/a | object | ||||||
wlan.static_ip | Static configuration or DHCP. | RW | boolean | false | ||||
wlan.ssid | Wifi network name. | RW | string | (empty) | ||||
wlan.pass | Wifi network password. | W | string | (empty) | ||||
wlan.ip_config.ip | Statically assigned device IP address. | RW | string | 192.168.5.5 | four octet | |||
wlan.ip_config.mask | Statically assigned network mask. | RW | string | 255.255.255.0 | four octet | |||
wlan.ip_config.gw | Statically assigned gateway IP address. | RW | string | 192.168.5.1 | four octet | |||
wlan.ip_config.dns | Statically assigned DNS server IP address. | RW | string | 8.8.8.8 | four octet | |||
mqtt | MQTT configuration. | object | ||||||
mqtt.seq_reset | Reset sequence number when reconnecting. | RW | boolean | false | ||||
mqtt.broker.address | Broker IP address. | RW | string | 192.168.5.4 | four octet | |||
mqtt.broker.port | Broker port. | RW | integer | 1883 | ||||
mqtt.broker.user | Broker username. Keep blank for anonymous. | RW | string | (empty) | ||||
mqtt.broker.pass | Broker password. Keep blank for anonymous. | W | string | (empty) | ||||
mqtt.broker.ka_s | Keepalive seconds. | RW | integer | 60 | seconds | |||
mqtt.broker.ping_s | Seconds between pings. | RW | integer | 5 | seconds | |||
sensor | Sensor output configuration. | object | ||||||
sensor.aggregate | Publish sensor values as a single payload. | RW | boolean | true | ||||
sensor.calibrate | Calibrate sensor values. | RW | boolean | true | ||||
sensor.convert | Convert sensor values. | RW | boolean | true | ||||
sensor.s0 | Binary PNP Sensor. | object | ||||||
sensor.s0.calibrate | Calibration formula. | RW | string | (v, False) | ||||
sensor.s0.convert | Conversion formula. | RW | string | (v, '/', False) | see RFC8428 | |||
sensor.s0.mode | switch , counter , or accumulator . |
RW | string | switch | ||||
sensor.s0.edge | any , rising , falling . |
RW | string | any | ||||
sensor.s0.period | Accumulator report period. | RW | integer | 1000 | milliseconds | |||
sensor.s1 | Binary NPN Sensor. | object | ||||||
sensor.s1.calibrate | Calibration formula. | RW | string | (v, False) | ||||
sensor.s1.convert | Conversion formula. | RW | string | (v, '/', False) | see RFC8428 | |||
sensor.s1.mode | switch , counter , or accumulator . |
RW | string | switch | ||||
sensor.s1.edge | any , rising , falling . |
RW | string | any | ||||
sensor.s1.period | Accumulator report period. | RW | integer | 1000 | milliseconds | |||
sensor.s2 | Analog Voltage Sensor. | object | ||||||
sensor.s2.deadband | Sensor dead-zone. | RW | integer | 100 | a value of 30 is 0.01V | |||
sensor.s2.calibrate | Calibration formula. | RW | string | (v * 0.000384615, False) | ||||
sensor.s2.convert | Conversion formula. | RW | string | (float('{:.1f}'.format((v - 0) / (10 - 0) * (10 - 0) + 0)), 'v', False) | see RFC8428 | |||
sensor.s3 | Analog Current Sensor. | object | ||||||
sensor.s3.deadband | Sensor dead-zone. | RW | integer | 100 | a value of 10 is 0.01mA | |||
sensor.s3.calibrate | Calibration formula. | RW | string | (v * 0.00075, False) | ||||
sensor.s3.convert | Conversion formula. | RW | string | (float('{:.1f}'.format((v - 4) / (20 - 4) * (20 - 4) + 4)), 'mA', False) | see RFC8428 |
- Navigate to chrome://flags
- Search for
Insecure origins treated as secure
flag - Enable option and provide domain/IP you are trying to connect to
- Relaunch
- Navigate to
http://your_server_address
- You will now be able to use bluetooth from the browser
- Ensure you have Docker installed
a. If you do not, follow https://docs.docker.com/ installation instructions for your OS - Open a terminal window
- Pull the
Sharc-Tech
image usingdocker pull ladder99/sharc-ui:latest
- Run the image inside of a container using
docker run -d -p 80:80 ladder99/sharc-ui:latest
- Navigate to https://localhost/ in your browser
- If you already have a MQTT Broker set up you are good to go!
- Ensure you have Docker and Docker Compose installed
- If you do not, follow https://docs.docker.com/ installation instructions for your OS
- Create a file named
docker-compose.yml
- Copy this configuration into the file:
version: "3.9"
services:
sharc-ui:
image: ladder99/sharc-ui:latest
container_name: sharc_tech
restart: unless-stopped
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "1m"
ports:
- "80:80/tcp"
- Go to directory that the file is located in
- Run
docker compose up -d
in the terminal - Navigate to https://localhost/ in your browser
- If you already have a MQTT Broker set up you are good to go!
- Ensure you have Docker and Docker Compose installed
- If you do not, follow https://docs.docker.com/ installation instructions for your OS
- Create a file named
docker-compose.yml
- Make sure to note down where this file is created.
- Copy this configuration into the file:
version: "3.9"
services:
sharc-ui:
image: ladder99/sharc-ui
container_name: sharc_tech
restart: unless-stopped
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "1m"
environment:
- REACT_APP_BROKER_IP=wss.sharc.tech
- REACT_APP_BROKER_PORT=443
ports:
- "80:80/tcp"
mosquitto:
container_name: mosquitto
image: eclipse-mosquitto
restart: unless-stopped
ports:
- "1883:1883/tcp"
- "9001:9001/tcp"
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- /home/your_username/volumes/mosquitto/config:/mosquitto/config:rw
- /home/your_username/volumes/mosquitto/data:/mosquitto/data:rw
- /home/your_username/volumes/mosquitto/log:/mosquitto/log:rw
logging:
driver: "json-file"
options:
max-size: "20m"
- Ensure that you replace
your_username
with the username of your computer - Go to the directory of the file created in step 2
- Run
docker compose up -d
in the terminal - Go to the newly created volume directory at
/home/your_username/volumes/mosquitto/config
- Create a file named
mosquitto.conf
- Copy this text into the file and save:
connection_messages true
log_dest stdout
log_dest stderr
log_timestamp true
log_type all
max_inflight_bytes 1000000
max_inflight_messages 1
max_queued_bytes 2000000
max_queued_messages 1000
message_size_limit 1500
persistence false
queue_qos0_messages false
retain_available true
per_listener_settings true
listener 1883 0.0.0.0
protocol mqtt
allow_anonymous true
max_connections 100
socket_domain ipv4
allow_zero_length_clientid false
listener 9001 0.0.0.0
protocol websockets
allow_anonymous true
max_connections 100
socket_domain ipv4
allow_zero_length_clientid false
This will ensure that your broker is set up to allow websocket connections on port 9001
- Navigate to https://localhost/ in your browser
- Congrats! You now have both Sharc-Tech and a MQTT Broker running locally