Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

sensor with rs485 via I2C to nodeMCU

Status
Not open for further replies.

ravi.2k17

Advanced Member level 4
Full Member level 1
Joined
Sep 30, 2019
Messages
111
Helped
0
Reputation
0
Reaction score
1
Trophy points
18
Activity points
874
hi all,

I want to connect multiple sensors (eg PIR HCSR01 and others) and LCD display with nodeMCU/Arduino using I2C GPIO extender.

Is RS485 protocol fully compatible with I2C communication? I know that I2C identifies connected devices with unique hex addresses.
Can those addresses will be detected over RS485 transmission ?

I use PIR HC-SR501 sensor which has only one TTL output at 3.3v. Do I need any adapter from PIR side for 12C? It does not have SDL & SDA pins.
https://botland.com.pl/en/motion-sensors/1655-pir-hc-sr501-motion-detector-green-5903351241359.html




PIR sensor 1 ---> RS485 transmitter -----> long cable -----> RS485 receiver ----> I2C port extender ----> NodeMCU
^ |
| |
| |
PIR sensor 2 ---> RS485 transmitter -----> long cable -----> RS485 receiver ----------- ------> LCD Panel




1604571032201.png



thanks
 

Attachments

  • 1604570929288.png
    1604570929288.png
    20.7 KB · Views: 252
Last edited:

Hi,

PIR sensor 1 ---> RS485 transmitter -----> long cable -----> RS485 receiver ----> I2C port extender ----> NodeMCU
quite possible, since the RS485 signal has nothing to do with I2C.
I2C just runs between NodeMCU and port extender as usual.

PIR sensor 2 ---> RS485 transmitter -----> long cable -----> RS485 receiver ----------- ------> LCD Panel
Here I2C is not involved at all.
And it misses any description how the LCD panel handles any logic input.
???

Klaus
 

Hi,


quite possible, since the RS485 signal has nothing to do with I2C.
I2C just runs between NodeMCU and port extender as usual.


Here I2C is not involved at all.
And it misses any description how the LCD panel handles any logic input.
???

Klaus
my diagram was not clear. i have updated it using tool. please refer it once again.
 

I'm not so sure. It think it can be done but you might have trouble with the bus direction control if you do it with a single transmitter and receiver. Remember I2C uses two wires and the data line is bi-directional. You might be able to do it with two independent Rs485 connections, one for clock and one for data but you might need some additional logic to set the direction of the data line. Don't forget I2C normally uses open drain data drivers to allow more than one device to communicate and Rs485 is actively driven.

Brian.
 

Hi,

the description isn´t clear at all.

My assumption is that the port extender has
* one I2C interface to the uC and
* single ended TTL/CMOS interface from the PIR sensors via RS485.

But guessing is not a good way to give good assistence.

Thus:
* give a link to the port extender datasheet, or at least it´s exact part name
* your I2C port extender in the picture has 4 black lines. We don´t know which one carries what signal...wich one is I2C or a single TTL/CMOS signal
* tell us what interface is used by the LCD panel. Maybe additionally: exact part name and link to the datasheet

************
RS485 is no protocol. It´s just an (hardware) interface standard and mainly defines the voltage levels, polarities, characteristic impedances...

I2C is a complete interface definition including hardware, voltage levels, timing and protocol...

Klaus
 

I'm not so sure. It think it can be done but you might have trouble with the bus direction control if you do it with a single transmitter and receiver. Remember I2C uses two wires and the data line is bi-directional. You might be able to do it with two independent Rs485 connections, one for clock and one for data but you might need some additional logic to set the direction of the data line. Don't forget I2C normally uses open drain data drivers to allow more than one device to communicate and Rs485 is actively driven.

Brian.
so what would be best and easiest for me. I was made to choose rs485 because of long distance requirement between sensor and nodemcu. and now i have to accommodate multiple sensors with same nodemcu/arduino. one possibility is to change the board and replace it with Arduino mega and drop the idea of multiplexing. what else?
 

Hi,
I can't help when you don't give the requested informations.

Klaus
 

It is also worth considering that if the PIR just produces a high or low pulse when triggered, there isn't much advantage in using ANY protocol unless you are talking about very long distances. As pointed out already, RS485 is just an electrical specification, normally it is used for carrying high speed data over long distances but for a slow signal and less than about 100m it doesn't really offer any advantages. You can probably just use the ground and output wire to connect directly to the NodeMCU. The supply to the PIR can be run along a third wire or produced locally wherever it is located.

I should also caution you that the most RS485 interfaces run from a 5V supply and produce 0V/5V levels at their output pins. The nodeMCU will be damaged if you connect 5V to any of its pins other than the regulator input.

Brian.
 

    KlausST

    Points: 2
    Helpful Answer Positive Rating
Hi,

the description isn´t clear at all.

My assumption is that the port extender has
* one I2C interface to the uC and
* single ended TTL/CMOS interface from the PIR sensors via RS485.

But guessing is not a good way to give good assistence.

Thus:
* give a link to the port extender datasheet, or at least it´s exact part name
* your I2C port extender in the picture has 4 black lines. We don´t know which one carries what signal...wich one is I2C or a single TTL/CMOS signal
* tell us what interface is used by the LCD panel. Maybe additionally: exact part name and link to the datasheet

************
RS485 is no protocol. It´s just an (hardware) interface standard and mainly defines the voltage levels, polarities, characteristic impedances...

I2C is a complete interface definition including hardware, voltage levels, timing and protocol...

Klaus


>>> give a link to the port extender datasheet, or at least it´s exact part name
my port extender for nodemcu

>>> your I2C port extender in the picture has 4 black lines.
this was just a block diagram to show relation with other modules. not a circuit schematics.


my pir sensor (this does not have inbuilt I2C interface)

>>> tell us what interface is used by the LCD panel.
my lcd display (this does not have inbuilt I2C interface)
**broken link removed**



thanks
--- Updated ---

It is also worth considering that if the PIR just produces a high or low pulse when triggered, there isn't much advantage in using ANY protocol unless you are talking about very long distances. As pointed out already, RS485 is just an electrical specification, normally it is used for carrying high speed data over long distances but for a slow signal and less than about 100m it doesn't really offer any advantages. You can probably just use the ground and output wire to connect directly to the NodeMCU. The supply to the PIR can be run along a third wire or produced locally wherever it is located.

I should also caution you that the most RS485 interfaces run from a 5V supply and produce 0V/5V levels at their output pins. The nodeMCU will be damaged if you connect 5V to any of its pins other than the regulator input.

Brian.


>>> it is used for carrying high speed data over long distances but for a slow signal and less than about 100m it doesn't really offer any advantages.
my requirement is to connect around 10 sensors with centralized board (nodemcu or arduino). the distance between a given sensor to nodemcu would be around 25 meters only. are you saying that using rs485 would not be helpful in this case?
initially when i asked in this forum, I was advised to use rs485 for such distance also. hence I started thinking in that direction. without using rs485 my project implementation would be easier. taking so much pain for i2c along with rs485 is worth in my case?
 
Last edited:

Really confusing informations.
Less clear than before.

Klaus
 

Really confusing informations.
Less clear than before.

Klaus
lt seems I am going too fast. Will start from basic queries.
Do I need to think for rs485 if the distance between sensor and board is 25 meters?
 

You originally implied the I2C was to be extended over a long distance using RS458 and for the reasons I gave it would be very difficult to do that. Later you imply only the connections to the sensors would use RS485 and the I2C expander would be located close to the nodeMCU.

I will try to clarify the two scenarios:

1. if you want to extend the I2C signals you can't easily use RS485. The reason is simple, I2C needs two wires and one of them is bi-directional. Although RS485 itself can be bi-directional there is no mechanism to reverse the data direction when it is needed. It can only send or receive but not both simultaneously and I2C protocols require rapid direction changes to carry ACK bits and return data. The I2C data and clock connections are normally open drain driven so that several devices can be connected to the same pair of line but RS485 would not allow for that. It isn't impossible to do but it needs additional logic circuits.

2. If you want to keep the extender close to the nodeMCU and just extend the PIR sensor connections it is much easier. The PIR doesn't send data per se, it just sends a high or low signal to say it has detected movement. It is a single wire carrying a relatively slow changing logic level so for relatively short distances it doesn't need any special drivers. All you need to do is connect the ground to ground and the output to the I2C expander input. How you power the PIR is up to you, it can be powered from the nodeMCU end or have its own locally generated supply voltage.

Brian.
 

You originally implied the I2C was to be extended over a long distance using RS458 and for the reasons I gave it would be very difficult to do that. Later you imply only the connections to the sensors would use RS485 and the I2C expander would be located close to the nodeMCU.

I will try to clarify the two scenarios:

1. if you want to extend the I2C signals you can't easily use RS485. The reason is simple, I2C needs two wires and one of them is bi-directional. Although RS485 itself can be bi-directional there is no mechanism to reverse the data direction when it is needed. It can only send or receive but not both simultaneously and I2C protocols require rapid direction changes to carry ACK bits and return data. The I2C data and clock connections are normally open drain driven so that several devices can be connected to the same pair of line but RS485 would not allow for that. It isn't impossible to do but it needs additional logic circuits.

2. If you want to keep the extender close to the nodeMCU and just extend the PIR sensor connections it is much easier. The PIR doesn't send data per se, it just sends a high or low signal to say it has detected movement. It is a single wire carrying a relatively slow changing logic level so for relatively short distances it doesn't need any special drivers. All you need to do is connect the ground to ground and the output to the I2C expander input. How you power the PIR is up to you, it can be powered from the nodeMCU end or have its own locally generated supply voltage.

Brian.

>>>> for relatively short distances it doesn't need any special drivers.
Regarding scenario 2, how much short is short here? Is 25 meter short in your opinion? I will keep port extender near to nodemcu. At the same time I do not want to loose signals also.

thanks
 

Whole this discussion is useless.
RS485 is physical layer for communication, not for transferring signals that occurs "from time to time".
The whole concept is wrong.
Use shielded cables for connecting PIR sensors to whatever multiplexer you want to use. Currents through wires (signaling) are negligible.
 

The limiting factor in distance is how short the pulse lasts when the PIR detects something. My guess is it is unlikely to be a very short pulse and it could last as long as movement is being detected. Its worth remembering that in the days of pulse dial telephones, the pulses were about 0.1 seconds long and could operate the telco equipment over a distance of about 5Km! Your 25m distance is no problem at all.

If I had to guess at the maximum distance you would reliably achieve I would say around 150m but it depends on the type of cable you use and any sources of interference it runs close to. The limit in distance comes mostly from two factors, firstly the ability of the PIR to drive the capacitance between the 'signal' and ground and secondly how much interference you can tolerate being picked up along the route.

To some degree you can remove interference at the expander end with a low pass filter as most pick-up will be at mains frequencies and above but it does slightly limit sensitivity to very brief PIR pulses (< 100mS) . You could also use a a screened cable to reduce pick-up into the center wire. Using RS485 is an option for very long cables but I wouldn't think it economical in your situation. Where RS485 wins is where the distance is long and there is considerable interference, for example where the cable is routed inside industrial machinery. Because it uses differential signals, and provided you use a suitable twisted pair of signal wires, any interference is picked up equally on both wires so it cancels out when one is inverted and added to the other.

Brian.
 

Whole this discussion is useless.
RS485 is physical layer for communication, not for transferring signals that occurs "from time to time".
The whole concept is wrong.
I agree that the discussion is useless. But because of missing and confusing infirmations.

But I don't agree that the RS485 is wrong. And even if there was no benefit, it won't cause any failures.
Any differential signaling will avoid common mode problems when noise is introduced in lengthy wiring.
I design industrial electronics. Switching 6000A nearby... here I use differential signaling even for low frequency signals and for much shorter wiring.
In my eyes the benefit of differential signaling does not depend on payload datarate.

No filter can suppress noise introduced in single ended signals the same way as differential wiring does.

We don't know much abot the OPs requirements and situations. That's the real problem of the discussion.
Maybe there is no noise problem at all, maybe single ended signaling is sufficient. I don't know.

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top