KS4027 KS4028 Smart Home Kit for Micro:bit Python Tutorial

Introduction:

Fueled by the rapid development of technology, smart homes automatically controlled remotely by smart phones and other devices have become more common. For the same reason, they have increasingly gained closer attention and caught people ‘s fancy.

Bearing the aim to make improvements in household living conditions, the smart home system has been integrated with technologies including computer science, telecommunication, automatic control and others and emerged as a comprehensive and smart system featuring safety, convenience, coziness, services , utility and environmental consciousness.

Description:

Launched by Keyestudio, this smart home kit is based on the open-source hardware of Micro:bit and designed for those who dream of living a more comfortable life with the help of technologies.

This smart home system, with Micro:bit as its control board, is equipped with a 1602 LCD, a DHT11 temperature and humidity sensor, an analog gas sensor(MQ_2), a PIR motion sensor , a 6812 RGB module, a servo, a steam sensor, a Micro:bit BT and other sensors.

With the help of these sensors, this kit can be applied to detect temperature, humidity and the concentration of flammable gases in your home and open and close doors. Furthermore, all the information detected can display on 1602 LCD in real time available for you to check and monitor via smart phones or iPad. By the way, it supports powering by solar energy or via USB cable.

This tutorial programs in MicroPython language which is the Micro:bit version of Python language. It will guide you to use software Mu to write MicroPython language for Micro:bit main board to control the smart home system. In this process, not only can you enhance your ability to make stuffs but also learn the skills of programming.

Python is one of the most popular programming language especially in machine learning for its availability and accessibility have brought huge convenience to this field. However, MicroPython is a lean and efficient implementation of the Python programming language for microcontrollers and embedded systems.

This tutorial is a Python tutorial for micro:bit smart home. If you haven’t learned the basic tutorial ( Makecode version of Tutorial), we strongly recommend you to learn it first. Because the basic one is programmed using graphical blocks, which is easier to understand and start.

Kit List:

When you get this delicate kit, please confirm whether all components listed below have been delivered.

#

Parts

Quantity

Picture

1

Micro:bit Main Board Included in KS4027 Not included in KS4028

1

6(1)

2

Keyestudio Micro:bit Expansion Board with IO Port

1

IMG_256

3

Wooden Board

7

椴木板_画板 1

4

Acrylic Board

3

91110

5

6812 RGB Module

1

16

6

Analog Gas Sensor

1

17

7

130 Motor Module

1

25(1)

8

Steam Sensor

1

14

9

DHT11 Temperature and Humidity Sensor

1

1

10

PIR Motion Sensor

1

15

11

Yellow LED Module

1

13

12

Rechargeable Lithium Battery Power Module with Solar and USB Ports

1

18

13

Battery Holder

1

21

14

Micro:bit Solar Energy Panel

1

22

15

Servo

2

IMG_256

16

I2C 1602 LCD Module

1

KS0062 (4)

17

Rocker Switch

1

13 (2)

18

15cm 3Pin F-F DuPont Wire

4

C:UsersAdminDesktopKS0078 旅行房车机器人安装步骤模块3pin 黑红黄 150mm(1).png3pin 黑红黄 150mm(1)

19

20cm 3Pin F-F DuPont Wire

2

C:UsersAdminDesktopKS0078 旅行房车机器人安装步骤模块3pin 黑红黄 200mm(1).png3pin 黑红黄 200mm(1)

20

20cm F-F DuPont Wire

4

23

21

20cm 4Pin F-F DuPont Wire

1

C:UsersAdminDesktopKS0078 旅行房车机器人安装步骤模块4pin 黑红蓝绿 200mm(1).png4pin 黑红蓝绿 200mm(1)

22

200mm 2Pin DuPont Wire

2

20

23

M2*8MM Round-head Screw

3

M3X6MM圆头 十字

24

M1.4*6MM Round-head Self-tapping Screw

10

MICRO SERVO 9G

25

M3 Nickel-plated Self-locking Nut

5

26

M4*8MM Round-head Screw

18

M3X6MM圆头 十字

27

M3*6MM Round-head Screw

9

M3X6MM圆头 十字

28

M3*10MM Round-head Screw

9

M3X8MM圆头 十字

29

M2*12MM Round-head Screw

5

M3X8MM圆头 十字

30

M4 Nickel-plated Nut

18

M3镀镍

31

M3 Nickel-plated Nut

6

M3镀镍

32

M2 Nickel-plated Nut

7

M2镀镍

33

M3*8MM Round-head Screw

2

M3X10MM平头

34

Wrench

1

C:UsersAdminDesktop模块十字套筒.jpg十字套筒

35

3.0*40MM Screwdriver Red-Black

1

36

2.0*40MM Screwdriver Purple-Black

1

螺丝钉

37

M3*45MM Dual-pass Copper Pillar

4

双通铜柱1

38

USB Cable AM/MK5P(micro) Black OD:3.5 L=1M PVC

1

IMG_256

39

F5 Blue to Blue LED

2

蓝灯

40

18650 Battery(Not Included)

1

Preparations:

Background Information about Micro:bit

( 1 )What is Micro:bit?

Micro:bit is an open source hardware platform based on the ARM architecture launched by British Broadcasting Corporation (BBC) together with ARM, Barclays, element14, Microsoft and other institutions. The core device is a 32-bit Arm Cortex-M4 with FPU micro-processing.

Though it is just the size of a credit card, the Micro:bit main board is equipped with loads of components,including a 5*5 LED dot matrix, 2 programmable buttons, an accelerometer, a compass, a thermometer, a touch-sensitive logo and a MEMS microphone, a Bluetooth module of low energy, and a buzzer and others. Thus, it also boasts multiple functions.

The buzzer built in the other side of the board makes playing all kinds of sound possible without any external equipment. The golden fingers and gears added provide a better fixing of crocodile clips. Moreover, this board has a sleeping mode to lower power consumption of batteries and it can be entered if users long press the Reset & Power button on the back of it. It is capable of reading the data of sensors, controlling servos and RGB lights and attaching with a shield so as to connect with various sensors. It also supports a variety of codes and graphical programming platforms, and is compatible with almost all PCs and mobile devices. It has no need to install drivers. It is of high integration of electronic modules, and has a serial port monitoring function for easy debugging.

The board has found wild applications. It can be applied in programming video games, making interactions between light and sound, controlling a robot, conducting scientific experiments, developing wearable devices and make some cool inventions like robots and musical instruments, basically everything imaginable.

( 2 )Layout

For the Micro: Bit main board, pressing the Reset & Power button , it will reset the Micro: Bit and rerun the program.

For more information,please resort to following links:

https://tech.microbit.org/hardware/

https://microbit.org/new-microbit/

https://www.microbit.org/get-started/user-guide/overview/

https://microbit.org/get-started/user-guide/features-in-depth/

( 3 ) Pinout

v2.0引脚-01(2)

The functions of pins:

GPIO

P0,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P19,P20

ADC/DAC

P0,P1,P2,P3,P4,P10

IIC

P19(SCL),P20(SDA)

SPI

P13(SCK),P14(MISO),P15(MOSI)

PWM(used frequently)

P0,P1,P2,P3,P4,P10

PWM(not frequently used)

P5、P6、P7、P8、P9、P11、P12、P13、P14、P15、P16、P19、P20

Occupied

P3(LED Col3),P4(LED Col1),P5(Button A),P6(LED Col4),P7(LED Col2),P10(LED Col5),P11(Button B)

Browse the official website for more details:

https://tech.microbit.org/hardware/edgeconnector/

https://microbit.org/guide/hardware/pins/

( 4 )Notes for the application of Micro:bit main board

  1. It is recommended to cover it with a silicone protector to prevent short circuit for it has a lot of sophisticated electronic components.

  2. Its IO port is very weak in driving since it can merely handle current less than 300mA. Therefore, do not connect it with devices operating in large current, such as servo MG995 and DC motor or it will get burnt. Furthermore, you must figure out the current requirements of the devices before you use them and it is generally recommended to use the board together with a Micro:bit shield.

  3. It is recommended to power the main board via the USB interface or via the battery of 3V. The IO port of this board is 3V, so it does not support sensors of 5V. If you need to connect sensors of 5 V, a Micro: Bit expansion board is required.

  4. When using pins(P3、P4、P6、P7、P10)shared with the LED dot matrix, blocking them from the matrix or the LEDs may display randomly and the data about sensors connected maybe wrong.

  5. Pin 19 and 20 can not be used as IO ports though the Makecode shows they can. They can only be used as I2C communication.

  6. The battery port of 3V cannot be connected with battery more than 3.3V or the main board will be damaged.

  7. Forbid to operate it on metal products to avoid short circuit.

To put it simple, Micro:bit V2 main board is like a microcomputer which has made programming at our fingertips and enhanced digital innovation. And as for programming environment, BBC provides a website: https://microbit.org/code/, which has a graphical MakeCode program easy for use.

Install Micro:bit driver

Micro:bit is free of driver installation. However, in case your computer fail to recognize the main board, you can install the diver too.

Just enter the link https://fs.keyestudio.com/KS4027-4028 to download the driver file of micro:bit in file folder .

Assemble the Smart Home

Part 1

Components Needed

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第一部分.jpg!_第一部分

Installation Diagram

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第一部分安装.jpg!_第一部分安装

Prototype

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第一部分完成.jpg!_第一部分完成 (wire up the 1602 LCD, as shown below) ef7d6ce5e6c7408c956d14399d8504e

Part 2

Components Needed

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第二部分.jpg!_第二部分

Installation Diagram

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第二部分安装.jpg!_第二部分安装

Prototype

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第二部分完成.jpg!_第二部分完成

Part 3

Components Needed

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第三部分.jpg!_第三部分

Installation Diagram

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第三部分安装.jpg!_第三部分安装

Prototype

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第三部分完成.jpg!_第三部分完成

Adjust the angle of the servo controlling windows to 0°

Wiring: Micro:bit Expansion Board

Servo

GND

Brown Wire

5V

Red Wire

S(9)

Orange Wire

Connect the main board with the shield and with the computer via USB cable;

Plug them up;

Turn the slide switch on the board to the “ON”end, and the rocker switch to the “1”end.

IMG_256

Example code:

After uploading the example code to Micro:bit, the angle of the servo is set to 0°.

Part 4

Components Needed (peel the sticker off the gear-shaped Acrylic board first)

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第四部分.jpg!_第四部分

Installation Diagram

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第四部分安装.jpg!_第四部分安装

Prototype

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第四部分完成.jpg!_第四部分完成

Part 5

Components Needed

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第五部分.jpg!_第五部分

Installation Diagram

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第五部分安装.jpg!_第五部分安装

Prototype

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第五部分完成.jpg!_第五部分完成

Part 6

Components Needed

(peel the sticker off the Acrylic board first)

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第六部分.jpg!_第六部分

Installation Diagram

(The gears of the N Board should be properly jointed with the wooden gear and do not fix the self-locking nut tight; after installation, the door is closed.)

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第六部分安装.jpg!_第六部分安装

Prototype

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第六部分完成.jpg!_第六部分完成

Part 7

Components Needed

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第七部分.jpg!_第七部分

Installation Diagram

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第七部分安装.jpg!_第七部分安装

Prototype

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第七部分完成.jpg!_第七部分完成

Part 8

Components Needed

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第八部分.jpg!_第八部分

Installation Diagram

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第八部分安装.jpg!_第八部分安装

Prototype

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第八部分完成.jpg!_第八部分完成

Part 9

Components Needed

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第九部分.jpg!_第九部分

Installation Diagram

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第九部分安装.jpg!_第九部分安装

Prototype

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第九部分完成.jpg!_第九部分完成

Part 10

Components Needed

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第十部分.jpg!_第十部分

Installation Diagram

(stick the solar panel along the right side of the line marked in the picture; pull the wires on the panel out from the hole in the middle.)

Prototype

1

Part 11

Components Needed

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第十一部分.jpg!_第十一部分

Installation Diagram

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第十一部分安装.jpg!_第十一部分安装

Prototype

C:UsersAdministratorDesktop熊巍创客教育组项目新智能家居安装步骤安装图片!_第十一部分完成.jpg!_第十一部分完成

Part 12

Components Needed

!_第十二部分

Installation Diagram

!_第十二部分安装

Prototype

!_第十二部分完成

Part 13

Components Needed

!_第十三部分

Installation Diagram

!_第十三部分安装

Prototype

!_第十三部分完成

Part 14

Components Needed

!_第十四部分

Installation Diagram

!_第十四部分安装

Prototype

!_第十四部分完成

Part 15

Components Needed

!_第十五部分

Installation Diagram

!_第十五部分安装

Prototype

!_第十五部分完成

Part 16

Components Needed

!_第十六部分

Installation Diagram

!_第十六部分安装

Prototype

!_第十六部分完成

Part 17

Component Needed

!_第十七部分

Installation Diagram

2

Prototype

!_第十七部分完成

Part 18

Components Needed

!_第十八部分

Installation Diagram

!_第十八部分安装

Prototype

!_第十八部分完成

Part 19

Components Needed

(peel the sticker off the Acrylic board first)

!_第十九部分

Installation Diagram

!_第十九部分安装

Prototype

!_第十九部分完成

Part 20

Components Needed

!_第二十部分

Installation Diagram

!_第二十部分安装

Prototype

!_第二十部分完成

Part 21

Components Needed

!_第二十一部分

Installation Diagram

!_第二十一部分安装

Prototype

!_第二十一部分完成

Start Wiring

The wiring of the battery holder

(plug its jack to the BAT end of the rechargeable power module)

cb8c1554135811286767d2a42b2880d

The wiring of the yellow LED

aa334cbf32c9effe78b2e4796e05310C:/Users/Administrator/AppData/Local/Temp/picturecompress_20210806091342/output_1.jpgoutput_1

IMG_256

The wiring of the RGB module

3e485e00ca9e8695c4b113c8c724e8aC:/Users/Administrator/AppData/Local/Temp/picturecompress_20210806091438/output_1.jpgoutput_1

IMG_256

The wiring of the PIR motion sensor

Use the longer Dupont wire

23599a31a9a21a3e2715add9ac5bc55C:/Users/Administrator/AppData/Local/Temp/picturecompress_20210806091533/output_1.jpgoutput_1

IMG_256

The wiring of the 1602LCD

ef7d6ce5e6c7408c956d14399d8504eC:/Users/Administrator/AppData/Local/Temp/picturecompress_20210806091556/output_1.jpgoutput_1

IMG_256

The wiring of the analog gas sensor

88b1ec43f948b822c0d56354a1fd194C:/Users/Administrator/AppData/Local/Temp/picturecompress_20210806091624/output_1.jpgoutput_1

IMG_256

The wiring of the humidity and temperature sensor

Use the longer Dupont wire

54692b56d2983e1ff24bb2cdc67824dC:/Users/Administrator/AppData/Local/Temp/picturecompress_20210806091700/output_1.jpgoutput_1

IMG_256

The wiring of the servo controlling the door

C:/Users/Administrator/AppData/Local/Temp/picturecompress_20210806091758/output_1.jpgoutput_1

IMG_256

The wiring of the servo controlling the window

a068e0fa63eef8e4c7d9376796b0f1aC:/Users/Administrator/AppData/Local/Temp/picturecompress_20210806091827/output_1.jpgoutput_1

IMG_256

The wiring of the rechargeable lithium battery power module (Connect the shield with it; attach the red wire to V and the black one to G.)

1381ef64bec45c99a61a415c336ebfc

The wiring of the solar panel

The wiring of the motor (Please pay attention to the pins and the connection cannot be reversed.)

5a9676493c388feb8c7c835afc3db33

The wiring of the steam sensor

(Connect it to the P0 of 3.3V or the analog value can not be read.)

IMG_256

Mount the Roof

Components Needed

!_第二十二部分

Installation Diagram

!_第二十二部分安装1

Prototype

!_第二十二部分安装1完成

Installation Diagram

!_第二十二部分安装2

Prototype

!_第二十二部分安装2完成

Install Micro:bit main board

!_第二十二部分安装3

Prototype

!_第二十二部分完成(总装完成)