Artemis Digital IO not working - plus BLE GATT

I recently purchased an Artemis nano for the next prototype of a system I am designing.

I have had a few issues and questions in my process getting my application to work on the board.

I am trying to run a few addressable LEDs with the board off a LiPo. It won’t send data to the LEDs which work fine with my ESP32 Thing. So I tried to simplify and just power up a simple blue LED, and still nothing. I have tried different pins, double checked all connections and code, verified the LED works. I can’t seem to figure out what’s going on. My best guess is it has something to do with the current source settings for the pins.

I would love to hear if you have any suggestions. I am really stoked on this new device and want to make it the core of a product I am developing.

I have a deadline for the next edition to be ready on Oct 12th for inclusion in a fashion show and have to verify this element of the circuit before I can design the PCBs.

I really want to base the design around Artemis, but am considering going back to ESP32 if I can’t figure this out soon.

PS. I am trying to create a custom profile for a BLE device. I see the example of how to interface with existing services but am having a hard time finding any documentation on adding a custom GATT service. Should I look at the edge board and loading code with the Ambiq SDK? Or can this be done just with some modification to the BLE LED Arduino sketch? I would be down to write a tutorial for this up if I can get some clear guidance.

Thanks so much for your help.

Hi skyfly200,

What addressable LEDs are you using with the Artemis and which library are you using with them?

As for BLE, we do have a beta example for the Arduino core but that is very much still a work in progress and will change as we work on improving it. If you want to dig into BLE functionality, the Ambiq SDK is probably the best option currently.

works out of the box with the Bdsk Arduino code for LED_BUILTIN bot analogWrite and digitalWrite.

  • Added analogWrite to pwm to LED_BUILTIN and added level mild. Still works. Need to add

extern void set_led_mild( void ); to nus_main.c and add set_led_mild(); to tagAlert Method

of nus_main.c in else if (alert == CH_ALERT_LVL_MILD) block.

Also add

extern void set_led_mild( void ){

analogWrite(LED_BUILTIN, 10);

}

in C-callable led functions at end of BLE_example_funcs.cpp

Then tried an external LED on pins A0 and 8. Notes from tests: Can’t get analogWrite for pwm to led to work…

from BLE_example_funcs.cpp

// C-callable led functions

//

// ****************************************

extern void set_led_high( void ){

//pinMode(D8, OUTPUT); // - no

//digitalWrite(LED_BUILTIN, HIGH);

analogWrite(LED_BUILTIN, 100);

//analogWrite(A0, 100); //KHE - Analog Write turns on briefly when

//called from .ino file then turns off.

//Executing Android HIGH command turns it back

//on till execute LOW or MID

//BUT - Device disconnects and does not reconnect

//after command execution. - LED_BUILTIN (19) does not have

//this problem. Try analogWrite (pwm) on digital.

digitalWrite(A0,HIGH); //digitalWrite Works great. Analog pin or something???

//analogWrite(8, 100); //won’t light but ble comm is fine

//analogWrite(8, 255); // no

analogWrite(D8, 255); //after adding D8 define beneath LED_BUILTIN for variant/config/variant.h … no

//digitalWrite(8, HIGH); //works great

digitalWrite HIGH and LOW works but analogWrite does not. GATT sent from nrfConnect or Bluetooth Android client example.

Found:

// \apollo3\hal\am_hal_gpio.c = file

// Input with various pullups (weak, 1.5K, 6K, 12K, 24K)

// The 1.5K - 24K pullup values are valid for select I2C enabled pads.

// For Apollo3 these pins are 0-1,5-6,8-9,25,27,39-40,42-43,48-49.

// The “weak” value is used for almost every other pad except pin 20.

so, I tried analogWrite to pin A2 (not in above list) and sure enough, pwm is working fine. I2C port pullups interfere with pwm? I’ve used esp8266’s lots. This is definately a different board. If you use normal .ino file and print to serial, you’ll see multiple steps through loop, then sleep for 9 sec’s, then 3+ instant loops again then 9 sec sleep…

so…analogWrite DOES NOT WORK on: A0,A1,8,10. All others do pwm with analogWrite.

Hmm, what version of the core are you using? We just released a [new version yesterday that fixed some pin definition problems so that might be what is causing the issue with those specific pins. Also, when you say 8 and 10 do you mean pins 8 and 10? Those are not analog pins and won’t work for analogWrite.](Release v1.0.12 · sparkfun/Arduino_Apollo3 · GitHub)

was using 11. 12 tested now. pins 8 and 10 do not analogWrite. pins A0,A1,A2,A3,4,A5,6,7,9,11,12,13,A14,A15,A16 all do pwm nicely with analogWrite. Did not set pinMode to OUTPUT and they still worked…both Analog and Digital pins. Did not try digitalWrite HIGH or LOW but assume they work.

digitalWrite works on pins 8 & 10 but only after setting pinMode OUTPUT (which I did not have to do on any other pins). PWM still no worky for 8 & 10 after pinMode OUTPUT. Probably beat this horse to death.

TS-Mark:
What addressable LEDs are you using with the Artemis and which library are you using with them?

Im using WS2812b

The library is WS2812FX

TS-Mark:
As for BLE, we do have a beta example for the Arduino core but that is very much still a work in progress and will change as we work on improving it. If you want to dig into BLE functionality, the Ambiq SDK is probably the best option currently.

I see the beta example. Would it be to difficult to add a custom service ID to that example and the corresponding handler functions?

I see where the services advertised are listed in the function tagScanData in ‘nus_main.c’ as unsigned integers. I imagine you could add a custom service UUID there and it would change how it show up to scanning devices. I still haven’t gathered how the handler for the imediate alert service is registered and how to register my own.

The issue with the library you are using is most likely just an incompatibility with the Apollo/Artemis Core. I tested two common addressable LED libraries, FastLED and NeoPixel but, unfortunately, neither are currently compatible with the Apollo/Artemis Core. There is a [pull request being reviewed but it has not been pushed to the library yet. You could try following along and editing/adding the [files the user has changed to see if you can get the WS2182B’s working with NeoPixel. You could also try modifying the WS2812FX library with similar changes and see if that helps.

As for your question regarding adding a custom service ID to the example, I’m afraid that is beyond my expertise and I do not have a good answer for you. I’ll try asking the engineer for the Apollo Core and see if that would be something you could modify easily.

Edit: I spoke with the engineer and you are on the right track with your line of thought to add a custom service ID.

Edit #2: I forgot that another user posted a WS2812 driver for Apollo 3. It’s a bit overkill since it uses CI for driving LEDs but you can view the GitHub repository for it [here if you want to take a look.](GitHub - konkers/light_stick)](Initial Apollo3 Implementation by csonsino · Pull Request #205 · adafruit/Adafruit_NeoPixel · GitHub)](Initial Apollo3 Implementation by csonsino · Pull Request #205 · adafruit/Adafruit_NeoPixel · GitHub)

Was BLE implemented in Arduino yet? I am not familiar with using SDK for programming.

DigitalWrite works on pins eight & 10 however best after putting pinMode OUTPUT (which I did not ought to do on another pins). PWM nevertheless no [easy work for 8 & 10 after pinMode OUTPUT. Probably beat this horse to death.](https://fintexec.coach)