First of all, I'm new to this forum and I'm new to arduino and electronics too. I might miss some very basic things that experienced people can spot within seconds.
I recently bought two NPK sensors on Amazon and I'm struggling to understand how they work. I followed several tutorials to make them run with an arduino, but unlike most other people here I just don't get any response at all. Although it seemed like getting back an FFFFFF, checking it with mySerial.available() reveals that there is no data to read and the FFFFFF seem to be the absence of incoming data (if I interpret this correctly).
My goal is to build a handheld device with battery, maybe a screen (optional) and Bluetooth to read the sensor data from an android device. And over time I would improve an initially very simple app to facilitate making protocols and statistics of the measurements done on various plants.
However, as a first step I would need the sensor to give me some data. But unfortunately none of the sensors do respond.
What I tried so far:
- following the tutorial on electronicclinic.com.
- I just realized that I forgot the two 470uf decoupling capacitors. If will order some and try again.
- two arduino uno with a MAX485 each, connected through modbus to test the modbus connection.
- Result: The slave is getting the inquiry frame sent by the master correctly. But if I try to send the received data back to the master there seems to be a loop between the two, sending more and more unwanted data back and forth. But if I leave the slave in the receiving state all frames are received correctly without further noises.
- Connect it to a USB-Dongle and try to send a inquiry frame from the PC with different Modbus monitoring software, but without any response from the sensors. I realized that all of the monitoring software did calculate a different checksum to what the sensor manual mentions.
- Using WinModbus to simulate a working sensor/slave (thanks to @markd833 again)
- As it turns out WinModbus did not accept the CRC numbers provided by the manuals of the sensors. I then implemented a function to calculate the CRC automatically and communication between Arduino as master and WinModbus as slave does work as expected.
I should mention that only one of my arduino uno seems to be original, the others have a different chip for which I had to install an extra driver first. But I imagine this shouldn't be the problem in my case.
- Does anybody have a Link to a software that is meant to work with these sensors? I saw in another Topic that @HPsunil got such a software from the seller. Unfortunately he did not respond to my request for a download link so far. I also did write to JXCT an hour ago, asking for a download link and I'm waiting for a response.
- Do I need terminal resistors in the modbus when using MAX485? (Tutorials on the internet do not use them and it seems to work). And if yes, where to put them exactly?
- Is there only one way to calculate the CRC-Code for Modbus communication? Or would the manufacturer be free to implement any other calculation to get a different CRC than the one expected by common Modbus monitoring software?
- any other suggestions what else I could try to test if the sensors do work correctly?
- Order decoupling capacitors and try again
- Get the original sensor monitoring software and test if sensors respond that way.
- Setting up another Arduino to act as a listener/man in the middle (thanks for this suggestion @markd833)
I'm happy to provide more details if needed. I'm sure I forgot something.