For those who had issue with nonworking connection or stability like me: add few milisecods (3-15ms) delay at the end of preTransmission() and few ms at the start of postTransmission() functions. It gives MAX485 some time for proper switching from reading/writing state.
Thank you for the video. Coud you explain how you can get both Tx/Rx modbus acquisition and Serial monitor at the same time? When the serial monitor is in use (such as in your video), no other serial communication should be possible. Unless you have two serial ports available which I do not think is the case for Arduino Nano.
You can actually see the modbus data in his serial monitor. So his Modbus slave _and_ his serial monitor are seeing each other's communication. This isn't a problem for serial monitor (as you just see some random garbage), but I'm a little surprised that the Modbus slave recovered so quickly. I do recall seeing something in the Modbus spec about ignoring non-conforming data. But you're right. The "proper" way to do this is to separate your communication lines; either using an Arduino Due or Mega (with four separate serial pin pairs so you can move the Modbus board to Serial1, Serial2, or Serial3) or send your human-readable output to an LCD display via I2C or something.
Hi , very informative video. I have one doubt if we need to write the value from the micro-controller to input register how can one should approach please guide regarded this. take this as in put don't generate output.
Hi John, no worries! Yes, that's good! Many people say "I can't do it", but they actually can - they just need to try! Believe it or not, I knew nothing about RS-485 a week ago! :-D
Good video, but this library is only for arduino as a teacher, do you know any library that is for master and slave and multiple slaves because I think it is only for one slave right? i test yout proyect with serial port monitor in the other side and i cant see data, can be my max485 broken?
hi Antony. just what I need and thanks for the in depth explanation, really cleared up a lot of unknowns for me. I have a problem with reading your code on one line due to my fuzzy screen. the line in question is: if resultMain == ?????Success) looks like loadMBSuccess but this does not make sense to me..nothing new there..:-) Also unit8-t resultMain; is this correct and could you are anyone explain this.. Thanks in anticipation
Hi, thanks for your comment. It's "node.ku8MBSuccess". It's "uint8_t"... U means 'unsigned'. That means that there is no '-' or '+', therefore it is only a positive value (>=0). Int means 'integer'. That means it is a whole number and not decimal. '8' is it's bit count, this is the amount of memory which is available to it for storing it's value. In an 8 bit variable, we can store 256 values. I don't know what '_t' means!
Hey Daniel Roibert, There's been some weird glitch in UA-cam where by I get notified of your message, but it's invisible - it's not in spam either. Who knows, but anyway, to answer your question, soon there will be a supporting website for my channel. You'll be able to download code from there. Unfortunately though, I just don't seem to get time to finish it! I'll try!
Vaishakh Chavan Hi, I'm afraid I'm not sure. There is something about using four wires instead of two... But then there are only two wires coming from the device itself, so I'm not sure.. :/
Yes. You are right. Still struggling with the library documentation to figure out what's going on. Can't figure how the response buffer ports data in. Keep at it.... 😂
Hi Antony In my case, have an energy meter with register address: 0x0000,.....0x000E,. Who can be implemented in Ardunino ? According to your code link the outcome is "a"
HI Antony,Awesome explaination.I did the same setup. But the part of (If result ==Ku8MBsuccess )is not getting true .What must be the cause?It will really be helpful if you reply
Thank's a lot for the simple and easy understanding video, please kindly : could you do another video using dixell controller like dixell XR10CX , this controller is used anywhere and no one has already did a video and explain the sketch , on the net you can find the user manuel with ful doc about modbus . thank's again even if not possible.
Thanks for this video , I have a case wich is quite close to this , I have a device HPMA115S0 it has UART communication and I want it to work with a plc over modbus serial rtu protocl I bought the same UART TTL TO RS485 you have , but I don't know how to implement the modbus rtu on this device without Arduino , is there anyway ?
Antony Cartwright, I am using an iSunery 10A MPPT controller but I can not find the Modbus protocol documentation for it anywhere. I tried to use your code and it didn't work, do you know how I can find the register cells?
Hello Anthony Cartwright, I got the controller ID#, serial communication parameters, and register addresses from the manufacture and followed your code and pinout using my Arduino mega 2560. But when I go to serial monitor I get "uz" repeatedly so the 'if' statement is not working. I'm not sure how to fix this issue. Please give me some feedback, this is for a college project.
Hope you're well Antony. If you didn't know which registry to read from, is there anyway to figure it out or is it information you would need to get from the manufacture?
Anthony, In the code above, you haven't specified a function code. Doesn't this need to be specified in the request sent through the modes protocol? Thank you in advance!
Good evening, my name is Luca Mozzini Vellen and I study at the HES-SO Haute école spécialisée de Suisse occidentale. I am doing a batchlor project on energy consumption and distribution in Switzerland. I've seen that you, like me, use a Tracer-BN Series with Rs-485 TTL MODBUS. I'd like to kindly ask if it's possible to have the code and the libraries you use in your video. This information will not be used for profit but only for school use. I'm at your disposal for further information, waiting for your answer and wish you a good evening. Best regards Luca Mozzini vellen
hello, Antony I am current working on same project but I am not being able to established communication between meter an arduino can you please guide on the same.
Ah. I see it in the documentation...(2)The serial communication parameters: 115200bps baudrate, 8 data bits, 1 stop bit and no parity,no handshaking. Still can't get it going though.
I have the same charge controller, how do you know what the mod bus command are in your chart? Is there a standard or is that a manual of some kind that comes with it, I will look online.
in my case, i am working with 40000 address which is why i have taken readHoldingregisters command instead of readinputregisters. but still the data is not showing on monitor why?
@@AntonyCartwright You are using the SAME port for debugging and modbus communication!!!!! The Arduino serial terminal y receiving the modbus packet and shows that boxes messages. And... the EPSolar 4215BN is receiving the Serial.print commands…. To solve this you shoud use another serial port for transmit and receive modbus. Arduino nano has got only 1 hardware serial port, you shoud use a "software serial port", like SoftwareSerial.h
right now im trying to read the values of a Eltrac energy meter via modbus , somehow i saw your video and tried the coding but im not able to get the output.
hello friend, a question, how do I write an input register, in the video you see how to read, with the function node.readInputregister, but to write how it would be, and finally if I want to read the register register how is the function, thanks
sir first of all thanks in advance i am trying to read data from fuji solar drive using max485 and arduino mega2560 . Following your code i make my sketch but i get some garbage value of different character plz help me to solve this problem...
Prasanjit Bhowmick Hi, all devices are different! You'd be better off looking specifically for modbus guides/examples for that device. This guide only covers the basics...
All i understand by your video(code) is that if i am using some different device then i need to change the address as per the device data sheet... and i m doing that but could not get any result getting some gurbage value and my code does not enter into the if statement if(result==node.ku8MBSuccess)... please suggest me where is the problem
i have took the address from manufacturer ....... and i always get output like %????!&@ this kind of charecter .even i remove the rs485 port from the drive still i got the same result...
Anthony, Still cant get it to work. Followed your instruction to a tee. The device I am using is a Delta PID DT4848 controller. The Modbus address is 1000 ( hex )as per the data sheet. Not getting any flashing Rx light at all. the Baud rate I tried everything and this device has a max rate of 19200. 8,N,1 protocol. I am sure that the RS 485 hardware works cos I tested it with a blink program and can transfer to another Uno through the 485 link. Am also dead sure that the device is alright cos I tested it with their generic software and a USB to 485 converter. Can see the data there. At wit's end here. Why does the Rx light not show up. Tried writing comment in the code to see if it goes to if (result == node.ku8MBSuccess) but apparently it does not. What am I missing? Aaaaarggh!....
The link to the controller is here. www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=5&cad=rja&uact=8&ved=0ahUKEwiBupecsaXXAhWGy7wKHaM9BDcQFgg9MAQ&url=https%3A%2F%2Fmecmod.com%2Fpdf%2Fdelta-dt-reguladores-temperatura2.pdf&usg=AOvVaw19Y7-cWuz8nQTnrn6lYb4h
Look at page 9 0f 13 wherein it says the first register is Hex address 1000. I've connected to these devices several times using HMI's or Scada's. I reckon theres something wrong with the RS485 control and receive functions. The Tx pin to DI, RO pin to Rx, DE to pin 3 and RE to pin 2 is what I have. I followed your code to a tee. The RS485 board needs VCC and GND and that's about it. I have the A and B pins connected to D+ and D- on pins 10 and 9 of the DTB4848 Delta temperature controller. Tried hooking up a scope to the A and B pins but all I get is a pull down of the high level when i a 1 second period as per the program. I get some junk on the serial port in Arduino IDE but even that does not change when I switch off the Delta controller . The code does not read data at all. I think there's no information exchange going on. Once again the functionality of the controller is tested with a USB to 485 controller and their generic software and works well. What am I doing that's just not getting any response from the controller.
That "silly" message is because Antony is using the SAME port for debugging and modbus communication!!!!! The Arduino serial terminal y receiving the modbus packet and shows that silly message. And... the EPSolar 4215BN is receiving the Serial.print commands…. To solve this you shoud use another serial port.
How Can I read address 30002 with 2 register? I need to read volume flow of whater. Using modscan32 and a usb adapter for rs485 I can read the correct value, but with arduino and this library the read value is different. According to the manual address 30002 is read as inputRegister. I'm using the mega arduino and the RS-485 TTL MODBUS converter I am using the IFC050 flow sensor (modbus manual link below) look at page 12: www.conaut.com.br/produtos?task=callelement&format=raw&item_id=50&element=943615ec-1ce8-4738-9563-523b9801c59c&method=download What's wrong with the code below? ------------------------------------------------------------------------------------------------------------------------------------------------------- //Code used in the project. ------------------------------------------------------------------------------------------------------------------------------------------------------- #include #define MAX485_DE 3 #define MAX485_RE_NEG 2 ModbusMaster node; void preTransmission(){ digitalWrite(MAX485_RE_NEG, 1); digitalWrite(MAX485_DE, 1); } void postTransmission(){ digitalWrite(MAX485_RE_NEG, 0); digitalWrite(MAX485_DE, 0); } void setup(){ pinMode(MAX485_RE_NEG, OUTPUT); pinMode(MAX485_DE, OUTPUT); digitalWrite(MAX485_RE_NEG, 0); digitalWrite(MAX485_DE, 0); Serial.begin(9600); Serial1.begin(19200); node.begin(1, Serial1); node.preTransmission(preTransmission); node.postTransmission(postTransmission); } void loop(){ uint8_t result; uint16_t data[6]; result = node.readInputRegisters(30002, 2); if (result == node.ku8MBSuccess){ Serial.print("Flow: "); Serial.println(node.getResponseBuffer(0x00)); }else{ Serial.println("Error"); } delay(500); } -------------------------------------------------------------------------------------------------------------------------------------------------------
It's only a guess, but if you're reading in two bytes, why do you have uint8_t result = node.readInputRegisters(30002, 2);? Shouldn't that be a 2 byte variable?
Actually I have no experience with modbus, so I followed an example on the internet. in your opinion what would be the correct form. Could you write the code?
For those who had issue with nonworking connection or stability like me: add few milisecods (3-15ms) delay at the end of preTransmission() and few ms at the start of postTransmission() functions. It gives MAX485 some time for proper switching from reading/writing state.
😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊
this is a great example in C-code and makes sense how thing happen in the logic... thanks...:)
Did you add a modbus message display?
Brilliant. Hope to do this. Though you make it sound so simple I reckon there's a lot more going on there. Thanks for the effort. Cheers.
Thank you for the video. Coud you explain how you can get both Tx/Rx modbus acquisition and Serial monitor at the same time? When the serial monitor is in use (such as in your video), no other serial communication should be possible. Unless you have two serial ports available which I do not think is the case for Arduino Nano.
You can actually see the modbus data in his serial monitor. So his Modbus slave _and_ his serial monitor are seeing each other's communication. This isn't a problem for serial monitor (as you just see some random garbage), but I'm a little surprised that the Modbus slave recovered so quickly. I do recall seeing something in the Modbus spec about ignoring non-conforming data. But you're right. The "proper" way to do this is to separate your communication lines; either using an Arduino Due or Mega (with four separate serial pin pairs so you can move the Modbus board to Serial1, Serial2, or Serial3) or send your human-readable output to an LCD display via I2C or something.
Hi , very informative video. I have one doubt if we need to write the value from the micro-controller to input register how can one should approach please guide regarded this. take this as in put don't generate output.
Thanks for the vids ... there are lots of RS485 devices out there and your videos are encouraging to anyone to give it a go ! 👍🏻
Hi John, no worries! Yes, that's good! Many people say "I can't do it", but they actually can - they just need to try! Believe it or not, I knew nothing about RS-485 a week ago! :-D
@@AntonyCartwright if the register length is 16 bits then how do I read?
Hii sir,
I have a device that Supports RS485. Its Absolute
address is 30001, length is 1, and type int. How I can read it in Arduino. Plz help me.
Good video, but this library is only for arduino as a teacher, do you know any library that is for master and slave and multiple slaves because I think it is only for one slave right?
i test yout proyect with serial port monitor in the other side and i cant see data, can be my max485 broken?
hi Antony. just what I need and thanks for the in depth explanation, really cleared up a lot of unknowns for me.
I have a problem with reading your code on one line due to my fuzzy screen.
the line in question is: if resultMain == ?????Success) looks like loadMBSuccess but this does not make sense to me..nothing new there..:-)
Also unit8-t resultMain; is this correct and could you are anyone explain this..
Thanks in anticipation
Hi, thanks for your comment. It's "node.ku8MBSuccess". It's "uint8_t"... U means 'unsigned'. That means that there is no '-' or '+', therefore it is only a positive value (>=0). Int means 'integer'. That means it is a whole number and not decimal. '8' is it's bit count, this is the amount of memory which is available to it for storing it's value. In an 8 bit variable, we can store 256 values. I don't know what '_t' means!
Hey Daniel Roibert, There's been some weird glitch in UA-cam where by I get notified of your message, but it's invisible - it's not in spam either. Who knows, but anyway, to answer your question, soon there will be a supporting website for my channel. You'll be able to download code from there. Unfortunately though, I just don't seem to get time to finish it! I'll try!
Antony Cartwright loved the video and the detail. This would be full duplex mode right?
Vaishakh Chavan Hi, I'm afraid I'm not sure. There is something about using four wires instead of two... But then there are only two wires coming from the device itself, so I'm not sure.. :/
Yes. You are right. Still struggling with the library documentation to figure out what's going on. Can't figure how the response buffer ports data in. Keep at it.... 😂
Vaishakh Chavan I'm the same. I don't fully understand it. Do you have the same charge controller?
Have a good day. Can you share the code?
Sir what is your inverter brand
Hi Antony
In my case, have an energy meter with register address: 0x0000,.....0x000E,. Who can be implemented in Ardunino ?
According to your code link the outcome is "a"
Hello! I send a data packet "slave func data srs16", but the result is this signal "00 slave func data srs16". Why do two zeros appear?
HI Antony,Awesome explaination.I did the same setup. But the part of (If result ==Ku8MBsuccess )is not getting true .What must be the cause?It will really be helpful if you reply
hey, i had to change to readHoldingRegisters instead of readInputRegisters. now its working like a charm :)
(if result == ku8MBSuccess) k lowercase, S uppercase
Thank's a lot for the simple and easy understanding video, please kindly : could you do another video using dixell controller like dixell XR10CX , this controller is used anywhere and no one has already did a video and explain the sketch , on the net you can find the user manuel with ful doc about modbus . thank's again even if not possible.
Thanks for this video ,
I have a case wich is quite close to this , I have a device HPMA115S0 it has UART communication and I want it to work with a plc over modbus serial rtu protocl I bought the same UART TTL TO RS485 you have , but I don't know how to implement the modbus rtu on this device without Arduino , is there anyway ?
Antony Cartwright, I am using an iSunery 10A MPPT controller but I can not find the Modbus protocol documentation for it anywhere. I tried to use your code and it didn't work, do you know how I can find the register cells?
Hello Anthony Cartwright, I got the controller ID#, serial communication parameters, and register addresses from the manufacture and followed your code and pinout using my Arduino mega 2560. But when I go to serial monitor I get "uz" repeatedly so the 'if' statement is not working. I'm not sure how to fix this issue. Please give me some feedback, this is for a college project.
why is the arduino not connected to the computer? How does the port monitor accept?
Hope you're well Antony. If you didn't know which registry to read from, is there anyway to figure it out or is it information you would need to get from the manufacture?
Hi Carl, I got my info from the manufacturer. A document made by the manufacturer to be specific.
Have you tried TTL-rs485 adapter with Nodemcu or ESP32 ? For ModbusRTU
do you have a link to the code used so i can copy and modify?
Anthony, In the code above, you haven't specified a function code. Doesn't this need to be specified in the request sent through the modes protocol? Thank you in advance!
Hi jjhuhu, I'm under the impression that the function code is included in the address, although I could be wrong.
Good evening, my name is Luca Mozzini Vellen and I study at the HES-SO Haute école spécialisée de Suisse occidentale. I am doing a batchlor project on energy consumption and distribution in Switzerland. I've seen that you, like me, use a Tracer-BN Series with Rs-485 TTL MODBUS. I'd like to kindly ask if it's possible to have the code and the libraries you use in your video. This information will not be used for profit but only for school use. I'm at your disposal for further information, waiting for your answer and wish you a good evening. Best regards Luca Mozzini vellen
hi,why you don't have the communicate format setting for modbus library
hello, Antony I am current working on same project but I am not being able to established communication between meter an arduino can you please guide on the same.
Hi Antony, How to modify the code to use hardware serial on Arduino MEGA board?
Can you advise about the Modbus structure that you are using... Ex. 8,E,1 or 7,E,0 describing the stop bits and the parity.
Ah. I see it in the documentation...(2)The serial communication parameters: 115200bps baudrate, 8 data bits, 1 stop bit and no parity,no handshaking. Still can't get it going though.
I have the same charge controller, how do you know what the mod bus command are in your chart? Is there a standard or is that a manual of some kind that comes with it, I will look online.
Hi, Yes, there is a chart somewhere. I googled it.
i use a eastron smd72d. when i try to read Watts (0x500) i get a value like 17200 and it should be like 40 Watts. please can you help me.
in my case, i am working with 40000 address which is why i have taken readHoldingregisters command instead of readinputregisters. but still the data is not showing on monitor
why?
GREAT EXAMPLE FOR MODBUS_MASTER LIB. OTHERWISE YOU CAN NOT USE SIMPLE 485 TTL CONVERTORS WITH THIS MODBUS LIB. THANKS.
What if we want to read multiple slave devices with arduino using modbus?
Thank you sir.... Awesome. I got the result. But can't we remove the boxes on serial monitor
Hi, I just left them. I don't know what that is.
@@AntonyCartwright
Thank you sir.
@@AntonyCartwright You are using the SAME port for debugging and modbus communication!!!!! The Arduino serial terminal y receiving the modbus packet and shows that boxes messages. And... the EPSolar 4215BN is receiving the Serial.print commands…. To solve this you shoud use another serial port for transmit and receive modbus. Arduino nano has got only 1 hardware serial port, you shoud use a "software serial port", like SoftwareSerial.h
Hey, how can I implement the same on a pressure sensor
Please help me, I have to get data from 30800 to 30450 (Input Register). But it does not take all the registers
Can I connect a power analyzer having Rs485 serial communication interface with Arduino mega. please help
hi sir we need a help for these project pls send the link hardware circuit of these project
Resultmain =Node.ku8MBSUCCESS what
This line means? Can anyone explain?
sir I have a similar project, but I use schneider PM2100 as the slave, can your programming be used too?
@random Sir have you tried the code with schneider PM2100? I have the exact same problem. It would be nice if u can confirm the working code, thank u.
How to use software serial for project?
sir i want a code to read data from secure elite 300 can you plzzz help me with itt
right now im trying to read the values of a Eltrac energy meter via modbus , somehow i saw your video and tried the coding but im not able to get the output.
Hi, have a read of the comments and see if they help. Antony...
kamalesh i am also trying.Kindly assist me
hello friend, a question, how do I write an input register, in the video you see how to read, with the function node.readInputregister, but to write how it would be, and finally if I want to read the register register how is the function, thanks
Hi, I'm afraid I don't know how to do that yet. It will be easy, but I've not looked.
i get error
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
is there a slave library?
How can i get the codes
Can you upload your code?
Awesome dude, good job
Hi, I've been trying this with an electricity meter that supports RS-485, but keep getting result = 226...
@Tech Support Technicrafts I solved by using the max3485 instead of max485
Worked instantaneously
@@jacopo.scarpellini Hi i had the same issues, u just change to max3485 ? The connection and code still same?
@@jidanmiftah6860 yes
Please help arduino to deltahmi communication relay control.
Great work, thank you a lot.
Where I can download code?
hello, can i have your source code, it is blury at the beginning of the video and I can`t read it.
Hi, please change video quality to 1080p, then it will be clear. :-)
Hola, muy bueno. Me puedes compartir el codigo, por favor,...
sir first of all thanks in advance i am trying to read data from fuji solar drive using max485 and arduino mega2560 . Following your code i make my sketch but i get some garbage value of different character plz help me to solve this problem...
Prasanjit Bhowmick Hi, all devices are different! You'd be better off looking specifically for modbus guides/examples for that device. This guide only covers the basics...
All i understand by your video(code) is that if i am using some different device then i need to change the address as per the device data sheet... and i m doing that but could not get any result getting some gurbage value and my code does not enter into the if statement if(result==node.ku8MBSuccess)... please suggest me where is the problem
So is the register address list in your documentation exactly the same as the register address list in my EPSolar Tracer documentation?
i have took the address from manufacturer ....... and i always get output like %????!&@ this kind of charecter .even i remove the rs485 port from the drive still i got the same result...
always get this kind of output in my serial monitor
Wow you use pin2, pin3 To communicate rs485 modbus, Thanks
Anthony, Still cant get it to work. Followed your instruction to a tee. The device I am using is a Delta PID DT4848 controller. The Modbus address is 1000 ( hex )as per the data sheet. Not getting any flashing Rx light at all. the Baud rate I tried everything and this device has a max rate of 19200. 8,N,1 protocol. I am sure that the RS 485 hardware works cos I tested it with a blink program and can transfer to another Uno through the 485 link. Am also dead sure that the device is alright cos I tested it with their generic software and a USB to 485 converter. Can see the data there.
At wit's end here. Why does the Rx light not show up. Tried writing comment in the code to see if it goes to if (result == node.ku8MBSuccess) but apparently it does not. What am I missing? Aaaaarggh!....
Vaishakh Chavan Is the ground line connected properly?
Antony Cartwright yes. Indeed it is. Can't figure out why it's not communicating. Any ideas on WhT to check cos am at my wits end with this.
Where is the documentation and which coils are you reading from? :-)
The link to the controller is here. www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=5&cad=rja&uact=8&ved=0ahUKEwiBupecsaXXAhWGy7wKHaM9BDcQFgg9MAQ&url=https%3A%2F%2Fmecmod.com%2Fpdf%2Fdelta-dt-reguladores-temperatura2.pdf&usg=AOvVaw19Y7-cWuz8nQTnrn6lYb4h
Look at page 9 0f 13 wherein it says the first register is Hex address 1000. I've connected to these devices several times using HMI's or Scada's. I reckon theres something wrong with the RS485 control and receive functions. The Tx pin to DI, RO pin to Rx, DE to pin 3 and RE to pin 2 is what I have. I followed your code to a tee. The RS485 board needs VCC and GND and that's about it. I have the A and B pins connected to D+ and D- on pins 10 and 9 of the DTB4848 Delta temperature controller. Tried hooking up a scope to the A and B pins but all I get is a pull down of the high level when i a 1 second period as per the program. I get some junk on the serial port in Arduino IDE but even that does not change when I switch off the Delta controller . The code does not read data at all. I think there's no information exchange going on. Once again the functionality of the controller is tested with a USB to 485 controller and their generic software and works well. What am I doing that's just not getting any response from the controller.
HOW TO SEND THE COMMANDS LIKE 12,04,00,10,00,0C,F3,69
works fin thanks man!!
Where is code attatched?????
Is the code available for download?
you can find it on the example folder on modbusmaster library
Can you help me with some modbus device? I would pay you for sure.
Hi Antony, the modbus address is 40200 to 40380 (i.e. 5 digits). Please help.
Thanks in advance
any update
Is there anyway to get rid of this silly message at the beginning of each loop.( °°°°~o)
That "silly" message is because Antony is using the SAME port for debugging and modbus communication!!!!! The Arduino serial terminal y receiving the modbus packet and shows that silly message. And... the EPSolar 4215BN is receiving the Serial.print commands…. To solve this you shoud use another serial port.
Great video
Sample Code?
nice video dude
can i have this code please
Hi, I don't provide code sorry!
How Can I read address 30002 with 2 register? I need to read volume flow of whater. Using modscan32 and a usb adapter for rs485 I can read the correct value, but with arduino and this library the read value is different. According to the manual address 30002 is read as inputRegister.
I'm using the mega arduino and the RS-485 TTL MODBUS converter
I am using the IFC050 flow sensor (modbus manual link below) look at page 12:
www.conaut.com.br/produtos?task=callelement&format=raw&item_id=50&element=943615ec-1ce8-4738-9563-523b9801c59c&method=download
What's wrong with the code below?
-------------------------------------------------------------------------------------------------------------------------------------------------------
//Code used in the project.
-------------------------------------------------------------------------------------------------------------------------------------------------------
#include
#define MAX485_DE 3
#define MAX485_RE_NEG 2
ModbusMaster node;
void preTransmission(){
digitalWrite(MAX485_RE_NEG, 1);
digitalWrite(MAX485_DE, 1);
}
void postTransmission(){
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
}
void setup(){
pinMode(MAX485_RE_NEG, OUTPUT);
pinMode(MAX485_DE, OUTPUT);
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
Serial.begin(9600);
Serial1.begin(19200);
node.begin(1, Serial1);
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
}
void loop(){
uint8_t result;
uint16_t data[6];
result = node.readInputRegisters(30002, 2);
if (result == node.ku8MBSuccess){
Serial.print("Flow: ");
Serial.println(node.getResponseBuffer(0x00));
}else{
Serial.println("Error");
}
delay(500);
}
-------------------------------------------------------------------------------------------------------------------------------------------------------
It's only a guess, but if you're reading in two bytes, why do you have uint8_t result = node.readInputRegisters(30002, 2);? Shouldn't that be a 2 byte variable?
Actually I have no experience with modbus, so I followed an example on the internet. in your opinion what would be the correct form. Could you write the code?
Please provide code
hi can you add the source code
Hi Kamalesh, I don't have a facility to do that at the moment, but it is coming very very soon. Probably within the next few days. :-)
i ment adres 0x0500
Hello Antony,thank you for this great video
can i get your Email please
Can you share source code please.