An encoder should be read with interrupt on change inputs to make sure you don't miss steps. Especially at any speed. You may be able to get a good response with an Arduino using say this library (see Interrupt under examples) https://github.com/brianlow/Rotary. However, on a Raspberry Pi, success may vary based on the OS latency (Real Time better), and the speed you are trying to capture.
Better may be to have a chip to read the encoder, and your Pi or Arduino reading the encoder count when it can.
Better may be just to read a magnetic pickup (hall effect) for speed.
Once you have a solid value, it is a cinch to get it into Cayenne!