Easy Modbus Using A Raspberry Pi
HTML-код
- Опубликовано: 21 июл 2024
- Today we're looking at Modbus using a Raspberry Pi, no node red or any of that nonsense! Just an RS-485 to USB converter and a bit of code.
The Code Itself
github.com/The-Intrigued-Engi...
The Minimal Modbus Documentation
minimalmodbus.readthedocs.io/... Наука
Hi! Thank you for a very instructional video! I looked over your "Finding and Listing Modbus Sensors Over RS-485" but wonder if there is any easier way to list the modbus address without having to use Siemens 1200 PLC. I am very new to this type of programming so any simplifications are greatly appreciated.
Cheers,
Fantastic Raspberry Pi Modbus information. Will this work on the New Orange Pi-5 SBC to run a PWM servo motor controller? Thank you.
Great Video, does the USB port detection works similar as on an Raspberry Pi emulator on PC?
-bash: cd: code/mb: No such file or directory
What to do,if these error is coming?
Hi men, I found your video very usefull, but I have a question for you, in this case I can see that you use a USB converter and you connect a a pair differencial cable to the instrument tha give you a temperature and the humiduty and the usb you conect to female cable and I supose taht you connect to the microUSB port of your raspberry, so my question is How may I read the modbus registers but I want to use the UART pin and read form the port ttyAMA0?, I hope your answer and excellent tutorial
thanks for this video, can u make similar video but using IOTstack or node-red? its gonna be interesting
Does anyone knows how to implement modus rtu communication btwn raspi and aurdino.
what if 3 or more sensor is coneected in modbus?
great explanation
I did the same but i don't get any ttyUSB :( using a Raspbian Stretch version on a Raspberry pi 2B. Any idea why it might not be working?
Nice video. Can you please tell me the specs for the temperature/humidity sensor that you're using here?
Thanks very much! We got these sensors in bulk a while a go and use them on various projects. Found them as an Alibaba special! Link below. Out the box about 10% were dead which isn't a great percentage but the 90% that worked have actually performed very well in the field with a low percentage of failures after install. That's actually saying something, we're based out in Saudi and we put these sensors through absolute hell!
www.alibaba.com/product-detail/MTH100-NRN-0-3-High-Accuracy_62437507744.html?spm=a2700.shop_plgr.41413.9.609c83a7xgY88f
You don't have to save devices lists and compare them, just run dmesg -w|grep tty, and plug your usb-rs485 device in, you will see tty number which system gave to your device.
That's awesome!! Just given you a big shout out for this in the video that's just uploaded. Love it!
Hi, awesome video by the way, helped us alot, but we are facing a problem with 2 of our sensor when we try to connect our sensors together. We connected 10 sensors by series, but 2 of the sensors when connected in series keep giving us invalid response error, check sum error. But when we connected it directly to the usb without connecting the sensor in series(individually ), it is able to work. We tried to change the wiring, but it keeps ended up getting that same error, so i am hoping that you can give us some thoughts on how we can debug it, or is there any setting that disable the sensor ability to connect in series(?). Hope to get a reply soon
increase your timeout
Please create a video for the SPI interface or point us in the correct direction on setting it up. Maybe a full video using the Pico W, and a website build. Or better yet.. use the normal Pico for the code to get the data from the rs485 wind vane and the wind speed, and then use i2c to send the data to a non pi SBC (Le Potato) that can then add cameras of the clouds and send it all as a webpage out to the world on a usb cell modem... I have all the rest done but the Pico side... This (the Pico) is my 4 dollar workaround for the GPIO addressing issue that the Le Potato has currently.
Wow! that's a whole load of stuff! Would definitely milk that over a few videos!! Haha. Honestly though I am planning a video on SPI, UART etc at some point.
@@Intrigued_Engineer thank you I love to give out a lot to get a small bit.
Thanks
thks for this video. it's exactly what i'm looking for.
i'm very new to this field and i have one prject: i have a Camera connected with the RPi and with the help of OCR I extract the text from the picture and I have to transfer know this text throught CAN bus. i wanted to use RS485 CAN HAT but I find it as easy using usb to rs485. please can you help me?
Glad it helped! Being honest I've no experience with CAN bus hats. My go to for this would be a USB/485 converter and handling the CAN bus within the Pi. But that's just me doing what I know. Is there a reason why you're using CAN bus specifically for this?
@@Intrigued_Engineer ok i will try with it.
yes i want to tranfert the data to some cloud that use CAN bus
Thank you
How do you do this with pymodbus TCP, do you just switch out the usb address with an IP address?
yes you need to make a connection first, than you can read registries choosing the right function code
Is it possible to connect multiple devices using only one adapter?!
Yeah you can connect multiple! the address is stored as an 8 bit integer so there are 256 "addresses" technically available from 0 - 255. You cant use address 0 as that's for something special and it's general convention not to use address 1 in a network as that's what most devices are by default so it is easier to add things to an existing network if you leave address 1 vacant. In a nutshell you can use addresses 2 - 255 meaning (using normal Modbus RTU) you can have 253 devices on one network.
@@Intrigued_Engineer So in each device I configure the address and can connect all of them to the same USB converter. I've seen that all modbus devices connect in series. Am I correct?
Correct yeah, all back to one USB. General convention is to "daisy chain" in series. With long runs you'll need to put termination resistors at each end to help minimize signal echoes but you'll need quite a large network for that to be an issue.
In reality I've done daisy chains, star networks and hybrids of the two and its never been an issue for getting clean data.
As a tip with minimal modbus, for reading loads of field devices, it can get a bit flustered and start to bit crash (only really seen this when trying to read ~20 sensors in a row). Its supposed to wait before being recalled but I've found its good to code in your own check function to check that the previous call is definitely finished before allowing the address to increment and moving onto the next call.
@@Intrigued_Engineer Thank you for the help, I was able to read two devices from different brands on the same converter. I'll take your other tips into account. I'll investigate a little bit more about the resistors.
is your name Ashley?
mb_address = 9 # Modbus address of sensor /// How to know the mb_address of sensor
you can read it on technical provider documentation, otherwise you can run a scan to all registries
😇 𝐩𝐫𝐨𝐦𝐨𝐬𝐦