• sales

    WeChat:spotpear

  • support

    WeChat:zhoujie13424403025

Chapter 3 of KitiBot-Microbit: Sensors

Chapter 3 Sensors

Micro:bit integrates temperature sensor, Accelerometer, compass and so on. In this chapter, we learn to use these sensor.

Temperature Sensor


In fact, micro:bit has no temperature sensor on board, what we used to measure temperature is the sensor in its main chip. The sensor is used to measure the temperature of chip but not the ambient temperature. However, we can take it as ambient temperature as they are similar.

The main chip we say is nRF51822, where the temperature is inside.


Find temperature block in Input class, combine with number block we could measure the temperature. Simulating the project, you can see the number changes when we change the temperature.


Download the project to micro:bit, touch the chip for some time, and you can find the value increased.

Accelerometer


MMMA8652 is integrated on micro:bit, locates at the left bottom of micro:bit


Acceleration: According to second Newton second law, the net force applied to a body produces a proportional acceleration. Acceleration is proportional to force and it is inversely proportional to body's mess. The direction of acceleration is same as force's, its formulas is F=ma. That is when force applied to body in one direction, and then the body trends to move to the same direction, this trend, we call it acceleration.

We say that acceleration is a trend to move, it could be only a trend without any move. Take a example, we are being applied gravity all the time, if there is not any holder we will fall. It is that we have a trend to falling, which is called the acceleration of gravity written as g in formulas.

We measure coordinate of x, y and z directions. With these three value, we could get the direction of accelerations. If there is only acceleration of gravity, the direction is downward. We keep measuring the value of x, y and z coordinates to get the acceleration of micro:bit.


Let's try it, find "on share" block in Input class


Using this block, micro:bit can detect the states as below. When it is free falling, the acceleration is 0. 3g, 6g and 8g stand for triple times, six times and eight times gravitional acceleration separately. You can shake the micro:bit to get these states.


Shaking on simulate area you can get different states, the LED matrix will display different icons. Download the code to test the actual effect.

magnetometer


Micro:bit integrates a magnetometer sensor MAG3110, marked with red frame on figure below. It is similar to accelerometer, magnetometer get the direction and size of magnetic force by measuring x, y and z coordinates.

We show magnetic force with bar chart.


When running the code, it will first display "DRAW a CIRCLE" to ask you to draw a circle. You need to move the micro:bit to calibrate magnetometer. The led on center will light on and turn to different directions, you need to move the micro:bit to get a circle as below to finish calibration.


After getting a smile face, the code is ready to use now.

At the beginning, there are only several leds light on, but if you close magnetometer of micro:bit to magnet, the magnetic field will be bigger, more leds will light on.

There is magnet on speaker, so you can test with your phone. Closer speaker of your phone to micro:bit.

Compass


micro:bit has not compass sensors, however we could combine the data of accelerometer and magnetometer and realize function of compass.

Accelerometer measure acceleration of gravity whose direction is downward. With acceleration we could check the states of micro:bit.

Effected by magnetic field, the horizontal component of terrestrial magnetism always point to Magnetic North.

【Note】you need to keep micro:bit motionless and avoid of other magnetic fields. Otherwise the measurement result is not correct.


After running the code, you need to "draw a circle" as well. It will display the position of X-axis against North. Put micro:bit horizontally and rotate it to make the value turn to 0. In this case, the direction x-axis point is the North.

Brightness


micro:bit has not actual light sensor on board. It sensors ambient light through LED matrix, keeps converting LED drivers to input and sampling decay time of voltage to get an approximate parameter of ambient light.

We use light level block here


Use bar chart to show light level, check on simulate area we can find that if light level is bigger, more leds are lighted on. You can try to light the LED matrix by flashlight.

Price: $31.89
Part Number: 5inch DPI LCD
Brand: Spotpear
SKU: 0105211