-
Introducing the Adafruit WICED Feather WiFi Created by Kevin Townsend Last updated on 2018-08-22 03:52:45 PM UTC
-
Guide Contents Guide Contents Overview Board Layout Pin Multiplexing 2 11 15 15 Accessing Pins in Software 16 Power Config 17 LIPO Cell Power Monitoring (A1) 18 16 Mbit (2MByte) SPI Flash PWM Outputs Assembly Header Options! Soldering in Plain Headers 19 20 21 21 24 Prepare the header strip: Add the breakout board: And Solder! 24 25 25 Soldering on Female Header 27 Tape In Place Flip & Tack Solder And Solder! 27 28 29 Get the WICED BSP Adding Adafruit Board Support 31 31 Add the Adafruit B
-
Install dfu-util 42 Building dfu-util From Source (Ubuntu 14.04 etc.) Testing the Installation Install Python Tools (BSP <= 0.6.
-
Connecting 61 bool connect ( void ) bool connect ( const char *ssid ) bool connect ( const char *ssid, const char *key, int enc_type = ENC_TYPE_AUTO ) bool begin ( void ) bool begin ( const char *ssid ) bool begin ( const char *ssid, const char *key, int enc_type = ENC_TYPE_AUTO ) void disconnect (void) Network and Connection Details bool connected ( void ); uint8_t* macAddress ( uint8_t *mac ); uint32_t localIP ( void ); uint32_t subnetMask ( void ); uint32_t gatewayIP ( void ); char* SSID ( void ); int
-
bool addProfile (char* ssid, char* key, wl_enc_type_t enc_type) bool removeProfile (char* ssid) void clearProfiles (void) char* profileSSID (uint8_t pos); int32_t profileEncryptionType (uint8_t pos); AdafruitTCP TCP Socket API Packet Buffering 73 73 73 void usePacketBuffering (bool enable) TLS/SSL Certificate Verification Verifying Certificates with the WICED Feather (Safer) Ignoring Certificate Verification (Easier) Default Root Certificates 74 74 74 74 75 void tlsRequireVerification (bool required)
-
uint8_t begin (uint16_t port) void stop (void) int beginPacket (IPAddress ip, uint16_t port) int beginPacket (const char *host, uint16_t port) int endPacket (void) int parsePacket (void) IPAddress remoteIP (void) uint16_t remotePort (void) Stream API 87 87 88 88 88 88 88 89 89 int read (void) int read (unsigned char* buffer, size_t len) int read (char* buffer, size_t len) int peek (void) int available (void) void flush (void) 89 89 90 90 90 size_t write (uint8_t byte) size_t write (const uint8_t *bu
-
bool connect ( IPAddress ip, uint16_t port = 1883, bool cleanSession = true, uint16_t keepalive_sec = MQTT_KEEPALIVE_DEFAULT); 111 bool connect ( const char* host, uint16_t port = 1883, bool cleanSession = true, uint16_t keepalive_sec = MQTT_KEEPALIVE_DEFAULT); 111 bool connectSSL ( IPAddress ip, uint16_t port = 8883, bool cleanSession = true, uint16_t keepalive_sec = MQTT_KEEPALIVE_DEFAULT) 112 bool connectSSL ( const char* host, uint16_t port = 8883, bool cleanSession = true, uint16_t keepalive_sec = MQTT
-
Functions 138 bool follow (feedHandler_t fp) bool unfollow (void) bool followed (void) Example AdafruitTwitter 1. Creating a WICED Twitter Application Enter the Application Details Set the Application Permissions Manage the Access Keys Copy the Appropriate Key Data Create your Access Token 2.
-
Downloading the Root Certificate for a Domain Parameters Usage 166 166 Converting PEM Files 167 Parameters Usage 167 167 feather_dfu.
-
Setup Compile and Flash Testing the Sketch HttpGetCallback Setup Compile and Flash Testing the Sketch HTTPSLargeData Setup Compile and Flash Testing the Sketch Throughput Setup Running Netcat Compile and Flash Testing the Sketch FeatherOLED Setup 184 184 184 186 186 186 186 188 188 188 188 190 190 190 190 191 193 193 Setting the Access Point Enabling LIPO Battery Monitoring (Optional) Enabling the TSL2561 Luminosity Sensor (Optional) Enabling MQTT to Adafruit IO (Optional) Compile and Flash Testing the S
-
Overview Feather (https://adafru.it/l7B) is the new development board from Adafruit, and like its namesake it is thin, light, and lets you fly! We designed Feather to be a new standard for portable microcontroller cores. This is the Adafruit WICED Feather - it's our most powerful Feather yet! We have other boards in the Feather family, check'em out here. (https://adafru.
-
The WICED Feather is based on Broadcom's WICED (Wireless Internet Connectivity for Embedded Devices) platform, and is paired up with a powerful STM32F205 ARM Cortex M3 processor running at 120MHz, with support for TLS 1.2 to access sites and web services safely and securely. We spent a lot of time adding support for this processor and WiFi chipset to the Arduino IDE you know and love. Programming doesn't rely on any online or third party tools to build, flash or run your code.
-
The WICED Feather has the following key features: Measures 2.0" x 0.9" x 0.28" (51mm x 23mm x 8mm) without headers soldered in Light as a (large?) feather - 5.7 grams STM32F205RG (https://adafru.it/m9A) 120MHz ARM Cortex M3 MCU BCM43362 (https://adafru.it/meC) 802.
-
Comes fully assembled and tested, with a USB bootloader that lets you quickly use it with the Arduino IDE. We also toss in some headers so you can solder it in and plug into a solderless breadboard. Lipoly battery (https://adafru.it/e0v) and MicroUSB cable (https://adafru.
-
Board Layout The WICED Feather uses the same standard pinout as the rest of the Feather family (https://adafru.it/m0b), allowing you to use the same Feather Wings across all your compatible devices. It has the standard Feather on board LIPO battery charger (simply connect a LIPO battery and USB power at the same time), and 3.3V voltage regulation from either USB or VBAT (the LIPO cell) with automatic switching between power supplies.
-
Accessing Pins in Software For most pin names, you must append 'P' to the pin name shown on the silk screen. The table below lists the pin names on the silkscreen and their corresponding macro in your Arduino code: © Adafruit Industries https://learn.adafruit.
-
Slikscreen Arduino Code Note(s) WAKE C3 C2 A3 A2 A1 SCK MOSI MISO RX TX DFU B5 SWCLK SWDIO A4 B4 A15 C7 C5 SCL SDA WAKE or PA0 PC3 PC2 PA3 PA2 PA1 SCK or PA5 MOSI or PA7 MISO or PA6 PA10 PA9 PB3 PB5 PA14 PA13 P14 PB4 PA15 PC7 PC5 PB6 PB7 - Other notable pins defined in feather.h (https://adafru.it/CaM) include: Main Macro Name Direct Arduino Pin Name BOARD_LED_PIN PA15 For further details on the board layout, see the schematic here (https://adafru.it/olE).
-
The following pins are included as part of the WICED Feather's power system: 3V: The output of the on-board 3.3V 600mA voltage regulator RTC: The input for the realt-time clock (RTC) on the STM32F205 (optional) GND: The common/GND pin which should be connect to GND on any other boards you use BAT: The input for the 3.7V LIPO cell EN: The 'EN' switch for the 3.3V voltage regulator. Set this to GND to disable power.
-
You need to double the calculated voltage to compensate for the 10K+10K voltage divider, so in reality every value from the ADC is equal to 1.61133mV on the LIPO cell, although it appears on the ADC at half that level. 16 Mbit (2MByte) SPI Flash The WICED Feather contains an optional (default = off) 16MBit SPI flash chip that is controlled by FeatherLib.
-
PWM Outputs Pins that can be used as PWM outputs are marked with a tilde character ('~') on the silk screen. The timers associated with specific PWM outputs are listed below. These timers are important since all PWM outputs on the same HW timer will use the same period or pulse width. This means that if you set the pulse width for PA1, which uses HW Timer 5, this will also set the pulse width for PA2 and PA3 which use the same timer peripheral block.
-
Assembly We ship Feathers fully tested but without headers attached - this gives you the most flexibility on choosing how to use and configure your Feather Header Options! Before you go gung-ho on soldering, there's a few options to consider! The first option is soldering in plain male headers, this lets you plug in the Feather into a solderless breadboard © Adafruit Industries https://learn.adafruit.
-
Another option is to go with socket female headers. This won't let you plug the Feather into a breadboard but it will let you attach featherwings very easily © Adafruit Industries https://learn.adafruit.
-
We also have 'slim' versions of the female headers, that are a little shorter and give a more compact shape © Adafruit Industries https://learn.adafruit.
-
Finally, there's the "Stacking Header" option. This one is sort of the best-of-both-worlds. You get the ability to plug into a solderless breadboard and plug a featherwing on top. But its a little bulky Soldering in Plain Headers Prepare the header strip: Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - long pins down © Adafruit Industries https://learn.adafruit.
-
Add the breakout board: Place the breakout board over the pins so that the short pins poke through the breakout pads And Solder! Be sure to solder all pins for reliable electrical contact. (For tips on soldering, be sure to check out our Guide to Excellent Soldering (https://adafru.it/aTk)). © Adafruit Industries https://learn.adafruit.
-
Solder the other strip as well. © Adafruit Industries https://learn.adafruit.
-
You're done! Check your solder joints visually and continue onto the next steps Soldering on Female Header Tape In Place For sockets you'll want to tape them in place so when you flip over the board they don't fall out Flip & Tack Solder After flipping over, solder one or two points on each strip, to 'tack' the header in place © Adafruit Industries https://learn.adafruit.
-
And Solder! Be sure to solder all pins for reliable electrical contact. (For tips on soldering, be sure to check out our Guide to Excellent Soldering (https://adafru.it/aTk)). © Adafruit Industries https://learn.adafruit.
-
© Adafruit Industries https://learn.adafruit.
-
You're done! Check your solder joints visually and continue onto the next steps © Adafruit Industries https://learn.adafruit.
-
Get the WICED BSP The WICED BSP installation procedure for 0.6.0 and higher is completely different than the manual installation procedure from earlier versions. See the notes at the bottom of this page if you are upgrading. To use the WICED Feather, you first need to install a board support package (BSP) that includes all the classes, drivers and example code that make it possible to create projects that can talk to the STM32F205 MCU and Broadcom radio.
-
build the list of available & installed boards. If you don't see the Additional Boards Manager URLs box, make sure you downloaded the Arduino IDE from arduino.cc! Older versions and derivatives of the IDE may not have it Add the Adafruit BSP List We will only need to add one URL to the IDE in this example, but you can add multiple URLS by separating them with commas. Copy and paste the link below into the Additional Boards Manager URLs option in the Arduino IDE preferences. https://www.adafruit.
-
Next, quit and reopen the Arduino IDE to ensure that all of the boards are properly installed. You should now be able to see the new boards listed in the Tools->Board menu. Finally follow the OS specific steps in this guide for your platform to finish the installation - basically installing drivers and permissions management. Upgrading From Earlier WICED BSP Releases (<0.6.0) If you are using an earlier version of the WICED SDK (< 0.6.
-
Windows Setup To setup the WICED Feather on Windows, the following steps are necessary: This page assumes you have already installed the WICED Feather BSP, as detailed earlier in this guide. Install Adafruit Windows Drivers If you are using a Windows based system, you will need to install a set of drivers for the USB DFU, USB CDC and other USB interfaces used by the WICED Feather to perform fimware updates and communicate with the device.
-
Install Python 2.7 Python is used by the WICED Feather for a number of cross-platform tools and scripts, meaning that you will need to install Python 2.7 (https://adafru.it/mbb) (ideally 2.7.9 or higher) on your system in order to communicate with the board. Depending on whether you are running a 32-bit (x86) or a 64-bit (AMD x64) version of Windows, download the installer linked below and start the installation process: https://adafru.it/mbc https://adafru.it/mbc https://adafru.it/mbd https://adafru.
-
Testing the Python Installation Once the installer is finished you can open the command line and enter the following command to test the availability of Python on your system: python --version You should see something like this: Python 2.7.11 Install Python Tools Update: Recent versions of the BSP now include a pre-compiled version of the feather_dfu tool in the '/tools/win32-x86/feather_dfu' folder, which should run on most systems once the libusb dependencies above are installed.
-
This will display some basic progress data on the installation process, and you should end up with something resembling the following output: C:\Users\me>pip install --pre pyusb Collecting pyusb Downloading pyusb-1.0.0rc1.tar.gz (53kB) 100% |################################| 57kB 1.3MB/s Installing collected packages: pyusb Running setup.py install for pyusb Successfully installed pyusb-1.0.
-
Setup Problems If you are having problems after running through all of the setup steps above, you may find the following information useful: I can get my device in DFU mode (fast blinky on the red LED), but the two USB CDC (COM) ports never enumerate. I have the USB drivers installed, though. What's wrong? On Windows, you can check if the device is enumerating properly with the following free tool: http://www.nirsoft.net/utils/usb_devices_view.
-
OS X Setup To setup the WICED Feather on OS X, the following steps are necessary: This page assumes you have already installed the WICED Feather BSP, as detailed earlier in this guide. Install dfu-util The WICED Feather uses USB DFU to perform firmware updates from the Arduino IDE. To enable to Arduino IDE to talk to the board you will need to install dfu-util. The easiest way to install dfu-util is to use homebrew (https://adafru.
-
To use these Python tools, you will need to have Python available on your system (which OS X does by default), but you will also need a few additional libraries to make the python scripts work. Running the following command from the command line will install these dependencies: Depending on your system setup you may need to run the pip commands with 'sudo' # On versions of OS X from 10.11.5 onward run ... sudo pip install pyusb sudo pip install click # On versions of 0S X before 10.11.5 run ...
-
AdaLink acts as a simple python-based abstraction layer between various HW debuggers, and the different ARM MCU families that we use at Adafruit. For installation instructions on AdaLink see the Readme file (https://adafru.it/fPq) in the git repository. © Adafruit Industries https://learn.adafruit.
-
Linux Setup To setup the WICED Feather on Linux (Ubuntu 14.04 was used here) the following steps are necessary: UDEV Setup On Linux you will need to add a small udev rule to make the WICED board available to non-root users. If you don't have this rule then you'll see permission errors from the Arduino IDE when it attempts to program the board. Create or edit a file called /etc/udev/rules.d/99-adafruit-boards.
-
$ sudo apt-get install dfu-util If you are using an older version of Ubuntu or if ' dfu-util -v ' displays an older version like 0.5 you will need to buid dfuutil from source, as described below. Building dfu-util From Source (Ubuntu 14.04 etc.) Ubuntu 14.04 and several other distributions use dfu-util 0.5 which is too old for the WICED Feather (which requires dfu-util version 0.8 or higher). To build dfu-util from source run the following commands (Ubuntu 14.
-
dfu-util 0.9 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2016 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Please report bugs to http://sourceforge.net/p/dfu-util/tickets/ Found DFU: [239a:0008] ver=0200, devnum=6, cfg=1, intf=0, path="2-1", alt=0, name="@Internal Flash /0x08000000/02*01 Install Python Tools (BSP <= 0.6.2) As of BSP release 0.6.
-
Optional: Install AdaLink If you ever need to reflash the USB DFU bootloader on the WICED Feather (which will require either a Segger JLink (https://adafru.it/e9G) or an STLink/V2 (http://adafru.it/2548)), you will also need to install a utility called AdaLink (https://adafru.it/fPq). AdaLink acts as a simple python-based abstraction layer between various HW debuggers, and the different ARM MCU families that we use at Adafruit. For installation instructions on AdaLink see the Readme file (https://adafru.
-
Arduino IDE Setup Once you have the WICED Feather board support package set up -- as described in Get the WICED BSP (https://adafru.it/rod) earlier in this guide -- you can start compiling code against FeatherLib or update the firmware on your device directly from the Arduino IDE.
-
The following sections are available in the menu: User Code: This section (which consists of 128KB flash and 16KB SRAM) is where your user sketches go, which is the project that you compile in the Arduino IDE. This is the section you will want to use 99% of the time! Feather Lib: This is the library that contains the low level WiFi stack and security layer, manage the RTOS (real time operating system) that schedules different tasks on the system, and does all of the heavy lifting for you.
-
general purpose serial data and is connected to the Serial Monitor. This is the port you should normally select in the Arduino IDE. The second port that is enumerated is for basic debugging and for future expansion, and enumerates a currently unused AT Parser that only supports a very basic set of commands (for example 'ATI' will return some basic information about the module). If you are not seeing a USB CDC port and are using a new WICED board, please see this FAQ: https://learn.adafruit.
-
Optional: Updating the Bootloader While you should never have to update the USB DFU bootloader on your WICED Feather, if you have a Segger JLink (https://adafru.it/e9G) or an STLink/V2 (http://adafru.it/2548) you can reflash the normally read-only bootloader from within the Arduino IDE. A J-Link or STLink is required since this is the only way to talk to the STM32F205 if the bootloader is somehow erased.
-
You can then click the Burn Bootloader menu entry and the Arduino IDE will attempt to use the JLink or STLink (via AdaLink (https://adafru.it/fPq)) to reflash the bootloader for you.
-
The 'Error during download get_status' message can be ignored and is related to the USB DFU interface as implemented on the MCU. © Adafruit Industries https://learn.adafruit.
-
System Architecture One of the key challenges creating the WICED Feather is that it is based on the Broadcom WICED WiFi stack, and due to the license terms we're unable to release any of the source files. This poses a bit of a dilemma since we tested almost every embedded WiFi stack out there, and WICED easily climbed to the top in terms of features, performance and reliability.
-
receiving commands using a custom protocol we call SDEP (Simple Data Exchange Protocol). An SDEP command is sent to the Feather lib, and a standard response is sent back and interpretted, allowing the two binary blobs to exist entirely independent of each other, and be updated separately. You normally never need to deal with SDEP commands directly since the commands are all hidden in the public WICED Feather helper classes (AdafruitFeather, AdafruitHTTP, etc.).
-
access to most of the flash and SRAM. Config Data (32KB) Two identical sets of non-volatile config data are stored in this section, and when any changes are made the bank used is switched to make sure that no data is lost during the updates. Normally you will never access this memory directly, and this is managed by the Feather Lib. USB DFU Bootloader (32KB) This code runs as soon as your device powers up and starts the Feather Lib, and also checks if any User Code is available.
-
update. When the solder jumper on the bottom of the WICED Feather is enabled, an addition USB Mass Storage class will enumerate that points to the SPI flash. This feature is not yet enabled, but when enabled the WICED Feather will use the following VID/PID combination: VID: 0x239A PID: 0x8010 Flash Updates All flash updates happen using USB DFU. There is no serial bootloader on the WICED Feather and the USB CDC ports are not required to perform a firmware update.
-
WICED Feather API In order to simplify the most common activities with the WICED Feather, several helper classes have been added to the board support package. These helper classes are described below, and detailed explanations of each class can be found later in this guide. AdafruitFeather This is the main class you will use to configure the WICED Feather.
-
AdafruitSDEP This class handles sending and receiving SDEP messages between the user code and the lower level feather lib. Normally you will never need to send SDEP messages yourself, and you will use the higher level helper classes mentionned elsewhere on this page, but AdafruitHTTP inherits from AdafruitSDEP, so you have access to all of the functions in AdafruitSDEP via the standard Feather object, such as Feather.sdep_n(...), Feather.errno(), etc.
-
AdafruitFeather AdafruitFeather is the main class that you will use for common operations like connecting to an access point (AP), checking error codes, getting your IP address, or working with stored AP profiles. AdafruitFeather API The following functions are available in AdafruitFeather (which is normally accessible as Feather.* in all of your sketches, for example ' Feather.factoryReset() '). © Adafruit Industries https://learn.adafruit.
-
char char char char const* const* const* const* bootloaderVersion sdkVersion firmwareVersion arduinoVersion ( ( ( ( void void void void ); ); ); ); int scanNetworks ( wl_ap_info_t ap_list[], uint8_t max_ap ); bool bool bool connect connect connect ( void ); ( const char *ssid ); ( const char *ssid, const char *key, int enc_type = ENC_TYPE_AUTO ); bool bool bool begin begin begin ( void ); ( const char *ssid ); ( const char *ssid, const char *key, int enc_type = ENC_TYPE_AUTO ); void disconne
-
sync. The following helper functions are provided to retrieve the current version numbers for the the various components used by your device. char const* bootloaderVersion ( void ) Returns the current bootloader version string. Parameters: None Returns: A null-terminated string containing the current bootloader version in the MAJOR, MINOR, REVISION format, ex: "1.0.0". char const* sdkVersion ( void ) Returns the current Broadcom WICED SDK version string.
-
max_ap: The maximum number of access points to write to 'ap_list'. Returns: The number of APs written into ap_list. See the 'Constants' page in this learning guide for details on the wl_ap_info_t struct. Connecting The following functions are used to connect to an access point. bool connect ( void ) This function will attempt to connect using the list of Profiles stored in non-volatile config memory on the WICED Feather.
-
bool begin ( const char *ssid ) This is an alias for ' bool connect(const char* ssid) ' described above, and is provided to match the Arduino Client interface. bool begin ( const char *ssid, const char *key, int enc_type = ENC_TYPE_AUTO ) This is an alias for ' bool connect(const char *ssid, const char *key, int enc_type) ' described above, and is provided to match the Arduino Client interface. void disconnect (void) Disconnects from the current access point.
-
Returns: A 32-bit integer containing the four bytes that make up the IPv4 subnet mask. uint32_t gatewayIP ( void ); Returns the IPv4 gateway IP. Parameters: None Returns: A 32-bit integer containing the four bytes that make up the IPv4 gateway address. char* SSID ( void ); Returns the SSID for the current access point (AP). Parameters: None Returns: A null-terminated string containing the SSID name for the current AP.
-
IPAddress hostByName ( const char* hostname ) Parameters: hostname: A string representing the domain name to lookup (ex. "www.adafruit.com"). Returns: The IPAddress (https://adafru.it/lGd) corresponding to the specified hostname. bool hostByName ( const char* hostname, IPAddress& result ) Looks up the domain name specified in the 'hostname' string, and assigns it to the IPAddress (https://adafru.it/lGd) referenced by the 'result'. Parameters: hostname: A string representing the domain name to lookup (ex.
-
ip: The IPAddress (https://adafru.it/lGd) to ping. Returns: The response time in milliseconds if the IP address responded to the ping request, or '0' if the ping failed. Factory Reset If you set your WICED Feather modules into an unknown state of encounter unexpected behaviour, you can try to perform a full factory reset or reset the non-volatile config memory using these helper functions.
-
Epoch time returns a 32-bit unsigned integer value representing the number of seconds since 1 January 1970. For example '1456472597' would convert to: Fri, 26 Feb 2016 07:43:17 GMT ISO8601 format timestamps return the time as a specifically formatted string similar to the timestamp below: 2016-02-18T17:12:46.061104 bool getISO8601Time ( iso8601_time_t* iso8601_time ) Updates 'iso8601_time' with the current timestamp in ISO8601 format.
-
Parameters: None Returns: A 32-bit unsigned integer representing the number of seconds since the 'Epoch', or 1 January 1970. TLS Root Certificate Management Connecting to secure TLS/SSL based servers requires a root certificate to verify that the certificate data from the remote server is valid. A set of common root certificates is included in the Featherlib by default, but custom certificates can also be added to the chain via the .addRootCA helper function, described below.
-
The default root CA list will be enabled by default unless Feather.enableRootCA(false) or Feather.clearRootCA() is called explicitly. bool initRootCA (void) This function allocates memory for the default list of root certificates and any custom root certificates present. Normally this function never needs to be called directly, and will be call on an as-needed bases by .addRootCA or .connectSSL. It is provided as a public function so that other classes can have access to it (AdafruitTCP, etc.).
-
Parameters: p: The 'Print' implementation to use. Leave this field empty and it will default to 'Serial' which is used for the Serial Monitor output. Returns: Nothing. void printNetwork (Print& p = Serial) Displays the following network details when connected to an AP: SSID Name SSID Encryption Method MAC Address Local IP Address Gateway Address Subnet Mask Parameters: p: The 'Print' implementation to use. Leave this field empty and it will default to 'Serial' which is used for the Serial Monitor output.
-
AdafruitFeather: Profiles The WICED Feather API allows you to store 'profiles', which contain all of the settings about a specific AP (access point). This means that you only need to enter your AP details once, and once connected you can store them in non-volatile config memory for later use, simplifying project management and speeding up connection time in certain instances.
-
bool addProfile (char* ssid, char* key, wl_enc_type_t enc_type) Saves the specified secure SSID to the profile list. This function should not be used with open access points. Parameters: ssid: A string containing the access point's SSID/name.
-
Removes the profile with the matching ssid from non-volatile memory. Parameters: ssid: A string containing the access point's SSID/name. Returns: 'true' (1) if the profile was successfully found and removed, otherwise 'false' (0). void clearProfiles (void) Clears all profiles from non-volatile memory. Parameters: None Returns: Nothing char* profileSSID (uint8_t pos); Returns a string containing the SSID name for the profile stored at the specified position.
-
AdafruitTCP AdafruitTCP makes it easier to work with raw TCP sockets. You can open sockets -- including SSL based secure socket connections -- and send and receive data using a few basic commands. The class also and exposes two convenient (optional) callbacks: Data Received Callback: Fires whenever incoming data is available (which can then be read via the .
-
By default packet buffering is DISABLED in AdafruitTCP void usePacketBuffering (bool enable) This will enable or disable packet buffering with AdafruitTCP data. Parameters: enable: Set this to 'true' (1) to enable packet buffering, otherwise 'false' (0) Returns: Nothing TLS/SSL Certificate Verification When opening a secure TCP connection to a TCP server, the client and server will begin to communicate with each other in an open connection to choose their cipher suite (AES, etc.
-
This still allows for an encrypted connection (using AES, etc.), but there is no guarantee that the server you are talking to is actually the server you think you're talking to, making it a less secure option. By default certificate verification is enabled on WICED Feather boards. You can disable verification via 'tlsRequireVerification(false)', which will cause any certificate to be accepted, but it will also allow man-in-themiddle type attacks.
-
In specialised cases (mostly when implementing sub-classes of AdafruitTCP) you may need access to the 'handle' for the TCP socket. The .getHandle function provides access to this. void getHandle (void) Returns the internal TCP socket handler value that uniquely identifies this TCP socket. This might be necessary when creating special sub-classes based on AdafruitTCP. Parameters: None Returns: The uint32_t socket handler value that uniquely identifies this TCP socket.
-
Note: A set of common root certificates are already included in the WICED Feather SDK, so most HTTPS websites will work out of the box, but if you need to add a new root certificate chain the TLS/certificate data is set using the following function in the Adafruit Feather class (accessible as `Feather.addRootCA(...
-
Parameters: None Returns: The first byte of incoming data available, or -1 if no data is available. int read (uint8_t * buf, size_t size) Reads up to the specified number of bytes from the data buffer (if any data is available). Parameters: buf: A pointer to the buffer where data should be written if any data is available size: The maximum number of bytes to read and copy into buf. Returns: The actual number of bytes read back, and written in buf.
-
void flush (void) Forces any buffered data to be transmitted to the TCP server, regardless of the size of the content. Parameters: None Returns: Nothing Callback API To make working with TCP sockets easier, a simple callback API is available in AdafruitTCP based on the following functions: void setReceivedCallback (tcpcallback_t fp) Registers the data received callback handler. Parameters: fp: The name of the function that will be executed when received data is available from the TCP server.
-
// Set the callback handlers for RX and disconnect tcp.setReceivedCallback(receive_callback); tcp.setDisconnectCallback(disconnect_callback); To read incoming data in the receive callback handler, you need to use the pTCP pointer, as shown in the sample code below: void receive_callback(void) { int c; // Print out any bytes available from the TCP server while ( (c = tcp.read())> 0 ) { Serial.write( (isprint(c) || iscntrl(c)) ? ((char)c) : '.'); } } void disconnect_callback(void) { Serial.println(); Serial.
-
// Attempt to connect to the AP using the specified SSID/key/encoding if ( !Feather.connect(WLAN_SSID, WLAN_PASS, WLAN_SECURITY ) ) { err_t err = Feather.errno(); Serial.println("Connection Error:"); switch (err) { case ERROR_WWD_ACCESS_POINT_NOT_FOUND: // SSID wasn't found when scanning for APs Serial.println("Invalid SSID"); break; case ERROR_WWD_INVALID_KEY: // Invalid SSID passkey Serial.
-
{ int c; // Print out any bytes available from the TCP server while ( (c = tcp.read())> 0 ) { Serial.write( (isprint(c) || iscntrl(c)) ? ((char)c) : '.'); } } void disconnect_callback(void) { Serial.println(); Serial.println("-------------------"); Serial.println("DISCONNECT CALLBACK"); Serial.println("-------------------"); Serial.println(); } © Adafruit Industries https://learn.adafruit.
-
AdafruitTCPServer This class allows you to create a simple TCP based server to communicate with other TCP clients. This class is still a work in progress and may undergo significant changes in a future version of the WICED Feather library. It should be considered experimental for now. Constructor AdafruitTCPServer has the following constructor: AdafruitTCPServer(uint16_t port) Parameters: port: The port to use for the TCP server (1..
-
Parameters: None Returns: Nothing. void setConnectCallback (tcpserver_callback_t fp) Sets the TCP server callback event handler function for any incoming connection requests. Parameters: fp: The function that will be used to handling incoming connection requests. Returns: Nothing. The connect callback function handler has the following syntax: /**************************************************************************/ /*! @brief This callback is fired when there is a connection request from a TCP client.
-
/**************************************************************************/ /*! @brief This callback is fired when there is a connection request from a TCP client. Use accept() to establish the connection and retrieve the client 'AdafruitTCP' instance. */ /**************************************************************************/ void connect_request_callback(void) { uint8_t buffer[256]; uint16_t len; AdafruitTCP client = tcpserver.available(); if ( client ) { // read data len = client.
-
// Tell the TCP Server to auto print error codes and halt on errors tcpserver.err_actions(true, true); // Setup callbacks: must be done before begin() tcpserver.setConnectCallback(connect_request_callback); // Starting server at defined port tcpserver.begin(); Serial.print("Listening on port "); Serial.
-
AdafruitUDP AdafruitUDP makes it easy to work with raw UDP sockets. It includes a convenient callback for incoming data, and a number of helper functions to read and write data over a UDP socket. You're free to 'poll' for incoming data and connection status, but the 'data received' callback fires whenever incoming data is available, which can then be read via the .read() and related commands.
-
Parameters: None Returns: Nothing int beginPacket (IPAddress ip, uint16_t port) Starts a UDP connection to write data to the specified remote IP address and port. Parameters: ip: The remote IPAddress (https://adafru.it/lGd) where the UDP server is located port: The remote port number to connect to (0..65535) Returns: '1' if successful, '0' if there was a problem connecting to the specified IP address or port.
-
Parameters: None Returns: The IPAddress (https://adafru.it/lGd) of the remote UDP server/connection. uint16_t remotePort (void) Returns the port for the remote UDP server. AdafruitUDP.parsePacket() must be called BEFORE this function. Parameters: None Returns: The port of the remote UDP server/connection. Stream API The following functions are based on the Stream (https://adafru.it/lGe) class that Arduino EthernetUDP (https://adafru.it/lGA) implements.
-
int peek (void) Reads a single byte from the UDP response buffer without advancing to the next position in the buffer. This function must be called AFTER AdafruitUDP.parsePacket()! Parameters: None Returns: The first byte available in the UDP buffer, or '-1' if no data is available. int available (void) Returns the number of bytes available to be read in the UDP buffer. This function must be called AFTER AdafruitUDP.
-
Returns: The number of bytes written. Callback Handlers AdafruitUDP supports a 'read' callback that will fire every time incoming UDP data is recieved over the open socket connection. The callback function has the following signature (although you are free to choose a different name if you wish to): void received_callback(void); Before you can use the callback function, you need to register your callback handler (using the function signature in the paragraph above).
-
Serial.print("Attempting to connect to: "); Serial.println(WLAN_SSID); if ( Feather.connect(WLAN_SSID, WLAN_PASS) ) { Serial.println("Connected!"); } else { Serial.printf("Failed! %s (%d)", Feather.errstr(), Feather.errno()); Serial.println(); } Serial.println(); return Feather.connected(); } void setup() { Serial.begin(115200); // wait for Serial port to connect. Needed for native USB port only while (!Serial) delay(1); Serial.println("UDP Echo Callback Example"); Serial.
-
if ( packetSize ) { // Print out the contents with remote information Serial.printf("Received %d bytes from ", packetSize); Serial.print( IPAddress(udp.remoteIP()) ); Serial.print( " : "); Serial.println( udp.remotePort() ); udp.read(packetBuffer, sizeof(packetBuffer)); Serial.print("Contents: "); Serial.write(packetBuffer, packetSize); Serial.println(); // Echo back contents udp.beginPacket(udp.remoteIP(), udp.remotePort()); udp.write(packetBuffer, packetSize); udp.
-
AdafruitHTTP AdafruitHTTP helps make working with HTTP requests easier, including HTTPS based servers with TLS certificates. It includes convenient callbacks for incoming data, as well as helper functions to deal with HTTP response headers, response codes, and other HTTP specific details.
-
The following functions enable you to send HTTP GET requests to an HTTP server: bool get (char const* url) This is a shortcut for the function below and uses the 'host' specified in .connect instead of re-entering it in the get request. See below for details. This shortcut function will only work if you used .connect with a domain name. It will return an error if you used .connect with an IP address. Please use the full .get() function below when connecting via an IP address.
-
Sends a POST request to the HTTP server at 'host'. Parameters: host: A null-terminated string containing the host name for the HTTP server (ex. "www.adafruit.com"). This is normally the same as the host used in .connect , but you can also access other host names that resolve to the same domain or IP such as "learn.adafruit.com" or "io.adafruit.com". url: The path for the HTTP post, minus the encoded arguments ("ex. "/testwifi/testpost.
-
#define SERVER #define PAGE #define PORT "wifitest.adafruit.com" // The TCP server to connect to "/testwifi/index.html" // The HTTP resource to request 80 // The TCP port to use // Some servers such as Facebook check the user_agent header to // return data accordingly. Setting 'curl' mimics a command line browser. // For a list of popular user agents see: http://www.useragentstring.com/pages/useragentstring.php #define USER_AGENT_HEADER "curl/7.45.
-
// Print all software versions Feather.printVersions(); // Try to connect to an AP while ( !connectAP() ) { delay(500); // delay between each attempt } // Connected: Print network info Feather.printNetwork(); // Tell the HTTP client to auto print error codes and halt on errors http.err_actions(true, true); // Set the callback handlers http.setReceivedCallback(receive_callback); http.setDisconnectCallback(disconnect_callback); // Connect to the HTTP server Serial.printf("Connecting to %s port %d ...
-
Serial.println("Connected!"); } else { Serial.printf("Failed! %s (%d)", Feather.errstr(), Feather.errno()); Serial.println(); } Serial.println(); return Feather.connected(); } © Adafruit Industries https://learn.adafruit.
-
AdafruitHTTPServer The AdafruitHTTPServer class requires WICED Feather Lib 0.6.0 or higher to run. AdafruitHTTPServer makes it easy to run an HTTP server on the WICED feather in either SoftAP or normal operating mode, allowing you to implement custom admin consoles, rich data visualisations, or to publish 'always available' documention for your project right on the board itself.
-
const char hello_html[] = "
Hello World!
"; HTTPPage pages[] = { HTTPPageRedirect("/", "/hello.html"), // Redirect root to hello page HTTPPage("/hello.
-
void info_html_generator (const char* url, const char* query, httppage_request_t* http_request); void file_not_found_generator (const char* url, const char* query, httppage_request_t* http_request); const char hello_html[] = "
Hello World!
"; HTTPPage pages[] = { HTTPPageRedirect("/", "/hello.html"), // redirect root to hello page HTTPPage("/hello.html", HTTP_MIME_TEXT_HTML, hello_html), HTTPPage("/info.html" , HTTP_MIME_TEXT_HTML, info_html_generator), HTTPPage("/404.
-
/**************************************************************************/ /*! * @brief HTTP 404 generator. The HTTP Server will automatically redirect * to "/404.html" when it can't find the requested url in the * list of registered pages * * The url and query string are already separated when this function * is called. * * @param url url of this page * @param query query string after '?' e.
-
// Configure HTTP Server Pages Serial.println("Adding Pages to HTTP Server"); httpserver.addPages(pages, pagecount); Serial.print("Starting HTTP Server ... "); httpserver.begin(PORT, MAX_CLIENTS); Serial.println(" running"); Starting/Stopping the HTTP Server You can start the HTTP server using the .begin function (and stop it via .stop ), with the following function signatures: Make sure you call the .addPages function BEFORE calling the .
-
void info_html_generator (const char* url, const char* query, httppage_request_t* http_request); void file_not_found_generator (const char* url, const char* query, httppage_request_t* http_request); const char hello_html[] = "
Hello World!
"; HTTPPage pages[] = { HTTPPageRedirect("/", "/hello.html"), // redirect root to hello page HTTPPage("/hello.html", HTTP_MIME_TEXT_HTML, hello_html), HTTPPage("/info.html" , HTTP_MIME_TEXT_HTML, info_html_generator), HTTPPage("/404.
-
/*! * @brief HTTP 404 generator. The HTTP Server will automatically redirect * to "/404.html" when it can't find the requested url in the * list of registered pages * * The url and query string are already separated when this function * is called. * * @param url url of this page * @param query query string after '?' e.
-
// Connected: Print network info Feather.printNetwork(); // Tell the HTTP client to auto print error codes and halt on errors httpserver.err_actions(true, true); // Configure HTTP Server Pages Serial.println("Adding Pages to HTTP Server"); httpserver.addPages(pages, pagecount); Serial.print("Starting HTTP Server ... "); httpserver.begin(PORT, MAX_CLIENTS); Serial.
-
Serial.println("DISCONNECTED CALLBACK"); Serial.println("---------------------"); Serial.println(); httpserver.stop(); } © Adafruit Industries https://learn.adafruit.
-
AdafruitMQTT The Adafruit WICED Feather API includes an internal MQTT client that allows you perform basic MQTT operations directly with any MQTT broker. AdafruitMQTT inherits from AdafruitTCP and also has access to all of the functions defined in the parent class. Note: You are also free to use an external Client (https://adafru.it/lFj) based MQTT library (for example Adafruit_MQTT_Library (https://adafru.it/fp6)) if you prefer or need something fully under your control.
-
bool connected ( void ); bool connect ( IPAddress ip, uint16_t port bool cleanSession uint16_t keepalive_sec ( const char* host, uint16_t port bool cleanSession uint16_t keepalive_sec bool connect bool connectSSL ( IPAddress uint16_t bool uint16_t bool connectSSL ( const char* uint16_t bool uint16_t ip, port cleanSession keepalive_sec host, port cleanSession keepalive_sec = 1883, = true, = MQTT_KEEPALIVE_DEFAULT); = 1883, = true, = MQTT_KEEPALIVE_DEFAULT); = 8883, = true, = MQTT_KEEPALIVE_DEFAULT);
-
bool connect ( IPAddress ip, uint16_t port = 1883, bool cleanSession = true, uint16_t keepalive_sec = MQTT_KEEPALIVE_DEFAULT); Establishes an open connection with the specified MQTT broker.
-
The server will treat a subscription as non-durable keepalive_sec: This value defines the maximum interval (in seconds) between messages being sent or received. Setting a value here ensures that at least one message is sent between the client and the broker within every 'keep alive' period. If no data was sent within 'keepalive_sec' seconds, the Client will send a simple ping to the broker to keep the connection alive. Setting this value to '0' disables the keep alive feature.
-
If set to false (0) both the client and server will maintain state across restarts of the client, the server and the connection. As state is maintained: Message delivery will be reliable meeting the specified QOS even if the client, server or connection are restarted. The server will treat a subscription as durable. If set to true (1) the client and server will not maintain state across restarts of the client, the server or the connection.
-
Returns: 'True' (1) if the publish was successful, otherwise 'false' (0) if an error occured (check .errno, .errstr, etc.). bool subscribe ( const char* topicFilter, uint8_t qos, messageHandler mh); Subscribes to a specific topic, using a callback mechanism to alert you when new data is available on the specific topicFilter. Parameters: topicFilter: The topic name or topic 'filter' to subscribe to.
-
/**************************************************************************/ /*! @brief MQTT subscribe event callback handler @param @param topic message The topic causing this callback to fire The new value associated with 'topic' @note 'topic' and 'message' are UTF8Strings (byte array), which means they are not null-terminated like C-style strings. You can access its data and len using .data & .len, although there is also a Serial.print override to handle UTF8String data types.
-
and this message will be sent if the server/broker is unable to contact the client for a specific amount of time. This functionality isn't a mandatory part of MQTT, but can be used to detect when nodes are online and offline. When you connect, you can for example set a string like "Online" to a specific topic, and then set a last will message of "Offline" to that same topic. If the node goes offline (battery failure, disconnect, etc.
-
Disconnect Callback An optional disconnect callback is available in AdafruitMQTT. This callback handler will fire when you are disconnected from the remote MQTT broker. To use the callback, add the following function to your sketch (the function name and the contents of the function can change depending on your project requirements): void disconnect_callback(void) { Serial.println(); Serial.println("-----------------------------"); Serial.println("DISCONNECTED FROM MQTT BROKER"); Serial.
-
* and subscribe to TOPIC_SUBSCRIBE (defined below). * * - When a message is received, it will echo back to TOPIC_ECHO * - If the received message is "stop", we will * unsubscribe from TOPIC_SUBSCRIBE and you won't be able to * echo content back to the broker any longer. * * Note: TOPIC_SUBSCRIBE and TOPIC_ECHO must not be the same topic! * Ex. They must not be "adafruit/+" and "adafruit/echo", since this will * cause an infinite loop (received -> echo -> received -> ....
-
Serial.println("DISCONNECTED FROM MQTT BROKER"); Serial.println("-----------------------------"); Serial.println(); } /**************************************************************************/ /*! @brief The setup function runs once when the board comes out of reset */ /**************************************************************************/ void setup() { Serial.begin(115200); // Wait for the USB serial port to connect. Needed for native USB port only while (!Serial) delay(1); Serial.
-
} Serial.println("OK"); Serial.print("Subscribing to " TOPIC_SUBSCRIBE " ... "); mqtt.subscribe(TOPIC_SUBSCRIBE, MQTT_QOS_AT_MOST_ONCE, subscribed_callback); // Will halted if an error occurs Serial.
-
{ // Attempt to connect to an AP Serial.print("Attempting to connect to: "); Serial.println(WLAN_SSID); if ( Feather.connect(WLAN_SSID, WLAN_PASS) ) { Serial.println("Connected!"); } else { Serial.printf("Failed! %s (%d)", Feather.errstr(), Feather.errno()); Serial.println(); } Serial.println(); return Feather.connected(); } © Adafruit Industries https://learn.adafruit.
-
AdafruitMQTTTopic AdafruitMQTT includes an OPTIONAL helper class called AdafruitMQTTTopic that can be used to publish data to a single topic on an MQTT broker. This helper class inherits from Print (https://adafru.it/lFk), which allows you to write data to MQTT topics similarly to how you would write data to the 'Serial Monitor', using .print statements. See 'MQTT/MqttTopicClass' in the examples folder for an example of how to use AdafruitMQTTTopic.
-
The default value for 'retain' is false, unless it is modified using this function. Parameters: on: Whether or not the published message should be 'retained' by the MQTT broker. Sending a message with the this set to 'false' (0) will clear any previously retained message from the broker.
-
/**************************************************************************/ /*! @brief MQTT subscribe event callback handler @param @param topic message The topic causing this callback to fire The new value associated with 'topic' @note 'topic' and 'message' are UTF8Strings (byte array), which means they are not null-terminated like C-style strings. You can access its data and len using .data & .len, although there is also a Serial.print override to handle UTF8String data types.
-
int number_of_days = 7; char* place = "somewhere"; pub.print(number_of_days); pub.print(" days since something happened "); pub.print(place); You can work around this '1 print = 1 publication' restriction by using the printf function, as shown in the example below: int number_of_days = 7; char* place = "somewhere"; pub.
-
* - Port 1883 : MQTT, unencrypted * - Port 8883 : MQTT, encrypted (TLS) * * Note: may You need an MQTT desktop client such as * - The lightweight Java client included in this repo: org.eclipse.paho.mqtt.utility-1.0.0.jar or * - A full desktop client like MQTT.fx https://learn.adafruit.com/desktop-mqtt-client-for-adafruit-io/installing-soft * * To run this demo * 1. Change WLAN_SSID/WLAN_PASS * 2. Decide whether you want to use TLS/SSL or not (USE_TLS) * 3.
-
Feather.printNetwork(); // Tell the MQTT client to auto print error codes and halt on errors mqtt.err_actions(true, true); // Set ClientID if defined #ifdef CLIENTID mqtt.clientID(CLIENTID); #endif // Last will must be set before connecting since it is part of the connection data mqtt.will(TOPIC, WILL_MESSAGE, MQTT_QOS_AT_LEAST_ONCE); // Connect to broker Serial.printf("Connecting to " BROKER_HOST " port %d ...
-
} } } /**************************************************************************/ /*! @brief MQTT subscribe event callback handler @param @param topic message The topic causing this callback to fire The new value associated with 'topic' @note 'topic' and 'message' are UTF8Strings (byte array), which means they are not null-terminated like C-style strings. You can access its data and len using .data & .len, although there is also a Serial.print override to handle UTF8String data types.
-
Serial.printf("Failed! %s (%d)", Feather.errstr(), Feather.errno()); Serial.println(); } Serial.println(); return Feather.connected(); } © Adafruit Industries https://learn.adafruit.
-
AdafruitAIO AdafruitAIO is a special class the inherits from AdafruitMQTT (described earlier in this learning guide). It takes the core features from AdafruitMQTT and adds some helper functions that make working with Adafruit IO (https://adafru.it/fsU) easier. If you're unfamiliar with Adafruit IO have a look at our introductory learning guide here: https://learn.adafruit.
-
MQTT_KEEPALIVE_DEFAULT) This function will attempt to connect to the Adafruit IO servers using a standard (unencrypted) connection. Parameters: cleanSession: Indicates whether the client and broker should remember 'state' across restarts and reconnects. 'State' maintenance is based on the Client ID so be sure to set a reusable value via .clientID if you set cleanSession to false!: If set to false (0) both the client and server will maintain state across restarts of the client, the server and the connection.
-
Setting a value here ensures that at least one message is sent between the client and the broker within every 'keep alive' period. If no data was sent within 'keepalive_sec' seconds, the Client will send a simple ping to the broker to keep the connection alive. Setting this value to '0' disables the keep alive feature. The default value is 60 seconds. Returns: 'True' (1) if the connection was successful, otherwise 'false' (0).
-
/**************************************************************************/ /*! @brief 'follow' event callback handler @param message The new value associated with this feed @note 'message' is a UTF8String (byte array), which means it is not null-terminated like C-style strings. You can access its data and len using .data & .len, although there is also a Serial.print override to handle UTF8String data types.
-
* It will connect to a public MQTT server (with/without TLS) * and subscribe to TOPIC_SUBSCRIBE (defined below). * * - When a message is received, it will echo back to TOPIC_ECHO * - If the received message is "stop", we will * unsubscribe from TOPIC_SUBSCRIBE and you won't be able to * echo content back to the broker any longer. * * Note: TOPIC_SUBSCRIBE and TOPIC_ECHO must not be the same topic! * Ex.
-
Serial.println(); Serial.println("-----------------------------"); Serial.println("DISCONNECTED FROM MQTT BROKER"); Serial.println("-----------------------------"); Serial.println(); } /**************************************************************************/ /*! @brief The setup function runs once when the board comes out of reset */ /**************************************************************************/ void setup() { Serial.begin(115200); // Wait for the USB serial port to connect.
-
mqtt.connect(BROKER_HOST, BROKER_PORT); } Serial.println("OK"); Serial.print("Subscribing to " TOPIC_SUBSCRIBE " ... "); mqtt.subscribe(TOPIC_SUBSCRIBE, MQTT_QOS_AT_MOST_ONCE, subscribed_callback); // Will halted if an error occurs Serial.
-
/**************************************************************************/ bool connectAP(void) { // Attempt to connect to an AP Serial.print("Attempting to connect to: "); Serial.println(WLAN_SSID); if ( Feather.connect(WLAN_SSID, WLAN_PASS) ) { Serial.println("Connected!"); } else { Serial.printf("Failed! %s (%d)", Feather.errstr(), Feather.errno()); Serial.println(); } Serial.println(); return Feather.connected(); } © Adafruit Industries https://learn.adafruit.
-
AdafruitAIOFeed AdafruitAIOFeed is an optional helper class based on AdafruitMQTTTopic. It aims to make working with feeds in Adafruit IO a bit easier, with the goal of implementing specialised classes that correspond to AIO feed types in the future. Be sure to look at the documentation for AdafruitMQTTTopic as well, since this class is a specialized version of that aimed at Adafruit IO.
-
fp: The callback handler function that will be fired when the feed changes on the AIO server. This function should have the following signature: The name of the callback handler function can be set to anything you like, although the parameters and return type must be identical. void feed_callback(UTF8String message) { Serial.println(message); } Returns: 'True' (1) if the operation was successful, otherwise 'false' (0).
-
/* This sketch connects to the Adafruit IO server at io.adafruit.com * and updates a 'PHOTOCELL_FEED' every 5 seconds. * * It also follow 'ONOFF_FEED' to receive updates from the AIO server via * the built-in follow/subscribe callback handler. * * To run this demo * 1. Change WLAN_SSID/WLAN_PASS * 2. Decide whether you want to use TLS/SSL or not (USE_TLS) * 3. Change AIO_USERNAME, AIO_KEY to match your own account details * 4. If you want, change PHOTOCELL_FEED and ONOFF_FEED to use different feeds * 5.
-
Feather.printNetwork(); // Tell the MQTT client to auto print error codes and halt on errors aio.err_actions(true, true); // Set ClientID if defined #ifdef CLIENTID aio.clientID(CLIENTID); #endif Serial.print("Connecting to io.adafruit.com ... "); if ( USE_TLS ) { aio.connectSSL(); // Will halted if an error occurs }else { aio.connect(); // Will halted if an error occurs } Serial.println("OK"); // 'Follow' the onoff feed to capture any state changes onoff.
-
/**************************************************************************/ /*! @brief Connect to defined Access Point */ /**************************************************************************/ bool connectAP(void) { // Attempt to connect to an AP Serial.print("Please wait while connecting to: '" WLAN_SSID "' ... "); if ( Feather.connect(WLAN_SSID, WLAN_PASS) ) { Serial.println("Connected!"); } else { Serial.printf("Failed! %s (%d)", Feather.errstr(), Feather.errno()); Serial.println(); } Serial.
-
AdafruitTwitter The AdafruitTwitter class requires WICED Feather Lib 0.5.5 or higher to run. The AdafruitTwitter class makes sending tweets easy via a custom Application that you can setup using this learning guide. 1. Creating a WICED Twitter Application In order to enable WICED to interact with Twitter, you first need to log in to twitter's app admin console at http://apps.twitter.com (https://adafru.
-
Then accept the license terms and click the Create your Twitter application button at the bottom of the page. This will redirect you to the main app config page, as shown below: Set the Application Permissions Click on the Permissions tab and set the appropriate permissions: © Adafruit Industries https://learn.adafruit.
-
Click the Update Settings button to save the permissions changes. Manage the Access Keys Go back to the Details tab and scroll down to the Application Settings section: Click the manage keys and access tokens link. Copy the Appropriate Key Data Make a note of the consumer key values blurred out below since you will need them in your sketch: © Adafruit Industries https://learn.adafruit.
-
Create your Access Token On the same page shown above, click the Create my access token button to give your account access to your new application: Make a note of the access token data shown blurred out below, which you will also need in your sketch: 2. Using the AdafruitTwitter Class © Adafruit Industries https://learn.adafruit.
-
Next, open the Applications/SendTweet example for WICED or create a new sketch with the following code, updating it with your access point details, as well as the Consumer and Access Tokens generated above: /********************************************************************* This is an example for our Feather WIFI modules Pick one up today in the adafruit shop! Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from
-
void setup() { Serial.begin(115200); // wait for serial port to connect. Needed for native USB port only while (!Serial) delay(1); Serial.println("Twitter Send Tweet Example\r\n"); // Print all software versions Feather.printVersions(); while ( !connectAP() ) { delay(500); // delay between each attempt } // Connected: Print network info Feather.printNetwork(); Twitter.begin(CONSUMER_KEY, CONSUMER_SECRET, TOKEN_ACCESS, TOKEN_SECRET); Twitter.err_actions(true, true); Serial.print("Sending tweet: " TWEET " ...
-
} Serial.println(); return Feather.connected(); } © Adafruit Industries https://learn.adafruit.
-
AdafruitSDEP All communication between the Arduino user code (your sketch) and the lower level WiFi stack from Broadcom happens over SDEP commands. SDEP stands for 'Simple Data Exchange Protocol', an in house protocol we use in a number of our products. This is similar to the way you would talk to an external I2C or SPI sensor via a set of pre-defined registers defined in the sensor datasheet.
-
Function Prototype: bool sdep(uint16_t cmd_id , uint16_t param_len , void const* p_param, uint16_t* p_result_len , void* p_result) Parameters: cmd_id: The 16-bit SDEP command ID param_len: The length of the p_param field containing the parameter data. Set this to '0' if no parameter is provided. p_param: A pointer to the parameter value to pass into the SDEP command handler. Set this to NULL if no parameter is provided.
-
non-zero value if any data is available. Since we know the size of the results variable, we don't need to read back the length of the response data, and we can insert NULL for 'p_result_len': int AdafruitTCP::available() { if ( _tcp_handle == 0 ) return 0; uint32_t result = 0; sdep(SDEP_CMD_TCP_AVAILABLE, 4, &_tcp_handle, NULL, &result); return result; } sdep_n This function sends an SDEP command with an array of parameter values, using a dedicated parameter array typedef called sdep_cmd_para_t.
-
This is a blocking command that only returns when the procedure succeeeds or fails. As such, we will ignore any return data from the command other than a possible SDEP error code. As such, p_results_len and p_result are both set to NULL here: bool AdafruitFeather::addProfile(char* ssid) { sdep_cmd_para_t para_arr[] = { { .len = strlen(ssid), .
-
return '0' if an error was encountered. Error Handling Functions The following functions are defined to work with any SDEP errors generated by the system: err_t errno (void) If sdep or sdep_n returned false as a return value, if means the SDEP command failed. To determine the error message, you can read the results from .errno() immediately after the .sdep or .sdep_n command, which will give you a 16-bit (uint16_t) error code.
-
// Attempt to connect to the AP if ( Feather.connect("SSID", "PASSWORD", ENC_TYPE_AUTO ) ) { int8_t rssi = Feather.RSSI(); uint32_t ipAddress = Feather.localIP(); // Do something now that you are connected to the AP! } else { // Display the error message err_t err = Feather.errno(); Serial.println("Connection Error:"); switch (err) { case ERROR_WWD_ACCESS_POINT_NOT_FOUND: // SSID wasn't found when scanning for APs Serial.
-
Client The WICED Feather supports the standard Arduino Client (https://adafru.it/lFj) interface that is used by many networking boards in the Arduino ecosystem. Adapting Client Examples Most existing Client based examples can easily be adapted to work with the WICED Feather board family if the following changes are made to the sketches: 1. Update Header Includes You will need to change the default WiFi (etc.) headers to the Adafruit versions, as shown below.
-
WICED Feather Client Code Note that at present .begin in the WICED Feather library returns a bool, not a status byte (as in the WiFi example above), so the example has been modified slightly to detect connection status via the .connected (https://adafru.it/lFn) function that is also part of the Client (https://adafru.it/lFj) interface.
-
Constants The WICED Feather library uses a handful of public constants, enums, typdefs and defines. In some situations, you will have to use these constants, enums, typedefs or defines in your own sketches, and the most common values are documented below: wl_enc_type_t This typedef (which resolves to an int32_t value) is used to indicate the security encoding mechanism used by your AP when establishing a connection. You can indicate the following values in the encoding type parameter of Feather.
-
err_t The most frequently encountered error codes are defined below: ERROR_NONE (0) This means that no error occurred and that execution completed as expected ERROR_OUT_OF_HEAP_SPACE (3) This error indicates that you have run out of heap memory in Feather Lib ERROR_NOT_CONNECTED (20) You will get this error if you try to perform an operation that requires a connection to an AP or the Internet when you aren't connected.
-
// Attempt to connect to the AP if ( Feather.connect("SSID", "PASSWORD", ENC_TYPE_AUTO ) ) { int8_t rssi = Feather.RSSI(); uint32_t ipAddress = Feather.localIP(); // Do something now that you are connected to the AP! } else { // Display the error message err_t err = Feather.errno(); Serial.println("Connection Error:"); switch (err) { case ERROR_WWD_ACCESS_POINT_NOT_FOUND: // SSID wasn't found when scanning for APs Serial.
-
© Adafruit Industries https://learn.adafruit.
-
Python Tools A set of python based tools are included as part of the WICED Feather SDK. You generally only need to use these tools in very specific circumstances, but they are listed below and then discussed in further detail elsewhere in this learning guide. On Windows, the BSP package that contains the tools folder is normally found in the %LOCALAPPDATA%\Arduino15\packages\adafruit\hardware\wiced\version folder.
-
pyresource.py This tool will recursively scan the contents of a folder, and convert any files found into ' HTTPResource ' entries that can be used with modules like the AdafruitHTTPServer (https://adafru.it/qoE). Location: /tools/pyresource/pyresource.py On Windows, the BSP package that contains the tools folder is normally found in the '%APPDATA%\Arduino15\packages\adafruit\hardware\wiced\0.6.0' folder. On OS X it can usually be found in the '~/Library/Arduino15/packages/adafruit/hardware/wiced/0.6.
-
Looking for files in 'resources' Converted 'resources/d3.min.js' to '_d3_min_js.h' Converted 'resources/favicon.ico' to 'favicon_ico.h' Converted 'resources/index.html' to 'index_html.h' Wrote resource index to 'resources.h' HTTPResource Records Looking at the example above, we can see that three static files were converted to headers and HTTPResource records ('d3.min.js', 'favicon.ico', and 'index.html').
-
#ifndef _RESOURCE_H_ #define _RESOURCE_H_ /* Auto-generated by pyresource. Do not edit this file. */ #include #include #include #include "http_common.h" "_d3_min_js.h" "favicon_ico.h" "index_html.h" /* HTTPPage collection from generated headers HTTPPage("/d3.min.js", HTTP_MIME_JAVASCRIPT, &_d3_min_js), HTTPPage("/favicon.ico", HTTP_MIME_IMAGE_MICROSOFT, &favicon_ico), HTTPPage("/index.
-
pycert.py pycert.py is a python tool that will retrieve the root certificate chain for a specific domain, converting it into a byte array and placing it in a standard C header file. This header file can then be referenced in your code, and added to the default WICED root certificate list (via Feather.addRootCA) that validates security data sent from secure domains and websites. Location: /tools/pycert/pycert.py On Windows, the BSP package that contains the tools folder is normally found in the '%APPDATA%\Ar
-
If you want to change the output filename (in case you have multiple header files to deal with), and convert two domains at the same time into a single header file, you would issue the following command: $ pycert download --output data.h google.com adafruit.com Converting PEM Files You can also use the convert command to convert a text PEM/.pem file to a C header, which is provided as a convenience since many browsers will allow you to navigate to a specific domain and export the certificate chain in .
-
feather_dfu.py WINDOWS USERS: Recent versions of the BSP include a pre-compiled version of feather_dfu for Windows. If you are using Windows as a platform, look in the 'tools/win32-x86/feather_dfu' folder for the executable file to use. This python tool is used by the Arduino IDE to perform common operations like resetting into DFU mode, updating the flash contents of the MCU, performing a factory reset, or getting some basic information about the modules.
-
$ python feather_dfu.py enter_dfu info Running this command will provide some basic information about your WICED Feather, and can be used when trying to debug issues in the support forums, etc. When you run the ' info ' command you will see results resembling the following: $ python feather_dfu.py info Feather ST32F205RGY 353231313533470E00430036 44:39:C4:EB:B9:64 0.1.0 3.5.2 0.5.0 0.5.
-
$ python feather_dfu.py reboot © Adafruit Industries https://learn.adafruit.
-
SDEP Commands SDEP commands allow the user code to communicate with the feather lib and vice versa. Normally you never need to use these commands directly (they are used by the higher level WICED Feather API), but they are documented below for advanced users and for debugging purposes.
-
SDEP_CMD_GET_UTC_TIME = 0x0603, ///< Get UTC time in seconds // TCP Commands SDEP_CMD_TCP_CONNECT SDEP_CMD_TCP_WRITE SDEP_CMD_TCP_FLUSH SDEP_CMD_TCP_READ SDEP_CMD_TCP_DISCONNECT SDEP_CMD_TCP_AVAILABLE SDEP_CMD_TCP_PEEK SDEP_CMD_TCP_STATUS SDEP_CMD_TCP_SET_CALLBACK SDEP_CMD_TCP_LISTEN SDEP_CMD_TCP_ACCEPT SDEP_CMD_TCP_PEER_INFO = = = = = = = = = = = = 0x0700, 0x0701, 0x0702, 0x0703, 0x0704, 0x0705, 0x0706, 0x0707, 0x0708, 0x0709, 0x070A, 0x070B, ///< ///< ///< ///< ///< ///< ///< ///< ///< Create TCP s
-
Generic Reset (0x0001) Causes a full system reset. An SDEP response message is sent before the system reset is performed. Command Enum: SDEP_CMD_RESET Command ID: 0x0001 Added: Codebase 0.5.0 Parameters: None. Return Code(s): ERROR_NONE if the command executed properly. Factory Reset (0x0002) Performs a factory reset of the device, resetting all config data in non-volatile memory to factory defaults, as well as erasing the Arduino user code area (leaving the bootloader and feather library intact).
-
Added: Codebase 0.5.0 Parameters: Parameter ID This optional parameter allows you to indicate the specific system information value to be returned.
-
Returns a string containing the internal name associated with the supplied 32-bit error code. Command Enum: SDEP_CMD_ERROR_STRING Command ID: 0x0006 Added: Codebase 0.5.0 Parameters: None. Error ID Indicates the specific error code to be converted to it's internal string representation. Mandatory: Yes Size: 4 bytes Type: uint32_t Response Message: If a valid error code is provided, a string representing the enum associated with that value will be returned.
-
Examples The WICED Feather board support package includes a number of examples to help you get your project up and running with a minimum of effort. Accessing the Examples (Arduino 1.6.5) At present, the BSP installation is a manual process, as described in Get the WICED BSP earlier in this guide. To access to examples contained in this BSP, you will need to use a different menu path than you normally would: Accessing the Examples (Arduino >= 1.6.8) Recent versions of the Arduino IDE (after the 1.6.
-
to your sketch will be saved to the original example file. If you need to revert back to the original example, you may need to copy the code back from the original github repo. The examples code can always be seen here: https://adafru.it/B0u https://adafru.it/B0u © Adafruit Industries https://learn.adafruit.
-
ScanNetworks This example (found in the Adafruit_WICED_Arduino/examples/WiFi folder) will scan for access points in range of the WICED Feather. Setup No particular setup is required for this sketch since it scans for available access points within range of the WICED Feather.
-
© Adafruit Industries https://learn.adafruit.
-
Ping This example (found in the Adafruit_WICED_Arduino/examples/WiFi folder) will ping the specified servers and display the ping response time(s). Setup Set your AP details using the WLAN_SSID and WLAN_PASS flags, setting them to the values used by you own access point: #define WLAN_SSID #define WLAN_PASS "YOURSSID" "YOURPASSWORD" By default the sketch will ping adafruit.com and two Google domain name servers (8.8.8.8 and 8.8.4.4).
-
specified server(s): © Adafruit Industries https://learn.adafruit.
-
GetHostByName This example (located in Adafruit_WICED_Arduino/examples/WiFi) will perform a DNS lookup based on the specified domain name or IP address. Setup Set your AP details using the WLAN_SSID and WLAN_PASS flags, setting them to the values used by you own access point: #define WLAN_SSID #define WLAN_PASS "YOUR SSID HERE" "YOUR SSID KEY HERE" Set the domain name or the IP address that you wish the resolve using the following variables: // target by hostname const char target_hostname[] = "adafruit.
-
© Adafruit Industries https://learn.adafruit.
-
HttpGetPolling This example (located in Adafruit_WICED_Arduino/examples/HTTP) will connect to an HTTP server and read the specified page using 'polling' (as opposed to using callbacks).
-
© Adafruit Industries https://learn.adafruit.
-
HttpGetCallback This example (located in Adafruit_WICED_Arduino/examples/HTTP) will connect to an HTTP server and read the specified page using 'callbacks' (as opposed to using polling).
-
© Adafruit Industries https://learn.adafruit.
-
HTTPSLargeData The example (located in the Adafruit_WICED_Arduino/examples/TLS folder) uses the AdafruitHTTP helper class and TLS to connect to a secure server and request a large file, which is then read using callbacks. It tries to calculate the throughput for the specified file, which can be 10KB, 100KB or 1MB (indicate the file you wish to use before compiling the sketch).
-
Serial Monitor icon in the upper-right of the IDE or via Tools > Serial Monitor: This will cause the WICED Feather to attempt to connect to the access point, and then make a secure (TLS based) connection and request to the Amazon S3 server for the specified file: © Adafruit Industries https://learn.adafruit.
-
Throughput The throughput example (located in the Adafruit_WICED_Arduino/examples/WiFi folder) uses AdafruitTCP to test the TCP throughput between the WICED Feather and another device running 'netcat', which simply listens for incoming TCP data on the specified port.
-
IDE: You should see the USB DFU progress as the update advances, and there will be a 'Done Uploading' message in the top left of the status bar when you are done: Testing the Sketch Wait a few seconds for the USB CDC serial interface to enumerate, and then open the Serial Monitor using either the Serial Monitor icon in the upper-right of the IDE or via Tools > Serial Monitor: This will cause the WICED Feather to attempt to connect to the access point, and then it will attempt to connect to the netcat TCP
-
button to start sending 1MB of data to netcat: This will start the throughput test, which will display the calculated KB per second from the transfer: © Adafruit Industries https://learn.adafruit.
-
FeatherOLED The FeatherOLED example (located in the Adafruit_WICED_Arduino/examples/Adafruit folder) uses the Adafruit_FeatherOLED (https://adafru.it/m3b) library to display basic information about the WICED Feather on the 128x32 I2C OLED Feather Wing (http://adafru.it/2900).
-
Enabling the TSL2561 Luminosity Sensor (Optional) You can also enable the TSL2561 light sensor (http://adafru.it/439) to demonstrate how to work with the Adafruit_Sensor library to read sensor data on the WICED Feather. To enable the TSL2561 in your sketch, simply set the SENSOR_TSL2561_ENABLED flag to '1': #define SENSOR_TSL2561_ENABLED 1 This will cause the WICED Feather to read a new data sample from the TSL2561 every ten (10) seconds.
-
You can compile and flash your sketch to the WICED Feather using the 'Download' arrow icon at the top of the IDE: You should see the USB DFU progress as the update advances, and there will be a 'Done Uploading' message in the top left of the status bar when you are done: Testing the Sketch Unlike many of the example sketches, this example will not wait for the USB CDC Serial Port to open before executing the code.
-
FAQs I bricked my board. Can I force the device into DFU mode? Yes. There are several ways to force the device into DFU mode if you somehow lock the board up with a faulty firmware image: Quickly double-click the RESET button on the board Set the DFU Pin to GND and reset the device (keeping DFU to GND during startup) Connect to the USB CDC interface at 1200 baud and disconnect. This magic baud rate signals to the module that we want to reset into DFU mode.
-
This is probably caused by an old version of pyusb. Update your pyusb version to 1.0b or higher via the following command: $ pip install --upgrade pyusb You also need to make sure that you have the libusb runtime dll installed on your system, which you can do via this libusb installer. See the Windows Setup page for details on using this installer though. My board isn't enumerating as a USB device, or is stuck in DFU mode.
-
dfu-util 0.8 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2014 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Please report bugs to dfu-util@lists.gnumonks.org dfu-util: Invalid DFU suffix signature dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! Opening DFU capable USB device... ID 239a:0008 Run-time device DFU version 011a Claiming USB DFU Interface... Setting Alternate Setting #0 ...
-
header rail) Connect SWDIO on the STLink to SWDIO on the WICED Feather Connect GND on the STLink to GND on the WICED Feather Connect RST on the STLink to RST on the WICED Feather Power both the WICED Feather and STLink using USB To connect a Segger J-Link to the WICED Feather: Consult the Segger JLink SWD and SWO Pinout for your JLink Connect SWCLK on the JLink to SWCLK on the WICED Feather (which is a single 0.
-
feather_dfu.py in the Arduino IDE. What should I do? If you get the following error in the Arduino IDE when trying to flash a sketch, you probably don't have dfu-util installed on your system: OSError: [Errno 2] No such file or directory OSError: [Errno 2] No such file or directory Install dfu-util as detailed in this guide for your target OS. © Adafruit Industries https://learn.adafruit.
-
Downloads Related Documents STM32F205RG Product Page (https://adafru.it/m9A) STM32F205 Datasheet (https://adafru.it/m9B) EagleCAD PCB files on GitHub (https://adafru.it/oer) Fritzing object available in the Adafruit Fritzing Library (https://adafru.it/aP3) https://adafru.it/z4f https://adafru.it/z4f Schematic The schematic for the latest WICED Feather board is shown below. Click the image for a higher resolution version. Fabrication Print Dimensions in Inches © Adafruit Industries https://learn.
-
© Adafruit Industries Last Updated: 2018-08-22 03:52:40 PM UTC Page 202 of 202