obniz Parts Library

M5StickC_RS485

GitHub
M5StickC_RS485
Usable Devices :
obniz_board
m5stickc
Found at :
秋月電子通商

M5StickC RS485

RS485-HAT is a TTL to RS485 converter for M5StickC.

wired(obniz, {tx, rx,{vcc, gnd, baud}})

connect to the obniz device.
When using M5StickC, You do not need to assign pins.

// JavaScript Examples
var obniz = new Obniz.M5StickC("OBNIZ_ID_HERE");
obniz.onconnect = async function() {
  var rs485 = obniz.wired("M5StickC_RS485"); // M5stick C

  rs485.onreceive = function(data, text) {
    console.log(text);
  }
  $("#send").click(function(){
    rs485.send("Hello")
  })
}

When using other devices, White, yellow, red and black wires correspond to scl, sda, vcc and gnd respectively.

name type required default description
vcc number(obniz Board io) no   Power Supply
gnd number(obniz Board io) no   Power Supply
tx number(obniz Board io) yes   tx
rx number(obniz Board io) yes   rx
baud number no   baudrate
// Javascript Example
var rs485 = obniz.wired("M5StickC_RS485", {tx: 0, rx:26}); // M5stick C

rs485.onreceive = function(data, text) {
  console.log(text);
}
$("#send").click(function(){
  rs485.send("Hello")
})

send(data)

send data via UART to RS485.

// Javascript Example
var rs485 = obniz.wired("M5StickC_RS485", {tx: 0, rx:26}); // M5stick C
rs485.send("Hello")

onreceive(data, text)

received data from RS485 via UART. This callback has same arguments with uart.onreceive()

// Javascript Example
var rs485 = obniz.wired("M5StickC_RS485", {tx: 0, rx:26}); // M5stick C

rs485.onreceive = function(data, text) {
  console.log(text);
}

Supported from: obniz.js 3.5.0