Table of Contents

Advertisement

Quick Links

Yocto-RangeFinder, User's guide

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Yocto-RangeFinder and is the answer not in the manual?

Questions and answers

Summary of Contents for Yoctopuce Yocto-RangeFinder

  • Page 1 Yocto-RangeFinder, User's guide...
  • Page 3: Table Of Contents

    5.2. Moving the sensor away ..................... 5.3. USB power distribution ....................... 6. Programming, general concepts ................6.1. Programming paradigm ...................... 6.2. The Yocto-RangeFinder module ..................6.3. Module control interface ..................... 6.4. RangeFinder function interface ................... 6.5. LightSensor function interface ....................
  • Page 4 11.3. Error handling ........................12. Using Yocto-RangeFinder with Visual Basic .NET ........12.1. Installation ......................... 12.2. Using the Yoctopuce API in a Visual Basic project ............12.3. Control of the RangeFinder function ................. 12.4. Control of the module part ....................
  • Page 5 14.4. Error handling ........................15. Using the Yocto-RangeFinder with Python ............15.1. Source files ........................15.2. Dynamic library ......................... 15.3. Control of the RangeFinder function ................. 15.4. Control of the module part ....................15.5. Error handling ........................16. Using the Yocto-RangeFinder with Java .............
  • Page 6 22.2. Linux and USB ........................ 22.3. ARM Platforms: HF and EL ..................... 22.4. Powered module but invisible for the OS ................ 22.5. Another process named xxx is already using yAPI ............22.6. Disconnections, erratic behavior ..................22.7. Damaged device ......................23.
  • Page 7: Introduction

    1. Introduction The Yocto-RangeFinder is a 58x20mm module enabling you to detect the presence of objects up to one or two meters away depending on conditions, and to evaluate the distance of the closest object. This module is based on a "ToF" (Time of Light) technology. The sensor emits laser pulses and measures the time they take to come back to the sensor after reflection against an obstacle.
  • Page 8: Safety Information

    1. Introduction 1.1. Safety Information Caution: The Yocto-RangeFinder is not certified for use in hazardous locations, explosive environments, or life-threatening applications. Caution: The Yocto-RangeFinder is not certified for use in medical environments or life-support applications. www.yoctopuce.com...
  • Page 9: Presentation

    All Yocto-modules share a number of common functionalities. USB connector Yoctopuce modules all come with a micro-B USB socket. The corresponding cables are not the most common, but the sockets are the smallest available. Warning: the USB connector is simply soldered in surface and can be pulled out if the USB plug acts as a lever.
  • Page 10: Specific Elements

    Serial number Each Yocto-module has a unique serial number assigned to it at the factory. For Yocto-RangeFinder modules, this number starts with YRNGFND1. The module can be software driven using this serial number. The serial number cannot be modified.
  • Page 11: Optional Accessories

    Micro-USB hub If you intend to put several Yoctopuce modules in a very small space, you can connect them directly to a micro-USB hub. Yoctopuce builds a USB hub particularly small for this purpose (down to 20mmx36mm), on which you can directly solder a USB cable instead of using a USB plug. For more details, see the micro-USB hub information sheet.
  • Page 12 You can install your Yocto-RangeFinder in an optional enclosure Picoflex connectors and flexible ribbon cable If you intend to move the sensor away from the Yocto-RangeFinder module using a pluggable cable, you will need 4-wire ribbon cable of 1.27mm pitch, and Picoflex connectors.
  • Page 13: Working Principle And Limitations

    3. Working principle and limitations The Yocto-RangeFinder emits laser pulses and measures the time that they take to come back to the sensor after their reflection against an obstacle. Time intervals for such a measure are so short that the sensor uses indirect physical principles to evaluate them. Therefore, a number of external perturbations can hinder the measure.
  • Page 14: Working Modes

    The next section describes using hardware calibration procedures. 3.6. Hardware calibration procedures Calibration procedures described in the following paragraphs are specific to the VL53L0CXV0DH/1 sensor in the Yocto-RangeFinder and act directly on its detection principle. You must not mistake www.yoctopuce.com...
  • Page 15 3. Working principle and limitations them with software calibration which you can perform a posteriori on the measures of all Yoctopuce sensors. Calibration for temperature variations To ensure proper operation of the sensor, you must run an automatic calibration process when the temperature varies of more than 8°C.
  • Page 16 For the result of calibration to be kept after the module restarts, you must save the computed parameters in the Yocto-RangeFinder flash memory. To do so, you must call the module method.
  • Page 17 3. Working principle and limitations To check the current measure: YRangeFinder any get_currentValue And to save the current calibration in the module flash memory, add -s in any command, for example: YRangeFinder -s any get_currentValue www.yoctopuce.com...
  • Page 18 www.yoctopuce.com...
  • Page 19: First Steps

    Windows versions currently supported are: Windows XP, Windows 2003, Windows Vista, Windows 7, Windows 8 and Windows 10. Both 32 bit and 64 bit versions are supported. Yoctopuce is frequently testing its modules on Windows 7 and Windows 10.
  • Page 20: Testing Usb Connectivity

    The correct type of cable is available on the Yoctopuce shop. You must plug in your Yocto-RangeFinder module with a USB cable of type A - micro B. If you insert a USB hub between the computer and the Yocto-RangeFinder module, make sure to take into account the USB current limits.
  • Page 21: Localization

    4.4. Test of the module The first item to check is that your module is working well: click on the serial number corresponding to your module. This displays a window summarizing the properties of your Yocto-RangeFinder. Properties of the Yocto-RangeFinder module.
  • Page 22 Logical names of functions Each Yoctopuce module has a serial number and a logical name. In the same way, each function on each Yoctopuce module has a hardware name and a logical name, the latter can be freely chosen by the user.
  • Page 23: Assembly And Connections

    5. Assembly and connections This chapter provides important information regarding the use of the Yocto-RangeFinder module in real-world situations. Make sure to read it carefully before going too far into your project if you want to avoid pitfalls. 5.1. Fixing While developing your project, you can simply let the module hang at the end of its cable.
  • Page 24: Moving The Sensor Away

    5. Assembly and connections 5.2. Moving the sensor away The Yocto-RangeFinder module is designed so that you can split it into two parts, allowing you to move away the sensor from the command sub-module. You can split the module by simply breaking the circuit.
  • Page 25: Usb Power Distribution

    2000mA, it actually works in every day life, and seldom makes hardware damage. What you should remember: if you connect Yoctopuce modules through one, or more, USB hub without external power supply, you have no safe-guard and you depend entirely on your computer manufacturer attention to provide as much current as possible on the USB ports, and to detect overloads before they lead to problems or to hardware damages.
  • Page 26 www.yoctopuce.com...
  • Page 27: Programming, General Concepts

    The Yoctopuce API was designed to be at the same time simple to use and sufficiently generic for the concepts used to be valid for all the modules in the Yoctopuce range, and this in all the available programming languages. Therefore, when you have understood how to drive your Yocto- RangeFinder with your favorite programming language, learning to use another module, even with a different language, will most likely take you only a minimum of time.
  • Page 28 YSensor, it will work with all Yoctopuce sensors, even those which do no yet exist. Programmation In the Yoctopuce API, priority was put on the ease of access to the module functions by offering the possibility to make abstractions of the modules implementing them. Therefore, it is quite possible to work with a set of functions without ever knowing exactly which module are hosting them at the hardware level.
  • Page 29: The Yocto-Rangefinder Module

    6.2. The Yocto-RangeFinder module The Yocto-RangeFinder module provides one instance of the RangeFinder function, corresponding to the range finder sensor, one instance of the LightSensor function, measuring the ambiant infrared level and one instance of the Temperature function, corresponding to the temperature sensor integrated into the device.
  • Page 30: Module Control Interface

    6.3. Module control interface This interface is identical for all Yoctopuce USB modules. It can be used to control the module global parameters, and to enumerate the functions provided by each module. productName Character string containing the commercial name of the module, as set by the factory.
  • Page 31: Rangefinder Function Interface

    32bit integer variable available for user storage. 6.4. RangeFinder function interface The Yoctopuce class YRangeFinder allows you to use and configure Yoctopuce range finder sensors. It inherits from the YSensor class the core functions to read measurements, register callback functions, access the autonomous datalogger. This class adds the ability to easily perform a one-point linear calibration to compensate the effect of a glass or filter placed in front of the sensor.
  • Page 32: Lightsensor Function Interface

    Magic attribute used to trigger hardware calibration procedures. 6.5. LightSensor function interface The Yoctopuce class YLightSensor allows you to read and configure Yoctopuce light sensors. It inherits from YSensor class the core functions to read measurements, to register callback functions,...
  • Page 33 Sensor health state (zero when a current measure is available). measureType Light sensor type used in the device. The measure can either approximate the response of the human eye, focus on a specific light spectrum, depending on the capabilities of the light-sensitive cell. www.yoctopuce.com...
  • Page 34: Temperature Function Interface

    6. Programming, general concepts 6.6. Temperature function interface The Yoctopuce class YTemperature allows you to read and configure Yoctopuce temperature sensors. It inherits from YSensor class the core functions to read measurements, to register callback functions, to access the autonomous datalogger. This class adds the ability to configure some specific parameters for some sensors (connection type, temperature mapping table).
  • Page 35: Datalogger Function Interface

    Magic attribute used to setup physical sensor parameters. 6.7. DataLogger function interface Yoctopuce sensors include a non-volatile memory capable of storing ongoing measured data automatically, without requiring a permanent connection to a computer. The DataLogger function controls the global parameters of the internal data logger.
  • Page 36: What Interface: Native, Dll Or Service

    The application uses the DLL to natively control the locally connected module Control by service Some languages do simply not allow you to easily gain access to the hardware layers of the machine. It is the case for Javascript, for instance. To deal with this case, Yoctopuce provides a www.yoctopuce.com...
  • Page 37 Whatever the selected programming language and the control paradigm used, programming itself stays strictly identical. From one language to another, functions bear exactly the same name, and have the same parameters. The only differences are linked to the constraints of the languages themselves. www.yoctopuce.com/EN/virtualhub.php www.yoctopuce.com...
  • Page 38: Programming, Where To Start

    At this point of the user's guide, you should know the main theoretical points of your Yocto- RangeFinder. It is now time to practice. You must download the Yoctopuce library for your favorite programming language from the Yoctopuce web site .
  • Page 39: Using The Yocto-Rangefinder In Command Line

    7. Using the Yocto-RangeFinder in command line When you want to perform a punctual operation on your Yocto-RangeFinder, such as reading a value, assigning a logical name, and so on, you can obviously use the Virtual Hub, but there is a simpler, faster, and more efficient method: the command line API.
  • Page 40: Control Of The Rangefinder Function

    This example uses the "any" target to indicate that we want to work on the first RangeFinder function found among all those available on the connected Yoctopuce modules when running. This prevents you from having to know the exact names of your function and of your module.
  • Page 41: Limitations

    7. Using the Yocto-RangeFinder in command line You can also use the following command to obtain an even more detailed list of the connected modules: C:\>YModule describe Each property of the module can be obtained thanks to a command of the...
  • Page 42 www.yoctopuce.com...
  • Page 43: Using Yocto-Rangefinder With Javascript / Ecmascript

    EcmaScript 2017 to differentiate it from the previous Library for JavaScript, now deprecated in favor of this new version. This library provides access to Yoctopuce devices for modern JavaScript engines. It can be used within a browser as well as with Node.js. The library will automatically detect upon initialization whether the runtime environment is a browser or a Node.js virtual machine, and use the most...
  • Page 44: Using Yoctopuce Library For Javascript / Ecmascript 2017

    JavaScript is one of those languages which do not generally allow you to directly access the hardware layers of your computer. Therefore the library can only be used to access network-enabled devices (connected through a YoctoHub), or USB devices accessible through Yoctopuce TCP/IP to USB gateway, named VirtualHub.
  • Page 45 For HTML examples, it is even simpler: there is nothing to install. Each example is a single HTML file that you can open in a browser to try it. In this context, loading the Yoctopuce library is no different from any standard HTML script include tag.
  • Page 46: Control Of The Rangefinder Function

    You can also rewrite this last asynchronous call as: myModule.get_syncProxy().then(logInfoProxy); 8.3. Control of the RangeFinder function A few lines of code are enough to use a Yocto-RangeFinder. Here is the skeleton of a JavaScript code snipplet to use the RangeFinder function. // For Node.js, we use function require() // For HTML, we would use <script src="...">...
  • Page 47 If your Yocto-RangeFinder is not connected on the host running the browser, replace in the example the address by the IP address of the host on which the Yocto-RangeFinder is 127.0.0.1...
  • Page 48 If you want to see how to use the library within a browser rather than with Node.js, switch to the directory example_html/Doc-GettingStarted-Yocto-RangeFinder. You will find there a single HTML file, with a JavaScript section similar to the code above, but with a few changes since it has to interact through an HTML page rather than through the JavaScript console.
  • Page 49: Control Of The Module Part

    8. Using Yocto-RangeFinder with JavaScript / EcmaScript <title>Hello World</title> <script src="../../lib/yocto_api.js"></script> <script src="../../lib/yocto_rangefinder.js"></script> <script src="../../lib/yocto_lightsensor.js"></script> <script src="../../lib/yocto_temperature.js"></script> <script> async function startDemo() { await YAPI.LogUnhandledPromiseRejections(); await YAPI.DisableExceptions(); // Setup the API to use the VirtualHub on local machine let errmsg = new YErrorMsg();...
  • Page 50 8. Using Yocto-RangeFinder with JavaScript / EcmaScript errmsg = YErrorMsg(); if(await YAPI.RegisterHub('127.0.0.1', errmsg) YAPI.SUCCESS) { console.log('Cannot contact VirtualHub on 127.0.0.1: '+errmsg.msg); return; // Select the relay to use module = YModule.FindModule(args[0]); if(await module.isOnline()) { if(args.length > 1) { if(args[1] 'ON') { await module.set_beacon(YModule.BEACON_ON);...
  • Page 51 8. Using Yocto-RangeFinder with JavaScript / EcmaScript await module.set_logicalName(newname); await module.saveToFlash(); console.log('Current name: '+await module.get_logicalName()); } else { console.log("Module not connected (check identification and USB cable)\n"); await YAPI.FreeAPI(); if(process.argv.length < 2) { console.log("usage: node demo.js <serial> [newLogicalName]"); } else { startDemo(process.argv.slice(2));...
  • Page 52: Error Handling

    The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
  • Page 53: Using Yocto-Rangefinder With Php

    VirtualHub software, and you are ready to start your first tests. You do not need to install any driver. 9.2. Control of the RangeFinder function A few lines of code are enough to use a Yocto-RangeFinder. Here is the skeleton of a PHP code snipplet to use the RangeFinder function. include('yocto_api.php');...
  • Page 54 (the standard port used by 127.0.0.1:4444 4444 Yoctopuce). You can very well modify this address, and enter the address of another machine on which the VirtualHub software is running. yFindRangeFinder function allows you to find a range finder from the serial number of the yFindRangeFinder module on which it resides and from its function name.
  • Page 55: Control Of The Module Part

    9. Using Yocto-RangeFinder with PHP <HTML> <HEAD> <TITLE>Hello World</TITLE> </HEAD> <BODY> <?php include('yocto_api.php'); include('yocto_rangefinder.php'); include('yocto_lightsensor.php'); include('yocto_temperature.php'); // Use explicit error handling rather than exceptions yDisableExceptions(); // Setup the API to use the VirtualHub on local machine (yRegisterHub('http://127.0.0.1:4444/', $errmsg) YAPI_SUCCESS) { die("Cannot contact VirtualHub on...
  • Page 56 9. Using Yocto-RangeFinder with PHP @$serial = $_GET['serial']; ($serial != '') { // Check if a specified module is available online $module = yFindModule("$serial"); if (!$module->isOnline()) { die("Module not connected (check serial and USB cable)"); } else { // or use any connected module suitable for the demo $module = yFirstModule();...
  • Page 57 9. Using Yocto-RangeFinder with PHP // Setup the API to use the VirtualHub on local machine if(yRegisterHub('http://127.0.0.1:4444/',$errmsg) YAPI_SUCCESS) { die("Cannot contact VirtualHub on 127.0.0.1"); @$serial = $_GET['serial']; ($serial != '') { // Check if a specified module is available online $module = yFindModule("$serial");...
  • Page 58: Http Callback Api And Nat Filters

    The PHP library is able to work in a specific mode called HTTP callback Yocto-API. With this mode, you can control Yoctopuce devices installed behind a NAT filter, such as a DSL router for example, and this without needing to open a port. The typical application is to control Yoctopuce devices, located on a private network, from a public web site.
  • Page 59 9. Using Yocto-RangeFinder with PHP But requests from the outside are blocked. Seeing Internet without being seen provides an enormous security advantage. However, this signifies that you cannot, a priori, set up your own web server at home to control a home automation installation from the outside.
  • Page 60 To code a web site which controls Yoctopuce modules interactively, you must create a user interface which stores in a file or in a database the actions to be performed on the Yoctopuce modules. These actions are then read and run by the control script.
  • Page 61: Error Handling

    The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
  • Page 62 9. Using Yocto-RangeFinder with PHP your program. At worst, if you display the value without testing it, it will be outside the expected bounds for the returned value. In the case of functions which do not normally return information, the return value is if everything went well, and a different error code in case of failure.
  • Page 63: Using Yocto-Rangefinder With C

    Yoctopuce libraries. 10.1. Control of the RangeFinder function A few lines of code are enough to use a Yocto-RangeFinder. Here is the skeleton of a C++ code snipplet to use the RangeFinder function.
  • Page 64 // Use rangefinder->get_currentValue(), ... Let's look at these lines in more details. yocto_api.h et yocto_rangefinder.h These two include files provide access to the functions allowing you to manage Yoctopuce modules. must always be used, is necessary to manage modules yocto_api.h yocto_rangefinder.h...
  • Page 65: Control Of The Module Part

    10. Using Yocto-RangeFinder with C++ using namespace std; static void usage(void) cout << "usage: demo <serial_number> " << endl; cout << " demo <logical_name>" << endl; cout << " demo any (use any discovered device)" << endl; now = yGetTickCount();...
  • Page 66 10. Using Yocto-RangeFinder with C++ using namespace std; static void usage(const char *exe) cout << "usage: " << exe << " <serial or logical name> [ON/OFF]" << endl; exit(1); int main(int argc, const char argv[]) string errmsg; // Setup the API to use local USB devices if(yRegisterHub("usb",...
  • Page 67 10. Using Yocto-RangeFinder with C++ exit(1); int main(int argc, const char argv[]) string errmsg; // Setup the API to use local USB devices if(yRegisterHub("usb", errmsg) YAPI_SUCCESS) { cerr << "RegisterHub error: " << errmsg << endl; return if(argc < usage(argv[0]);...
  • Page 68: Error Handling

    The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
  • Page 69 10. Using Yocto-RangeFinder with C++ • It facilitates debugging if you are looking for the cause of a problem linked to the Yoctopuce library; • It reduces the dependencies on third party components, for example in the case where you would need to recompile this project for another architecture in many years;...
  • Page 70 10. Using Yocto-RangeFinder with C++ gcc (...) -lyocto -lm -lpthread -lusb-1.0 -lstdc++ www.yoctopuce.com...
  • Page 71: Using Yocto-Rangefinder With Objective-C

    Lion. If you are still under Snow Leopard, you need to be registered as Apple developer to be able to download XCode 4.2. The Yoctopuce library is ARC compatible. You can therefore implement your projects either using the traditional retain / release method, or using the Automatic Reference Counting.
  • Page 72 There are only a few really important lines in this example. We will look at them in details. yocto_api.h et yocto_rangefinder.h These two import files provide access to the functions allowing you to manage Yoctopuce modules. must always be used, is necessary to manage modules yocto_api.h...
  • Page 73: Control Of The Module Part

    11. Using Yocto-RangeFinder with Objective-C names as well, as long as you have initialized them. Let us imagine a Yocto-RangeFinder module with serial number YRNGFND1-123456 which you have named "MyModule", and for which you have given the rangeFinder function the name "MyFunction". The following five calls are strictly equivalent, as long as "MyFunction"...
  • Page 74 11. Using Yocto-RangeFinder with Objective-C NSLog(@"upTime: sec\n", [module upTime] / 1000); NSLog(@"USB current: mA\n", [module usbCurrent]); NSLog(@"logs: %@\n", [module get_lastLogs]); } else { NSLog(@"%@ not connected (check identification and USB cable)\n", serial_or_name); [YAPI FreeAPI]; return Each property of the module can be read thanks to a method of type...
  • Page 75: Error Handling

    The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
  • Page 76 11. Using Yocto-RangeFinder with Objective-C As this latest situation is not the most desirable, the Yoctopuce library offers another possibility for error handling, allowing you to create a robust program without needing to catch exceptions at every line of code. You simply need to call the function to commute the YAPI.DisableExceptions()
  • Page 77: Using Yocto-Rangefinder With Visual Basic .Net

    Yoctopuce modules that your project is going to manage. If in doubt, select all the files. You then have the choice between simply adding these files to your project, or to add them as links (the Add button is in fact a scroll-down menu).
  • Page 78: Control Of The Rangefinder Function

    Naturally, the libraries function in a strictly identical manner if you integrate them in an application with a graphical interface. 12.3. Control of the RangeFinder function A few lines of code are enough to use a Yocto-RangeFinder. Here is the skeleton of a Visual Basic code snipplet to use the RangeFinder function. [...]...
  • Page 79 12. Using Yocto-RangeFinder with Visual Basic .NET get_currentValue method of the object returned by allows you get_currentValue() yFindRangeFinder to obtain the distance measured by the sensor, in mm or in inches depending on the sensor configuration. A real example Launch Microsoft VisualBasic and open the corresponding sample project provided in the directory Examples/Doc-GettingStarted-Yocto-RangeFinder of the Yoctopuce library.
  • Page 80: Control Of The Module Part

    12. Using Yocto-RangeFinder with Visual Basic .NET 12.4. Control of the module part Each module can be controlled in a similar manner, you can find below a simple sample program displaying the main parameters of the module and enabling you to activate the localization beacon.
  • Page 81 12. Using Yocto-RangeFinder with Visual Basic .NET Sub usage() Console.WriteLine("usage: demo <serial or logical name> <new logical name>") End Sub Sub Main() Dim argv() As String System.Environment.GetCommandLineArgs() errmsg String "" newname String YModule (argv.Length <> 3) Then usage() REM Setup the API to use local USB devices yRegisterHub("usb",...
  • Page 82: Error Handling

    The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
  • Page 83: Using Yocto-Rangefinder With C

    13.2. Using the Yoctopuce API in a Visual C# project The Visual C#.NET Yoctopuce library is composed of a DLL and of source files in Visual C#. The DLL is not a .NET DLL, but a classic DLL, written in C, which manages the low level communications with the modules .
  • Page 84: Control Of The Rangefinder Function

    Naturally, the libraries function in a strictly identical manner if you integrate them in an application with a graphical interface. 13.3. Control of the RangeFinder function A few lines of code are enough to use a Yocto-RangeFinder. Here is the skeleton of a C# code snipplet to use the RangeFinder function. [...] string errmsg ="";...
  • Page 85 13. Using Yocto-RangeFinder with C# get_currentValue method object returned get_currentValue() allows you to obtain the distance measured by the sensor, YRangeFinder.FindRangeFinder in mm or in inches depending on the sensor configuration. A real example Launch Microsoft Visual C# and open the corresponding sample project provided in the directory Examples/Doc-GettingStarted-Yocto-RangeFinder of the Yoctopuce library.
  • Page 86: Control Of The Module Part

    13. Using Yocto-RangeFinder with C# 13.4. Control of the module part Each module can be controlled in a similar manner, you can find below a simple sample program displaying the main parameters of the module and enabling you to activate the localization beacon.
  • Page 87 13. Using Yocto-RangeFinder with C# Each property of the module can be read thanks to a method of type YModule.get_xxxx() and properties which are not read-only can be modified with the help of the YModule.set_xxx() method. For more details regarding the used functions, refer to the API chapters.
  • Page 88: Error Handling

    The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
  • Page 89 13. Using Yocto-RangeFinder with C# values, which can be tested by the caller when necessary. For each function, the name of each return value in case of error is systematically documented in the library reference. The name always follows the same logic: a...
  • Page 90 www.yoctopuce.com...
  • Page 91: Using Yocto-Rangefinder With Delphi

    Delphi libraries. By default, the Yoctopuce Delphi library uses the yapi.dll DLL, all the applications you will create with Delphi must have access to this DLL. The simplest way to ensure this is to make sure yapi.dll is located in the same directory as the executable file of your application.
  • Page 92 14. Using Yocto-RangeFinder with Delphi yocto_lightSensor, yocto_temperature; Procedure Usage(); exe : string; begin exe:= ExtractFileName(paramstr(0)); WriteLn(exe+' <serial_number>'); WriteLn(exe+' <logical_name>'); WriteLn(exe+' any'); sleep(2500); halt; End; rf : TYRangeFinder; ir : TYLightSensor; tmp : TYTemperature; m : TYModule; errmsg,target : string; done : boolean;...
  • Page 93: Control Of The Module Part

    14. Using Yocto-RangeFinder with Delphi yocto_api and yocto_rangefinder These two units provide access to the functions allowing you to manage Yoctopuce modules. must always be used, is necessary to manage modules yocto_api yocto_rangefinder containing a range finder, such as Yocto-RangeFinder.
  • Page 94 14. Using Yocto-RangeFinder with Delphi Writeln('Logs Writeln(module.get_lastlogs()); Writeln(''); Writeln('r : refresh / b:beacon ON / space : beacon off'); else Writeln('Module not connected (check identification and USB cable)'); end; procedure beacon(module:Tymodule;state:integer); begin module.set_beacon(state); refresh(module); end; module : TYModule; : char;...
  • Page 95 14. Using Yocto-RangeFinder with Delphi exit; end; module := yFindModule(serial); if (not(module.isOnline)) then begin writeln('Module not connected (check identification and USB cable)'); exit; end; Writeln('Current logical name : '+module.get_logicalName()); Write('Enter new name : Readln(newname); if (not(yCheckLogicalName(newname))) then begin Writeln('invalid logical name');...
  • Page 96: Error Handling

    The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
  • Page 97: Using The Yocto-Rangefinder With Python

    Naturally, the libraries function in a strictly identical manner if you integrate them in an application with a graphical interface. 15.3. Control of the RangeFinder function A few lines of code are enough to use a Yocto-RangeFinder. Here is the skeleton of a Python code snipplet to use the RangeFinder function. http://www.python.org/download/ www.yoctopuce.com/EN/libraries.php...
  • Page 98 You can use logical names as well, as long as you have initialized them. Let us imagine a Yocto-RangeFinder module with serial number YRNGFND1-123456 which you have named "MyModule", and for which you have given the rangeFinder function the name "MyFunction".
  • Page 99: Control Of The Module Part

    15. Using the Yocto-RangeFinder with Python from yocto_temperature import usage(): scriptname = os.path.basename(sys.argv[0]) print("Usage:") print(scriptname + <serial_number>') print(scriptname + <logical_name>') print(scriptname + ' any sys.exit() die(msg): sys.exit(msg + ' (check USB cable)') errmsg = YRefParam() if len(sys.argv) < 2: usage() target = sys.argv[1]...
  • Page 100 15. Using the Yocto-RangeFinder with Python m.set_beacon(YModule.BEACON_ON) if sys.argv[2].upper() == "OFF": m.set_beacon(YModule.BEACON_OFF) print("serial: " m.get_serialNumber()) print("logical name: " m.get_logicalName()) print("luminosity: " str(m.get_luminosity())) if m.get_beacon() == YModule.BEACON_ON: print("beacon: ON") else: print("beacon: OFF") print("upTime: " str(m.get_upTime() 1000) " sec") print("USB current: "...
  • Page 101: Error Handling

    The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
  • Page 102 15. Using the Yocto-RangeFinder with Python When you work without exceptions, you can obtain an error code and an error message explaining the source of the error. You can request them from the object which returned the error, calling the methods.
  • Page 103: Using The Yocto-Rangefinder With Java

    Naturally, the libraries function in a strictly identical manner if you integrate them in an application with a graphical interface. 16.2. Control of the RangeFinder function A few lines of code are enough to use a Yocto-RangeFinder. Here is the skeleton of a Java code snippet to use the RangeFinder function. [...] // Get access to your device, connected locally on USB for instance YAPI.RegisterHub("127.0.0.1");...
  • Page 104 You can use logical names as well, as long as you have initialized them. Let us imagine a Yocto-RangeFinder module with serial number YRNGFND1-123456 which you have named "MyModule", and for which you have given the rangeFinder function the name "MyFunction".
  • Page 105: Control Of The Module Part

    16. Using the Yocto-RangeFinder with Java YRangeFinder rf; (args.length > 0) { rf = YRangeFinder.FindRangeFinder(args[0] + ".rangeFinder1"); } else { rf = YRangeFinder.FirstRangeFinder(); (rf == null) { System.out.println("No module connected (check USB cable)"); System.exit(1); if (!rf.isOnline()) { System.out.println("Module not connected (check identification and USB cable)"...
  • Page 106 16. Using the Yocto-RangeFinder with Java module = YModule.FindModule(args[0]); // use serial or logical name try { (args.length > 1) { if (args[1].equalsIgnoreCase("ON")) { module.setBeacon(YModule.BEACON_ON); } else { module.setBeacon(YModule.BEACON_OFF); System.out.println("serial: " + module.get_serialNumber()); System.out.println("logical name: " + module.get_logicalName()); System.out.println("luminosity: "...
  • Page 107: Error Handling

    When you implement a program which must interact with USB modules, you cannot disregard error handling. Inevitably, there will be a time when a user will have unplugged the device, either before running the software, or even while the software is running. The Yoctopuce library is designed to help www.yoctopuce.com...
  • Page 108 16. Using the Yocto-RangeFinder with Java you support this kind of behavior, but your code must nevertheless be conceived to interpret in the best possible way the errors indicated by the library. The simplest way to work around the problem is the one used in the short examples provided in this...
  • Page 109: Using The Yocto-Rangefinder With Android

    In an ideal world, you would only need to have a smart phone running under Android to be able to make Yoctopuce modules work. Unfortunately, it is not quite so in the real world. A machine running under Android must fulfil to a few requirements to be able to manage Yoctopuce USB modules natively.
  • Page 110: Activating The Usb Port Under Android

    The user can deny or authorize access to the device. If the user authorizes the access, the application can access the connected device as long as Yoctohubs are a plug and play way to add network connectivity to your Yoctopuce devices. more info on http:// www.yoctopuce.com/EN/products/category/extensions-and-networking...
  • Page 111 This file contains a list of USB vendorId and deviceID in decimal. The following example runs the application as soon as a Yocto-Relay or a YoctoPowerRelay is connected. You can find the vendorID and the deviceID of Yoctopuce modules in the characteristics section of the documentation.
  • Page 112: Control Of The Rangefinder Function

    17. Using the Yocto-RangeFinder with Android 17.5. Control of the RangeFinder function A few lines of code are enough to use a Yocto-RangeFinder. Here is the skeleton of a Java code snippet to use the RangeFinder function. [...] // Retrieving the object representing the module (connected here locally by USB) YAPI.EnableUSBHost(this);...
  • Page 113 17. Using the Yocto-RangeFinder with Android A real example Launch you Java environment and open the corresponding sample project provided in the directory Examples//Doc-Examples of the Yoctopuce library. In this example, you can recognize the functions explained above, but this time used with all the side materials needed to make it work nicely as a small demo.
  • Page 114: Control Of The Module Part

    17. Using the Yocto-RangeFinder with Android handler.postDelayed(r, 500); @Override protected void onStop() super.onStop(); handler.removeCallbacks(r); YAPI.FreeAPI(); @Override public void onItemSelected(AdapterView<?> parent, View view, pos, long serial = parent.getItemAtPosition(pos).toString(); @Override public void onNothingSelected(AdapterView<?> arg0) final Runnable new Runnable() public void run() (serial != null) { YRangeFinder rf = YRangeFinder.FindRangeFinder(serial + ".rangeFinder1");...
  • Page 115 17. Using the Yocto-RangeFinder with Android @Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.modulecontrol); Spinner my_spin = (Spinner) findViewById(R.id.spinner1); my_spin.setOnItemSelectedListener(this); aa = ArrayAdapter<String>(this, android.R.layout.simple_spinner_item); aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); my_spin.setAdapter(aa); @Override protected void onStart() super.onStart(); try { aa.clear(); YAPI.EnableUSBHost(this); YAPI.RegisterHub("usb"); YModule r = YModule.FirstModule(); while...
  • Page 116 17. Using the Yocto-RangeFinder with Android public void refreshInfo(View view) DisplayModuleInfo(); public void toggleBeacon(View view) (module == null) return; boolean on = ((Switch) view).isChecked(); try { if (on) { module.setBeacon(YModule.BEACON_ON); } else { module.setBeacon(YModule.BEACON_OFF); } catch (YAPI_Exception e) { e.printStackTrace();...
  • Page 117 17. Using the Yocto-RangeFinder with Android @Override protected void onStart() super.onStart(); try { aa.clear(); YAPI.EnableUSBHost(this); YAPI.RegisterHub("usb"); YModule r = YModule.FirstModule(); while (r != null) { String hwid = r.get_hardwareId(); aa.add(hwid); r = r.nextModule(); } catch (YAPI_Exception e) { e.printStackTrace(); // refresh Spinner with detected relay aa.notifyDataSetChanged();...
  • Page 118 17. Using the Yocto-RangeFinder with Android Warning: the number of write cycles of the nonvolatile memory of the module is limited. When this limit is reached, nothing guaranties that the saving process is performed correctly. This limit, linked to the technology employed by the module micro-processor, is located at about 100000 cycles. In short, you can use the function only 100000 times in the life of the module.
  • Page 119: Error Handling

    Inevitably, there will be a time when a user will have unplugged the device, either before running the software, or even while the software is running. The Yoctopuce library is designed to help you support this kind of behavior, but your code must nevertheless be conceived to interpret in the best possible way the errors indicated by the library.
  • Page 120 www.yoctopuce.com...
  • Page 121: Advanced Programming

    To be warned as soon as a module is connected, you need three pieces of code. The callback The callback is the function which is called each time a new Yoctopuce module is connected. It takes as parameter the relevant module. static void deviceArrival(YModule Console.WriteLine("New module...
  • Page 122 Detecting a modification in the value of a sensor The Yoctopuce API also provides a callback system allowing you to be notified automatically with the value of any sensor, either when the value has changed in a significant way or periodically at a preset frequency.
  • Page 123 Yoctopuce devices (for instance, you can also receive a callback any time a relay state changes).
  • Page 124: The Data Logger

    // do not forget to save the setting Note: Yoctopuce modules do not need an active USB connection to work: they start working as soon as they are powered on. The Yocto-RangeFinder can store data without necessarily being connected to a computer: you only need to activate the automatic start of the data logger and to power on the module with a simple USB charger.
  • Page 125 Retrieving the data To load recorded measures from the Yocto-RangeFinder flash memory, you must call the method of the desired sensor, and specify the time interval for which you get_recordedData() want to retrieve measures.
  • Page 126: Sensor Calibration

    Examples/Prog-DataLogger. Timestamp As the Yocto-RangeFinder does not have a battery, it cannot guess alone the current time when powered on. Nevertheless, the Yocto-RangeFinder will automatically try to adjust its real-time reference using the host to which it is connected, in order to properly attach a timestamp to each measure in the datalogger: •...
  • Page 127 The Yoctopuce modules support two types of calibration. On the one hand, a linear interpolation based on 1 to 5 reference points, which can be performed directly inside the Yocto-RangeFinder. On the other hand, the API supports an external arbitrary calibration, implemented with callbacks.
  • Page 128 Correction example with 3 calibration points Back to normal To cancel the effect of a calibration on a function, call the calibrateFromPoints() method with two empty arrays. Double[] ValuesBefore = {}; Double[] ValuesAfter = {}; YRangeFinder f = YRangeFinder.FirstRangeFinder(); www.yoctopuce.com...
  • Page 129 Note that these interpolation callbacks are global, and not specific to each function. Thus, each time someone requests a value from a module which contains in its flash memory the correct number of calibration points, the corresponding callback is called to correct the value before returning it, enabling thus a perfectly transparent measure correction. www.yoctopuce.com...
  • Page 130 www.yoctopuce.com...
  • Page 131: Firmware Update

    You can update your module firmware from your Android phone or tablet with the Yocto-Firmware application. This application lists all the Yoctopuce modules connected by USB and checks if a more recent firmware is available on www.yoctopuce.com. If a more recent firmware is available, you can...
  • Page 132: Updating The Firmware With The Programming Library

    = m.next(); Finding the correct firmware The first step to update a Yoctopuce module is to find which firmware you must use. The method of the YModule object does exactly this. The checkFirmware(path, onlynew) method checks that the firmware given as argument ( ) is compatible with the module.
  • Page 133 " is compatible and newer"); You can also give the "www.yoctopuce.com" string as argument to check whether there is a more recent published firmware on Yoctopuce's web site. In this case, the method returns the firmware URL. You can use this URL to download the firmware on your disk or use this URL when updating the firmware (see below).
  • Page 134: The "Update" Mode

    (or to restore default parameters). null YFirmwareUpdateupdate fw_update; fw_update = YFirmwareUpdate(allBootLoader[0], newfirm, null); status = fw_update.startUpdate(); ..www.yoctopuce.com...
  • Page 135: Using With Unsupported Languages

    (JavaScript, PHP, Java, ...). In fact, the VirtualHub is a small web server able to route HTTP requests to Yoctopuce modules. This means that if you can make an HTTP request from your programming language, you can drive Yoctopuce modules, even if this language is not officially supported.
  • Page 136 Rather logically, attributes can be modified in the same manner. http://127.0.0.1:4444/bySerial/YRNGFND1-12345/api/proximity?logicalName=myFunction You can find the list of available attributes for your Yocto-RangeFinder at the beginning of the Programming chapter. Accessing Yoctopuce data logger through the REST interface This section only applies to devices with a built-in data logger.
  • Page 137: Using Dynamic Libraries

    20.3. Using dynamic libraries The low level Yoctopuce API is available under several formats of dynamic libraries written in C. The sources are available with the C++ API. If you use one of these low level libraries, you do not need the VirtualHub anymore.
  • Page 138 (yapiHTTPRequest(serial,setValue,data,sizeof(dataBuffer),fullsize,errmsg)<0) then begin writeln(errmsg); halt; end; end. Module inventory To perform an inventory of Yoctopuce modules, you need two functions from the dynamic library: int yapiGetAllDevices(int *buffer,int maxsize,int *neededsize,char *errmsg); int yapiGetDeviceInfo(int devdesc,yDeviceSt *infos, char *errmsg); The yapiGetAllDevices function retrieves the list of all connected modules as a list of handles. buffer points to a 32-bit integer array which contains the returned handles.
  • Page 139 This data structure has the following format: Size Name Type Description (bytes) vendorid Yoctopuce USB ID deviceid Module USB ID devrelease Module version nbinbterfaces int Number of USB interfaces used by the module manufacturer char[]...
  • Page 140: Porting The High Level Library

    20.4. Porting the high level library As all the sources of the Yoctopuce API are fully provided, you can very well port the whole API in the language of your choice. Note, however, that a large portion of the API source code is automatically generated.
  • Page 141: High-Level Api Reference

    21. High-level API Reference This chapter summarizes the high-level API functions to drive your Yocto-RangeFinder. Syntax and exact type names may vary from one language to another, but, unless otherwise stated, all the functions are available in every language. For detailed information regarding the types of arguments and return values for a given language, refer to the definition file for this language ( yocto_api.*...
  • Page 142: General Functions

    21. High-level API Reference 21.1. General functions These general functions should be used to initialize and configure the Yoctopuce library. In most cases, a simple call to function should be enough. The module-specific functions yRegisterHub() should then be used to retrieve an object that provides interaction yFind...()
  • Page 143 Setup the Yoctopuce library to no more use modules connected on a previously registered machine with RegisterHub. yUpdateDeviceList(errmsg) Triggers a (re)detection of connected Yoctopuce modules.
  • Page 144 , and . If you try to configure a logical name with an incorrect string, the invalid characters are ignored. Parameters : name a string containing the name to check. Returns : true false if the name is valid, otherwise. www.yoctopuce.com...
  • Page 145 YAPI.ClearHTTPCallbackCacheDir() YAPI yClearHTTPCallbackCacheDir() Disables the HTTP callback cache. function yClearHTTPCallbackCacheDir( $bool_removeFiles) This method disables the HTTP callback cache, and can additionally cleanup the cache directory. Parameters : bool_removeFiles True to clear the content of the cache. Returns : nothing. www.yoctopuce.com...
  • Page 146 ) void DisableExceptions( ) def DisableExceptions( ) function yDisableExceptions( ) function DisableExceptions( ) When exceptions are disabled, every function returns a specific error value which depends on its type and which is documented in this reference manual. www.yoctopuce.com...
  • Page 147 Be aware than when exceptions are enabled, every function that fails triggers an exception. If the exception is not caught by the user code, it either fires the debugger or aborts (i.e. crash) the program. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 148 USB host port of the system. This yRegisterHub("usb") function takes as argument, an object of class android.content.Context (or any subclass). It is not necessary to call this function to reach modules through the network. Parameters : osContext an object of class android.content.Context (or any subclass). www.yoctopuce.com...
  • Page 149 21. High-level API Reference YAPI.FreeAPI() YAPI yFreeAPI() Frees dynamically allocated memory blocks used by the Yoctopuce library. function yFreeAPI( ) void yFreeAPI( ) +(void) FreeAPI procedure yFreeAPI( ) procedure yFreeAPI( ) void FreeAPI( ) void FreeAPI( ) java void FreeAPI( )
  • Page 150 21. High-level API Reference YAPI.GetAPIVersion() YAPI yGetAPIVersion() Returns the version identifier for the Yoctopuce library in use. function yGetAPIVersion( ) string yGetAPIVersion( ) +(NSString*) GetAPIVersion function yGetAPIVersion( ): string function yGetAPIVersion( ) As String String GetAPIVersion( ) String GetAPIVersion( )
  • Page 151 GetTickCount( ) def GetTickCount( ) function yGetTickCount( ) function GetTickCount( ) This counter can be used to compute delays in relation with Yoctopuce devices, which also uses the millisecond as timebase. Returns : a long integer corresponding to the millisecond counter.
  • Page 152 This function may signal an error in case there is a communication problem while contacting a module. Parameters : errmsg a string passed by reference to receive any error message. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 153 21. High-level API Reference YAPI.InitAPI() YAPI yInitAPI() Initializes the Yoctopuce programming library explicitly. function yInitAPI( mode, errmsg) YRETCODE yInitAPI( int mode, string& errmsg) +(YRETCODE) InitAPI :(int) mode :(NSError**) errmsg function yInitAPI( mode: integer, var errmsg: string): integer function yInitAPI( ByVal...
  • Page 154 "usb","callback" or the root URL of the hub to monitor errmsg a string passed by reference to receive any error message. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 155 RegisterDeviceArrivalCallback( arrivalCallback) function yRegisterDeviceArrivalCallback( $arrivalCallback) function RegisterDeviceArrivalCallback( arrivalCallback) This callback will be invoked while yUpdateDeviceList is running. You will have to call this function on a regular basis. Parameters : arrivalCallback a procedure taking a YModule parameter, or null www.yoctopuce.com...
  • Page 156 RegisterDeviceRemovalCallback( removalCallback) function yRegisterDeviceRemovalCallback( $removalCallback) function RegisterDeviceRemovalCallback( removalCallback) This callback will be invoked while yUpdateDeviceList is running. You will have to call this function on a regular basis. Parameters : removalCallback a procedure taking a YModule parameter, or null www.yoctopuce.com...
  • Page 157 API run in "HTTP Callback" mode. This a special mode allowing to take control of Yoctopuce devices through a NAT filter when using a VirtualHub or a networked YoctoHub. You only need to configure your hub to call your server script on a regular basis. This mode is currently available for PHP and Node.JS only.
  • Page 158 21. High-level API Reference On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 159 URL of the network hub (this URL can be passed to RegisterHub). This callback will be invoked while yUpdateDeviceList is running. You will have to call this function on a regular basis. Parameters : hubDiscoveryCallback a procedure taking two string parameter, the serial www.yoctopuce.com...
  • Page 160 RegisterLogFunction( LogCallback logfun) java void RegisterLogFunction( LogHandler logfun) def RegisterLogFunction( logfun) This callback will be called each time the API have something to say. Quite useful to debug the API. Parameters : logfun null a procedure taking a string parameter, or www.yoctopuce.com...
  • Page 161 For in this case, it is therefore recommended to manually select the proper architecture by calling SelectArchitecture() before any other call to the library. Parameters : arch "armhf" "armel" A string containing the architecture to use. Possibles value are: "i386" "x86_64" "32bit" "64bit" Returns : nothing. On failure, throws an exception. www.yoctopuce.com...
  • Page 162 +(void) SetDelegate :(id) object The methods yDeviceArrival yDeviceRemoval will be invoked while yUpdateDeviceList is running. You will have to call this function on a regular basis. Parameters : object YAPIDelegate an object that must follow the protocol , or www.yoctopuce.com...
  • Page 163 This folder must exist and the PHP script needs to have write access to it. It is recommended to use a folder that is not published on the Web server since the library will save some data of Yoctopuce devices into this folder. Note: This feature is supported by YoctoHub and VirtualHub since version 27750.
  • Page 164 (not supported on Microsoft Internet Explorer). Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 165 USB packets. A delay of 50 milliseconds is generally enough. In case of doubt, contact Yoctopuce support. To disable USB packets acknowledge, call this function with the value 0. Note: this feature is only available on Android.
  • Page 166 This function implements a passive waiting loop, meaning that it does not consume CPU cycles significantly. The processor is left available for other threads and processes. During the pause, the library nevertheless reads from time to time information from the Yoctopuce modules by calling , in order to stay up-to-date.
  • Page 167 "usb","callback" or the root URL of the hub to monitor mstimeout the number of millisecond available to test the connection. errmsg a string passed by reference to receive any error message. Returns : YAPI_SUCCESS when the call succeeds. On failure returns a negative error code. www.yoctopuce.com...
  • Page 168 Task<int> TriggerHubDiscovery( ) def TriggerHubDiscovery( errmsg=None) Parameters : errmsg a string passed by reference to receive any error message. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 169 21. High-level API Reference YAPI.UnregisterHub() YAPI yUnregisterHub() Setup the Yoctopuce library to no more use modules connected on a previously registered machine with RegisterHub. function yUnregisterHub( url) void yUnregisterHub( const string& url) +(void) UnregisterHub :(NSString *) procedure yUnregisterHub( url: string)
  • Page 170 21. High-level API Reference YAPI.UpdateDeviceList() YAPI yUpdateDeviceList() Triggers a (re)detection of connected Yoctopuce modules. function yUpdateDeviceList( errmsg) YRETCODE yUpdateDeviceList( string& errmsg) +(YRETCODE) UpdateDeviceList :(NSError**) errmsg function yUpdateDeviceList( var errmsg: string): integer function yUpdateDeviceList( ByRef errmsg As String) As YRETCODE YRETCODE UpdateDeviceList( ref string errmsg)
  • Page 171 21. High-level API Reference YAPI.UpdateDeviceList_async() YAPI yUpdateDeviceList_async() Triggers a (re)detection of connected Yoctopuce modules. function yUpdateDeviceList_async( callback, context) The library searches the machines or USB ports previously registered using , and yRegisterHub() invokes any user-defined callback function in case a change in the list of connected devices is detected.
  • Page 172: Module Control Interface

    21. High-level API Reference 21.2. Module control interface This interface is identical for all Yoctopuce USB modules. It can be used to control the module global parameters, and to enumerate the functions provided by each module. In order to use the functions described here, you should include: <script type='text/javascript' src='yocto_api.js'></script>...
  • Page 173 Returns the number of milliseconds spent since the module was powered on. module→get_url() Returns the URL used to access the module. module→get_usbCurrent() Returns the current consumed by the module on the USB bus, in milli-amps. module→get_userData() set_userData Returns the value of the userData attribute, as previously stored using method www.yoctopuce.com...
  • Page 174 Stores a 32 bit value in the device RAM. module→triggerFirmwareUpdate(secBeforeReboot) Schedules a module reboot into special firmware update mode. module→updateFirmware(path) Prepares a firmware update of the module. module→updateFirmwareEx(path, force) Prepares a firmware update of the module. module→wait_async(callback, context) www.yoctopuce.com...
  • Page 175 21. High-level API Reference Waits for all pending asynchronous commands on the module to complete, and invoke the user-provided callback function. www.yoctopuce.com...
  • Page 176 Parameters : func a string containing either the serial number or the logical name of the desired module Returns : YModule object allowing you to drive the module or get additional information on the module. www.yoctopuce.com...
  • Page 177 The search is performed first by hardware name, then by logical name. Parameters : yctx a YAPI context func a string that uniquely characterizes the module Returns : YModule object allowing you to drive the module. www.yoctopuce.com...
  • Page 178 ) function FirstModule( ) Use the method YModule.nextModule() to iterate on the next modules. Returns : YModule null a pointer to a object, corresponding to the first module currently online, or a pointer if there are none. www.yoctopuce.com...
  • Page 179 Returns : the path of the byn file to use or a empty string if no byn files matches the requirement On failure, throws an exception or returns a string that start with "error:". www.yoctopuce.com...
  • Page 180 ) void clearCache( ) java def clearCache( ) function clearCache( ) function clearCache( ) Invalidates the cache of the module attributes. Forces the next call to get_xxx() or loadxxx() to use values that come from the device. www.yoctopuce.com...
  • Page 181 ) String describe( ) java def describe( ) function describe( ) function describe( ) The text may include either the logical name or the serial number of the module. Returns : a string that describes the module www.yoctopuce.com...
  • Page 182 $pathname) function download( pathname) YModule target download pathname Parameters : pathname name of the new file to load Returns : a binary buffer with the file content On failure, throws an exception or returns YAPI_INVALID_STRING www.yoctopuce.com...
  • Page 183 0 for the first function. Returns : a string corresponding to the base type of the function On failure, throws an exception or returns an empty string. www.yoctopuce.com...
  • Page 184 ) As Integer int functionCount( ) int functionCount( ) java def functionCount( ) function functionCount( ) function functionCount( ) Returns : the number of functions on the module On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 185 0 for the first function. Returns : a string corresponding to the unambiguous hardware identifier of the requested module function On failure, throws an exception or returns an empty string. www.yoctopuce.com...
  • Page 186 0 for the first function. Returns : a string corresponding to the logical name of the requested module function On failure, throws an exception or returns an empty string. www.yoctopuce.com...
  • Page 187 0 for the first function. Returns : a string corresponding to the type of the function On failure, throws an exception or returns an empty string. www.yoctopuce.com...
  • Page 188 0 for the first function. Returns : a short string (up to 6 characters) corresponding to the advertised value of the requested module function On failure, throws an exception or returns an empty string. www.yoctopuce.com...
  • Page 189 Useful to backup all the logical names, calibrations parameters, and uploaded files of a device. Returns : a binary buffer with all the settings. On failure, throws an exception or returns an binary object of size 0. www.yoctopuce.com...
  • Page 190 Task<int> get_beacon( ) def get_beacon( ) function get_beacon( ) function get_beacon( ) YModule target get_beacon Returns : Y_BEACON_OFF Y_BEACON_ON either , according to the state of the localization beacon On failure, throws an exception or returns Y_BEACON_INVALID www.yoctopuce.com...
  • Page 191 ) function get_errorMessage( ) function get_errorMessage( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a string corresponding to the latest error message that occured while using this module object www.yoctopuce.com...
  • Page 192 ) function get_errorType( ) function get_errorType( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a number corresponding to the code of the latest error that occurred while using this module object...
  • Page 193 Task<string> get_firmwareRelease( ) def get_firmwareRelease( ) function get_firmwareRelease( ) function get_firmwareRelease( ) YModule target get_firmwareRelease Returns : a string corresponding to the version of the firmware embedded in the module On failure, throws an exception or returns Y_FIRMWARERELEASE_INVALID www.yoctopuce.com...
  • Page 194 ArrayList<String> get_functionIds( String funType) java async Task<List<string>> get_functionIds( string funType) def get_functionIds( funType) function get_functionIds( $funType) function get_functionIds( funType) YModule target get_functionIds funType Parameters : funType The type of function (Relay, LightSensor, Voltage,...) Returns : an array of strings. www.yoctopuce.com...
  • Page 195 ) String get_hardwareId( ) java def get_hardwareId( ) function get_hardwareId( ) function get_hardwareId( ) The unique hardware identifier is made of the device serial number followed by string ".module". Returns : a string that uniquely identifies the module www.yoctopuce.com...
  • Page 196 ) function get_icon2d( ) YModule target get_icon2d The icon is a PNG image and does not exceeds 1536 bytes. Returns : a binary buffer with module icon, in png format. On failure, throws an exception or returns YAPI_INVALID_STRING www.yoctopuce.com...
  • Page 197 . O n f a i l u r e , t h r o w s a n e x c e p t i o n o r r e t u r n s YAPI_INVALID_STRING www.yoctopuce.com...
  • Page 198 String get_logicalName( ) java async Task<string> get_logicalName( ) def get_logicalName( ) function get_logicalName( ) function get_logicalName( ) YModule target get_logicalName Returns : a string corresponding to the logical name of the module On failure, throws an exception or returns Y_LOGICALNAME_INVALID www.yoctopuce.com...
  • Page 199 Task<int> get_luminosity( ) def get_luminosity( ) function get_luminosity( ) function get_luminosity( ) YModule target get_luminosity Returns : an integer corresponding to the luminosity of the module informative leds (from 0 to 100) On failure, throws an exception or returns Y_LUMINOSITY_INVALID www.yoctopuce.com...
  • Page 200 ) YModule target get_parentHub If the module is connected by USB, or if the module is the root YoctoHub, an empty string is returned. Returns : a string with the serial number of the YoctoHub or an empty string www.yoctopuce.com...
  • Page 201 Task<int> get_persistentSettings( ) def get_persistentSettings( ) function get_persistentSettings( ) function get_persistentSettings( ) YModule target get_persistentSettings Returns : Y_PERSISTENTSETTINGS_LOADED Y_PERSISTENTSETTINGS_SAVED a value among Y_PERSISTENTSETTINGS_MODIFIED corresponding to the current state of persistent module settings On failure, throws an exception or returns Y_PERSISTENTSETTINGS_INVALID www.yoctopuce.com...
  • Page 202 ) java async Task<int> get_productId( ) def get_productId( ) function get_productId( ) function get_productId( ) YModule target get_productId Returns : an integer corresponding to the USB device identifier of the module On failure, throws an exception or returns Y_PRODUCTID_INVALID www.yoctopuce.com...
  • Page 203 Task<string> get_productName( ) def get_productName( ) function get_productName( ) function get_productName( ) YModule target get_productName Returns : a string corresponding to the commercial name of the module, as set by the factory On failure, throws an exception or returns Y_PRODUCTNAME_INVALID www.yoctopuce.com...
  • Page 204 ) java async Task<int> get_productRelease( ) def get_productRelease( ) function get_productRelease( ) function get_productRelease( ) YModule target get_productRelease Returns : an integer corresponding to the hardware release version of the module On failure, throws an exception or returns Y_PRODUCTRELEASE_INVALID www.yoctopuce.com...
  • Page 205 ) function get_rebootCountdown( ) YModule target get_rebootCountdown Returns : an integer corresponding to the remaining number of seconds before the module restarts, or zero when no reboot has been scheduled On failure, throws an exception or returns Y_REBOOTCOUNTDOWN_INVALID www.yoctopuce.com...
  • Page 206 Task<string> get_serialNumber( ) def get_serialNumber( ) function get_serialNumber( ) function get_serialNumber( ) YModule target get_serialNumber Returns : a string corresponding to the serial number of the module, as set by the factory On failure, throws an exception or returns Y_SERIALNUMBER_INVALID www.yoctopuce.com...
  • Page 207 ArrayList<String> get_subDevices( ) java def get_subDevices( ) function get_subDevices( ) YModule target get_subDevices This method only makes sense when called for a YoctoHub/VirtualHub. Otherwise, an empty array will be returned. Returns : an array of strings containing the sub modules. www.yoctopuce.com...
  • Page 208 Task<long> get_upTime( ) def get_upTime( ) function get_upTime( ) function get_upTime( ) YModule target get_upTime Returns : an integer corresponding to the number of milliseconds spent since the module was powered on On failure, throws an exception or returns Y_UPTIME_INVALID www.yoctopuce.com...
  • Page 209 ) As String string get_url( ) String get_url( ) java def get_url( ) function get_url( ) YModule target get_url If the module is connected by USB, the string 'usb' is returned. Returns : a string with the URL of the module. www.yoctopuce.com...
  • Page 210 Task<int> get_usbCurrent( ) def get_usbCurrent( ) function get_usbCurrent( ) function get_usbCurrent( ) YModule target get_usbCurrent Returns : an integer corresponding to the current consumed by the module on the USB bus, in milli-amps On failure, throws an exception or returns Y_USBCURRENT_INVALID www.yoctopuce.com...
  • Page 211 ) function get_userData( ) function get_userData( ) This attribute is never touched directly by the API, and is at disposal of the caller to store a context. Returns : the object stored previously by the caller. www.yoctopuce.com...
  • Page 212 ) YModule target get_userVar On startup and after a device reboot, the value is always reset to zero. Returns : an integer corresponding to the value previously stored in this attribute On failure, throws an exception or returns Y_USERVAR_INVALID www.yoctopuce.com...
  • Page 213 $funcId) function hasFunction( funcId) YModule target hasFunction funcId This method takes a function identifier and returns a boolean. Parameters : funcId the requested function identifier Returns : true if the device has the function identifier www.yoctopuce.com...
  • Page 214 If there are valid cached values for the module, that have not yet expired, the device is considered reachable. No exception is raised if there is an error while trying to contact the requested module. Returns : true if the module can be reached, and false otherwise www.yoctopuce.com...
  • Page 215 The callback function receives three arguments: the caller-specific context object, the receiving module object and the boolean result context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 216 Parameters : msValidity an integer corresponding to the validity attributed to the loaded module parameters, in milliseconds Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 217 The callback function receives three arguments: the caller-specific context object, the receiving module object and the error code YAPI_SUCCESS context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 218 This function is useful in particular to trace the execution of HTTP callbacks. If a newline is desired after the message, it must be included in the string. Parameters : text the string to append to the logs. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 219 YModule nextModule( ) def nextModule( ) function nextModule( ) function nextModule( ) Returns : a pointer to a YModule object, corresponding to the next module found, or a null pointer if there are no more modules to enumerate. www.yoctopuce.com...
  • Page 220 $secBeforeReboot) function reboot( secBeforeReboot) YModule target reboot secBeforeReboot Parameters : secBeforeReboot number of seconds before rebooting Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 221 This callback will be called each time that a module sends a new log message. Mostly useful to debug a Yoctopuce module. Parameters : callback the callback function to call, or a null pointer. The callback function should take two arguments: the module object that emitted the log message, and the character string containing the log.
  • Page 222 ) int revertFromFlash( ) java async Task<int> revertFromFlash( ) def revertFromFlash( ) function revertFromFlash( ) function revertFromFlash( ) YModule target revertFromFlash Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 223 Warning: the number of allowed save operations during a module life is limited (about 100000 cycles). Do not call this function within a loop. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 224 Parameters : settings a binary buffer with all the settings. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 225 Parameters : settings a binary buffer with all the settings. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 226 Task<int> set_beacon( int newval) def set_beacon( newval) function set_beacon( $newval) function set_beacon( newval) YModule target set_beacon newval Parameters : newval either Y_BEACON_OFF Y_BEACON_ON Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 227 Parameters : newval a string corresponding to the logical name of the module Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 228 Parameters : newval an integer corresponding to the luminosity of the module informative leds Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 229 $data) function set_userData( data) This attribute is never touched by the API, and is at disposal of the caller to store a context. Parameters : data any kind of object to be stored www.yoctopuce.com...
  • Page 230 This attribute is at programmer disposal, should he need to store a state variable. On startup and after a device reboot, the value is always reset to zero. Parameters : newval an integer Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 231 $secBeforeReboot) function triggerFirmwareUpdate( secBeforeReboot) YModule target triggerFirmwareUpdate secBeforeReboot Parameters : secBeforeReboot number of seconds before rebooting Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 232 $path) function updateFirmware( path) YModule target updateFirmware path This method returns a object which handles the firmware update process. YFirmwareUpdate Parameters : path .byn the path of the file to use. Returns : YFirmwareUpdate object or NULL on error. www.yoctopuce.com...
  • Page 233 YFirmwareUpdate Parameters : path .byn the path of the file to use. force true to force the firmware update even if some prerequisites appear not to be met Returns : YFirmwareUpdate object or NULL on error. www.yoctopuce.com...
  • Page 234 The callback function receives two arguments: the caller-specific context object and the receiving function object. context caller-specific object that is passed as-is to the callback function Returns : nothing. www.yoctopuce.com...
  • Page 235: Rangefinder Function Interface

    21. High-level API Reference 21.3. RangeFinder function interface The Yoctopuce class YRangeFinder allows you to use and configure Yoctopuce range finder sensors. It inherits from the YSensor class the core functions to read measurements, register callback functions, access the autonomous datalogger. This class adds the ability to easily perform a one-point linear calibration to compensate the effect of a glass or filter placed in front of the sensor.
  • Page 236 Returns the sensor health state code, which is zero when there is an up-to-date measure available or a positive code if the sensor is not able to provide a measure right now. rangefinder→get_unit() Returns the measuring unit for the range measured. rangefinder→get_userData() set_userData Returns the value of the userData attribute, as previously stored using method www.yoctopuce.com...
  • Page 237 Changes the measuring unit for the measured range. rangefinder→set_userData(data) Stores a user context provided as argument in the userData attribute of the function. rangefinder→startDataLogger() Starts the data logger on the device. rangefinder→stopDataLogger() Stops the datalogger on the device. rangefinder→triggerOffsetCalibration(targetDist) www.yoctopuce.com...
  • Page 238 Triggers the hardware cross-talk calibration of the distance sensor. rangefinder→unmuteValueCallbacks() Re-enables the propagation of every new advertised value to the parent hub. rangefinder→wait_async(callback, context) Waits for all pending asynchronous commands on the module to complete, and invoke the user-provided callback function. www.yoctopuce.com...
  • Page 239 Parameters : func a string that uniquely characterizes the range finder Returns : YRangeFinder object allowing you to drive the range finder. www.yoctopuce.com...
  • Page 240 The search is performed first by hardware name, then by logical name. Parameters : yctx a YAPI context func a string that uniquely characterizes the range finder Returns : YRangeFinder object allowing you to drive the range finder. www.yoctopuce.com...
  • Page 241 ) function FirstRangeFinder( ) Use the method YRangeFinder.nextRangeFinder() to iterate on next range finders. Returns : YRangeFinder null a pointer to a object, corresponding to the first range finder currently online, or a pointer if there are none. www.yoctopuce.com...
  • Page 242 Use the method YRangeFinder.nextRangeFinder() to iterate on next range finders. Parameters : yctx a YAPI context. Returns : YRangeFinder null a pointer to a object, corresponding to the first range finder currently online, or a pointer if there are none. www.yoctopuce.com...
  • Page 243 For more information on advanced capabilities to refine the calibration of sensors, please contact support@yoctopuce.com. Parameters : rawValues array of floating point numbers, corresponding to the raw values returned by the sensor for the correction points.
  • Page 244 ) YRangeFinder target cancelCoverGlassCalibrations Remember to call the method of the module if the modification must be kept. saveToFlash() Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 245 ) void clearCache( ) java def clearCache( ) function clearCache( ) function clearCache( ) Invalidates the cache of the range finder attributes. Forces the next call to get_xxx() or loadxxx() to use values that come from the device. www.yoctopuce.com...
  • Page 246 Relay(BadCustomeName.relay1)=unresolved has not yet been connected. This method does not trigger any USB or TCP transaction and can therefore be used in a debugger. Returns : Relay(MyCustomName.relay1)=RELAYLO1- a string that describes the range finder (ex: 123456.relay1 www.yoctopuce.com...
  • Page 247 Task<string> get_advertisedValue( ) def get_advertisedValue( ) function get_advertisedValue( ) function get_advertisedValue( ) YRangeFinder target get_advertisedValue Returns : a string corresponding to the current value of the range finder (no more than 6 characters). On failure, throws an exception or returns Y_ADVERTISEDVALUE_INVALID www.yoctopuce.com...
  • Page 248 ) function get_currentRawValue( ) YRangeFinder target get_currentRawValue Returns : a floating point number corresponding to the uncalibrated, unrounded raw value returned by the sensor, in mm, as a floating point number On failure, throws an exception or returns Y_CURRENTRAWVALUE_INVALID www.yoctopuce.com...
  • Page 249 Task<double> get_currentTemperature( ) def get_currentTemperature( ) function get_currentTemperature( ) function get_currentTemperature( ) YRangeFinder target get_currentTemperature Returns : a floating point number corresponding to the current sensor temperature, as a floating point number On failure, throws an exception or returns Y_CURRENTTEMPERATURE_INVALID www.yoctopuce.com...
  • Page 250 ) function get_currentValue( ) YRangeFinder target get_currentValue Returns : a floating point number corresponding to the current value of the range measured, in mm, as a floating point number On failure, throws an exception or returns Y_CURRENTVALUE_INVALID www.yoctopuce.com...
  • Page 251 ) function get_dataLogger( ) This method returns an object of class YDatalogger that can control global parameters of the data logger. The returned object should not be freed. Returns : an YDataLogger object or null on error. www.yoctopuce.com...
  • Page 252 ) function get_errorMessage( ) function get_errorMessage( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a string corresponding to the latest error message that occured while using the range finder object...
  • Page 253 ) function get_errorType( ) function get_errorType( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a number corresponding to the code of the latest error that occurred while using the range finder object...
  • Page 254 (for example: MyCustomName.relay1 Returns : a string that uniquely identifies the range finder using logical names (ex: MyCustomName.relay1 On failure, throws an exception or returns Y_FRIENDLYNAME_INVALID www.yoctopuce.com...
  • Page 255 , t h e r e t u r n e d v a l u e Y_FUNCTIONDESCRIPTOR_INVALID www.yoctopuce.com...
  • Page 256 ) As String string get_functionId( ) String get_functionId( ) java def get_functionId( ) function get_functionId( ) function get_functionId( ) For example relay1 Returns : a string that identifies the range finder (ex: relay1 On failure, throws an exception or returns Y_FUNCTIONID_INVALID www.yoctopuce.com...
  • Page 257 ) YRangeFinder target get_hardwareCalibrationTemperature This function can be used to determine if a new calibration for ambient temperature is required. Returns : a temperature, as a floating point number. On failure, throws an exception or return YAPI_INVALID_DOUBLE. www.yoctopuce.com...
  • Page 258 The unique hardware identifier is composed of the device serial number and of the hardware identifier of the range finder (for example RELAYLO1-123456.relay1 Returns : a string that uniquely identifies the range finder (ex: RELAYLO1-123456.relay1 On failure, throws an exception or returns Y_HARDWAREID_INVALID www.yoctopuce.com...
  • Page 259 ) function get_highestValue( ) function get_highestValue( ) YRangeFinder target get_highestValue Returns : a floating point number corresponding to the maximal value observed for the range measured since the device was started On failure, throws an exception or returns Y_HIGHESTVALUE_INVALID www.yoctopuce.com...
  • Page 260 ) YRangeFinder target get_logFrequency Returns : a string corresponding to the datalogger recording frequency for this function, or "OFF" when measures are not stored in the data logger flash memory On failure, throws an exception or returns Y_LOGFREQUENCY_INVALID www.yoctopuce.com...
  • Page 261 String get_logicalName( ) java async Task<string> get_logicalName( ) def get_logicalName( ) function get_logicalName( ) function get_logicalName( ) YRangeFinder target get_logicalName Returns : a string corresponding to the logical name of the range finder. On failure, throws an exception or returns Y_LOGICALNAME_INVALID www.yoctopuce.com...
  • Page 262 ) function get_lowestValue( ) function get_lowestValue( ) YRangeFinder target get_lowestValue Returns : a floating point number corresponding to the minimal value observed for the range measured since the device was started On failure, throws an exception or returns Y_LOWESTVALUE_INVALID www.yoctopuce.com...
  • Page 263 YModule get_module( ) java def get_module( ) function get_module( ) function get_module( ) If the function cannot be located on any module, the returned instance of YModule is not shown as on- line. Returns : YModule an instance of www.yoctopuce.com...
  • Page 264 The callback function receives three arguments: the caller-specific context object, the receiving function object and the requested YModule object context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 265 The rangefinder running mode allows you to put priority on precision, speed or maximum range. Returns : a value among Y_RANGEFINDERMODE_DEFAULT Y_RANGEFINDERMODE_LONG_RANGE Y_RANGEFINDERMODE_HIGH_ACCURACY Y_RANGEFINDERMODE_HIGH_SPEED corresponding to the range finder running mode On failure, throws an exception or returns Y_RANGEFINDERMODE_INVALID www.yoctopuce.com...
  • Page 266 January 1, 1970 UTC. The special value 0 can be used to include any meaasure, without ending limit. Returns : an instance of YDataSet, providing access to historical data. Past measures can be loaded progressively using methods from the YDataSet object. www.yoctopuce.com...
  • Page 267 ) function get_reportFrequency( ) YRangeFinder target get_reportFrequency Returns : a string corresponding to the timed value notification frequency, or "OFF" if timed value notifications are disabled for this function On failure, throws an exception or returns Y_REPORTFREQUENCY_INVALID www.yoctopuce.com...
  • Page 268 The resolution corresponds to the numerical precision of the measures, which is not always the same as the actual precision of the sensor. Returns : a floating point number corresponding to the resolution of the measured values On failure, throws an exception or returns Y_RESOLUTION_INVALID www.yoctopuce.com...
  • Page 269 On failure, throws an exception or returns Y_SENSORSTATE_INVALID www.yoctopuce.com...
  • Page 270 String get_unit( ) java async Task<string> get_unit( ) def get_unit( ) function get_unit( ) function get_unit( ) YRangeFinder target get_unit Returns : a string corresponding to the measuring unit for the range measured On failure, throws an exception or returns Y_UNIT_INVALID www.yoctopuce.com...
  • Page 271 ) function get_userData( ) function get_userData( ) This attribute is never touched directly by the API, and is at disposal of the caller to store a context. Returns : the object stored previously by the caller. www.yoctopuce.com...
  • Page 272 If there is a cached value for the range finder in cache, that has not yet expired, the device is considered reachable. No exception is raised if there is an error while trying to contact the device hosting the range finder. Returns : true if the range finder can be reached, and false otherwise www.yoctopuce.com...
  • Page 273 The callback function receives three arguments: the caller-specific context object, the receiving function object and the boolean result context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 274 Returns false if the device is unreachable, or if the sensor does not have a current measure to transmit. No exception is raised if there is an error while trying to contact the device hosting $THEFUNCTION$. Returns : true if the sensor can provide an up-to-date measure, and false otherwise www.yoctopuce.com...
  • Page 275 Parameters : msValidity an integer corresponding to the validity attributed to the loaded function parameters, in milliseconds Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 276 $attrName) function loadAttribute( attrName) Parameters : attrName the name of the requested attribute Returns : a string with the value of the the attribute On failure, throws an exception or returns an empty string. www.yoctopuce.com...
  • Page 277 Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 278 The callback function receives three arguments: the caller-specific context object, the receiving function object and the error code YAPI_SUCCESS context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 279 HTTP callback. Remember to call the method saveToFlash() of the module if the modification must be kept. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 280 YRangeFinder nextRangeFinder( ) def nextRangeFinder( ) function nextRangeFinder( ) function nextRangeFinder( ) Returns : a pointer to a YRangeFinder object, corresponding to a range finder currently online, or a null pointer if there are no more range finders to enumerate. www.yoctopuce.com...
  • Page 281 To unregister a callback, pass a null pointer as argument. Parameters : callback the callback function to call, or a null pointer. The callback function should take two arguments: the function object of which the value has changed, and an YMeasure object describing the new advertised value. www.yoctopuce.com...
  • Page 282 To unregister a callback, pass a null pointer as argument. Parameters : callback the callback function to call, or a null pointer. The callback function should take two arguments: the function object of which the value has changed, and the character string describing the new advertised value. www.yoctopuce.com...
  • Page 283 YRangeFinder target set_highestValue newval Parameters : newval a floating point number corresponding to the recorded maximal value observed Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 284 (eg. "4/h"). To disable recording for this function, use the value "OFF". Parameters : newval a string corresponding to the datalogger recording frequency for this function Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 285 Parameters : newval a string corresponding to the logical name of the range finder. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 286 YRangeFinder target set_lowestValue newval Parameters : newval a floating point number corresponding to the recorded minimal value observed Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 287 Y _ R A N G E F I N D E R M O D E _ D E F A U L T Y_RANGEFINDERMODE_LONG_RANGE Y_RANGEFINDERMODE_HIGH_ACCURACY Y_RANGEFINDERMODE_HIGH_SPEED corresponding to the rangefinder running mode, allowing you to put priority on precision, speed or maximum range Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 288 (eg. "4/h"). To disable timed value notifications for this function, use the value "OFF". Parameters : newval a string corresponding to the timed value notification frequency for this function Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 289 Parameters : newval a floating point number corresponding to the resolution of the measured physical values Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 290 Parameters : newval a string corresponding to the measuring unit for the measured range Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 291 $data) function set_userData( data) This attribute is never touched by the API, and is at disposal of the caller to store a context. Parameters : data any kind of object to be stored www.yoctopuce.com...
  • Page 292 ) function startDataLogger( ) function startDataLogger( ) YRangeFinder target startDataLogger Note that the data logger will only save the measures on this sensor if the logFrequency is not set to "OFF". Returns : YAPI_SUCCESS if the call succeeds. www.yoctopuce.com...
  • Page 293 ): LongInt function stopDataLogger( ) As Integer int stopDataLogger( ) int stopDataLogger( ) java async Task<int> stopDataLogger( ) def stopDataLogger( ) function stopDataLogger( ) function stopDataLogger( ) YRangeFinder target stopDataLogger Returns : YAPI_SUCCESS if the call succeeds. www.yoctopuce.com...
  • Page 294 Parameters : targetDist true distance of the calibration target, in mm or inches, depending on the unit selected in the device Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 295 This function is part of the calibration procedure to compensate for the the effect of a cover glass. Make sure to read the chapter about hardware calibration for details on the calibration procedure for proper results. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 296 That calibration process needs no physical interaction with the sensor. It is performed automatically at device startup, but it is recommended to start it again when the temperature delta since the latest calibration exceeds 8°C. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 297 Parameters : targetDist true distance of the calibration target, in mm or inches, depending on the unit selected in the device Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 298 This function reverts the effect of a previous call to . Remember to call the muteValueCallbacks() method of the module if the modification must be kept. saveToFlash() Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 299 The callback function receives two arguments: the caller-specific context object and the receiving function object. context caller-specific object that is passed as-is to the callback function Returns : nothing. www.yoctopuce.com...
  • Page 300: Temperature Function Interface

    21. High-level API Reference 21.4. Temperature function interface The Yoctopuce class YTemperature allows you to read and configure Yoctopuce temperature sensors. It inherits from YSensor class the core functions to read measurements, to register callback functions, to access the autonomous datalogger. This class adds the ability to configure some specific parameters for some sensors (connection type, temperature mapping table).
  • Page 301 Returns the current value of the electrical signal measured by the sensor. temperature→get_unit() Returns the measuring unit for the temperature. temperature→get_userData() Returns the value of the userData attribute, as previously stored using method set_userData temperature→isOnline() Checks if the temperature sensor is currently reachable, without raising any error. temperature→isOnline_async(callback, context) www.yoctopuce.com...
  • Page 302 Records a thermistor response table, in order to interpolate the temperature from the measured resistance. temperature→set_unit(newval) Changes the measuring unit for the measured temperature. temperature→set_userData(data) Stores a user context provided as argument in the userData attribute of the function. www.yoctopuce.com...
  • Page 303 Stops the datalogger on the device. temperature→unmuteValueCallbacks() Re-enables the propagation of every new advertised value to the parent hub. temperature→wait_async(callback, context) Waits for all pending asynchronous commands on the module to complete, and invoke the user-provided callback function. www.yoctopuce.com...
  • Page 304 FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time. Parameters : func a string that uniquely characterizes the temperature sensor Returns : YTemperature object allowing you to drive the temperature sensor. www.yoctopuce.com...
  • Page 305 The search is performed first by hardware name, then by logical name. Parameters : yctx a YAPI context func a string that uniquely characterizes the temperature sensor Returns : YTemperature object allowing you to drive the temperature sensor. www.yoctopuce.com...
  • Page 306 ) function FirstTemperature( ) Use the method YTemperature.nextTemperature() to iterate on next temperature sensors. Returns : YTemperature a pointer to a object, corresponding to the first temperature sensor currently online, or a null pointer if there are none. www.yoctopuce.com...
  • Page 307 Use the method YTemperature.nextTemperature() to iterate on next temperature sensors. Parameters : yctx a YAPI context. Returns : YTemperature a pointer to a object, corresponding to the first temperature sensor currently online, or a null pointer if there are none. www.yoctopuce.com...
  • Page 308 For more information on advanced capabilities to refine the calibration of sensors, please contact support@yoctopuce.com. Parameters : rawValues array of floating point numbers, corresponding to the raw values returned by the sensor for the correction points.
  • Page 309 ) void clearCache( ) java def clearCache( ) function clearCache( ) function clearCache( ) Invalidates the cache of the temperature sensor attributes. Forces the next call to get_xxx() or loadxxx() to use values that come from the device. www.yoctopuce.com...
  • Page 310 ( e x : Relay(MyCustomName.relay1)=RELAYLO1-123456.relay1 www.yoctopuce.com...
  • Page 311 Task<string> get_advertisedValue( ) def get_advertisedValue( ) function get_advertisedValue( ) function get_advertisedValue( ) YTemperature target get_advertisedValue Returns : a string corresponding to the current value of the temperature sensor (no more than 6 characters). On failure, throws an exception or returns Y_ADVERTISEDVALUE_INVALID www.yoctopuce.com...
  • Page 312 ) function get_currentRawValue( ) YTemperature target get_currentRawValue Returns : a floating point number corresponding to the uncalibrated, unrounded raw value returned by the sensor, in Celsius, as a floating point number On failure, throws an exception or returns Y_CURRENTRAWVALUE_INVALID www.yoctopuce.com...
  • Page 313 ) function get_currentValue( ) function get_currentValue( ) YTemperature target get_currentValue Returns : a floating point number corresponding to the current value of the temperature, in Celsius, as a floating point number On failure, throws an exception or returns Y_CURRENTVALUE_INVALID www.yoctopuce.com...
  • Page 314 ) function get_dataLogger( ) This method returns an object of class YDatalogger that can control global parameters of the data logger. The returned object should not be freed. Returns : an YDataLogger object or null on error. www.yoctopuce.com...
  • Page 315 ) function get_errorMessage( ) function get_errorMessage( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a string corresponding to the latest error message that occured while using the temperature sensor object...
  • Page 316 ) function get_errorType( ) function get_errorType( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a number corresponding to the code of the latest error that occurred while using the temperature sensor object www.yoctopuce.com...
  • Page 317 (for example: MyCustomName.relay1 Returns : a string that uniquely identifies the temperature sensor using logical names (ex: MyCustomName.relay1 On failure, throws an exception or returns Y_FRIENDLYNAME_INVALID www.yoctopuce.com...
  • Page 318 , t h e r e t u r n e d v a l u e Y_FUNCTIONDESCRIPTOR_INVALID www.yoctopuce.com...
  • Page 319 ) As String string get_functionId( ) String get_functionId( ) java def get_functionId( ) function get_functionId( ) function get_functionId( ) For example relay1 Returns : a string that identifies the temperature sensor (ex: relay1 On failure, throws an exception or returns Y_FUNCTIONID_INVALID www.yoctopuce.com...
  • Page 320 The unique hardware identifier is composed of the device serial number and of the hardware identifier of the temperature sensor (for example RELAYLO1-123456.relay1 Returns : a string that uniquely identifies the temperature sensor (ex: RELAYLO1-123456.relay1 On failure, throws an exception or returns Y_HARDWAREID_INVALID www.yoctopuce.com...
  • Page 321 ) function get_highestValue( ) function get_highestValue( ) YTemperature target get_highestValue Returns : a floating point number corresponding to the maximal value observed for the temperature since the device was started On failure, throws an exception or returns Y_HIGHESTVALUE_INVALID www.yoctopuce.com...
  • Page 322 ) YTemperature target get_logFrequency Returns : a string corresponding to the datalogger recording frequency for this function, or "OFF" when measures are not stored in the data logger flash memory On failure, throws an exception or returns Y_LOGFREQUENCY_INVALID www.yoctopuce.com...
  • Page 323 String get_logicalName( ) java async Task<string> get_logicalName( ) def get_logicalName( ) function get_logicalName( ) function get_logicalName( ) YTemperature target get_logicalName Returns : a string corresponding to the logical name of the temperature sensor. On failure, throws an exception or returns Y_LOGICALNAME_INVALID www.yoctopuce.com...
  • Page 324 ) function get_lowestValue( ) function get_lowestValue( ) YTemperature target get_lowestValue Returns : a floating point number corresponding to the minimal value observed for the temperature since the device was started On failure, throws an exception or returns Y_LOWESTVALUE_INVALID www.yoctopuce.com...
  • Page 325 YModule get_module( ) java def get_module( ) function get_module( ) function get_module( ) If the function cannot be located on any module, the returned instance of YModule is not shown as on- line. Returns : YModule an instance of www.yoctopuce.com...
  • Page 326 The callback function receives three arguments: the caller-specific context object, the receiving function object and the requested YModule object context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 327 January 1, 1970 UTC. The special value 0 can be used to include any meaasure, without ending limit. Returns : an instance of YDataSet, providing access to historical data. Past measures can be loaded progressively using methods from the YDataSet object. www.yoctopuce.com...
  • Page 328 ) function get_reportFrequency( ) YTemperature target get_reportFrequency Returns : a string corresponding to the timed value notification frequency, or "OFF" if timed value notifications are disabled for this function On failure, throws an exception or returns Y_REPORTFREQUENCY_INVALID www.yoctopuce.com...
  • Page 329 The resolution corresponds to the numerical precision of the measures, which is not always the same as the actual precision of the sensor. Returns : a floating point number corresponding to the resolution of the measured values On failure, throws an exception or returns Y_RESOLUTION_INVALID www.yoctopuce.com...
  • Page 330 On failure, throws an exception or returns Y_SENSORSTATE_INVALID www.yoctopuce.com...
  • Page 331 Y _ S E N S O R T Y P E _ P T 1 0 0 _ 3 W I R E S Y_SENSORTYPE_PT100_2WIRES Y_SENSORTYPE_RES_OHM Y_SENSORTYPE_RES_NTC Y_SENSORTYPE_RES_LINEAR Y_SENSORTYPE_RES_INTERNAL corresponding to the temperature sensor type On failure, throws an exception or returns Y_SENSORTYPE_INVALID www.yoctopuce.com...
  • Page 332 Task<string> get_signalUnit( ) def get_signalUnit( ) function get_signalUnit( ) function get_signalUnit( ) YTemperature target get_signalUnit Returns : a string corresponding to the measuring unit of the electrical signal used by the sensor On failure, throws an exception or returns Y_SIGNALUNIT_INVALID www.yoctopuce.com...
  • Page 333 ) function get_signalValue( ) function get_signalValue( ) YTemperature target get_signalValue Returns : a floating point number corresponding to the current value of the electrical signal measured by the sensor On failure, throws an exception or returns Y_SIGNALVALUE_INVALID www.yoctopuce.com...
  • Page 334 String get_unit( ) java async Task<string> get_unit( ) def get_unit( ) function get_unit( ) function get_unit( ) YTemperature target get_unit Returns : a string corresponding to the measuring unit for the temperature On failure, throws an exception or returns Y_UNIT_INVALID www.yoctopuce.com...
  • Page 335 ) function get_userData( ) function get_userData( ) This attribute is never touched directly by the API, and is at disposal of the caller to store a context. Returns : the object stored previously by the caller. www.yoctopuce.com...
  • Page 336 If there is a cached value for the temperature sensor in cache, that has not yet expired, the device is considered reachable. No exception is raised if there is an error while trying to contact the device hosting the temperature sensor. Returns : true if the temperature sensor can be reached, and false otherwise www.yoctopuce.com...
  • Page 337 The callback function receives three arguments: the caller-specific context object, the receiving function object and the boolean result context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 338 Returns false if the device is unreachable, or if the sensor does not have a current measure to transmit. No exception is raised if there is an error while trying to contact the device hosting $THEFUNCTION$. Returns : true if the sensor can provide an up-to-date measure, and false otherwise www.yoctopuce.com...
  • Page 339 Parameters : msValidity an integer corresponding to the validity attributed to the loaded function parameters, in milliseconds Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 340 $attrName) function loadAttribute( attrName) Parameters : attrName the name of the requested attribute Returns : a string with the value of the the attribute On failure, throws an exception or returns an empty string. www.yoctopuce.com...
  • Page 341 Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 342 (in Ohms) for each of the temperature included in the first argument, index by index. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 343 The callback function receives three arguments: the caller-specific context object, the receiving function object and the error code YAPI_SUCCESS context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 344 HTTP callback. Remember to call the method saveToFlash() of the module if the modification must be kept. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 345 YTemperature nextTemperature( ) def nextTemperature( ) function nextTemperature( ) function nextTemperature( ) Returns : a pointer to a YTemperature object, corresponding to a temperature sensor currently online, or a null pointer if there are no more temperature sensors to enumerate. www.yoctopuce.com...
  • Page 346 To unregister a callback, pass a null pointer as argument. Parameters : callback the callback function to call, or a null pointer. The callback function should take two arguments: the function object of which the value has changed, and an YMeasure object describing the new advertised value. www.yoctopuce.com...
  • Page 347 To unregister a callback, pass a null pointer as argument. Parameters : callback the callback function to call, or a null pointer. The callback function should take two arguments: the function object of which the value has changed, and the character string describing the new advertised value. www.yoctopuce.com...
  • Page 348 YTemperature target set_highestValue newval Parameters : newval a floating point number corresponding to the recorded maximal value observed Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 349 (eg. "4/h"). To disable recording for this function, use the value "OFF". Parameters : newval a string corresponding to the datalogger recording frequency for this function Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 350 Parameters : newval a string corresponding to the logical name of the temperature sensor. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 351 YTemperature target set_lowestValue newval Parameters : newval a floating point number corresponding to the recorded minimal value observed Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 352 This function can only be used with a temperature sensor based on thermistors. Parameters : res25 thermistor resistance at 25 degrees Celsius beta Beta value Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 353 (eg. "4/h"). To disable timed value notifications for this function, use the value "OFF". Parameters : newval a string corresponding to the timed value notification frequency for this function Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 354 Parameters : newval a floating point number corresponding to the resolution of the measured physical values Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 355 Y _ S E N S O R T Y P E _ R E S _ L I N E A R a n d Y_SENSORTYPE_RES_INTERNAL Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 356 (in Ohms) for each of the temperature included in the first argument, index by index. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 357 Parameters : newval a string corresponding to the measuring unit for the measured temperature Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 358 $data) function set_userData( data) This attribute is never touched by the API, and is at disposal of the caller to store a context. Parameters : data any kind of object to be stored www.yoctopuce.com...
  • Page 359 ) function startDataLogger( ) function startDataLogger( ) YTemperature target startDataLogger Note that the data logger will only save the measures on this sensor if the logFrequency is not set to "OFF". Returns : YAPI_SUCCESS if the call succeeds. www.yoctopuce.com...
  • Page 360 ): LongInt function stopDataLogger( ) As Integer int stopDataLogger( ) int stopDataLogger( ) java async Task<int> stopDataLogger( ) def stopDataLogger( ) function stopDataLogger( ) function stopDataLogger( ) YTemperature target stopDataLogger Returns : YAPI_SUCCESS if the call succeeds. www.yoctopuce.com...
  • Page 361 This function reverts the effect of a previous call to . Remember to call the muteValueCallbacks() method of the module if the modification must be kept. saveToFlash() Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 362 The callback function receives two arguments: the caller-specific context object and the receiving function object. context caller-specific object that is passed as-is to the callback function Returns : nothing. www.yoctopuce.com...
  • Page 363: Lightsensor Function Interface

    21. High-level API Reference 21.5. LightSensor function interface The Yoctopuce class YLightSensor allows you to read and configure Yoctopuce light sensors. It inherits from YSensor class the core functions to read measurements, to register callback functions, to access the autonomous datalogger. This class adds the ability to easily perform a one-point linear calibration to compensate the effect of a glass or filter placed in front of the sensor.
  • Page 364 Returns the measuring unit for the ambient light. lightsensor→get_userData() Returns the value of the userData attribute, as previously stored using method set_userData lightsensor→isOnline() Checks if the light sensor is currently reachable, without raising any error. www.yoctopuce.com...
  • Page 365 Stops the datalogger on the device. lightsensor→unmuteValueCallbacks() Re-enables the propagation of every new advertised value to the parent hub. lightsensor→wait_async(callback, context) Waits for all pending asynchronous commands on the module to complete, and invoke the user-provided callback function. www.yoctopuce.com...
  • Page 366 Parameters : func a string that uniquely characterizes the light sensor Returns : YLightSensor object allowing you to drive the light sensor. www.yoctopuce.com...
  • Page 367 The search is performed first by hardware name, then by logical name. Parameters : yctx a YAPI context func a string that uniquely characterizes the light sensor Returns : YLightSensor object allowing you to drive the light sensor. www.yoctopuce.com...
  • Page 368 ) function FirstLightSensor( ) Use the method YLightSensor.nextLightSensor() to iterate on next light sensors. Returns : YLightSensor null a pointer to a object, corresponding to the first light sensor currently online, or a pointer if there are none. www.yoctopuce.com...
  • Page 369 Use the method YLightSensor.nextLightSensor() to iterate on next light sensors. Parameters : yctx a YAPI context. Returns : YLightSensor null a pointer to a object, corresponding to the first light sensor currently online, or a pointer if there are none. www.yoctopuce.com...
  • Page 370 Task<int> calibrate( double calibratedVal) def calibrate( calibratedVal) function calibrate( $calibratedVal) function calibrate( calibratedVal) YLightSensor target calibrate calibratedVal Parameters : calibratedVal the desired target value. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 371 For more information on advanced capabilities to refine the calibration of sensors, please contact support@yoctopuce.com. Parameters : rawValues array of floating point numbers, corresponding to the raw values returned by the sensor for the correction points.
  • Page 372 ) void clearCache( ) java def clearCache( ) function clearCache( ) function clearCache( ) Invalidates the cache of the light sensor attributes. Forces the next call to get_xxx() or loadxxx() to use values that come from the device. www.yoctopuce.com...
  • Page 373 Relay(BadCustomeName.relay1)=unresolved has not yet been connected. This method does not trigger any USB or TCP transaction and can therefore be used in a debugger. Returns : Relay(MyCustomName.relay1)=RELAYLO1- a string that describes the light sensor (ex: 123456.relay1 www.yoctopuce.com...
  • Page 374 Task<string> get_advertisedValue( ) def get_advertisedValue( ) function get_advertisedValue( ) function get_advertisedValue( ) YLightSensor target get_advertisedValue Returns : a string corresponding to the current value of the light sensor (no more than 6 characters). On failure, throws an exception or returns Y_ADVERTISEDVALUE_INVALID www.yoctopuce.com...
  • Page 375 ) YLightSensor target get_currentRawValue Returns : a floating point number corresponding to the uncalibrated, unrounded raw value returned by the sensor, in the specified unit, as a floating point number On failure, throws an exception or returns Y_CURRENTRAWVALUE_INVALID www.yoctopuce.com...
  • Page 376 ) function get_currentValue( ) YLightSensor target get_currentValue Returns : a floating point number corresponding to the current value of the ambient light, in the specified unit, as a floating point number On failure, throws an exception or returns Y_CURRENTVALUE_INVALID www.yoctopuce.com...
  • Page 377 ) function get_dataLogger( ) This method returns an object of class YDatalogger that can control global parameters of the data logger. The returned object should not be freed. Returns : an YDataLogger object or null on error. www.yoctopuce.com...
  • Page 378 ) function get_errorMessage( ) function get_errorMessage( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a string corresponding to the latest error message that occured while using the light sensor object...
  • Page 379 ) function get_errorType( ) function get_errorType( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a number corresponding to the code of the latest error that occurred while using the light sensor object...
  • Page 380 (for example: MyCustomName.relay1 Returns : a string that uniquely identifies the light sensor using logical names (ex: MyCustomName.relay1 On failure, throws an exception or returns Y_FRIENDLYNAME_INVALID www.yoctopuce.com...
  • Page 381 , t h e r e t u r n e d v a l u e Y_FUNCTIONDESCRIPTOR_INVALID www.yoctopuce.com...
  • Page 382 ) As String string get_functionId( ) String get_functionId( ) java def get_functionId( ) function get_functionId( ) function get_functionId( ) For example relay1 Returns : a string that identifies the light sensor (ex: relay1 On failure, throws an exception or returns Y_FUNCTIONID_INVALID www.yoctopuce.com...
  • Page 383 The unique hardware identifier is composed of the device serial number and of the hardware identifier of the light sensor (for example RELAYLO1-123456.relay1 Returns : a string that uniquely identifies the light sensor (ex: RELAYLO1-123456.relay1 On failure, throws an exception or returns Y_HARDWAREID_INVALID www.yoctopuce.com...
  • Page 384 ) function get_highestValue( ) function get_highestValue( ) YLightSensor target get_highestValue Returns : a floating point number corresponding to the maximal value observed for the ambient light since the device was started On failure, throws an exception or returns Y_HIGHESTVALUE_INVALID www.yoctopuce.com...
  • Page 385 ) YLightSensor target get_logFrequency Returns : a string corresponding to the datalogger recording frequency for this function, or "OFF" when measures are not stored in the data logger flash memory On failure, throws an exception or returns Y_LOGFREQUENCY_INVALID www.yoctopuce.com...
  • Page 386 String get_logicalName( ) java async Task<string> get_logicalName( ) def get_logicalName( ) function get_logicalName( ) function get_logicalName( ) YLightSensor target get_logicalName Returns : a string corresponding to the logical name of the light sensor. On failure, throws an exception or returns Y_LOGICALNAME_INVALID www.yoctopuce.com...
  • Page 387 ) function get_lowestValue( ) function get_lowestValue( ) YLightSensor target get_lowestValue Returns : a floating point number corresponding to the minimal value observed for the ambient light since the device was started On failure, throws an exception or returns Y_LOWESTVALUE_INVALID www.yoctopuce.com...
  • Page 388 On failure, throws an exception or returns Y_MEASURETYPE_INVALID www.yoctopuce.com...
  • Page 389 YModule get_module( ) java def get_module( ) function get_module( ) function get_module( ) If the function cannot be located on any module, the returned instance of YModule is not shown as on- line. Returns : YModule an instance of www.yoctopuce.com...
  • Page 390 The callback function receives three arguments: the caller-specific context object, the receiving function object and the requested YModule object context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 391 January 1, 1970 UTC. The special value 0 can be used to include any meaasure, without ending limit. Returns : an instance of YDataSet, providing access to historical data. Past measures can be loaded progressively using methods from the YDataSet object. www.yoctopuce.com...
  • Page 392 ) function get_reportFrequency( ) YLightSensor target get_reportFrequency Returns : a string corresponding to the timed value notification frequency, or "OFF" if timed value notifications are disabled for this function On failure, throws an exception or returns Y_REPORTFREQUENCY_INVALID www.yoctopuce.com...
  • Page 393 The resolution corresponds to the numerical precision of the measures, which is not always the same as the actual precision of the sensor. Returns : a floating point number corresponding to the resolution of the measured values On failure, throws an exception or returns Y_RESOLUTION_INVALID www.yoctopuce.com...
  • Page 394 On failure, throws an exception or returns Y_SENSORSTATE_INVALID www.yoctopuce.com...
  • Page 395 String get_unit( ) java async Task<string> get_unit( ) def get_unit( ) function get_unit( ) function get_unit( ) YLightSensor target get_unit Returns : a string corresponding to the measuring unit for the ambient light On failure, throws an exception or returns Y_UNIT_INVALID www.yoctopuce.com...
  • Page 396 ) function get_userData( ) function get_userData( ) This attribute is never touched directly by the API, and is at disposal of the caller to store a context. Returns : the object stored previously by the caller. www.yoctopuce.com...
  • Page 397 If there is a cached value for the light sensor in cache, that has not yet expired, the device is considered reachable. No exception is raised if there is an error while trying to contact the device hosting the light sensor. Returns : true if the light sensor can be reached, and false otherwise www.yoctopuce.com...
  • Page 398 The callback function receives three arguments: the caller-specific context object, the receiving function object and the boolean result context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 399 Returns false if the device is unreachable, or if the sensor does not have a current measure to transmit. No exception is raised if there is an error while trying to contact the device hosting $THEFUNCTION$. Returns : true if the sensor can provide an up-to-date measure, and false otherwise www.yoctopuce.com...
  • Page 400 Parameters : msValidity an integer corresponding to the validity attributed to the loaded function parameters, in milliseconds Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 401 $attrName) function loadAttribute( attrName) Parameters : attrName the name of the requested attribute Returns : a string with the value of the the attribute On failure, throws an exception or returns an empty string. www.yoctopuce.com...
  • Page 402 Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 403 The callback function receives three arguments: the caller-specific context object, the receiving function object and the error code YAPI_SUCCESS context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 404 HTTP callback. Remember to call the method saveToFlash() of the module if the modification must be kept. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 405 YLightSensor nextLightSensor( ) def nextLightSensor( ) function nextLightSensor( ) function nextLightSensor( ) Returns : a pointer to a YLightSensor object, corresponding to a light sensor currently online, or a null pointer if there are no more light sensors to enumerate. www.yoctopuce.com...
  • Page 406 To unregister a callback, pass a null pointer as argument. Parameters : callback the callback function to call, or a null pointer. The callback function should take two arguments: the function object of which the value has changed, and an YMeasure object describing the new advertised value. www.yoctopuce.com...
  • Page 407 To unregister a callback, pass a null pointer as argument. Parameters : callback the callback function to call, or a null pointer. The callback function should take two arguments: the function object of which the value has changed, and the character string describing the new advertised value. www.yoctopuce.com...
  • Page 408 YLightSensor target set_highestValue newval Parameters : newval a floating point number corresponding to the recorded maximal value observed Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 409 (eg. "4/h"). To disable recording for this function, use the value "OFF". Parameters : newval a string corresponding to the datalogger recording frequency for this function Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 410 Parameters : newval a string corresponding to the logical name of the light sensor. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 411 YLightSensor target set_lowestValue newval Parameters : newval a floating point number corresponding to the recorded minimal value observed Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 412 Parameters : newval a value among Y_MEASURETYPE_HUMAN_EYE Y_MEASURETYPE_WIDE_SPECTRUM Y_MEASURETYPE_INFRARED Y_MEASURETYPE_HIGH_RATE a n d Y_MEASURETYPE_HIGH_ENERGY Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 413 (eg. "4/h"). To disable timed value notifications for this function, use the value "OFF". Parameters : newval a string corresponding to the timed value notification frequency for this function Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 414 Parameters : newval a floating point number corresponding to the resolution of the measured physical values Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 415 $data) function set_userData( data) This attribute is never touched by the API, and is at disposal of the caller to store a context. Parameters : data any kind of object to be stored www.yoctopuce.com...
  • Page 416 ) function startDataLogger( ) function startDataLogger( ) YLightSensor target startDataLogger Note that the data logger will only save the measures on this sensor if the logFrequency is not set to "OFF". Returns : YAPI_SUCCESS if the call succeeds. www.yoctopuce.com...
  • Page 417 ): LongInt function stopDataLogger( ) As Integer int stopDataLogger( ) int stopDataLogger( ) java async Task<int> stopDataLogger( ) def stopDataLogger( ) function stopDataLogger( ) function stopDataLogger( ) YLightSensor target stopDataLogger Returns : YAPI_SUCCESS if the call succeeds. www.yoctopuce.com...
  • Page 418 This function reverts the effect of a previous call to . Remember to call the muteValueCallbacks() method of the module if the modification must be kept. saveToFlash() Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 419 The callback function receives two arguments: the caller-specific context object and the receiving function object. context caller-specific object that is passed as-is to the callback function Returns : nothing. www.yoctopuce.com...
  • Page 420: Datalogger Function Interface

    21. High-level API Reference 21.6. DataLogger function interface Yoctopuce sensors include a non-volatile memory capable of storing ongoing measured data automatically, without requiring a permanent connection to a computer. The DataLogger function controls the global parameters of the internal data logger.
  • Page 421 Disables the propagation of every new advertised value to the parent hub. datalogger→nextDataLogger() Continues the enumeration of data loggers started using yFirstDataLogger() datalogger→registerValueCallback(callback) Registers the callback function that is invoked on every change of advertised value. datalogger→set_autoStart(newval) Changes the default activation state of the data logger on power up. datalogger→set_beaconDriven(newval) www.yoctopuce.com...
  • Page 422 Stores a user context provided as argument in the userData attribute of the function. datalogger→unmuteValueCallbacks() Re-enables the propagation of every new advertised value to the parent hub. datalogger→wait_async(callback, context) Waits for all pending asynchronous commands on the module to complete, and invoke the user-provided callback function. www.yoctopuce.com...
  • Page 423 Parameters : func a string that uniquely characterizes the data logger Returns : YDataLogger object allowing you to drive the data logger. www.yoctopuce.com...
  • Page 424 The search is performed first by hardware name, then by logical name. Parameters : yctx a YAPI context func a string that uniquely characterizes the data logger Returns : YDataLogger object allowing you to drive the data logger. www.yoctopuce.com...
  • Page 425 ) function FirstDataLogger( ) Use the method YDataLogger.nextDataLogger() to iterate on next data loggers. Returns : YDataLogger null a pointer to a object, corresponding to the first data logger currently online, or a pointer if there are none. www.yoctopuce.com...
  • Page 426 Use the method YDataLogger.nextDataLogger() to iterate on next data loggers. Parameters : yctx a YAPI context. Returns : YDataLogger null a pointer to a object, corresponding to the first data logger currently online, or a pointer if there are none. www.yoctopuce.com...
  • Page 427 ) void clearCache( ) java def clearCache( ) function clearCache( ) function clearCache( ) Invalidates the cache of the data logger attributes. Forces the next call to get_xxx() or loadxxx() to use values that come from the device. www.yoctopuce.com...
  • Page 428 Relay(BadCustomeName.relay1)=unresolved has not yet been connected. This method does not trigger any USB or TCP transaction and can therefore be used in a debugger. Returns : Relay(MyCustomName.relay1)=RELAYLO1- a string that describes the data logger (ex: 123456.relay1 www.yoctopuce.com...
  • Page 429 ) function forgetAllDataStreams( ) function forgetAllDataStreams( ) YDataLogger target forgetAllDataStreams This method also resets the current run index to zero. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 430 Task<string> get_advertisedValue( ) def get_advertisedValue( ) function get_advertisedValue( ) function get_advertisedValue( ) YDataLogger target get_advertisedValue Returns : a string corresponding to the current value of the data logger (no more than 6 characters). On failure, throws an exception or returns Y_ADVERTISEDVALUE_INVALID www.yoctopuce.com...
  • Page 431 ) function get_autoStart( ) function get_autoStart( ) YDataLogger target get_autoStart Returns : Y_AUTOSTART_OFF Y_AUTOSTART_ON either , according to the default activation state of the data logger on power up On failure, throws an exception or returns Y_AUTOSTART_INVALID www.yoctopuce.com...
  • Page 432 ) function get_beaconDriven( ) function get_beaconDriven( ) YDataLogger target get_beaconDriven Returns : Y_BEACONDRIVEN_OFF Y_BEACONDRIVEN_ON either , according to true if the data logger is synchronised with the localization beacon On failure, throws an exception or returns Y_BEACONDRIVEN_INVALID www.yoctopuce.com...
  • Page 433 YDataLogger target get_currentRunIndex Returns : an integer corresponding to the current run number, corresponding to the number of times the module was powered on with the dataLogger enabled at some point On failure, throws an exception or returns Y_CURRENTRUNINDEX_INVALID www.yoctopuce.com...
  • Page 434 This function only works if the device uses a recent firmware, as YDataSet objects are not supported by firmwares older than version 13000. Returns : a list of YDataSet object. On failure, throws an exception or returns an empty list. www.yoctopuce.com...
  • Page 435 Parameters : an array of YDataStream objects to be filled in Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 436 ) function get_errorMessage( ) function get_errorMessage( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a string corresponding to the latest error message that occured while using the data logger object...
  • Page 437 ) function get_errorType( ) function get_errorType( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a number corresponding to the code of the latest error that occurred while using the data logger object...
  • Page 438 (for example: MyCustomName.relay1 Returns : a string that uniquely identifies the data logger using logical names (ex: MyCustomName.relay1 On failure, throws an exception or returns Y_FRIENDLYNAME_INVALID www.yoctopuce.com...
  • Page 439 , t h e r e t u r n e d v a l u e Y_FUNCTIONDESCRIPTOR_INVALID www.yoctopuce.com...
  • Page 440 ) As String string get_functionId( ) String get_functionId( ) java def get_functionId( ) function get_functionId( ) function get_functionId( ) For example relay1 Returns : a string that identifies the data logger (ex: relay1 On failure, throws an exception or returns Y_FUNCTIONID_INVALID www.yoctopuce.com...
  • Page 441 The unique hardware identifier is composed of the device serial number and of the hardware identifier of the data logger (for example RELAYLO1-123456.relay1 Returns : a string that uniquely identifies the data logger (ex: RELAYLO1-123456.relay1 On failure, throws an exception or returns Y_HARDWAREID_INVALID www.yoctopuce.com...
  • Page 442 String get_logicalName( ) java async Task<string> get_logicalName( ) def get_logicalName( ) function get_logicalName( ) function get_logicalName( ) YDataLogger target get_logicalName Returns : a string corresponding to the logical name of the data logger. On failure, throws an exception or returns Y_LOGICALNAME_INVALID www.yoctopuce.com...
  • Page 443 YModule get_module( ) java def get_module( ) function get_module( ) function get_module( ) If the function cannot be located on any module, the returned instance of YModule is not shown as on- line. Returns : YModule an instance of www.yoctopuce.com...
  • Page 444 The callback function receives three arguments: the caller-specific context object, the receiving function object and the requested YModule object context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 445 Task<int> get_recording( ) def get_recording( ) function get_recording( ) function get_recording( ) YDataLogger target get_recording Returns : Y_RECORDING_OFF Y_RECORDING_ON Y_RECORDING_PENDING a value among corresponding to the current activation state of the data logger On failure, throws an exception or returns Y_RECORDING_INVALID www.yoctopuce.com...
  • Page 446 Task<long> get_timeUTC( ) def get_timeUTC( ) function get_timeUTC( ) function get_timeUTC( ) YDataLogger target get_timeUTC Returns : an integer corresponding to the Unix timestamp for current UTC time, if known On failure, throws an exception or returns Y_TIMEUTC_INVALID www.yoctopuce.com...
  • Page 447 ) function get_userData( ) function get_userData( ) This attribute is never touched directly by the API, and is at disposal of the caller to store a context. Returns : the object stored previously by the caller. www.yoctopuce.com...
  • Page 448 If there is a cached value for the data logger in cache, that has not yet expired, the device is considered reachable. No exception is raised if there is an error while trying to contact the device hosting the data logger. Returns : true if the data logger can be reached, and false otherwise www.yoctopuce.com...
  • Page 449 The callback function receives three arguments: the caller-specific context object, the receiving function object and the boolean result context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 450 Parameters : msValidity an integer corresponding to the validity attributed to the loaded function parameters, in milliseconds Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 451 $attrName) function loadAttribute( attrName) Parameters : attrName the name of the requested attribute Returns : a string with the value of the the attribute On failure, throws an exception or returns an empty string. www.yoctopuce.com...
  • Page 452 The callback function receives three arguments: the caller-specific context object, the receiving function object and the error code YAPI_SUCCESS context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
  • Page 453 HTTP callback. Remember to call the method saveToFlash() of the module if the modification must be kept. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 454 YDataLogger nextDataLogger( ) def nextDataLogger( ) function nextDataLogger( ) function nextDataLogger( ) Returns : a pointer to a YDataLogger object, corresponding to a data logger currently online, or a null pointer if there are no more data loggers to enumerate. www.yoctopuce.com...
  • Page 455 To unregister a callback, pass a null pointer as argument. Parameters : callback the callback function to call, or a null pointer. The callback function should take two arguments: the function object of which the value has changed, and the character string describing the new advertised value. www.yoctopuce.com...
  • Page 456 Parameters : newval Y_AUTOSTART_OFF Y_AUTOSTART_ON either , according to the default activation state of the data logger on power up Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 457 Parameters : newval Y_BEACONDRIVEN_OFF Y_BEACONDRIVEN_ON either , according to the type of synchronisation of the data logger Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 458 Parameters : newval a string corresponding to the logical name of the data logger. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 459 Y _ R E C O R D I N G _ O N a n d Y_RECORDING_PENDING corresponding to the activation state of the data logger to start/stop recording data Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 460 YDataLogger target set_timeUTC newval Parameters : newval an integer corresponding to the current UTC time reference used for recorded data Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 461 $data) function set_userData( data) This attribute is never touched by the API, and is at disposal of the caller to store a context. Parameters : data any kind of object to be stored www.yoctopuce.com...
  • Page 462 This function reverts the effect of a previous call to . Remember to call the muteValueCallbacks() method of the module if the modification must be kept. saveToFlash() Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 463 The callback function receives two arguments: the caller-specific context object and the receiving function object. context caller-specific object that is passed as-is to the callback function Returns : nothing. www.yoctopuce.com...
  • Page 464: Recorded Data Sequence

    In order to use the functions described here, you should include: <script type='text/javascript' src='yocto_api.js'></script> #include "yocto_api.h" #import "yocto_api.h" uses yocto_api; yocto_api.vb yocto_api.cs import com.yoctopuce.YoctoAPI.YModule; java import com.yoctopuce.YoctoAPI.YModule; from yocto_api import * require_once('yocto_api.php'); in HTML: <script src="../../lib/yocto_api.js"></script> in node.js: require('yoctolib-es2017/yocto_api.js'); methods YDataSet dataset→get_endTimeUTC()
  • Page 465 Returns an YMeasure object which summarizes the whole DataSet. dataset→get_unit() Returns the measuring unit for the measured value. dataset→loadMore() Loads the the next block of measures from the dataLogger, and updates the progress indicator. dataset→loadMore_async(callback, context) Loads the the next block of measures from the dataLogger asynchronously. www.yoctopuce.com...
  • Page 466 Returns : an unsigned number corresponding to the number of seconds between the Jan 1, 1970 and the end of this data set (i.e. Unix time representation of the absolute time). www.yoctopuce.com...
  • Page 467 ): string function get_functionId( ) As String string get_functionId( ) String get_functionId( ) java async Task<string> get_functionId( ) def get_functionId( ) function get_functionId( ) function get_functionId( ) For example temperature1 Returns : a string that identifies the function (ex: temperature1 www.yoctopuce.com...
  • Page 468 The unique hardware identifier is composed of the device serial number and of the hardware identifier of the function (for example THRMCPL1-123456.temperature1 Returns : a string that uniquely identifies the function (ex: THRMCPL1-123456.temperature1 On failure, throws an exception or returns Y_HARDWAREID_INVALID www.yoctopuce.com...
  • Page 469 UTC clock. Returns : a table of records, where each record depicts the measured value for a given time interval On failure, throws an exception or returns an empty array. www.yoctopuce.com...
  • Page 470 Parameters : measure condensed measure from the list previously returned by get_preview() Returns : a table of records, where each record depicts the measured values during a time interval On failure, throws an exception or returns an empty array. www.yoctopuce.com...
  • Page 471 This preview is available as soon as has been called for the first time. loadMore() Returns : a table of records, where each record depicts the measured values during a time interval On failure, throws an exception or returns an empty array. www.yoctopuce.com...
  • Page 472 , the progress is zero. Each time get_dataSet loadMore() invoked, the progress is updated, to reach the value 100 only once all measures have been loaded. Returns : an integer in the range 0 to 100 (percentage of completion). www.yoctopuce.com...
  • Page 473 Returns : an unsigned number corresponding to the number of seconds between the Jan 1, 1970 and the beginning of this data set (i.e. Unix time representation of the absolute time). www.yoctopuce.com...
  • Page 474 - the average value observed during the time interval - the maximal value observed during the time interval This summary is available as soon as has been called for the first time. loadMore() Returns : an YMeasure object www.yoctopuce.com...
  • Page 475 ) As String string get_unit( ) String get_unit( ) java async Task<string> get_unit( ) def get_unit( ) function get_unit( ) function get_unit( ) Returns : a string that represents a physical unit. On failure, throws an exception or returns Y_UNIT_INVALID www.yoctopuce.com...
  • Page 476 ) function loadMore( ) Returns : an integer in the range 0 to 100 (percentage of completion), or a negative error code in case of failure. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
  • Page 477 - the YDataSet object whose loadMore_async was invoked - the load result: either the progress indicator (0...100), or a negative error code in case of failure. context user-specific object that is passed as-is to the callback function Returns : nothing. www.yoctopuce.com...
  • Page 478: Measured Value

    In order to use the functions described here, you should include: <script type='text/javascript' src='yocto_api.js'></script> #include "yocto_api.h" #import "yocto_api.h" uses yocto_api; yocto_api.vb yocto_api.cs import com.yoctopuce.YoctoAPI.YModule; java import com.yoctopuce.YoctoAPI.YModule; from yocto_api import * require_once('yocto_api.php'); in HTML: <script src="../../lib/yocto_api.js"></script> in node.js: require('yoctolib-es2017/yocto_api.js'); YMeasure methods measure→get_averageValue()
  • Page 479 ): double function get_averageValue( ) As Double double get_averageValue( ) double get_averageValue( ) java double get_averageValue( ) def get_averageValue( ) function get_averageValue( ) function get_averageValue( ) Returns : a floating-point number corresponding to the average value observed. www.yoctopuce.com...
  • Page 480 When the recording rate is higher than 1 sample per second, the timestamp may have a fractional part. Returns : an floating point number corresponding to the number of seconds between the Jan 1, 1970 UTC and the end of this measure. www.yoctopuce.com...
  • Page 481 ): double function get_maxValue( ) As Double double get_maxValue( ) double get_maxValue( ) java double get_maxValue( ) def get_maxValue( ) function get_maxValue( ) function get_maxValue( ) Returns : a floating-point number corresponding to the largest value observed. www.yoctopuce.com...
  • Page 482 ): double function get_minValue( ) As Double double get_minValue( ) double get_minValue( ) java double get_minValue( ) def get_minValue( ) function get_minValue( ) function get_minValue( ) Returns : a floating-point number corresponding to the smallest value observed. www.yoctopuce.com...
  • Page 483 When the recording rate is higher then 1 sample per second, the timestamp may have a fractional part. Returns : an floating point number corresponding to the number of seconds between the Jan 1, 1970 UTC and the beginning of this measure. www.yoctopuce.com...
  • Page 484 www.yoctopuce.com...
  • Page 485: Troubleshooting

    22. Troubleshooting 22.1. Where to start? If it is the first time that you use a Yoctopuce module and you do not really know where to start, have a look at the Yoctopuce blog. There is a section dedicated to beginners 22.2.
  • Page 486: Arm Platforms: Hf And El

    22.4. Powered module but invisible for the OS If your Yocto-RangeFinder is connected by USB, if its blue led is on, but if the operating system cannot see the module, check that you are using a true USB cable with data wires, and not a charging cable.
  • Page 487 Waste Electrical and Electronic Equipment (WEEE) If you really want to get rid of your Yocto-RangeFinder, do not throw it away in a trash bin but bring it to a local WEEE recycling point. In this way, it will be disposed properly by a specialized WEEE recycling center.
  • Page 488 www.yoctopuce.com...
  • Page 489: Characteristics

    23. Characteristics You can find below a summary of the main technical characteristics of your Yocto-RangeFinder module. Width 20 mm Length 58 mm Weight USB connector micro-B Max accuracy Max distance 2 m (~6%) Field of view (FOV) 25 °...
  • Page 490 23. Characteristics www.yoctopuce.com...
  • Page 493: Index

    Index DataLogger 29, 414 Delphi 85 Access 103 describe, YDataLogger 421 Accessories 5 describe, YLightSensor 366 Activating 104 describe, YModule 174 Advanced 115 describe, YRangeFinder 239 Already 480 describe, YTemperature 303 Ambient 7 Description 33 Android 103, 104, 125 Detected 7 Another 480 Device 480 Application 125...
  • Page 494 functionName, YModule 179 get_hardwareId, YDataSet 461 Functions 136 get_hardwareId, YLightSensor 376 functionType, YModule 180 get_hardwareId, YModule 188 functionValue, YModule 181 get_hardwareId, YRangeFinder 251 get_hardwareId, YTemperature 313 get_highestValue, YLightSensor 377 get_highestValue, YRangeFinder 252 General 21, 33, 136 get_highestValue, YTemperature 314 get_advertisedValue, YDataLogger 423 get_icon2d, YModule 189 get_advertisedValue, YLightSensor 367 get_lastLogs, YModule 190...
  • Page 495 get_signalUnit, YTemperature 325 get_signalValue, YTemperature 326 get_startTimeUTC, YDataSet 466 Languages 129 get_startTimeUTC, YMeasure 476 Libraries 131 get_subDevices, YModule 200 Library 38, 62, 91, 125, 126, 134 get_summary, YDataSet 467 Light 7 get_timeUTC, YDataLogger 439 LightSensor 26, 357 get_unit, YDataSet 468 Limitations 7, 35 get_unit, YLightSensor 388 Linux 479...
  • Page 496 set_beaconDriven, YDataLogger 450 set_highestValue, YLightSensor 401 Objective-C 65 set_highestValue, YRangeFinder 276 Objects 7 set_highestValue, YTemperature 341 Optional 5 set_logFrequency, YLightSensor 402 set_logFrequency, YRangeFinder 277 set_logFrequency, YTemperature 342 set_logicalName, YDataLogger 451 Paradigm 21 set_logicalName, YLightSensor 403 Platforms 480 set_logicalName, YModule 220 Port 104 set_logicalName, YRangeFinder 278 Porting 134...
  • Page 497 Variants 62 YMeasure 472-476 Variations 8 YModule 169-227 Versus 37 Yocto-Firmware 125 VirtualHub 103, 125, 129 Yocto-RangeFinder 23, 33, 37, 47, 57, 65, 71, Visual 71, 77 77, 85, 91, 97, 103 YoctoHub 125 yPreregisterHub 147 wait_async, YDataLogger 456 YRangeFinder 232-292...

Table of Contents