Connecting 7 in 1 Soil Sensor with GW1NSR-4C using UART

OP #7705071

Hello,

I am trying to make a UART connection between the GW1NSR-4C Chip(LilyGO T-FPGA board) and the 7 in 1 Soil Sensor. The Soil Sensor follows the RTU Modbus Protocol, requires CRC error check, and by default, the baud rate is 9600.

I have to use the Gowin EDA software to program the GW1NSR-4C chip(C6/I5 Speed Grade)

The GW1NSR-4C chip on the LilyGO T-FPGA board is connected to a 27 MHz crystal oscillator which I am using to generate the baud rate. I have defined the UART.v file as the top module and I also have a Transmitter and a Receiver module with a CRC_16 module.

I need help with the code, as currently, I am trying to build the code to send the request frame to the sensor for all 7 parameters then receive back the response frame and further calculate the parameter values.

Currently, I am trying to just work on the transmitter part of the code and check the request frame output by connecting Arduino via UART and printing on the serial monitor. But the problem is in the current code, whatever data I am sending is sent twice, and after implementation of the CRC in the code, all the data sent is 0(sent twice). I don't know what to do and am I in urgent need to complete this project.

Can somebody help?

Please let me know if any more details are needed to be shared.

Attached files:

Jainesh wrote:

I am trying to make a UART connection between the GW1NSR-4C Chip(LilyGO T-FPGA board) and the 7 in 1 Soil Sensor. The Soil Sensor follows the RTU Modbus Protocol, requires CRC error check, and by default, the baud rate is 9600.

So you try to build a RS-232 (UART) <-> RS-485 (Modbus) bridge?

There are USB adaptors and even Modbus gateways (Modbus to UART/Ethernet/Wifi/...) available.

Reply

A question of your own? This thread is over 2 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.