Sending AT Commands

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
frednikgohar
 
Posts: 14
Joined: Wed Aug 11, 2021 2:33 pm

Sending AT Commands

Post by frednikgohar »

I am trying to find a way to send AT Commands to the BLE module on my Itsy Bitsy Express board (https://www.adafruit.com/product/4481) - specifically, I'm trying to change the advertised name on the BLE.

The only tutorial/code sample I've found is an Arduino sketch for the nRF51 (https://learn.adafruit.com/introducing- ... /atcommand) which can be found in Examples if one installs the Arduino code examples. However, this does not build for the Express boards.

Are there any tutorials, sample code, etc for the Express board? Preferably in Circuit Python?

I've also tried sending AT Commands via Blufruit Connect iOS app using the UART. The problem there seems to be that whatever I send from the app to the Express shows up on the board's UART with an appended b'<string>'

So for example, if I send the string:

hello

It shows up on the Express' UART as:

b'hello'

Does anyone have any ideas?

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Sending AT Commands

Post by adafruit_support_mike »

Are you using the nRF52840 version?

https://www.adafruit.com/product/4481

If so, that one doesn’t use AT-commands. It runs the BLE code stack directly, so you can/must use the API’s .setName() method in C++, or the .string attribute in CircuitPython:

https://circuitpython.readthedocs.io/en ... apter.name

User avatar
frednikgohar
 
Posts: 14
Joined: Wed Aug 11, 2021 2:33 pm

Re: Sending AT Commands

Post by frednikgohar »

Thanks Mike,

I'm a total newbie to programming but was able to get it working... sort of. Seems that I changed the name but it is not persistent. Here's what I did in CircuitPython:

Code: Select all

from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService

import board

ble = BLERadio()
uart = UARTService()
advertisement = ProvideServicesAdvertisement(uart)

newName = "NewBLEname"
ble.name = newName
# Check new name was set
print("New BLE Name is: ", ble.name)
What prints is indeed NewBLEname. However:

1- if I upload a new code, the name reverts back to CIRCUITPYxxxx
2- the name of the disk drive, as is mounted to my OSX Sierra, never changes.

Interestingly, up until today the name of the board as mounted on my machine was also CIRCUITPYxxxx - until earlier this afternoon where for some reason it changed to FSRCUITPY (seems like the first two letters changed from CI to FS). Not sure how this change occurred but it has been persistently FSRCUITPY (no xxx append) when mounted, even after several soft resets via onboard RST button and/or unplug/replug of the device via USB.

Finally, I know this is off topic but I'm trying to access the other onboard button (the SW) and per the instruction, it should be read/set via:

Code: Select all

import board

print(board.D4)     # as SW is connected to GPIO 4
However, I get this error:

Code: Select all

Traceback (most recent call last):
  File "code.py", line 22, in <module>
AttributeError: 'module' object has no attribute 'D4'
Any ideas how best to get/set the state of the onboard SW? Any sample code would be much appreciated. Thanks in advance.

/F

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Sending AT Commands

Post by adafruit_support_mike »

frednikgohar wrote:Seems that I changed the name but it is not persistent. Here's what I did in CircuitPython:
That’s normal. The bootloader sets some default values so the board starts in a known condition every time. The last thing you want is persistent settings from some piece of code you ran months ago suddenly popping up to cause problems in the code you’re using today.

If you want to set the device name, you have to do it as part if the setup code.
frednikgohar wrote:Interestingly, up until today the name of the board as mounted on my machine was also CIRCUITPYxxxx - until earlier this afternoon where for some reason it changed to FSRCUITPY (seems like the first two letters changed from CI to FS). Not sure how this change occurred but it has been persistently FSRCUITPY (no xxx append) when mounted, even after several soft resets via onboard RST button and/or unplug/replug of the device via USB.
Hmm.. I’ve never seen that before. Let me check with the folks who handle the low-level CircuitPython code.
frednikgohar wrote:Any ideas how best to get/set the state of the onboard SW?
Try using board.SWITCH instead of board.D4. The symbol name may have changed since the tutorial was written.

User avatar
frednikgohar
 
Posts: 14
Joined: Wed Aug 11, 2021 2:33 pm

Re: Sending AT Commands

Post by frednikgohar »

####################### RAPTOR - Prototype Firmware ########################
Noted. This totally makes sense.

Re the disk name changing proper name on OSX: turns out this is very normal as well; one can simply right-click a mounted drive in OSX Finder and change the display name of that drive.

However, regarding the onboard switch:

I have tried

Code: Select all

board.D4
in addition to

Code: Select all

board.switch
,

Code: Select all

board.SW
,

Code: Select all

board.SW1
and a few other permutations... all to no avail. Furthermore, there is very little documentation and forum discussions on this. At the end, I simply added my own push button on D2 and am using an external one. Maybe someone should look at this over at Adafruit. Happy to open a new thread on this if its helpful to others.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Sending AT Commands

Post by adafruit_support_mike »

‘SWITCH’ was a literal string, caps and all. Did you try that as well?

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”