Maestro Arduino RP2040 Issue

Hi, I’m using the Meastro with the Arduino library. I’m having trouble with the getPosition() data.
The maestro is working properly in every other way. I can control servos just fine, and if I call up getMovingState() I get a 1 if there are any servos moving, and a 0 when they all stop. The problem is the getPosition() returns what appears to be a very large value. As I move the servo from one limit to the other, the returned position value changes very quickly and reaches the max 16bit value (65,535) and rolls over several times across the travel. I was expecting a value range of around 2000-8000?
I tried using a 24 channel maestro through a BSS138 level shifter to a feather RP2040. I also tried an 18 channel maestro to a different feather RP2040 with a TXB0108 shifter. Also tried from 9600 baud up to 115200. If in the same position, the numbers repeat perfectly, so it isn’t a noise issue either. Any idea what is going on?

Bytes positions are swapped on the feather it seems.


We have not tried our Maestro Arduino library with an RP2040 yet, but I would be glad to look into it more with you. The returned value of the getPosition() command should be in the same range as the setTarget(), so your expectations for a value between 2000 and 8000 are correct. Could you post your code as well as the results you are getting form the getPosition() command? What is happening that makes you think the byte positions are getting swapped? Also, are you using the earlephilhower RP2040 board definition or the official Arduino RP2040 (Mbed OS) board definition?


I was thinking it may have been an issue with the level shifter, so I scoped the meastro TX line. I captured a value of 0111000000010111 which is exactly what I was seeing on the RP2040 serial monitor at the time (28695). That made me think the bytes were flipped. Swapped them and it equaled 6000, exactly what I was expecting. Makes sense now why the number would move so fast, it was wrapping around every 256. I opened up the PololuMaestro.cpp file and swapped the lowerByte with the upperByte variable and now everything works. Thank you for the reply =)

We tried to reproduce the problem here but were unable to; the getPosition() function in the Maestro library worked fine with a Raspberry Pi Pico as expected. If you would like to look into why it didn’t work for you and can provide the information I asked for, we would be happy to investigate further.


I’m usind the earlephilhower board definitions, ver 2.6.3. Specifically the “Adafruit Feather RP2040” with the adafruit feather board. It may be something specific to that board. I tried it with the example smooth servo example sketch, just put in something like 10 getPositions() with 200ms delay in between each of the movements in the example to watch the position change. I was also running the software on the computer to watch things at the same time. I also ran the same sketch on an Arduino UNO and got the expected results. I don’t have the code anymore, It was just a test and I didn’t save it. Anything else that you would like to know?

I was also using Serial1 on the Feather to the Meastro, if that makes a difference.

Thank you for the additional information. After testing further, we were able to reproduce the problem by programming the Pico as a Feather RP2040 and using Serial1. In our tests, we were able to track down the problem to some junk data being generated on the serial line during the boot process (which caused the incoming serial data from the Maestro to parsed incorrectly). I suggest flushing the serial input near the beginning of your program (after setting up the serial), for example:

while (MaestroSerial->available()) { MaestroSerial->read(); }

You could try adding a delay for a few milliseconds before initializing serial to see if that helps as well.