Skip to content

Commit

Permalink
V1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bunjongy committed Nov 29, 2022
1 parent 93c5a2a commit fa7d6a4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
2 changes: 2 additions & 0 deletions RodaiSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "driver/uart.h"
#include "freertos/queue.h"
#include "esp_log.h"
#include "driver/gpio.h"
#include "sdkconfig.h"

#define CRC_START_MODBUS 0xFFFF
#define CRC_POLY_16 0xA001
Expand Down
39 changes: 33 additions & 6 deletions RodaiSensor.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
#pragma once
#ifndef RODAI_SENSOR_H_
#define RODAI_SENSOR_H_
#include <Arduino.h>
#include "driver/uart.h"
#include "driver/gpio.h"
#include "sdkconfig.h"

#if CONFIG_IDF_TARGET_ESP32
#define UART_PORT UART_NUM_1
#define UART_TX GPIO_NUM_23
#define UART_RX GPIO_NUM_22
#define UART_DIR GPIO_NUM_4
#elif CONFIG_IDF_TARGET_ESP32S2
#define UART_PORT UART_NUM_1
#define UART_TX GPIO_NUM_1
#define UART_RX GPIO_NUM_2
#define UART_DIR GPIO_NUM_3
#elif CONFIG_IDF_TARGET_ESP32C3
#define UART_PORT UART_NUM_1
#define UART_TX GPIO_NUM_4
#define UART_RX GPIO_NUM_5
#define UART_DIR GPIO_NUM_6
#elif CONFIG_IDF_TARGET_ESP32S3
#define UART_PORT UART_NUM_1
#define UART_TX GPIO_NUM_1
#define UART_RX GPIO_NUM_2
#define UART_DIR GPIO_NUM_3
#endif

class RodaiSensor
{
private:
uart_port_t _uart_num = UART_NUM_1;
uart_port_t _uart_num = UART_PORT;
int _baud_rate = 9600;
bool crc_tab16_init = false;
uint16_t crc_tab16[256];
Expand All @@ -15,12 +40,14 @@ class RodaiSensor
int readRegisters(uint8_t addr, uint8_t funcCode, uint16_t strAddr, uint16_t count, uint8_t *data, int tempBaudrate);

public:
RodaiSensor(uart_port_t uart_num = UART_NUM_1,
int tx_io_num = GPIO_NUM_23,
int rx_io_num = GPIO_NUM_22,
int rts_io_num = GPIO_NUM_4,
RodaiSensor(uart_port_t uart_num = UART_PORT,
int tx_io_num = UART_TX,
int rx_io_num = UART_RX,
int rts_io_num = UART_DIR,
int cts_io_num = UART_PIN_NO_CHANGE,
int baud_rate = 9600);

int getRodaiSoilWaterContentValue(uint8_t addr);
};

#endif /* MAIN_DNS_SERVER_H_ */
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name=RodaiSensor
version=1.0.2
version=1.0.3
author=Bunjong Yosapa
maintainer=Bunjong Yosapa <[email protected]>
sentence=Read all sensor form Rodai.xyz.
paragraph=
category=Sensor
url=https://github.com/bunjongy/RodaiSensor
architectures=esp32
architectures=esp32,esp32s2,esp32s3
includes=RodaiSensor.h

0 comments on commit fa7d6a4

Please sign in to comment.