My son and I are trying to work write a program, in Python, that takes repeated readings (within a loop) from our DI thermal infrared sensor and also from our EV3 gyro. We’ve adapted the sensor examples from the github so that, on their own, each works within the loop that we want. However, we can’t get them both to work within the same program.
One of two things happens. If, before calling result = BrickPiUpdateValues() for the Gyro, we do not include the line BrickPiSetupSensors(), we get an error message when we try to run, pointing to this line. If we do NOT include this line, then we can run without an error message, but the Gyro returns an invariant result of 0.
The DI-dtIR code contains stuff at the beginning which we don’t quite understand. My guess is that this sets up the bus for the sensors in a way that is incompatible with what the EV3 sensors needs. Is this correct? And if so, is there a way to get these two sensors working together smoothly? I guess as a worst case we could spring for an EV3 IR sensor, since the sensor example for that looks a lot simpler! But we were hoping to use the DI one, which we’ve already got!
Could you post the code? That might help us a bit in troubleshooting the challenge you’re facing.
The dTIR needs a little bit of “space”; it can’t be polled as quickly as other sensors. You might try inserting a few 0.1 second pauses in the code, and see if that improves the operation.
Attached is code that does not use the gyro at all. [The relevant code is Thing_Seer1. I’d previously uploaded a different version, which is there as Thing_Seer, and which I can’t seem to remove from this post.) I’d like to take a gyro reading within the function turn(direction, power), (and then have the function return that value to the larger program that called it).` The most natural thing, I think, would be to call