Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 9,968
» Latest member: xoilacmovie
» Forum threads: 4,245
» Forum posts: 21,029

Full Statistics

Online Users
There are currently 159 online users.
» 0 Member(s) | 140 Guest(s)
AhrefsBot, Amazonbot, Applebot, Baidu, Bing, Bytespider, Crawl, Google, PetalBot, bot

Latest Threads
Modbus 485 extender kcs V...
Forum: N30
Last Post: admin
10 hours ago
» Replies: 11
» Views: 130
N10 with L1 and L2 suppor...
Forum: N10
Last Post: admin
Yesterday, 11:34 PM
» Replies: 1
» Views: 10
KC868-A16v3 PCB layout CA...
Forum: Schematic & diagram & Dimensions of KinCony PCB layout CAD file
Last Post: admin
Yesterday, 11:33 PM
» Replies: 2
» Views: 483
Ceiling fan control not w...
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
09-15-2026, 11:11 PM
» Replies: 9
» Views: 119
Case
Forum: KC868-A16S
Last Post: admin
09-15-2026, 02:26 AM
» Replies: 5
» Views: 80
KC868-A16S PCB layout CAD...
Forum: Schematic & diagram & Dimensions of KinCony PCB layout CAD file
Last Post: admin
09-14-2026, 11:23 PM
» Replies: 0
» Views: 24
flash kc868-a4
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
09-14-2026, 11:18 PM
» Replies: 25
» Views: 5,112
KC868-A16 – Using AI3/AI4...
Forum: KC868-A16
Last Post: admin
09-14-2026, 08:27 AM
» Replies: 1
» Views: 53
Questions on CO16
Forum: CO16
Last Post: admin
09-13-2026, 01:26 PM
» Replies: 3
» Views: 63
RED DIP switch function
Forum: Pi5M32
Last Post: admin
09-12-2026, 11:50 PM
» Replies: 0
» Views: 33

  temperature humidity sensor convertor – TR RS485 Modbus protocol
Posted by: admin - 10-28-2025, 12:42 AM - Forum: Extender module - No Replies

Code:
================================================================================
  RS485 TEMPERATURE & HUMIDITY SENSOR PROTOCOL SPECIFICATION
================================================================================

Communication: RS485 (Modbus-based Custom Protocol)

================================================================================
1. OVERVIEW
================================================================================

This document describes the custom Modbus-based protocol for communicating with
temperature and humidity sensors over RS485. The protocol supports up to 32
sensors per slave device, allowing for distributed sensor networks.

Key Features:
- Modbus RTU framing with CRC16
- Custom function code for sensor data reading
- Support for 1-32 sensors per slave address
- Temperature and humidity readings with 0.1 degree/percent precision
- Explicit encoding for unavailable sensor data

================================================================================
2. PROTOCOL PARAMETERS
================================================================================

Modbus Function Code: 0x0A (READ_SENSOR_DATA)
Baud Rate: As configured by RS485 driver
Data Format: 8N1 (8 data bits, no parity, 1 stop bit)
CRC: Modbus CRC16 (polynomial 0xA001)

Sensor Address Range: 1-32 (0x01-0x20)
Slave Address Range: 1-247 (0x01-0xF7, standard Modbus range)

================================================================================
3. REQUEST FORMAT
================================================================================

The master sends a request to read sensor data from a specific sensor.

Request Frame Structure:
┌──────────────┬──────────────┬────────────────┬────────────────┬──────────┐
│ Byte Index   │ 0            │ 1              │ 2              │ 3        │
├──────────────┼──────────────┼────────────────┼────────────────┼──────────┤
│ Field        │ Slave Addr   │ Function Code  │ Sensor ID High │ Sensor ID│
│              │              │                │                │ Low      │
├──────────────┼──────────────┼────────────────┼────────────────┼──────────┤
│ Value        │ 0x01-0xF7    │ 0x0A           │ 0x00           │ 0x01-0x20│
└──────────────┴──────────────┴────────────────┴────────────────┴──────────┘
┌──────────────┬──────────────┐
│ Byte Index   │ 4-5          │
├──────────────┼──────────────┤
│ Field        │ CRC16        │
├──────────────┼──────────────┤
│ Value        │ Lo-Hi bytes  │
└──────────────┴──────────────┘

Total Length: 6 bytes

Field Descriptions:
- Slave Address: The Modbus slave device address (1-247)
- Function Code: Always 0x0A for sensor data reading
- Sensor ID High: Always 0x00 (reserved for future use)
- Sensor ID Low: Sensor number (1-32) on the slave device
- CRC16: Modbus CRC16 checksum (low byte first, then high byte)

Example Request (Read sensor 1 from slave 0x01):
  Request: 01 0A 00 01 [CRC_LOW] [CRC_HIGH]

================================================================================
4. RESPONSE FORMAT
================================================================================

The slave responds with temperature and humidity data for the requested sensor.

Response Frame Structure:
┌─────────────┬────────────┬──────────────┬────────────┬──────────────────┐
│ Byte Index  │ 0          │ 1            │ 2          │ 3-7              │
├─────────────┼────────────┼──────────────┼────────────┼──────────────────┤
│ Field       │ Slave Addr │ Function Code│ Byte Count │ Temperature Data │
│             │            │              │            │ (5 bytes)        │
├─────────────┼────────────┼──────────────┼────────────┼──────────────────┤
│ Value       │ 0x01-0xF7  │ 0x0A         │ 0x0A (10)  │ See section 5    │
└─────────────┴────────────┴──────────────┴────────────┴──────────────────┘
┌─────────────┬──────────────────┬──────────┐
│ Byte Index  │ 8-12             │ 13-14    │
├─────────────┼──────────────────┼──────────┤
│ Field       │ Humidity Data    │ CRC16    │
│             │ (5 bytes)        │          │
├─────────────┼──────────────────┼──────────┤
│ Value       │ See section 5    │ Lo-Hi    │
└─────────────┴──────────────────┴──────────┘

Total Length: 15 bytes

Field Descriptions:
- Slave Address: Echo of the slave address from request
- Function Code: Echo of 0x0A
- Byte Count: Always 0x0A (10 decimal) - 5 bytes temp + 5 bytes humidity
- Temperature Data: 5-byte encoded temperature value
- Humidity Data: 5-byte encoded humidity value
- CRC16: Modbus CRC16 checksum (low byte first, then high byte)

Minimum Valid Response Length: 14 bytes
Expected Response Length: 15 bytes (with CRC)

================================================================================
5. DATA ENCODING
================================================================================

Both temperature and humidity use the same 5-byte encoding format:

5.1 Data Structure
┌──────────────┬──────────┬──────────┬──────────┬──────────┬──────────┐
│ Byte Index   │ 0        │ 1        │ 2        │ 3        │ 4        │
├──────────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
│ Field        │ Sign     │ Hundreds │ Tens     │ Ones     │ Decimal  │
├──────────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
│ Value Range  │ 0 or 1   │ 0-9      │ 0-9      │ 0-9      │ 0-9      │
└──────────────┴──────────┴──────────┴──────────┴──────────┴──────────┘

5.2 Field Definitions
- Sign: 0 = positive, 1 = negative
- Hundreds: Hundreds digit (0-9)
- Tens: Tens digit (0-9)
- Ones: Ones digit (0-9)
- Decimal: First decimal place (0-9, represents 0.0-0.9)

5.3 Value Calculation
Final Value = Sign × (Hundreds × 100 + Tens × 10 + Ones + Decimal × 0.1)

Where Sign is: +1 if sign byte is 0, -1 if sign byte is 1

5.4 Data Not Available Indicator
When sensor data is not available or invalid, ALL 5 bytes are set to 0xFF:
  0xFF 0xFF 0xFF 0xFF 0xFF

The receiver should check if any byte is NOT 0xFF to determine if data is valid.
If all bytes are 0xFF, the data should be treated as unavailable (-100.0 default).

5.5 Encoding Examples

Example 1: Temperature = 25.3°C
  Bytes: 00 00 02 05 03
  Calculation: +(0×100 + 2×10 + 5 + 3×0.1) = +25.3

Example 2: Temperature = -5.7°C
  Bytes: 01 00 00 05 07
  Calculation: -(0×100 + 0×10 + 5 + 7×0.1) = -5.7

Example 3: Humidity = 65.0%
  Bytes: 00 00 06 05 00
  Calculation: +(0×100 + 6×10 + 5 + 0×0.1) = +65.0

Example 4: Data not available
  Bytes: FF FF FF FF FF
  Interpretation: No valid data (-100.0 default value)

Example 5: Temperature = 100.5°C
  Bytes: 00 01 00 00 05
  Calculation: +(1×100 + 0×10 + 0 + 5×0.1) = +100.5

================================================================================
6. COMPLETE TRANSACTION EXAMPLE
================================================================================

Master requests data from sensor 1 on slave 0x01:

REQUEST (6 bytes):
  01 0A 00 01 XX XX
  └─ Slave address: 0x01
     └─ Function code: 0x0A
        └─ Sensor ID high: 0x00
           └─ Sensor ID low: 0x01
              └─ CRC16 (calculated over bytes 0-3)

RESPONSE (15 bytes):
  01 0A 0A 00 00 02 05 03 00 00 06 05 00 XX XX
  └─ Slave address: 0x01
     └─ Function code: 0x0A
        └─ Byte count: 0x0A (10 bytes)
           └─ Temperature: 00 00 02 05 03 (+25.3°C)
                          └─ Humidity: 00 00 06 05 00 (+65.0%)
                                      └─ CRC16

Decoded Result:
  Temperature: +25.3°C
  Humidity: +65.0%

================================================================================
7. ERROR HANDLING
================================================================================

7.1 Invalid Response Conditions
The receiver should reject responses in the following cases:

1. Slave address mismatch: Response slave address ≠ request slave address
2. Function code mismatch: Response function code ≠ 0x0A
3. Insufficient length: Response length < 14 bytes
4. Invalid byte count: Byte count field ≠ 0x0A (10)
5. CRC error: Calculated CRC ≠ received CRC

7.2 Data Validation
After successful frame validation, check each sensor value:

- If all 5 bytes are 0xFF: Data not available, use default (-100.0)
- If at least one byte is NOT 0xFF: Decode the value normally
- Value range checking should be performed at application level

7.3 Timeout Handling
Recommended timeout: 50-100ms after sending request
If no response within timeout: Retry or report communication error

7.4 Modbus Exception Responses
Standard Modbus exception codes may be returned:
  [Slave Addr] [0x8A] [Exception Code] [CRC]

Where 0x8A = 0x0A + 0x80 (function code with MSB set)

Common exception codes:
- 0x01: Illegal Function (function code not supported)
- 0x02: Illegal Data Address (sensor address out of range)
- 0x03: Illegal Data Value (invalid request parameters)
- 0x04: Slave Device Failure (sensor read error)

================================================================================
8. IMPLEMENTATION NOTES
================================================================================

8.1 Multi-Sensor Support
- A single slave device can support 1-32 sensors (addresses 1-32)
- Each sensor must be initialized before reading
- Sensor addresses are independent of slave addresses
- Multiple slaves can exist on the same RS485 bus

8.2 Polling Frequency
- Recommended polling interval: 1-5 seconds per sensor
- Add delays between consecutive requests to prevent bus collisions
- Minimum delay between requests: 50ms

8.3 Bus Configuration
- RS485 requires proper termination resistors (120Ω)
- Maximum bus length depends on baud rate (typically 1200m at 9600 baud)
- Maximum number of devices: 32-247 (depending on hardware)

8.4 Data Caching
- The master typically caches the last received values
- Cached values are updated when new responses arrive
- Applications read from cache rather than directly from bus

8.5 CRC Calculation
- Use standard Modbus CRC16 algorithm
- Polynomial: 0xA001 (reversed 0x8005)
- Initial value: 0xFFFF
- CRC bytes transmitted: low byte first, then high byte

================================================================================
9. PROTOCOL LIMITATIONS
================================================================================

- Maximum sensors per slave: 32
- Temperature/humidity precision: 0.1 units
- Maximum value range: -999.9 to +999.9
- No timestamp or sensor identification in response
- No batch reading (must query each sensor individually)
- No sensor configuration commands in this protocol version

================================================================================
END OF SPECIFICATION
================================================================================

Print this item

  KC868-H32B Pro wrong firmware update
Posted by: Yooo - 10-27-2025, 01:53 PM - Forum: KC868-HxB series Smart Controller - Replies (1)

I have a KC868-H32B Pro controller on which I put a wrong firmware, I try to put the correct one on RS232 but I can't, it doesn't detect the bootloader. can i do something else or is it a brick?

Print this item

  IIC Connector type
Posted by: Eggman - 10-26-2025, 11:21 PM - Forum: KC868-A series and Uair Smart Controller - Replies (1)

Can someone tell me what type of connector is used on the KC868-A6 for the IIC port?  Is it a JST XH 2.5mm pitch.

Print this item

  kc868 pzem017 18b20
Posted by: billythekid57 - 10-26-2025, 05:04 PM - Forum: KC868-A series and Uair Smart Controller - Replies (10)

Hello to the forum, this is my first post. I purchased two KC868 A16 boards to use with DS18B20 temperature sensors and PZEM 017 meters. I saw two firmwares here; one has working inputs and outputs, but it doesn't have DS18B20 or PZEM listed. I tried the other for DS18B20, and it works, except now the inputs are missing. I tried using TasmoCompiler to create a binary, but the update says the file is invalid. I set ESP32 and ESP32 S3, but neither works. If anyone has a firmware that works, please let me know.

Print this item

  Connection Internet
Posted by: shochif - 10-26-2025, 10:51 AM - Forum: KinCony Server-Mini / Server-16 Raspberry Pi4 relay module - Replies (1)

can i using sim7600E for the main internet an i share the internet using switch base on HomeAssistant???

Print this item

  Z1 Transmit action from. Home Asssistant
Posted by: paulbalinnel - 10-26-2025, 09:06 AM - Forum: KC868-AG / AG Pro / AG8 / Z1 - Replies (14)

Hello, please describe the best way to send an action from HA for RF to be transmitted from Z1.

Currently, I have a TV lift with a remote that has UP, STOP, and DOWN buttons. I have already programmed these as RF1, RF2, and RF3 in KCS. However, they appear in HA as binary sensors, not switches.

TCP and HTTP?

Thanks

Print this item

  Reed water meter
Posted by: mdiessner - 10-25-2025, 05:42 AM - Forum: B16 - Replies (3)

I would like to use this product:
https://www.kincony.com/esp32-s3-16ch-sm...oller.html

In order to read water meter
https://www.transducers.co.za/media/1868...-meter.pdf

Please advise if this is possible, it not what else to use?

The idea is to count every pulse using the digital input, and increasing the count value and storing the value in case of reboot/power failure

Print this item

  KC868-A16
Posted by: eligijus - 10-24-2025, 05:32 AM - Forum: "KCS" v2 firmware system - Replies (9)

Hello, can you upload an example yaml file # DHT22 temperature-humidity sensor integration into home assistant

Print this item

  Problem when connecting USB-C
Posted by: aym55 - 10-23-2025, 06:27 PM - Forum: N10 - Replies (1)

Hello,
I just bought N10 module, i connected it to 24V power and it works. However when i try to put USB-C cable from computer to Kincony for download firmware it suddenly have short cut and my 24V power supply turn off , i must take off usb-c for it to work again, this situation is from early begining.I get deffective Unit ?

Thanks.

Print this item

  Free Sample
Posted by: jamesfreeman - 10-23-2025, 05:58 PM - Forum: Apply for free sample product - No Replies

Hello,

I would like to request a free sample, under conditions A and B. We are a 501c3 non profit educational makerspace in Austin Tx. We would like to develop a home automation class, and I believe your products would be a great platform to use. Please let me know if this works for you.

Print this item