I am using the V5 and coding in PROS as a project which needs a humidity and air quality sensor.
I am wondering if this is possible and how will I wire it up to work with v5. Can I use sensor.get_value() to get the value?
Calling sensor.get_value() method (VCS, PROS) would only work for analog sensors that output measurement as voltage between 0 and 5v.
Both sensors that you have linked to only have I2C interface, which I don’t believe V5 has native support for, unlike previous generation Cortex.
V5 legacy 3-wire ports (ADI) are connected to a separate co-processor which runs its own firmware and reports raw analog and digital values to the main processor only about each 10 ms:
I don’t think this is fast enough to bit bang I2C or any custom protocol, like the one used by DHT11.
Do you really need to use V5? It would be so much easier to connect those sensors to a cheap Arduino or ESP8266/32 board.
I have already started on the rest of the robot, so…
Is there any way to use I2C at all?
If I use an Arduino, how will I communicate with the V5 brain?
Are there any sensors I can use with V5 directly after rewiring?
As @John_TYler said, the easiest way to interface with V5 would be to get sensors that output analog values in the first place. V5 was not designed to be an open system with native support for Serial or I2C interfaces (that are supported by Cortex).
However, if you have to use I2C sensors you could do that through an I2C enabled board like Arduino. Depending on how much and what type of information you need to communicate to the V5 robot, you have multiple options.
If you just need to send a simple Yes/No bit to the robot, based on the sensor crossing some threshold value, then you can wire one of the digital Arduino output pins to one of the V5 3-wire ports that will let you read 0 or 1 value.
If you need to communicate a range of values back to V5, then you could connect a small capacitor to one of the Arduino PWM output pins and use it as an analog input on one of the V5 3-wire ports.
If you want to send back digital data you could setup two digital pins as low speed bit-bang serial interface between Arduino and V5. As long as it allows > 15-20 ms time between consecutive bits you should be able to do that.
Finally, if you need to send high speed high volume data you could use RS485 or USB interfaces of V5, but that is not a simple task:
Just so we have an example. This would work and could be wired directly as an analog device with a V5.
What you linked would require an arduino, maybe a vex cortex could do it? A V5 definitely couldn’t. Then you would need to get the data from the arduino/cortex to a V5, somehow.
My goal at the end of this is to create a robot that drives to a specific location using the vision sensor. Then it will gather humidity (and maybe temperature) and air quality data. If the values seem okay, it will move to another location. If not then the robot will stay there and filter/ humidify the air.
Short answer is no. Neither Cortex nor V5 do not expose SPI interface to the end user. (SD card interface, probably, uses some variant of SPI, but V5 firmware wouldn’t let you use it for arbitrary sensors.)
You will still need to connect any SPI or I2C sensors to another board.
I would suggest you to get an Arduino nano or mini. Use it to read and filter sensor data, and then relay it slowly to V5 brain using a protocol similar to DHT11/22 linked above but at much slower rate. This way you could reuse DHT library code with minor modifications to make it about 1000 times slower to work with V5.
That’s interesting. Are you doing it as an educational exercise?
Because, I would imagine that if you had to dehumidify the area for real on a scale where DHT11 could pick the changes with its +/-5% accuracy, you would need to carry a commercial scale dehumidifier that would require power supply that is well beyond V5 capabilities.
I am doing it for fun and to learn. I am planning to use battery powered purifiers/ humidifiers.
So, if I use an Arduino, I have all my sensors and use them to gather the data, then I can use the output on an Arduino to output the data digital or analog to a 3 wire port (what wiring?). I then can use sensor.get_value() to get the data on the robot side.
Is this correct or is there anything I am missing.
What @technik3k suggested was to very slowly with digital pin send values from the arduino and the v5. 1 bit every 10ms of communication in some cases is totally enough. ( you can get some speedup by using multiple pins at a time)
So would you hook this up to the Arduino and use the output on this module to the v5 and input from the Arduino?
What @technik3k said, I output on an Arduino to output the data digitally as a DHT11 and use the 3-wire port on the v5 to receive the data, connecting 5V and ground?
Also do I need to do anything extra other than use output every 10ms to the V5 and get digital?
Do I need a separate output for each sensor, or can I use one?
Can I use this:
It says: Digital I/O Pins 14 (of which 6 provide PWM output), so I can use these as my output, right?
So the speed is going to depend on you. You have implement some way of communicating the data. Seems the sensor has 4 bytes of data (2 bytes for each temp + humidity) you could reduce this by lowering resolution or lowering precision.
So 32 bits would take 320ms best case, let’s assume another 50% of overhead and we get around 500ms. You could of course make all this parallelized if you wanted so let’s say
500ms / number of ports you dedicate to it.
If you wanted a more robust communication it would be longer but that’s probably fine.
So in the real world scenario we have to do stuff like this to have Allen Bradley talk to Fanuc Robots, what we do is have:
Sensors (1,2,3,…) —> PLC (Or arduino in this case) —> DAC (We call them Amp Cards) —> Fanuc Cell
What we do is have the secondary brain (Arduino) Collect all your data and then send one output
signal when all the conditions are made. If the Fanuc Cell does not get a packet within certain amount of time it will move to certain stage telling the brain to start conditions over.
I would have your Arduino record everything and only send send a ready to move signal (Or alternatively keep pulsing not ready to move yet). Have the V5 look for that one condition and use it to move.
How will I send one bit every 10ms for temp, humidity ,and air quality?
All I need are readings every .5-1 sec.
Or, if I tell the robot bad air or bad humidity, will that be 1 bit, so I will output a 1, 2, 3, 4 to the v5 and use if statement to tell the robot what to do?
Do I wire 5v, ground and a data pin to the v5s 3-wire ports for the data?