MycilaJSY 13.0.0
Arduino / ESP32 library for the JSY1031, JSY-MK-163, JSY-MK-193, JSY-MK-194, JSY-MK-227, JSY-MK-229, JSY-MK-333 families single-phase and three-phase AC bidirectional meters from Shenzhen Jiansiyan Technologies Co, Ltd.
|
Data Structures | |
class | Data |
class | Metrics |
Public Types | |
enum | BaudRate : uint32_t { UNKNOWN = 0 , BAUD_1200 = 1200 , BAUD_2400 = 2400 , BAUD_4800 = 4800 , BAUD_9600 = 9600 , BAUD_19200 = 19200 , BAUD_38400 = 38400 } |
enum class | EventType { EVT_READ , EVT_CHANGE , EVT_READ_ERROR , EVT_READ_TIMEOUT , EVT_READ_PEER } |
enum class | Mode { UNKNOWN , AC , DC } |
typedef std::function< void(EventType eventType)> | Callback |
Public Member Functions | |
void | begin (HardwareSerial &serial, int8_t rxPin, int8_t txPin, bool async, uint8_t core=MYCILA_JSY_ASYNC_CORE, uint32_t stackSize=MYCILA_JSY_ASYNC_STACK_SIZE, uint32_t pause=MYCILA_JSY_ASYNC_READ_PAUSE_MS) |
Initialize the JSY with the given RX and TX pins. | |
void | begin (HardwareSerial &serial, int8_t rxPin, int8_t txPin, BaudRate baudRate=BaudRate::UNKNOWN, uint8_t destinationAddress=MYCILA_JSY_ADDRESS_BROADCAST, uint16_t model=MYCILA_JSY_MK_UNKNOWN, bool async=false, uint8_t core=MYCILA_JSY_ASYNC_CORE, uint32_t stackSize=MYCILA_JSY_ASYNC_STACK_SIZE, uint32_t pause=MYCILA_JSY_ASYNC_READ_PAUSE_MS) |
Initialize the JSY with the given RX and TX pins. | |
void | end () |
Ends the JSY communication. | |
bool | setDeviceAddress (uint8_t newAddress) |
Set a new address for a device. | |
bool | setDeviceAddress (uint8_t address, uint8_t newAddress) |
Set a new address for a device. | |
uint16_t | readModel () |
Reads the JSY model. | |
uint16_t | readModel (uint8_t address) |
Reads the JSY model. | |
uint16_t | getModel () const |
Get the cached JSY model that was read during begin() | |
const char * | getModelName () const |
Mode | readMode () |
Reads the JSY mode (AC or DC). Some JSY are able to work with either AC or DC current. | |
Mode | readMode (uint8_t address) |
Reads the JSY mode (AC or DC). Some JSY are able to work with either AC or DC current. | |
bool | setMode (Mode mode) |
Set the JSY mode (AC or DC). Some JSY are able to work with either AC or DC current. | |
bool | setMode (uint8_t address, Mode mode) |
Set the JSY mode (AC or DC). Some JSY are able to work with either AC or DC current. | |
bool | read () |
Read the JSY values. | |
bool | read (uint8_t address) |
Read the JSY values. | |
bool | resetEnergy () |
Reset the energy counters of the JSY. | |
bool | resetEnergy (uint8_t address) |
Reset the energy counters of the JSY. | |
bool | setBaudRate (BaudRate baudRate) |
Change the baud rate of the JSY. | |
bool | setBaudRate (uint8_t address, BaudRate baudRate) |
Change the baud rate of the JSY. | |
gpio_num_t | getRXPin () const |
gpio_num_t | getTXPin () const |
bool | isEnabled () const |
BaudRate | getBaudRate () const |
uint8_t | getDestinationAddress () const |
Get the address used to send requests. | |
BaudRate | getMinAvailableBaudRate () const |
BaudRate | getMaxAvailableBaudRate () const |
Get the maximum available baud rate supported by the current JSY model connected. | |
bool | isBaudRateSupported (BaudRate baudRate) const |
Check if a baud rate is supported by the current JSY model connected. | |
uint8_t | getLastAddress () const |
Get the address of the last device's response. | |
uint32_t | getTime () const |
bool | isConnected () const |
void | setCallback (Callback callback) |
Static Public Member Functions | |
static const char * | getModelName (uint16_t model) |
Get the name of the JSY model. | |
static BaudRate | getMinAvailableBaudRate (uint16_t model) |
static BaudRate | getMaxAvailableBaudRate (uint16_t model) |
static bool | isBaudRateSupported (uint16_t model, BaudRate baudRate) |
Data Fields | |
Data | data |
Access the runtime JSY data. | |
Definition at line 86 of file MycilaJSY.h.
std::function<void(EventType eventType)> Mycila::JSY::Callback |
Definition at line 306 of file MycilaJSY.h.
enum Mycila::JSY::BaudRate : uint32_t |
Definition at line 88 of file MycilaJSY.h.
|
strong |
Definition at line 106 of file MycilaJSY.h.
|
strong |
Definition at line 119 of file MycilaJSY.h.
|
inline |
Definition at line 308 of file MycilaJSY.h.
void Mycila::JSY::begin | ( | HardwareSerial & | serial, |
int8_t | rxPin, | ||
int8_t | txPin, | ||
BaudRate | baudRate = BaudRate::UNKNOWN, | ||
uint8_t | destinationAddress = MYCILA_JSY_ADDRESS_BROADCAST, | ||
uint16_t | model = MYCILA_JSY_MK_UNKNOWN, | ||
bool | async = false, | ||
uint8_t | core = MYCILA_JSY_ASYNC_CORE, | ||
uint32_t | stackSize = MYCILA_JSY_ASYNC_STACK_SIZE, | ||
uint32_t | pause = MYCILA_JSY_ASYNC_READ_PAUSE_MS ) |
Initialize the JSY with the given RX and TX pins.
serial | The serial port to use |
rxPin | RX board pin connected to the TX of the JSY |
txPin | TX board pin connected to the RX of the JSY |
baudRate | The baud rate of the JSY. If set to BaudRate::UNKNOWN, the baud rate is automatically detected |
destinationAddress | The address of the device to communicate with (1-255) or MYCILA_JSY_ADDRESS_BROADCAST for all devices |
model | The model of the JSY. If set to MYCILA_JSY_MK_UNKNOWN, the model is automatically detected |
async | If true, the JSY will be read in a separate task (default: false) |
core | The core to use for the async task (default: MYCILA_JSY_ASYNC_CORE) |
stackSize | The stack size of the async task (default: MYCILA_JSY_ASYNC_STACK_SIZE) |
pause | Time in milliseconds to wait between each read in async mode (default: MYCILA_JSY_ASYNC_READ_PAUSE_MS) |
Definition at line 624 of file MycilaJSY.cpp.
|
inline |
Initialize the JSY with the given RX and TX pins.
serial | The serial port to use |
rxPin | RX board pin connected to the TX of the JSY |
txPin | TX board pin connected to the RX of the JSY |
async | If true, the JSY will be read in a separate task (default: false) |
core | The core to use for the async task (default: MYCILA_JSY_ASYNC_CORE) |
stackSize | The stack size of the async task (default: MYCILA_JSY_ASYNC_STACK_SIZE) |
pause | Time in milliseconds to wait between each read in async mode (default: MYCILA_JSY_ASYNC_READ_PAUSE_MS) |
Definition at line 321 of file MycilaJSY.h.
void Mycila::JSY::end | ( | ) |
Ends the JSY communication.
Definition at line 713 of file MycilaJSY.cpp.
|
inline |
Definition at line 498 of file MycilaJSY.h.
|
inline |
Get the address used to send requests.
Definition at line 504 of file MycilaJSY.h.
|
inline |
Get the address of the last device's response.
Definition at line 527 of file MycilaJSY.h.
Mycila::JSY::BaudRate Mycila::JSY::getMaxAvailableBaudRate | ( | ) | const |
Get the maximum available baud rate supported by the current JSY model connected.
Definition at line 1302 of file MycilaJSY.cpp.
|
static |
Definition at line 1308 of file MycilaJSY.cpp.
Mycila::JSY::BaudRate Mycila::JSY::getMinAvailableBaudRate | ( | ) | const |
Definition at line 1279 of file MycilaJSY.cpp.
|
static |
Definition at line 1285 of file MycilaJSY.cpp.
|
inline |
Get the cached JSY model that was read during begin()
Definition at line 398 of file MycilaJSY.h.
|
inline |
Definition at line 400 of file MycilaJSY.h.
|
static |
Get the name of the JSY model.
model | The JSY model |
Definition at line 1617 of file MycilaJSY.cpp.
|
inline |
Definition at line 495 of file MycilaJSY.h.
|
inline |
Definition at line 532 of file MycilaJSY.h.
|
inline |
Definition at line 496 of file MycilaJSY.h.
bool Mycila::JSY::isBaudRateSupported | ( | BaudRate | baudRate | ) | const |
Check if a baud rate is supported by the current JSY model connected.
Definition at line 1325 of file MycilaJSY.cpp.
|
static |
Definition at line 1331 of file MycilaJSY.cpp.
|
inline |
Definition at line 535 of file MycilaJSY.h.
|
inline |
Definition at line 497 of file MycilaJSY.h.
|
inline |
Read the JSY values.
Definition at line 446 of file MycilaJSY.h.
|
inline |
Read the JSY values.
address | The address of the device to read (1-255) or MYCILA_JSY_ADDRESS_BROADCAST for all devices |
Definition at line 454 of file MycilaJSY.h.
|
inline |
Reads the JSY mode (AC or DC). Some JSY are able to work with either AC or DC current.
Definition at line 414 of file MycilaJSY.h.
|
inline |
Reads the JSY mode (AC or DC). Some JSY are able to work with either AC or DC current.
address | The address of the device to read (1-255) or MYCILA_JSY_ADDRESS_BROADCAST for all devices |
Definition at line 422 of file MycilaJSY.h.
|
inline |
Reads the JSY model.
Definition at line 384 of file MycilaJSY.h.
uint16_t Mycila::JSY::readModel | ( | uint8_t | address | ) |
Reads the JSY model.
address | The address of the device to read (1-255) or MYCILA_JSY_ADDRESS_BROADCAST for all devices |
Definition at line 1115 of file MycilaJSY.cpp.
|
inline |
Reset the energy counters of the JSY.
Definition at line 461 of file MycilaJSY.h.
bool Mycila::JSY::resetEnergy | ( | uint8_t | address | ) |
Reset the energy counters of the JSY.
address | The address of the device to reset (1-255) or MYCILA_JSY_ADDRESS_BROADCAST for all devices |
Definition at line 1251 of file MycilaJSY.cpp.
|
inline |
Change the baud rate of the JSY.
baudRate | The new baud rate to set |
Definition at line 480 of file MycilaJSY.h.
bool Mycila::JSY::setBaudRate | ( | uint8_t | address, |
BaudRate | baudRate ) |
Change the baud rate of the JSY.
address | The address of the device to change (1-255) or MYCILA_JSY_ADDRESS_BROADCAST for all devices |
baudRate | The new baud rate to set |
Definition at line 1335 of file MycilaJSY.cpp.
|
inline |
Definition at line 537 of file MycilaJSY.h.
bool Mycila::JSY::setDeviceAddress | ( | uint8_t | address, |
uint8_t | newAddress ) |
Set a new address for a device.
address | The address of the device to change (1-255) or MYCILA_JSY_ADDRESS_BROADCAST for the broadcast address |
newAddress | The new address to set (1-255) |
Definition at line 1339 of file MycilaJSY.cpp.
|
inline |
Set a new address for a device.
newAddress | The new address to set (1-255) |
Definition at line 367 of file MycilaJSY.h.
|
inline |
Set the JSY mode (AC or DC). Some JSY are able to work with either AC or DC current.
mode | The mode to set |
Definition at line 430 of file MycilaJSY.h.
|
inline |
Set the JSY mode (AC or DC). Some JSY are able to work with either AC or DC current.
address | The address of the device to set (1-255) or MYCILA_JSY_ADDRESS_BROADCAST for all devices |
mode | The mode to set |
Definition at line 439 of file MycilaJSY.h.
Data Mycila::JSY::data |
Access the runtime JSY data.
Definition at line 543 of file MycilaJSY.h.