Nominate our 2022 Qt Champions!

Ambient Temperature Sensor

  • Hello everyone!
    I am trying to work with the AmbientTemperatureSensor in Qt Qml for Android.
    I have just ran the Qt example called accelbuble( And just added nexn code to the qml part:
    Rectangle {
    TextField {
    id: txt
    anchors.fill: parent
    text: (temp.reading ? temp.reading.temperature : "unknown")

    AmbientTemperatureSensor {
        dataRate: 100
        active: true
        id: temp
        onReadingChanged: {
            var t = (temp.reading ? temp.reading.temperature : "unknown");
            txt.text = t;
            console.log("Temp: ",t);

    But the program always write "unknown", even if i run it on real mobile phone.
    I am new to QML, so thanks for your answers!

  • It seems you are getting your technologies mixed up. The example you run is for the accelerometer (movement) but you are talking about a temperature sensor. Just adding bits of code is not going to make code run, there is a little more to it than that.

Log in to reply