What's the best way I read 20+ sensors (air and water temp, and humidity) spread over 10+ meters (large room)
Main logic will run on Raspberry. Sensors and actuators connected to Arduino(s)
I2C doesn't cover the distance.
I'm in the design phase, so I can go in what ever direction makes sense.
Maybe use multiple Arduinos?
There will also be multiple actuators, but that part is easier, so I left it out of the diagram.
Suggestions appreciated.
I can see using a serial protocol for Controller to controller communication.
I'd like to get the cabling as simple as possible. Since each controller board will need power, can i use USB for power and communication?
Also, the sensor communication will affect how many boards I need (for example, if i need an Arduino within 3 feet of every sensor, I'll need several Arduino boards, so if I use a hardwired serial line to connect those boards to the Raspberry, I'll have lots of wiring. )
if you use RS485 you could run 4 core cable ground, 5V power and A and B signals
you could use Arduino Nanos with RS485 modules
depending on the sensors and distance a nano could possibly support several sensors
what sensors are you looking at? power requirement, interface (analogue, I2C, SPI, ??) , etc
I assume the RPi would act as a master and the arduinos slaves?
the master could poll the slaves for data at regular intervals
The location doesn't have wifi. I could setup wifi, but since each device needs power, I'll need cabling anyway. I don't really want to constantly monitor and replace batteries.
Your pretty much on target. RPI is master controller. Arduinos will be slaves
RS485 between boards makes sense.
Will the nanos need shields for RS485?
Can the nanos receive power and communicate RS485 over usb (that would provide a single cable to each board?)
if so, I could buy a half dozen nanos, place them to read multiple sensors over I2c and Supply power and communication by USB? Make sense?
I've wired up and programmed micro controllers in the past, but it's been quite a while and I'm just getting familiar with all the hardware choices available today.
The system is a control system for a hydroponic greenhouse, so sensors will be temp, humidity, but also the nutrients & PH sensors for the water. I'm using water as a thermal bank (to heat in winter and cool in summer) and the greenhouse will have 2 temperature zones. , so there will be multiple air and water temp sensors (including exterior temp) plus a couple of humidity sensors. There will be actuator for fans, water pumps, nutrient mixers, etc, but those can be controlled at a central location and the distance covered by the power cord.
There is no wifi to the greenhouse. I'm going to run an eth cable out to the structure. Using wifi between the boards is a possibility, but if I can use the same USB cable I use for power I'd prefer a hardwire connection. If i need a separate cable for RS485 then wifi might be simpler/cleaner.
if you wish to use RS485 the Nanos would require RS485 modules to interface to the bus
The is a PIC based Arduino with onboard RS485 but I have no idea of availability or cost
The NodeMCU ESP-12E is a nice board with WiFi etc - it would still require a RS485 module
One consideration is the nano operates at 5V logic the ESP8266 3.3V so may effect how you interface sensors
what sensors are you using ?
I'm a bit confused on this device. it says it's a serial device. I think you download/program by a serial connection over USB. So can I send data back over the USB?? Or can I send data back over wifi using what ever protocol??
It's small, cheap, and supports protocols to connect to my sensors. I could get one for every sensor if needed.
As i said, It's been a while since I worked with microcontrollers and communication protocols, so i have some reviewing to do, but I'd like to narrow down what i need to dig into before I go wasting a lot of time in the wrong direction ....
So in a nutshell, it seems like RPI and Arduino should be able to comm over usb. Yes/No?
So as long as I can address them correctly, logic suggests I could hook up multiple arduinos through a powered USB hub and I'd have power and communications. Then any of micro controllers that have analog GPIO pins (for sensors) and a usb port for comms, should work. Yes/no? Am i missing something ?
it is a thought - I have communicated from arduino type micros to PCs thru USB ports (a virtual COM port is created and can be accessed from C++, C#, Java, etc) but only over a few metres
you idea should be possible using some powered USB hubs - not sure about maximum lengths of USB cables though - see usb-cable-max-lengths
perhaps try some experiments??
you would have to have a protocol - the RPi acting as a master and polling USB slaves
or can USB handle multiple devices attempting to communicate at the same time? I don't know
There are some YouTube videos connecting rpi & arduino with usb. They only connect two devices, so I might have to experiment see if I can address different devices for polling.
A work around might be to broadcast to all slaves but they each respond to a different argument in the message.
Not sure what protocol to use, haven’t done anything over usb, but I ran Iscsi over Ethernet some years ago. It’s slower, but works.
Sounds like I have some experimenting to do, but it would give me a cleaner setup.
when an Arduino is plugged into a USB port on a RPi it creates a virtual USB-to-serial port, see control-arduino-with-a-gui-on-a-raspberry-pi-4
not sure what connecting several Arduinos using a USB hub will do - I will experiment!
I’ve looked at those.
They are a good “plan B” but I’m hoping to avoid WiFi for a couple of reasons. And as long as I need power at each device,(since I’d want to avoid batteries) If I can do comms over the same cable that would be ideal
If that fails, I might go with a WiFi solution.
Thanks for the suggestion. I’ll check out ESP-Now
connected four Arduino micros to a USB hub and tested using Win10 and a RPi
between the USB hub and hosts was a 5 metre USB cable (longest I could find)
the Arduinos ran a simple program which identified them, e.g.
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println();
}
void loop() {
static unsigned long int count=0;
Serial.print("Arduino_Uno_1 ");
Serial.println(count++);
delay(1000);;
}