DeviceBit Platform and Control Board Joint Test

Share for us

How to Operate DeviceBit Platform

Register an Account on DeviceBit Platform

Login the website (http://www.devicebit.com/home/publicsensors) as shown in fig 5.1. Click Sign Up on the top right corner of the page.

The following page will appear, as shown in fig 5.2. Type your username, password, and Email. Then log on to your mailbox to activate your account.

Add a New Device

Click to enter User Center, go to My Devices -> Devices -> Add A device, fill in corresponding information and then save.

ID: The ID of the device, allocated by system automatically. It is unique for each device. Type: The type of the device.

Ø Arduino: Arduino Board.

Ø Lw-board: The board developed by DeviceBit. Ø Other: Other board.

Name: The name of the device. For example, Smart Home Description: Description of the device.

Public: If your devices are public, other users can also view them and their measurement. Location: The location of your device. Click the location point on the Map.

Add a New Sensor or Controller

The next step is to add a new sensor or controller connected to your device.

  1. Add a new sensor

As shown in fig 5.4, go  to My  Devices  ->  Sensors&Controllers  ->  Sensors, and  then  click Add button to create a new sensor.

Now, the following page will appear, as shown in Fig 5.5:

ID: The ID of the new sensor. It is unique for each sensor. Type: The type of the new sensor.

Unit: The unit of the measurement.

Device: Select the device which the sensor is to be connected to. Name: The name of the new sensor.

Data Conversion: To calibrate your sensor’s measurement. You can fill in the Coefficient and offset if applicable.

Picture: Upload the picture of your sensor.

Public: If your sensors are public, other users can also view them and their measurement. Normal range: The normal range of the sensor’s measurement. You can set it according to your actual need.

Overrange alarm: Turn it on and you will receive the alert by SMS or email when the sensor’s measurement is out of the range.

Data post period: The system indicates that the sensor is OFFLINE if it does not get the data posted by the sensor within every data post period set here.

Remark: Remark of the sensor.

  1. Add a new controller

As  shown in fig 5.6, go to My Devices -> Sensors&Controllers -> Controllers, and then    click Add button to add a new controller.

Now, the following page will appear, as shown in Fig 5.7:

Fill in the related information and then click Save.

The related parameters are explained as follows:

ID: The ID of the new controller. It is unique for each controller. Name: The name of the new controller.

Device: To select the device which the controller is connected to.

Type: The type of the new controller, which can be switch control or numerical control. For switch type, 0 or 1 is used to control the switch. While for numerical type, the controller status is adjusted by different numerical values.

Max-value: The max-value for numerical type. Min-value: The min-value for numerical type.

How to Operate Control Board

Control board is divided into acquisition board and control board. The acquisition board is mainly composed of SUNFOUNDER MEGA2560 and W5100, used to collect sensor data, upload the sensor data to DeviceBit Platform, receive control commands from DeviceBit Platform, and finally send these control commands to the control board via wireless RF module. The control board will

perform related operations after receiving these commands. That is the working process of control board terminal. For specific steps, please see below:

Acquisition board

Components:

SUNFOUNDER MEGA2560 * 1 W5100 * 1

DHT11 * 1

Photoresistor module * 1

Gas sensor MQ-2 * 1

RFID-RC522 * 1

PIR * 1

Gas pressure BMP180 * 1

NRF24L01 * 1

LED * 2

220 Ohm Resistor * 2

USB Cable * 1

Breadboard * 1

Jumper wires

Steps:

First, connect the circuit (connect W5100 and SUNFOUNDER MEGA2560 as shown below)

Connect a 220 Ohm resistor and an LED in series to pin 38 on SUNFOUNDER MEGA2560. Connect another 220 Ohm resistor and another LED in series to pin 40 on SUNFOUNDER MEGA2560. These two LEDs are used to indicate the status of RFID and PIR.

Second, program (Please refer to example code in CD we provide)

Program description: Since we need to detect the status of RFID and PIR in real time, so we upload the data to DeviceBit Platform, and also we use many delays. If we place the code that used to detect the status of RFID and PIR in main loop, it will seriously affect the real-time performance. As a result, we use timer 1 of master chip to regularly detect the status of RFID and PIR to ensure real time. The timer 1 is actually easy to use, that is, set several registers. The registers we use here are TCCR1A (T/C1 control register A), TCCR1B (T/C1 control register B), TCNT1 (16-bit counting register), TIMSK (interrupt mask register) and SREG (interrupt register).

TCCR1A: Since we only use the timing overflow interrupt of timer 1 here, so we set it to 0 to mask the output function of PWM.

TCCR1B: Here we only need to set the CS12, CS11, and CS10 bit of TCCR1B to 1, 0, and 1. That is, select 1024 frequency division.

TCNT1: This register is used to set the timing initial value of timer. We set it to 65536 – F_CPU/F_DIV

* TIME, F_CPU (main frequency of master control board) to 16000000 (16MHz), F_DIV (frequency dividing ratio) to 1024. For TIME (timing length), we define it as 0.1. That is, it will go to the interrupt service program of timer 1 to perform corresponding tasks every 0.1 seconds. The task here is to query the status of PIR and RFID.

TIMSK: This register can be used to turn timers on and off. The timer 1 is opened as long as we set TOIE1 to 1.

SREG: As long as we set the seventh I to 1, we can open the master switch of interrupt. The TOIE1 setting of timer 1 can take effect only if the master switch of the interrupt is opened.

The interrupt service routine for Timer 1 is corresponding to the ISR (TIMER1 OVR vect) function. Once entering the interrupt service routine, the 16-bit counting register will be reset. So we need to reload the initial value, that is, call “TCNT1 = 65536 – F_CPU/F_DIV *TIME;” statement again in the interrupt service routine.

Third, compile the program

Fourth, burn the program into SUNFOUNDER MEGA2560 board

Control Board

Components:

SUNFOUNDER NANO * 1

NRF24L01 * 1

4-channel Relay Module * 1

USB Cable * 1

Steps:

First, connect the circuit

Second, program (Please refer to example code in CD we provide)

Third, compile the program

Fourth, burn the program into SUNFOUNDER NANO board

The physical connection diagram for joint debugging is shown below:

After all the above steps, visit http://www.devicebit.com/home/publicsensors to enter the DeviceBit Platform. Click UserCenteron the top right corner of the page (If you have already login), you will see the following interface as shown in Fig 5.8:

If you have not login, click Login, as shown in Fig 5.9:

Fill in your Username, Password and Verification Code, as shown in Fig 5.10:

After entering into User Center, you will see the following interface as shown in Fig 5.11:

Click Devices, you will see the following interface as shown in Fig 5.12:

Click red “Details” to see your device details, as shown in Fig 5.13:

Return to the interface as shown in Fig 5.11, click Sensors&Controllerson the left side to see your sensors and controllers, as shown in Fig 5.14:

Click Controllers to see your controllers, as shown in Fig 5.15:

If everything goes well, the status icon of Switch should display as blue, which indicate that your master control board is connected to Devicebit Platform. Click Switch, if the icon color changes from blue to red, check the status of your relay at the receiving end, if normal, the corresponding relay should pull in, and the corresponding LED light should be lit. Click Switch again, the icon color change back from red to blue, check the relay status, if normal, the LED light just lit should go out, and the corresponding relay should be disconnected.

Back to the interface as shown in Fig 5.11, click Real-time Data on the left side to see the real-time data of your sensor, as shown in Fig 5.16:

If your master control board is connected to Devicebit Platform and work as normal, the status indicator light of the corresponding sensor on the left side should display as blue, otherwise grey. Click View on the right side to see the corresponding curve of sensor, as shown in figure 5.17:

How to Operate Web app on Mobile Phone

Visit m.devicebit.com on your mobile phone to enter into Devicebit Platform.

Click the icon on the top left corner to select a language.

Select English.

Click Devices icon.

The figure above shows the number of sensors and controllers, click the back icon on the top left corner to return to the interface as shown in Fig 5.20, then click Sensors icon.

Click the back icon on the top left corner to return to the interface as shown in Fig 5.20, then click Controllers icon.

If the connection between your master control board and DeviceBit Platform works normally, switch icons will display as green, otherwise grey. Click any switch icon, you will see the icon color change from green to red. Check your receiving terminal, if everything goes well, the corresponding relay will conduct and the corresponding LED will be lit.

Summary

This paper details how to DIY a simple Smart Home system with SUNFOUNDER MEGA2560 and W5100. Through hands-on practice, you have had a more visual recognition on the Internet of Things. Of course this is only the first step you set your foot in the field of Internet of Things, you can make further exploration on the basis of this paper.