Message Boards Message Boards

Why do I have different temperature data on Micro:bit and Mathematica?

Posted 27 days ago

Hello,

I am playing with Micro:bit and Mathematica. I wanted to simply visualize current temperature (measuring constantly) in Mathematica with temperature sensor on Micro:bit. I have programmed Micro:bit and wrote a code in Mathematica using Dynamic and ThermometherGauge function to do the visualization. It works, but I noticed that data showing in MakeCode is different (and more accurate) than the data showing in Mathematica. And I can be sure that the temperature showing in Mathematica is wrong because 32ºC is not possible currently and it never changes. And the gauge is constantly showing 10 then 50 and then 32ºC. I do not know why is that.

Code for Micro:bit in JavaScript:

let temp = 0
basic.forever(function () {

})
basic.forever(function () {
    // Get the temperature in Celsius
    temp = input.temperature()
    // Write temperature to serial as a number
    serial.writeNumber(temp)
    // Write a newline to ensure proper reading
    serial.writeLine("")
    // Wait for 2 seconds before sending next value
    basic.pause(2000)
})

Mathematica:

Dynamic[temp = DeviceRead[microbit] ] 
 Dynamic[ThermometerGauge[temp, {0, 50}, ScaleOrigin -> 0, 
   GaugeLabels -> "Temperature (°C)"]]

Thanks in advance!

POSTED BY: Ivo P.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract