Cannt Reading Wind Direction after read LightLevel from MicroBit

Cannt Reading Wind Direction after reading LightLevel from MicroBit.

always get “???”

without “input.lightLevel()” is ok

I changed to a different microbit, but the same phenomenon occurred.

plz help.

Code this


input.onButtonPressed(Button.A, function () {

control.reset()

})

weatherbit.startWindMonitoring()

weatherbit.startRainMonitoring()

weatherbit.startWeatherMonitoring()

basic.forever(function () {

serial.writeLine(weatherbit.windDirection())

serial.writeLine(“” + input.lightLevel())

basic.pause(1000)

})

Hi azuma52s,

It most likely is an issue with your code and, unfortunately, SparkFun’s Tech Support cannot assist with debugging custom code. I would recommend adjusting the print statement for the Light Sensor to try and get it working or create a string for both Wind Direction and Light Level similar to the example [here.](https://learn.sparkfun.com/tutorials/microclimate-kit-experiment-guide/experiment-7-logging-to-the-microsd-card)

I code this using https://makecode.microbit.org/ and https://makecode.microbit.org/pkg/spark … eather-bit

Im not using my custom code.

Sorry for any confusion here but the code you have written, while using the weather:bit extension, is not in any of our guides so that would constitute custom code. We cannot help you debug this but again, I would recommend referring to the completed examples from the [Experiment Guide to identify what is causing the issue with your code with known-good example code.

Most likely, it is how you are trying to print the Light Sensor data since it constantly returns “???” meaning the print statement is probably invalid.](micro:climate Kit Experiment Guide - SparkFun Learn)

TS-Mark:
Sorry for any confusion here but the code you have written, while using the weather:bit extension, is not in any of our guides so that would constitute custom code. We cannot help you debug this but again, I would recommend referring to the completed examples from the [Experiment Guide to identify what is causing the issue with your code with known-good example code.

Most likely, it is how you are trying to print the Light Sensor data since it constantly returns “???” meaning the print statement is probably invalid.
[/quote]

OK. I remake the code most simple.

I bought another weather:bit to check hardware problem. but I got same problem.

code this. (sorry Im a Japanese)](micro:climate Kit Experiment Guide - SparkFun Learn)

Hi again,

I’m pretty sure it is a code issue since you’re having the same issue with two boards. Try modifying the [Light Level Experiment to redirect serial to USB. Then use the “Serial Write Number” block and duplicate the “Light Level” block and place that in the “serial write number” block. I tried that with a micro:bit here and it works just fine to print the light level values over serial to a terminal program. Here is the JavaScript of that MakeCode:

let lightVal = 0
basic.forever(function () {
    serial.redirectToUSB()
    lightVal = input.lightLevel()
    serial.writeNumber(input.lightLevel())
})

I cannot help you get everything working together but hopefully this gives you a place to start. Also, the [MakeCode Reference Page is a great resource to learn the various functions of MakeCode to keep learning and developing your own code.](Reference)](https://learn.sparkfun.com/tutorials/microclimate-kit-experiment-guide/all#experiment-2-reading-the-light-level)

I found a bug in ex. weatherbit.windDirection()

this function returns “???” after call input.lightlevel()

basic.forever(function () {

lightlevel = input.lightLevel()

let i = 0

for (i = 0; i < 5; i++) {

dir = weatherbit.windDirection()

basic.pause(1)

if (dir != “???”) break;

}

serial.writeLine(“” + i + “:” + dir + lightlevel)

})

‘No one wants to admit self mistakes.’

outpus like this

3:S32

3:S33

2:S32

3:S33

3:S32

3:S33