Adafruit Feather NRF52 Custom Controls, No Coding Required

by drmpf in Circuits > Arduino

3137 Views, 11 Favorites, 0 Comments

Adafruit Feather NRF52 Custom Controls, No Coding Required

Feather52Boards.jpg
previewMenuWithChart.png
instructableMainImg.png
sampleGuages.png

Update 23rd April 2019 -- For date/time plots using only Arduino millis() see Arduino Date/Time Plotting/Logging Using Millis() and PfodApp The latest free pfodDesigner V3.0.3610+ generated complete Arduino sketches to plot data against date/time using Arduino millis()

Update 28th November 2017 -- Using Adafruit Feather nRF52 Arduino IDE board addon V0.7.5, the TX and RX pins are swapped. (see comments below for test code). This instructable does not use the TX/RX pins.

Read This First

Read This First – Do you really need BLE? – BLE Problems and How to Fix them

Introduction

Adafruit Feather nRF52 is a BLE (Bluetooth Low Energy) board supporting Bluetooth V5. Each different BLE board has its own supporting library, pin outs and capabilities which can make it difficult to get up and running.

This tutorial covers creating custom controls on your Android mobile for the Adafruit Feather nRF52. It uses the free pfodDesigner V3.3221+ to create custom multi-levels menus, plots and data logging that can be displayed on pfodApp (a paid app).

The pfodDesigner generates all the Arduino code needed for the Adafruit Feather nRF52.

The general purpose pfodApp handles the user display and interaction on your Android mobile. No Android programming is required.

What is displayed to the user on their mobile is completely controlled by the code you load into your Feather52. Even if you decide not to use pfodApp, the free pfodDesigner will still generate template code that allows you to set up a Nordic 'uart' connection to your Feather52 board.

pfodDesignerV3.3221+ displays Feather52's unique selection of board pins when you choose which pin to connect a menu item to.

This instructable is also available online Adafruit Feather nRF52 LE - Custom Controls with pfodApp

Parts List

Prices as at Nov 2017 excluding shipping

Install the Arduino IDE on your computer and then download and install the Board Manager for the Adafruit Feather nRF52 Check you can connect to and program your Feather nRF52 board.

Creating the Custom Android Menus for Adafruit BLE Feather52 and Generating the Code

pwmLed70.png

The free pfodDesignerV3 V3.3221+ Android app lets you create custom menus and then generates all the code for your particular BLE module. pfodApp is then used to display your custom menu on your Android mobile and let you control your module. No Android or Arduino coding is required.

The free pfodDesignerV3 is used to create the menu in a WISIWYG fashion and show you an accurate preview of how the menu will look on your mobile. The pfodDesignerV3 allows you to create menus and sub-menus with buttons and sliders, optionally connected to I/O pins, and generate the sketch code for you (see the pfodDesigner example tutorials) but the pfodDesignerV3 does not cover all the features pfodApp supports. See the pfodSpecification.pdf for a complete list including dwg primitives, data logging and plotting, multi- and single- selections screens, sliders, text input, etc.

Create the Custom menu to control the Adafruit BLE Feather52 RED LED

The tutorial Design a Custom menu to turn the Arduino Led on and off has step by step instructions for creating this menu using pfodDesignerV3. If you don't like the colours of font sizes or the text, you can easily edit them in pfodDesignerV3 to whatever you want and see a WYSIWYG (What You See Is What You Get) display of the designed menu.
There are two change to make for Adafruit BLE Feather52 and the are i) set Feather52 as the Target for the code generator for the new menu before adding the Led control menu item and ii) instead of selecting an On/Off control a PWM slider is selected and the build in RED LED is set as the output pin.

Choosing Adafruit Feather NRF52 As the Target for the Code Generation

defaultSerialTarget.png
targetOptions.png
BLEtargetOptions_1.png
BLEtargetOptions_2.png
Feather52_selected.png

Having started a new Menu in pfodDesigner, first you need to choose Adafruit Feather nRF52 as the Target for the code generation. When you start a new menu or edit an existing menu, the top button shows the Target board. The default is Serial.

Click on the Target button to open the Target selections.

Choose Bluetooth Low Energy button. There a number of BLE boards supported scroll down to see them all. Select the Adafruit Feather nRF52 as the target

Then use the mobile's back button to exit the Target selections screen and return to the Edit Menu screen.

PWM Control of RED Led

addMenuItem_1.png
addMenuItem_2.png
pwmOutputOrSliderSelected.png
notConnected.png
pwmPins_1.png
pwmPins_2.png
redBold_5.png

You can now continue with the Design a Custom menu to turn the Arduino Led on and off tutorial to Generate the Code except select PWM output as the menu item to add.

Then when scroll down to connect an I/O pin and click it to change

Then Scroll down to list of pins available for PWM use on the Feather52 and choose the RED Led.

Complete the menu item by editing the Leading Text, Setting BOLD, Background RED and increasing the font size to +5

Setting the Prompt and Generating the Code

editPrompt.png
preview42.png
generateCodebutton.png
generateCodeMenu.png

You can then go back to the main menu and set Edit Prompt to “Feather52” BOLD, font size +6 and a White background.

Finally go back to the main menu and preview your design before scrolling down to select Generate Code

Exit pfodDesigner and transfer the code file (\pfodAppRawData\pfodDesignerV3.txt) to your computer (see pfodAppForAndroidGettingStarted.pdf page32)

A copy of the generated code sketch is here (Feather52_Led_Chart.ino) Program your Feather52 and then create a BLE connection in pfodApp and connect to your board and display the slider to adjust the RED Led. It will display exactly as the preview above.

Adding a Plot to the Feather52 Control Menu

previewMenuWithChart.png
previewChartAfterHide.png
pfodAppChart.png

Using the Led Controller as a basis, you can add more menu items for reading or controlling the other Digital pins and for reading, plotting and logging the Analog inputs, A0 for example. Check out the various pfodDesigner tutorials on using the various menu items. The How to Display Arduino Data on Android for Beginners tutorial covers creating plots.

Below is preview with a chart button added and and a preview of the chart of A0 with some dummy data. Note: The default voltage reference for ADC on the Feather52 is 3.6V so when setting up the plot the “Edit Max Display” was set to 3.6 so that the 0 to 1023 reading was scaled to 0 to 3.6 for logging and display.

The generated sketch for this display is here (Feather52_Led_Chart.ino)

When loaded into your Feather52 and connected to your mobile, via pfodApp, you can touch the A0 board pin with your finger to get some reading and show a plot.

As well as plotting the Analog values, the readings are also logged, in CSV format, to a file on your mobile. If you named the connection in pfodApp, as “Feather52”, as shown above, then the logged CSV data is saved to the file \pfodAppRawData\Feather52.txt You can download this CSV file for further use.

Adding a Custom Control to the Feather52 Menu

pfodApp_pwm_chart_dwg.png

pfodApp V3 adds dwg primitives. You can use these primitives:- rectangles, circles, arcs, labels, touchZones, etc.. to create sophisticated graphical UI's You can even include one graphic within another and scale and pan it. See Custom Arduino Controls for Android for a tutorial on dwg primitives. See Arduino for Beginners for examples of scaling and panning a graphical UI.

Using primitive graphics gives you complete control over the display, but requires more work to create your interface. The pfodDwgControl library provides a number of pre-build controls, on/off buttons, guages, sliders, you can just drop into your graphic. The pfodDesigner lets you insert a simple graphic menu item with just an on/off button so that your generated code will have a template you can modify later to add your own graphics.

Graphics are just another menu item and can be added to any menu. Here is the generated code for this menu, Feather52_Led_Chart_Dwg.ino This sketch needs the pfodParser.zip and pfodDwgControls.zip libraries to be installed first.

Graphic UIs can take a number of messages to define all the primitives, colours, labels etc used. pfodApp limits each message from your device to 1024 bytes, but allows for a graphic to be defined by multiple messages. The generated code has provision for 2 messages but the second on is just empty and so pfodApp know not to ask for a third. You can extend this to as many messages as you need to build your display. Arduino101 Starter, controlled by Android/pfodApp uses 8 messages. pfodApp caches the menu and any graphics against the parser version string so that next time you connect you only don't need to send the whole graphic again, just the updates if any.

Sample Screens and Other Custom Controls

sampleGuages.png
sliderMoved.png

The pfodDesignerV3 only supports a sub-set of the screens that pfodApp supports. For a complete list see the pfodSpecification.pdf. The SampleAdafruitFeather52Screens.ino sketch includes additional screens supported by pfodApp but not included in the pfodDesigner. Most of the screens have no formatting to keep the messages clear and simple. You can add your own colours and font styles, using the pfodDesignerV3 as a guide. Also see the pfodDemo Android app for other examples.

The SampleAdafruitFeather52Screens.ino sketch needs the pfodParser.zip and pfodDwgControls.zip libraries to be installed first.

One of the screens in the SampleAdafruitFeather52Screens.ino includes two custom controls. A custom slider to control the RED led and a gauge to show the current setting. That screen uses pfodApp drawing primitives to draw the board controls and to define the user touch zones and actions. As you move your finger over the slider control it updates the screen immediately to show the new setting. Again this update is NOT build into pfodApp but is completely controlled by the code in your Feather52 so you can customize it as you wish.

The Custom Arduino Controls for Android tutorial covers how to code your own custom controls and the Arduino101 Starter, controlled by Android/pfodApp tutorial describes how the Zoom and Pan works.

Conclusion

This tutorial has shown how you can easily communicate with and control the Adafruit Feather nRF52 board.
No Android programming is required. pfodApp handles all of that.
No Arduino coding is required.
The (free) pfodDesignerV2 generates complete sketches for this and a variety of other BLE modules as well as ESP8266 and WiFi, Bluetooth and SMS shields.