Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Getting Sensor values into vector from callback function MATLAB

Featured Replies

Geschrieben

Hello,

 

I am using Ambient Light Bricklet(V2) with MatLab. I would like to know how to get the vector data of sensor values from callback  function. Because, I want to plot this data with other sensors(Temperature and Pressure).

 

 

function matlab_example_callback()    
import com.tinkerforge.IPConnection; 
import com.tinkerforge.BrickletAmbientLightV2; 
HOST = 'localhost'; PORT = 4223; UID = 'XYZ'; 
ipcon = IPConnection(); 
al = handle(BrickletAmbientLightV2(UID, ipcon), 'CallbackProperties');  ipcon.connect(HOST, PORT); 
set(al, 'IlluminanceCallback', @(h, e) cb_illuminance(e)); al.setIlluminanceCallbackPeriod(1000); 
input('Press key to exit\n', 's'); 
ipcon.disconnect(); 
end 
function cb_illuminance(e) 
fprintf('Illuminance: %g Lux\n', e.illuminance/100.0); 
end

  • 1 year later...
Geschrieben

Is this topic solved or documented? I'm struggling with exactly this.

 

How do I get the data from the callback function back to the main function in MATLAB? I like to write all accelerations into an array while the callback function is active. After the sensors stopped sending data, I like to run some statistics on the entire data stream.

 

% Register 16-bit continuous acceleration callback to function cb_continuous_acceleration
    set(a, 'ContinuousAcceleration16BitCallback', @(h, e) cb_continuous_acceleration(e));

 

Within the callback, I can get access to the sensor data using the "e" object. However, how do I get the data back to the main function?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.