Loading

Report as inappropriate

Reading the pins shouldn't change the state. Not sure what's going on there, but ignoring that for a moment...

gpio export 23 out changes the state of the output, to "activate" the relay. But then going high or low doesn't turn it off.

You shouldn't need a pull up or down resistor, since the pi will be actively choosing 0V or 3.3V. pull ups/downs are usually for inputs, not outputs.

What relay are you using? Is it a premade board like I'm using from sainsmart? Are you sure it will trigger with 3.3V? It sounds like at either state (0, 3.3V) it's causing the relay to be in one state, but when the pin is floating (when the pi isn't controlling the output) it's able to deactivate the relay.

As a hack/workaround, you could just gpio export 23 out in the printer_on script and gpio export 23 in in the printer_off script. One possible problem with that is that if the relay isn't stable when the pi is in gpio export 23 in, then it might toggle on.