Description
This web application is build for collecting data from BBC microbit sensors and displaying room temperature, light levels during day/night and store all incoming information from the sensors in the database overtime.
Web application functionalities
- A database to store the data
- Possibility to watch the data collection in a terminal as it collects live.
- Web Application with minimalistic design to make it as clear as possible for the eyes of the user.
- Show the stored information with the help of a web application.
- Measure temperature/light level during the day.
- Show the highest and lowest value of the temperature/light during the day.
- Possible to add as many number of micro bits and rooms as user likes.
- Color coded values.
- Login function to show the history of the measurements and only accessible through admin.
- Only admin able to add sensor/s.
You can use any common browser(not internet Explorer).
A terminal is also needed. You can use e.g cygwin or powershell.
Node Js must be installed on your system, follow the link to install for desired operating system. Node
Project Microbit is built with npm, navigate to project to project folder in the terminal and type npm install
to get all the used dependencies in this project.
The script is in python so python must be installed on your system. Pip is also used and the dependencies choosen are Serial, pytz and MYSQL-connector.
pip install pyserial
pip install mysql-connector
pip install pytz
Database is created with Mysql and you must have MYSQL installed on your system. You can install MYSQL with the help of this link depending on your operating system MYSQL
Setup the database with setup.sql and after ddl.sql. First navigate to projectfolder/sql then run the following commands in the terminal.
- First run this command to create database sensors.
mysql -uroot -p < setup.sql
and entering root password that you have chosen during MYSQL installation. - Run this command to create tables.
mysql -uroot -p sensors < ddl.sql
The python script can be uploaded to the sensors by using an online pythoneditor e.g https://python.microbit.org/v/2.0 Transfer LoadReceiver.py to a sensor that you want it to be a reciever(R) to recieve data from other microbits. Transfer LoadSender.py to your other microbit/s. Give each microbit a unique id and specify number of seconds between each reading.
Connect the reciever microbit with usb to pc and it should indicate/display "R" and don't forget to specify which port you are using in connect.py file on line 14 port = "/dev/ttyS8"
if not sure which port then run check.py python3 check.py
in the terminal. Connect the other microbits to a battery source provided with microbits and they should display their id's.
In e.g cygwin or Powershell terminal navigate your way to where the project is located and run "node index.js" to start the server.
Start the website by typing http://localhost:1337/sensors/index.
user: admin
pass: admin
Navigate to "Add sensors" and add the desired number of sensors.
NOTE: in field sensors id be sure to enter the id that displays on the sensors otherwise the data will be lost and not saved in the database.
Open a terminal and navigate yourself to the project folder and to start collecting data, just run "python3 connect.py".
The information can be shown if clicked on sensors names.
Incase you get error "cannot open port", there is a python script which loops through all your ports and shows which port your reciever"R" is using.
Navigate to project folder and run python3 check.py
and it will show you the port that you are using.
You can read more about BBC Microbit here BBC microbit