13 Replies Latest reply on Jun 5, 2014 5:49 AM by ShawnA_01

    How to get started (coming from arduino)

      Hey guys, I just finished the "Quick Start Guide" and loaded up the heart rate example. I do not own a iphone or win8 machine but it showed up listed on my android phone, and when I paired it beeped accordingly.

       

      I would like to know if there are any tutorials to start a very simple with buttons and pwm (I plan to write one as I learn myself).

       

      I have working code from my arduino using a bt serial module and here is some code i would like to replicate:

       

      void setup()

      {

          // pin numbers

         pinMode(3, INPUT);

         pinMode(6, OUTPUT);

         pinMode(7, OUTPUT);

         pinMode(8, OUTPUT);

       

         Serial.begin(9600);

       

         // JY-MCU v1.08 defaults to 9600.

         btSerial.begin(9600);

         btSerial.write("AT+BAUD4");

         btSerial.write("AT+NAMEMyBTProject");

         btSerial.write("AT+PIN1234");

      }


      ******* LOOP ******

      if(btSerial.available()) {

          while(btSerial.available()) {

           ...

      **********************

       

      I just started a few mins ago, so sorry If the answer is very obvious. I figured I'd post this as I read the docs.

        • 1. Re: How to get started (coming from arduino)
          ShawnA_01

          There is a lot to read, and many example programs to browse.  The content can be intimidating... 

           

          In your training mission I recommend you browse the source code for pwm_tones.c as it doesn't do anything with the radio.

           

          Then read ~Doc/How-to-Write-WICED-Smart-Applications.pdf as your next "read".  

           

          If you're using the SDK 2.0.1 you then want to run the WICED-Smart application builder found here:

          5-29-2014 9-13-23 AM.png

           

          Note:  You may want to purchase an IOS device (ie iPad), as BLE has limited support on Android from what I've seen so far.

          1 of 1 people found this helpful
          • 2. Re: How to get started (coming from arduino)

            Thanks, I'll try more this weekend!

            • 3. Re: How to get started (coming from arduino)
              userc_6396

              BTW:

              I tried an Android phone (Galaxy S4, S3 does not seem to be working). With right App installed, I can see

              a device which seems to be the BT LE eval (it has to be a real BT LE App).

              I have not tried to pair (I am a bit surprised that pairing works - my regular BT scan does not find. I guess I cannot pair really, just see on BT LE Scan).

               

              I want to try also the audio, at least the PWM. I am just surprised that no other output is there, e.g. I2S or S/PDIF (other vendors have on BT chips). I want to send audio to this BT LE eval, listen to music on it.

              The LS1 (loudspeaker) works for me, with the PWM demo project it is generating sound. But not yet clear

              for me how to send audio from smartphone to it ...

              • 4. Re: How to get started (coming from arduino)
                userc_6396

                Just to mention:

                My Galaxy S3 works now with BLE after an OS update.

                A good demo is the hello_sensor in SDK. This one has also an Android APK which you can copy to smartphone and install. It works for me.

                It helps also to find in Google PlayStore some BLE apps, e.g. "BLE Scanner". It finds my eval board and I can "bond" (connect). Eval beeps then but nothing else (just some debug/status info to see).

                And: sometimes I had to enable GPS (depends on App you have installed, they seem to expect GPS running).

                 

                Meanwhile I like "BLE Scanner" because an App which updates RSSI frequently. I can see the signal strength.

                • 5. Re: How to get started (coming from arduino)

                  The "Wiced smart device configuration" generates alot of code . I'm sitting down and trying to get a simple blinky example to blink an LED.

                  • 6. Re: How to get started (coming from arduino)
                    MichaelF_56

                    For the blinking LED, try the Hello Sensor application.  I believe there is also help and docs for this app as well.

                    • 7. Re: How to get started (coming from arduino)
                      dmiya

                      BLE only transmits 20~bytes per 7.5ms (as fastest and iOS doesn't accept this short interval).

                      So BCM20736 doesn't have I2S nor SPDIF I think.

                       

                      Technically, around 20kbps is possible and voice can be transmitted.

                      But for music, audio quality will be worse than legacy A2DP.

                      1 of 1 people found this helpful
                      • 8. Re: How to get started (coming from arduino)
                        MichaelF_56

                        Correct.  Our BLE devices do not support I2S or SPDIF.

                        • 9. Re: How to get started (coming from arduino)
                          ArvindS_76

                          > Technically, around 20kbps is possible and voice can be transmitted.

                          With 2073x, you can achieve 80+ kbps at the GATT layer because the baseband packets use the MD bit in the header to indicate to the master that there is more data to transmit from the slave to the master (so there will be multiple transfers per connection interval - for example, 4 or even 5 packets in the 7.5mS period). Try the speed_test application in SDK 2.0.1 along with the corresponding peer app (for Windows in the application directory) and you should see throughputs much higher than 20 kbps.

                          1 of 1 people found this helpful
                          • 10. Re: How to get started (coming from arduino)

                            Hey guys, I having a hard time trying to get started. This is what my file config looks like and I hit generate code. I want to connect an LED to a GPIO and based on the recommendations I should use hello_sensor.c as an example. However, The hello_sensor project containts hello_sensor.c/h but my project generates jareddlc_blink.c, jareddlc_blink_db.c/h I am confused as to what file I should be modifying.

                             

                            from what I gathered, I should modify the following struct from hello_sensor.c:

                             

                            // Following structure defines GPIO configuration used by the application

                            const BLE_PROFILE_GPIO_CFG hello_sensor_gpio_cfg =

                            {

                                /*.gpio_pin =*/

                                {

                                    GPIO_PIN_WP,      // This need to be used to enable/disable NVRAM write protect

                                    GPIO_PIN_BUTTON,  // Button GPIO is configured to trigger either direction of interrupt

                                    GPIO_PIN_LED,    // LED GPIO, optional to provide visual effects

                                    GPIO_PIN_BATTERY, // Battery monitoring GPIO. When it is lower than particular level, it will give notification to the application

                                    GPIO_PIN_BUZZER,  // Buzzer GPIO, optional to provide audio effects

                                    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // other GPIOs are not used

                                },

                                /*.gpio_flag =*/

                                {

                                    GPIO_SETTINGS_WP,

                                    GPIO_SETTINGS_BUTTON,

                                    GPIO_SETTINGS_LED,

                                    GPIO_SETTINGS_BATTERY,

                                    GPIO_SETTINGS_BUZZER,

                                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

                                }

                            };

                             

                            However this code gets generated in my jareddlc_blink_db.c file as:

                             

                            // Following structure defines GPIO configuration used by the application

                            const BLE_PROFILE_GPIO_CFG jareddlc_blink_gpio_cfg =

                            {

                                {

                                    GPIO_PIN_WP,                               // This need to be used to enable/disable NVRAM write protect

                                    GPIO_PIN_BUTTON, GPIO_PIN_LED, -1, -1,

                                    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // Other GPIOs are not used

                                },

                                /*.gpio_flag =*/

                                {

                                    GPIO_SETTINGS_WP,

                                    GPIO_SETTINGS_BUTTON, GPIO_SETTINGS_LED, 0, 0,

                                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

                                }

                            };

                             

                             

                            Based on my Image uploaded on a different post of GPIO pin headers I want to connect my LED to pin P1 and Be able to turn it on off. I'm just very confused as to how to get started, I don't know what the execution flow is. For instance where Do I insert my functions if I want to create a while loop while. Sorry if this is extremely easy but I am missing the point, I've already read the getting started and I think I didn't encounter any of this information. If I did please let me know where. Thanks

                             

                             

                            start.jpg

                            • 11. Re: How to get started (coming from arduino)
                              dmiya

                              If you want to use P1 as LED, you need to modify GPIO_PIN_LED to 1 in gpio_cfg.

                               

                              WICED Smart doesn't have main loop.

                              You need to write your code with event driven architecture.

                              1 of 1 people found this helpful
                              • 12. Re: How to get started (coming from arduino)

                                so is it safe to assume that the gpio_cfg = {...} is from 0-15? so if i want P1 it needs to be {somethingHere, GPIO_PIN_LED, ...}

                                 

                                That is right, I remember reading about it being event driven. Does this mean, event emitting and receiving? Thanks!

                                • 13. Re: How to get started (coming from arduino)
                                  ShawnA_01

                                  For GPIO information:  The entries in gpio_cfg = {...} (which is an array of structures) can be in any order (ie they do not need to be sequential based on GPIO number).  Just make sure there is a one-to-one match for the .gpio_pin versus the .gpio_flag elements of the structure or you will have indeterminate behavior.

                                   

                                  Stated differently:  In the array, you don't have to list GPIO0 before GPIO1, although it may be more logical/readable.     Spend a few moments learning the relationship between the gpio_cfg = {...} and the platform.h file that gets used to identify which GPIO pins map to which physical pins coming out of the device.

                                   

                                  WARNING:  When looking at schematics, be aware that the Broadcom evaluation board uses the chip-on-board datasheet, not the (SPIL) module datasheet.  Make sure to use the correct datasheet for the device you are placing on your board.   Module datasheets have an 'S' at the end.

                                   


                                  For event driven:. Learn about registering for callbacks.  Their capabilities are everywhere!

                                  Examples (stolen from hello_sensor.c):

                                  bleprofile_regAppEvtHandler(BLECM_APP_EVT_LINK_UP, hello_sensor_connection_up);

                                  bleprofile_regAppEvtHandler(BLECM_APP_EVT_LINK_DOWN, hello_sensor_connection_down);

                                  bleprofile_regAppEvtHandler(BLECM_APP_EVT_ADV_TIMEOUT, hello_sensor_advertisement_stopped);

                                   

                                  There are also timers that generate interrupts.   Perhaps put a state-machine in a timer ISR to advance to the next state after a certain amount of time elapses?

                                   

                                  There are GPIO interrupts...  Perhaps put a state-machine in one of those to advance to the next state when a button is pressed.... look at pwm_tones.c for a good example.

                                   

                                   

                                  My advice:   Either learn everything you can about the sample applications, e.g. pwm_tones, hello_sensor, etc or start from scratch with the Wiced Smart Device Configuration code generator.   Don't try to merge these source files (the one you create, with the sample application) when you are first trying to learn.

                                  1 of 1 people found this helpful