Hello everyone, this is my first post here so maybe it is in wrong section but if needed i will change it.
I am building IoT project and i have multiple sensors connected to NodeMcu which is communicating through mqtt with my GUI and backend part.
Now i want to add more sensors so my opinion is to connect some arduino to the NodeMcu. I have tested this with serial connection between them and it was working correctly.
My idea is to connect 2 arduinos to nodemcu but it looks like impossible to me.
Arduino 1 to send data from sensors to nodemcu.
Arduino 2 to receive commands from nodemcu.
Is it possible to connect multiple arduinos to Nodemcu and if it is please provide me some example.
Using port extenders such as the PCF8574 or MCP23017 you can have lots of sensors. Or if your sensors communicate over I2C you can also connect lots of them to the I2C bus.
I built a project around the ESP8266 controller (as used on the NodeMCU) with over 20 sensors and 12 outputs switching motors and the like.
wvmarle:
Using port extenders such as the PCF8574 or MCP23017 you can have lots of sensors. Or if your sensors communicate over I2C you can also connect lots of them to the I2C bus.
I built a project around the ESP8266 controller (as used on the NodeMCU) with over 20 sensors and 12 outputs switching motors and the like.
WoW. Thank you! I did not know that such things exist Its my first time to hear about it. Thank you very much! Can I use multiple of them?
Also question about your project. Did you use extenders or not?
bambusx2:
WoW. Thank you! I did not know that such things exist Its my first time to hear about it. Thank you very much! Can I use multiple of them?
The two that I mentioned use the I2C bus; can select up to 8 addresses so 8*16=128 extra I/O. Use 8x MCP23017 and 8x PCF8575 and you have 256 I/O possible.
Another option is shift registers; simpler, cheaper and they can be daisy chained virtually unlimited; but not as easy to work with.
Also question about your project. Did you use extenders or not?
Of course. That's the way it's done. Two MCP23017 in that specific case.
Still no decoupling cap, but for some reason they added a 3.3V regulator, which is useless when used with the NodeMCU.
I just notice that these boards are using the cheaper PCF8575, not the MCP23017. The main difference between the two is that the PCF8574 and PCF8575 can not source current; a HIGH output signal is through the internal pull-up resistor. That means they can't even drive a MOSFET gate directly, and LEDs have to be configured active LOW.
The MCP23017 OTOH can source significant current, making that a much easier chip to work with.
I kind of assumed that C1 or C2 - presumably related to the regulator - would be a decoupling cap. I don't have one of the boards here to examine, just the red one (somewhere!).
wvmarle:
I just notice that these boards are using the cheaper PCF8575, not the MCP23017.
Reason why I refer to them. OK, I'm a cheapskate!
wvmarle:
That means they can't even drive a MOSFET gate directly, and LEDs have to be configured active LOW.
As I see it, the OP here is wishing to connect sensors, which do not usually need to be driven high. The HC-SR04 could be an exception but it does have a 10k pull-up.
[
I have bought both MCP23017 and PCF8575 and both of them are for extending digital pins. I found videos and tutorials where they use it only for Leds and Buttons. I cant find tutorial for reading values from a sensor.
Also the problem of nodemcu I think is that it has only one analog pin. And a lot of sensors are working with analog pins. So instead of using MCP23017 or PCF8575 I will need to add analog multiplexer.
Do you have some tutorial or book where they use MCP23017 for reading values from sensors? (PIR sensor, DHT, Water level and etc.)
PIR: is a simple on/off sensor, and can be read like a button. Depending on the sensor you may need to enable the internal pull-up resistor.
DHT11/DHT22: can not be read through a port extender due to the protocol used.
Water level: name a specific one.
When using the PCF8575 with LEDs remember that this part can only sink current, so wire LED & current limiting resistor between pin and Vcc, making them active low.
Up to eight port extenders (of a given type, plus a similar number of an alternate type) connect to the same two I2C pins, so you should have some pins available for the difficult sensors such as the DHT22.
So far you have not cited any analog sensors - and most sensors are in fact digital.