Adding on GPIO channels

Hi I am a mbientlab metawear RG sensor user, I am planning on combining the sensor with 3 pressure sensors, but currently, the app we are using which is the metawear mbientlab app only has a gpio port for analog reading, we need additional 2 channels, is it possible to advise on how to add on the channels using android studios?

Comments

  • You will need to modify the timer to:
    1. Read data from 3 pins.
    2. Update the graph to display 3 lines.
    3. Expand the saveData function to save the additional data sets..
    The barometer panel does items #2 and #3 for 2 data sets.
  • hi but why modify the timer when im just adding on two more gpio channels? and how to modify??
  • The timer needs to schedule more gpio reads; right now it only schedules one read whereas in your case, you want 3.  You should read the Android Documentation about Timers and Gpio first to get a feel for what the current code is doing.
  • Do you have any videos on how to add in more GPIO ports?
  • No, we don't have any videos on this topic.

    Have you looked at the app source code yet and the documentation I linked you? If so, what specifically about the tuner, gpio, and app code is unclear to you?
  • How to make it work on android studio?? Can we have the specific steps? For example, how to input the mbientlab into android studio. Is it using the API??
    Thank you.
  • We have an Android tutorial that you can follow for a quickstart guide on using the MetaWear API.  The tutorial provides a project template for MetaWear apps which you can import into Android Studio as an existing project.

    The GPIO panel is implemented in the GpioFragment class.  As mentioned in my first post, you need to modify the code to:
    1. Read from 3 channels
    2. Display 3 lines on the graph
    3. Write 3 sets of data in the saveData function

  • ok thank you:) but sorry to disturb again but there seems to be an error with the sample code for the sample android app, because even before making any changes to the code it also cannot be built.
  • You'll have to post the error before we can help you.
  • Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:prepareDebugUnitTestDependencies, :app:mockableAndroidJar, :app:generateDebugAndroidTestSources, :app:assembleDebug]
    :app:clean
    :app:preBuild UP-TO-DATE
    :app:preDebugBuild UP-TO-DATE
    :app:checkDebugManifest
    :app:preReleaseBuild UP-TO-DATE
    :app:prepareComAndroidSupportAnimatedVectorDrawable2320Library
    :app:prepareComAndroidSupportAppcompatV72320Library
    :app:prepareComAndroidSupportDesign2320Library
    :app:prepareComAndroidSupportRecyclerviewV72320Library
    :app:prepareComAndroidSupportSupportV42320Library
    :app:prepareComAndroidSupportSupportVectorDrawable2320Library
    :app:prepareComMbientlabBletoolboxScanner020Library
    Jar found at unexpected path (sources.jar) in /Users/npstudent/.gradle/caches/modules-2/files-2.1/com.mbientlab.bletoolbox/scanner/0.2.0/dac5ea6d3c22da721cb5c42b4433f005b55e4fc9/scanner-0.2.0.aar and will be ignored. Jars should be placed inside 'jars' folder to be merged into dex. Jars that are in assets/ or res/raw/ will be copied as-is.
    :app:prepareComMbientlabMetawear259Library
    Jar found at unexpected path (sources.jar) in /Users/npstudent/.gradle/caches/modules-2/files-2.1/com.mbientlab/metawear/2.5.9/ade8bbcadcda41e5f4f12cf71a2cc4bdf09feb4e/metawear-2.5.9.aar and will be ignored. Jars should be placed inside 'jars' folder to be merged into dex. Jars that are in assets/ or res/raw/ will be copied as-is.
    :app:prepareDebugDependencies
    :app:compileDebugAidl
    :app:compileDebugRenderscript
    :app:generateDebugBuildConfig
    :app:mergeDebugShaders
    :app:compileDebugShaders
    :app:generateDebugAssets
    :app:mergeDebugAssets
    :app:generateDebugResValues UP-TO-DATE
    :app:generateDebugResources
    :app:mergeDebugResources
    :app:processDebugManifest
    :app:processDebugResources
    :app:generateDebugSources
    :app:preDebugUnitTestBuild UP-TO-DATE
    :app:prepareDebugUnitTestDependencies
    :app:mockableAndroidJar UP-TO-DATE
    :app:preDebugAndroidTestBuild UP-TO-DATE
    :app:prepareDebugAndroidTestDependencies
    :app:compileDebugAndroidTestAidl
    :app:processDebugAndroidTestManifest
    :app:compileDebugAndroidTestRenderscript
    :app:generateDebugAndroidTestBuildConfig
    :app:mergeDebugAndroidTestShaders
    :app:compileDebugAndroidTestShaders
    :app:generateDebugAndroidTestAssets
    :app:mergeDebugAndroidTestAssets
    :app:generateDebugAndroidTestResValues UP-TO-DATE
    :app:generateDebugAndroidTestResources
    :app:mergeDebugAndroidTestResources
    :app:processDebugAndroidTestResources
    :app:generateDebugAndroidTestSources
    :app:incrementalDebugJavaCompilationSafeguard
    :app:compileDebugJavaWithJavac
    :app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
    /Users/npstudent/Desktop/SCHOOL/FYP/Metawear-SampleAndroidApp(reference)/app/src/main/java/com/mbientlab/metawear/app/I2cFragment.java
    Error:(51, 8) error: class I2CFragment is public, should be declared in a file named I2CFragment.java
    Note: /Users/npstudent/Desktop/SCHOOL/FYP/Metawear-SampleAndroidApp(reference)/app/src/main/java/com/mbientlab/metawear/app/NavigationActivity.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    :app:compileDebugJavaWithJavac FAILED
    Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.
    Information:BUILD FAILED
    Information:Total time: 13.468 secs
    Information:2 errors
    Information:0 warnings
    Information:See complete output in console

    thank you
  • The error and the appropriate fix is given in the log output:
    /Users/npstudent/Desktop/SCHOOL/FYP/Metawear-SampleAndroidApp(reference)/app/src/main/java/com/mbientlab/metawear/app/I2cFragment.java
    Error:(51, 8) error: class I2CFragment is public, should be declared in a file named I2CFragment.java

    You need to rename the file to I2CFragment.java to match the class name. It appears that I have mixed the cases when naming the file due to Window's case-insensitive file system.
  • ok thank you so much for the help before. Is it ok for you to advice me on which part of the codes i should change so that i can just add on 2 more gpio ports??

  • Please see my earlier post regarding a general overview on what you need to do.  Alternatively, it may be easier to create your own SensorFragment subclass, in the same way done by the BarometerFragment class, and simply having the app configure your GPIO pins for you rather than be manually configured by the user as with the current GPIO fragment.
  • so it is easier to do up a new code instead of changing it directly from the gpiofragment codes?

  • That depends on what you're most comfortable with.  If you're not sure, then stick with the original idea of modifying the gpio code.  
  • hi, 
    which part of the barometer fragment to focus on that is related to what we are planning to do. As in which part of the coding can we reference from to update the graph to display 3 lines and expand the saveData function to save additional data sets?? Will it be possible if you take screenshots of it??
    thank you so much.

  • The entire class is relevant for what you want to do.
This discussion has been closed.