Troubles configuring Xbee with AT commands from microcontroller

I am working on a battery-powered remote control project using XBee Pro S2C (intend to use XBEE3 in future. The goal is to not have to use XCTU to configure the modules, and instead have an 8-bit PIC send AT commands over UART to change some settings. Right now all I care about is enabling pin sleep mode so I can save battery.

So here’s the rub: I can of course successfully turn on pin sleep with XCTU (SM = 1). I can see the string of commands XCTU uses in the console window, which are as follows: +++ [OK] ATSM1 [OK] ATWR [OK] ATAC [OK] ATCN [OK]. Now if I try to do the same from the console window, I only get an OK after entering command mode [+++] and no response from any subsequent AT commands. However, I can open up a desktop terminal (in my case, realterm) and send the commands and get all OK’s, and indeed verify in XCTU that pin sleep has been enabled.

Now to my application: I hook up the Dout pin to my terminal to watch the module response. Upon pressing the correct keys, the PIC sends the above sequence of commands to the module (respecting guard times, with some delay between them, etc) and I see five 'OK’s come back as I would hope. However it just doesn’t stick. Plug into XCTU and see that nothing has changed.

I’m sure others have done this… any insight is much appreciated.

I should add before anyone points this out, but I know XCTU and my terminal program add carriage return to the end of commands, and my application includes the CR with the AT commands.

Answering my own question…

Turns out I was trying to send hex value 0x01 when I should have been sending ASCII ‘1’, which is actually 0x31. Now it’s working as it should.

A silly mistake but glad to have found it because I was starting to pull my hair out.

Cheers all.