Skip to content

AnalogIn corrupted after MeshInterface::get_default_instance(); #326

Description

@maclobdell

Description of defect

Adding an AnalogIn object to mbed-os-example-mesh-minimal results in corrupted AnalogIn measurement values.

If the AnalogIn measurement is placed before mesh = MeshInterface::get_default_instance(); (or if that line is commented out), then the correct measurements are printed out.

Expected behavior (with get_default_instance() is commented out).
Full scale uint16 (0 to 65,536) measurements as expected.

61978
61986
61984
61994

Actual behavior (with get_default_instance() called before the measurement)
Results limited to 1 decimal digit. Sometimes in different situations the measurements are 2 or 3 digits consistently but they are always random instead of related to the actual analog value.

0
8
1
3
7

Target(s) affected by this defect ?

K64F
NUCLEO_F429ZI

Toolchain(s) (name and version) displaying this defect ?

GCC_ARM

What version of Mbed-os are you using (tag or sha) ?

Mbed 5.15 (b114a9c)
Mbed OS 6.5 (f227856)

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

N/A

How is this defect reproduced ?

Plug in any analog sensor or voltage value (0-3.3V) to an analog input such as A1.

Add the following code to the mbed-os-example-mesh-minimal main.cpp.

AnalogIn water_sensor(A1);
uint16_t water_sensor_value = 0;

First commend out this part:

    mesh = MeshInterface::get_default_instance();
    if (!mesh) {
        printf("Error! MeshInterface not found!\n");
        return -1;
    }

And then add this part:

    while(1){
        water_sensor_value = water_sensor.read_u16();
        printf("%d\r\n",water_sensor_value);
        ThisThread::sleep_for(2000);
    }

Lastly, to recreate the problem, uncomment the section with get_default_instance().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions