Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
resources:eval:user-guides:eval-adicup3029:reference_designs:demo_adxl362 [31 May 2017 10:46] – [Project Structure] Stefan Poparesources:eval:user-guides:eval-adicup3029:reference_designs:demo_adxl362 [08 Mar 2021 07:21] (current) – [Obtaining the Source Code] adding in .Hex files Zuedmar Arceo
Line 2: Line 2:
  
 The **ADuCM3029_demo_esp8266** is a Wi-Fi demo project for the **EVAL-ADICUP3029** base board with additional **EVAL-ADXL362-ARDZ** shield, created using the Analog Devices Cross Core Embedded Studio. The **ADuCM3029_demo_esp8266** is a Wi-Fi demo project for the **EVAL-ADICUP3029** base board with additional **EVAL-ADXL362-ARDZ** shield, created using the Analog Devices Cross Core Embedded Studio.
 +
 +<note important>This documentation is to be used with the source code hosted on **Github**. The link is available in the **Obtaining the Source Code** section. </note>
  
 ===== General Description/Overview ===== ===== General Description/Overview =====
Line 10: Line 12:
  
 Also, in order to fully make use of the IOT capability, **MQTT** messaging protocol is used as it is extremely simple and lightweight. Also, in order to fully make use of the IOT capability, **MQTT** messaging protocol is used as it is extremely simple and lightweight.
 +
 +===== Demo Requirements  =====
 +
 +The following is a list of items needed in order to replicate this demo.
 +  * Hardware
 +    * EVAL-ADICUP3029
 +    * EVAL-ADXL362-ARDZ
 +    * Mirco USB to USB cable
 +    * PC or Laptop with a USB port
 +  * Software
 +    * ADuCM3029_demo_adxl362 software
 +    * CrossCore Embedded Studio (2.6.0 or higher)
 +    * ADuCM302x DFP (2.0.0 or higher)
 +    * ADICUP3029 BSP (1.1.0 or higher)
 +    * Mosquitto Broker
  
 ===== Setting up the Hardware ===== ===== Setting up the Hardware =====
  
-   - Move the **S2 switch** to the **WiFi** position{{ :resources:eval:user-guides:eval-adicup3029:reference_designs:adicup3029_switch.png?nolink |}} +   - Move the **S2 switch** to the **WiFi** position on the **EVAL-ADICUP3029**. {{ :resources:eval:user-guides:eval-adicup3029:reference_designs:adicup3029_switch.png?nolink |}} 
-   Plug the **ESP8266** in the **P1** connector: {{ :resources:eval:user-guides:eval-adicup3029:reference_designs:adicup3029_esp8266.png?nolink |}} +   The ESP8266 Enable Pin needs to be tied directly to 3.3V or pulled high to the GPIO via a 10K ohm resistor.  Because this is not currently on the Rev B or Rev C version of the ADICUP3029, you will need to solder a small fly wire from the 3.3V pin to the enable pin.\\ {{:resources:eval:user-guides:eval-adicup3029:reference_designs:reference_design_esp8266_hw_mod_back.png?400 |}}{{:resources:eval:user-guides:eval-adicup3029:reference_designs:reference_design_esp8266_hw_mod_front.png?385 |}}\\ \\ \\ \\ \\ \\ \\ \\ \\ \\  
-   - Plug the **EVAL-ADXL362-ARDZ** shield in the **EVAL-ADICUP3029** base board{{ :resources:eval:user-guides:eval-adicup3029:reference_designs:img_20170530_121613444_hdr.jpg?nolink |}}+   - Plug the **ESP8266** in the **P1** connector on the **EVAL-ADICUP3029**. 
 +   - Plug the **EVAL-ADXL362-ARDZ** shield in the **EVAL-ADICUP3029** base board{{ :resources:eval:user-guides:eval-adicup3029:reference_designs:reference_design_adicup3029_esp8266_adxl362_hw_mod_combo.png?800 |}}
    - Plug the USB cable    - Plug the USB cable
  
-===== Configuring the Software =====+===== Obtaining the Software =====
  
-This example uses the [[https://mosquitto.org |Eclipse Mosquitto]] which is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 3.and 3.1.1. MQTT provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for "Internet of Things" messaging such as with low power sensors or mobile devices such as phonesembedded computers or microcontrollers.+There are two basic ways to program the ADICUP3029 with the software for the ESP8266. 
 +  - Dragging and Dropping the .Hex to the Daplink drive 
 +  - BuildingCompiling, and Debugging using CCES
  
-The program connects to a WiFi network and to a TCP MQTT broker. After receiving the //SUBACK// confirmation from the server, the program enters an infinite loop where it waits for an ADXL-362 interrupt which is triggered when the acceleration on any axes is greater than **50 mG**. Afterwards, the program publishes the x, y, z readings on **//adxl//** topic. A subscriber to this topic can view this information.  +Using the drag and drop method, the software is going to be a version that Analog Devices creates for testing and evaluation purposes.  This is the EASIEST way to get started with the reference design
-  - [[https://mosquitto.org/download/ |Download mosquitto]]  +
-  - Double click the downloaded .exe file +
-  - Make sure [[http://slproweb.com/products/Win32OpenSSL.html |OpenSSL]]  and [[ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/dll/x86/ |pthreads ]] are installed before you continue +
-  - Click next and finish the installation +
-  - If everything is now in place, you should be able to run mosquitto. Open Command Prompt and navigate to the folder where mosquitto is installedThe default location is C:\Program Files (x86)\mosquitto +
-  - Type mosquitto.exe -v to start the broker in verbose mode:{{ :resources:eval:user-guides:eval-adicup3029:reference_designs:mosquitto_exe_v.png?nolink |}} +
-  - The mosquitto broker is now running locally and has the same IP as your machine and by default runs on port 1883. Open a new Command Prompt and type **ipconfig** to get your local IP address +
-  - In the ESP8266.h header file you need to configure the following parameters: **SSID** - //Service set identifier, which is the name of the WiFi network to connect the ESP8266//, **PASS** - //WiFi network password//, **MQTT_SERVER** - //IP of the mosquitto broker from the previous step//, **PORT** - //by default is 1883// +
-===== Outputting Data =====+
  
-  - You are now ready to run the program. If everything works fine, in the CrossCore Embedded Studio console you should see: {{ :resources:eval:user-guides:eval-adicup3029:reference_designs:esp_running_ok.png?nolink |}} +Importing the project into CrossCore is going to allow you to change parameters and customize the software to fit your needsbut will be bit more advanced and will require you to download the CrossCore toolchain.  
-  - The program has connected to the local WiFi network, to the TCP mosquitto brokersubscribed to //subtopic// an received //SUBACK// as confirmation from the broker. +
-  - The program will publish x, y, z data on the **//adxl//** topic. In order to view this information, we can use mosquitto_sub and subscribe to the **//adxl//** topic. +
-  - Open another Command Prompt and navigate to the folder where mosquitto is installed and type **mosquitto_sub -t adxl**: {{ :resources:eval:user-guides:eval-adicup3029:reference_designs:adxl_sub.png?nolink |}} +
-  - At each ADXL-362 movement, an interrupt is triggered and as a result, the x, y, z information is published. In the console **//publishing sensor reading//** message is displayed, while in the mosquitto_sub cmd window you should see the values of x, y, z axis:  {{ :resources:eval:user-guides:eval-adicup3029:reference_designs:mosquitto_sub_adxl.png?nolink |}} {{ :resources:eval:user-guides:eval-adicup3029:reference_designs:console_publish_reading.png?nolink | +
-}} +
-===== Obtaining the Source Code ===== +
- +
-We recommend not opening the project directly, but rather import it into CrossCore Embedded Studios and make a local copy in your workspace. +
  
-The source code and include files of the **AduCM3029_demo_esp8266** can be found here:+The software for the **ADuCM3029_demo_esp8266** can be found here:
  
 <WRAP round 80% download> <WRAP round 80% download>
 +Prebuilt ESP8266 Hex File
 +  * [[https://github.com/analogdevicesinc/EVAL-ADICUP3029/releases/download/Latest/ADuCM3029_demo_esp8266_.hex| AduCM3029_demo_esp8266.Hex]]
 +Complete ESP8266 Source Files
 +  * [[https://github.com/analogdevicesinc/EVAL-ADICUP3029/tree/master/projects/ADuCM3029_demo_esp8266| AduCM3029_demo_esp8266 Source Code]]
 + 
 +</WRAP>
  
-[[https://github.com/analogdevicesinc/EVAL-ADICUP3029/tree/master/projects/ADuCM3029_demo_esp8266| AduCM3029_demo_esp8266 at Github]]+<WRAP center round info 80%> 
 +For more information on importing, debugging, or other tools related questions, please see the [[/resources/eval/user-guides/eval-adicup3029/tools/cces_user_guide |tools user guide.]]  
 +</WRAP> 
 + 
 +===== Configuring the Software (parameters.h) ===== 
 + 
 +  * ** Accelerometer scan interval** - how often to update sensor information. Set the // SCAN_SENSOR_TIME // parameter (//ADXL362.h//):  
 + 
 +<code> 
 +#define SCAN_SENSOR_TIME       500      // msecs 
 +</code> 
 + 
 +  * ** Sensor activity and inactivity thresholds** - //ACCEL_CFG_ACT_TRESH// and //ACCEL_CFG_INACT_TRESH// paramaters used to determine at which acceleration values the sensor can react at sleep/wake-up commands:
    
 +<code>
 +#define ACCEL_CFG_ACT_TRESH    50      // msecs
 +#define ACCEL_CFG_INACT_TRESH  50      // msecs
 +</code>
 +
 +  * ** Sensor activity and inactivity time** - //ACCEL_CFG_ACT_TIMER// and //ACCEL_CFG_INACT_TIMER// paramaters used to determine sleep/wake-up intervals: 
 +
 +<code>
 +#define ACCEL_CFG_ACT_TIMER   100      // msecs
 +#define ACCEL_CFG_INACT_TIMER 10       // msecs
 +</code>
 +
 +  * **Network parameters** Here you should set your Wi-Fi connection and MQTT information: 
 +
 +<code>
 +#define WIFI_SSID       "****" 
 +#define WIFI_PASS       "****" 
 +#define SERVER_ADDR "****" 
 +</code>
 +
 +===== Using an MQTT Broker =====
 +
 +The program connects to a WiFi network and to a TCP MQTT broker. After receiving the //SUBACK// confirmation from the server, the program enters an infinite loop where it waits for an ADXL-362 interrupt which is triggered when the acceleration on any axes is greater than **50 mG**. Afterwards, the program publishes the x, y, z readings on **//adxl//** topic. A subscriber to this topic can view this information.
 +
 +==== Installing the Mosquitto Broker ====
 +
 +This example uses the [[https://mosquitto.org |Eclipse Mosquitto]] which is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 3.1 and 3.1.1. However, the user is free to use his favorite MQTT broker with minimal changes. MQTT provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for "Internet of Things" messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers.
 +
 +
 +<WRAP center round help 60%>
 +Alternatively, there is an additional step-by-step procedure written which can be used in combination with the steps outlined below.  The combination of both procedures should be enough to get most PC/laptops working.[[https://sivatechworld.wordpress.com/2015/06/11/step-by-step-installing-and-configuring-mosquitto-with-windows-7/ | Installing and Configuring Mosquitto ]]
 +
 </WRAP> </WRAP>
  
 +  - [[https://mosquitto.org/download/ |Download mosquitto]] 
 +  - Double click the downloaded .exe file, and install the Mosquitto program
 +  - During the install, Mosquitto will ask you to make sure you have 2 other programs installed.  
 +  - Click the links within the Windows install wizard **BEFORE** completing the Mosquitto install.
 +      - [[http://slproweb.com/products/Win32OpenSSL.html |OpenSSL]]
 +      - [[ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/dll/x86/ |pthreads ]]
 +      - Refer to pictures outlined in the additional [[https://sivatechworld.wordpress.com/2015/06/11/step-by-step-installing-and-configuring-mosquitto-with-windows-7|step by step instructions.]]
 +  - Make sure these additional programs are installed before you continue
 +  - Click next and finish the installation.
 +      - You may run into an issue that says "VCRUNTIME140.dll is missing.  In order to proceed you must first have this installed.{{ :resources:eval:user-guides:eval-adicup3029:reference_designs:reference_design_vcruntime_dll_missing.png?600 |}}
 +      - After looking around, I found a great website to download the DLL files from, as well as a great video that shows you have to fix the issue, and it did work for me.  //Please note, that this solution is **NOT** affiliated with Analog Devices, and Analog Devices assumes no responsibility for any problems or damages occurred during this process. //
 +      - [[https://www.youtube.com/watch?v=-R3LuYNQf98| How to fix VCRUNTIME140.DLL Missing Video ]]
 +      - [[http://www.sts-tutorial.com/sites/downloadCenter.php?vcruntime140| VCRUNTIME140.DLL Download ]]
 +      - Re-Run the Mosquitto.exe file, inorder to complete the installation process.
 +
 +==== Setting up Mosquitto to Receive MQTT Data ==== 
 +
 +  - With Mosquitto and other software properly installed, you should be able to run mosquitto. Open a Command Prompt and navigate to the folder where mosquitto is installed. The default location is C:\Program Files (x86)\mosquitto
 +  - Type mosquitto.exe -v to start the broker in verbose mode.  Copy this code block into your command line editor to navigate to the folder and execute the program:<code> cd C:\Program Files (x86)\mosquitto\mosquitto.exe -v </code>  It should look like the following picture{{ :resources:eval:user-guides:eval-adicup3029:reference_designs:mosquitto_exe_v.png?nolink |}}<WRAP center round important 80%>  Make sure that your computer or laptop is connected to the same network you are going to configure in the parameters.h file.  Once you run the executable, Mosquitto assumes that you are running on that network.</WRAP>
 +  - The mosquitto broker is now running locally and has the same IP as your machine and by default runs on port 1883. Open a new Command Prompt and type **ipconfig** to get your local IP address
 +  - In the parameters.h header file you need to configure the following parameters: <code>
 +SSID = ""         //Service set identifier, name of the WiFi network to connect the ESP8266//
 +PASS = ""         //WiFi network password//
 +SERVER_ADDR = ""  //IP of the mosquitto broker from the previous step//
 +SERVER_PORT = "1883"     //by default is 1883//
 +</code>
 +  - Open a third Command Prompt and navigate to the folder where mosquitto is installed and type this command and hit the <ENTER> key:<code> cd C:\Program Files (x86)\mosquitto\mosquitto_sub -t adxl </code> This command subscribes to the topic and will display the accelerometer data.  It should look similar to the image below.{{ :resources:eval:user-guides:eval-adicup3029:reference_designs:adxl_sub.png?nolink |}}
 +
 +===== Outputting Data =====
 +
 +  - You are now ready to flash the program on the ADICUP3029 and run it. Before downloading the code, please press the **WIFI_RESET** button (**S4**) on the ADICUP3029.
 +  - If everything works fine, in the CrossCore Embedded Studio console you should see: {{ :resources:eval:user-guides:eval-adicup3029:reference_designs:esp_running_ok.png?nolink |}}
 +  - The program has connected to the local WiFi network, to the TCP mosquitto broker, subscribed to //subtopic// an received //SUBACK// as a confirmation from the broker.
 +  - The program will publish x, y, z data on the **//adxl//** topic. In order to view this information, we can use mosquitto_sub and subscribe to the **//adxl//** topic.
 +  - At each ADXL362 movement, an interrupt is triggered and as a result, the x, y, z information is published. In the console **//publishing sensor reading//** message is displayed, while in the mosquitto_sub cmd window you should see the values of x, y, z axis:  {{ :resources:eval:user-guides:eval-adicup3029:reference_designs:mosquitto_sub_adxl.png?nolink |}}
  
 ===== How to use the Tools ===== ===== How to use the Tools =====
Line 67: Line 155:
 The ADuCM3029_demo_esp8266 project use basic ARM Cortex-M C/C++ Project structure. This project contains: system initialization part - disabling watchdog, setting system clock, enabling clock for peripheral; port configuration for SPI, accelerometer sensor; ESP8266 initialization - UART and GPIO.{{ :resources:eval:user-guides:eval-adicup3029:reference_designs:proj_structure.png?nolink |}} The ADuCM3029_demo_esp8266 project use basic ARM Cortex-M C/C++ Project structure. This project contains: system initialization part - disabling watchdog, setting system clock, enabling clock for peripheral; port configuration for SPI, accelerometer sensor; ESP8266 initialization - UART and GPIO.{{ :resources:eval:user-guides:eval-adicup3029:reference_designs:proj_structure.png?nolink |}}
  
-In the src folder you will find the source and header files related to adxl362 application, ESP8266 library and MQTT library. The Communication.c/h files contain SPI and UART specific data, meanwhile the ADXL362.c/h files contain the accelerometer data. +In the srcs/app_src folder you will find the source file for the main application: 
- +  - ADuCM3029_demo_esp8266.c: is the file containing the main function 
-  - **MQTT** folder contains the library which implements the MQTT protocol. We recommend to use it as is, without modifying anything.  +  - parameters.h: is the files where configurable parameters can be modified 
-  - **ADXL362.c/h** are the files for ADXL362 accelerometer control. Here you can modify: +  noos: is directory containing linked resources from the noos repoEg. Adxl362 driver, network files and platform drivers (spi, uart
-            * ** Accelerometer scan interval** how often to update sensor information. Set the // SCAN_SENSOR_TIME // parameter - **msec** (//ADXL362.h//): <code> #define SCAN_SENSOR_TIME   500 </code> +  Mqtt client is linked as static libraryCan be found in noos/libraries/mqtt 
-            * ** Sensor activity and inactivity thresholds** - //ACT_VALUE// and //INACT_VALUE// paramaters used to determine at which acceleration values the sensor can react at sleep/wake-up commands (// ADXL362.h //): <code> #define ACT_VALUE          50  +  - To build mqtt library run the following command in the ADuCM3029_demo_esp8266 folder: <code>make libs</code>
- #define INACT_VALUE        50 </code> +
-            * ** Sensor activity and inactivity time** //ACT_TIMER// and //INACT_TIMER// paramaters used to determine sleep/wake-up intervals(// ADXL362.//): <code> #define ACT_TIMER          100 +
- #define INACT_TIMER        10 </code> +
-  - **ESP8266.c/h** is the ESP8288 Library which uses AT commands and UART to communicate with the WiFi module. Here you can and should modify:  +
-            * ** SSID, PASS and MQTT_SERVER** - replace with your specific data: <code> #define SSID           "****"  +
- #define PASS         "****"  +
- #define MQTT_SERVER "****" </code> +
- +
-// End of Document //+
  
  
 +// End of Document//
resources/eval/user-guides/eval-adicup3029/reference_designs/demo_adxl362.1496220379.txt.gz · Last modified: 31 May 2017 10:46 by Stefan Popa