We’re configuring a KNOT to use the three GPIO digital pins to switch additional LEDs. As per the documentation https://help.mikrotik.com/docs/spaces/ROS/pages/68944101/GPIO pins 4 and 6 are permanently set to output and are working as expected. We’ve set pin5 to direction OUTPUT but the behaviour doesn’t match that of pins 4 and 6. When we set pin5 to output=0 it doesn’t short the connection like pins 4 and 6, and there is a 2.45V reading. When we set it to output=1 the voltage increases to 2.9V. We wouldn’t expect any significant voltage across the pins.
Our expectation was that by setting the direction to OUTPUT pin5 would behave the same as the other 2 digital output pins (4 and 6). Has anyone else experienced this, or have any recommendations on how to fix?
You might want to look at the KNOT user manual, which has the GPIO assignments. The main GPIO docs do note that they vary by device, but it’s easy to forgot there is an KNOT specific page that has a bit more specifics:
/iot gpio digital print
Columns: NAME, DIRECTION, OUTPUT
# NAME DIRECTION OUTPUT
0 pin4 output 0
1 pin5 output 0
2 pin6 output 0
suggests we can set it to output (so it has changed here to output), and we can set the output value to 0 or 1, it just behaves differently on the GPIO board to pin4/6. But I agree, the docs imply pin5 works as input or output by not stating pin5 can only be input, but do not explicitly say it works as output.
Might want to file a ticket at help.mikrotik.com to ask. Either it’s a bug, or docs are wrong. What you’re doing seems like it should work based on my reading too.
This is an expected behaviour - the pin 5 is a digital input pin, it is directly connected to the SoC, wheres the digital output pins (4 and 6) have transistors that can short the connection to GND.
I’ve suggested they make this clearer in the documentation that although it can be changed to output it does not behave in the same way as the other digital output pins.
Pin 5 is described as being selectable as either input or output.
That a digital pin may (or may not) sink to 0 V (and how much current it can sink) depends of course on the implementation, but the nature of output of the pin is clear.
To me the 2.45 vs. 2.9 V don’t sound as a good digital 0/1 anyway, neither along the traditional TTL 5 V logic, nor following the newish Arduino (more tolerant) one: https://learn.sparkfun.com/tutorials/logic-levels/all
but maybe that depends on the exact way you measured the voltage levels.