F18: Wireless sensor network
Contents
Wireless Sensor Network
Abstract
A wireless sensor network (WSN) consists of collection of sensor nodes. Each individual node consists of MCU with on-board sensors and Nordic wireless mesh for communication, which are distributed to monitor physical or environmental conditions, such as temperature, ambient light, humidity etc. The SJ-One board contains an onboard light intensity sensor, and a custom PCB for the project has a combined Temperature, Pressure, and Humidity sensor and an air quality sensor. These sensor data are transmitted to a network coordinator which is the controls the wireless mesh network. The advantage of a mesh configuration is that the data flow is uninterrupted in the network even if one of the nodes fails. The coordinator board colates the data from all nodes, and displays it on a 16x32 LED matrix.
Objectives & Introduction
Show list of your objectives. This section includes the high level details of your project. You can write about the various sensors or peripherals you used to get your project completed.
Team Members & Responsibilities
- Halak Vyas
- Temperature, Pressure and Humidity Sensor Driver (BME280), RTC Config (primary), Wireless driver (secondary), .
- Jay Parsana
- Display driver (primary), Sensor drivers
- Prashant Gandhi
- PCB Assembly, PCB Design (review), Sensor drivers
- Tristan French
- Team lead, PCB Design (primary), PCB Assembly (secondary), Display driver (secondary)
- Vatsal Makani
- Wireless driver (Primary), PCB design (secondary), Wiki lead
Schedule
Week# | Date | Task | Actual |
---|---|---|---|
1 | 10/9 | Tristan
Everyone
|
Tristan
Everyone
|
2 | 10/16 | Everyone
|
Everyone
Unforeseen issues
|
3 | 10/23 | Vatsal
|
Vatsal
|
4 | 10/30 | Halak
Tristan
|
Halak
Tristan
|
5 | 11/6 | Halak
Jay
Prashant
Tristan
Vatsal
|
Halak
Jay
Prashant
Tristan
Vatsal
|
6 | 11/13 | Halak
Jay
Prashant
Tristan
Vatsal
|
Halak
Jay
Prashant
Tristan
Vatsal
|
7 | 11/20 | Halak
Jay
Prashant
Tristan
Vatsal
|
Halak
Jay
Prashant
Tristan
Vatsal
|
8 | 11/27 | Halak
Jay
Prashant
Tristan
Vatsal
|
Halak
Jay
Prashant
Tristan
Vatsal
|
9 | 12/4 | Halak
Jay
Prashant
Tristan
Vatsal
Everyone
|
Halak
Jay
Prashant
Tristan
Vatsal
Everyone
|
10 | 12/11 | Everyone
|
Everyone
|
11 | 12/19 | Everyone
|
Everyone
|
Parts List & Cost
Top level BoM
Item# | Part | Source | Quantity | Unit
Cost($) |
Total
Cost($) |
---|---|---|---|---|---|
1 | SJ One Board | Preet | 5 | 80.00 | 400.00 |
2 | Adafruit RGB LED Matrix | LED Matrix | 1 | 24.95 | 24.95 |
3 | LED matrix Connector board | LED Matrix | 1 | 1.00 | 1.00 |
4 | Led Matrix Power Adapter | N/A (Stock) | 1 | N/A | 0.00 |
5 | Air Quality Sensor | Willwin | 4 | 4.50 | 18.00 |
6 | Custom Sensor PCB Assembly | In House | 4 | 14.72 | 58.87 |
7 | CR1225 RTC Battries | Amazon | 10 | 0.7 | 6.99 |
Total (minus SJ One cost): $109.82
Custom PCB BoM
Item# | Part | Source | Quantity | Unit
Cost($) |
Total
Cost($) |
---|---|---|---|---|---|
1 | Custom Sensor PCB | JLCPCB | 4 | 0.20 | 0.80 |
2 | SMD P, T, H sensor | Digikey | 1 | 6.628 | 6.628 |
3 | USB mini-B SMD receptacle | Digikey | 1 | 0.87 | 0.87 |
4 | 2-position screw terminal, .1in pitch | Digikey | 1 | 0.595 | 0.595 |
5 | 2-pin male header, .1in pitch | Digikey | 2 | 0.099 | 0.198 |
6 | 4-pin female header, .1in pitch | Digikey | 1 | 0.45 | 0.45 |
7 | 17-pin female header w/ long pins, .1in pitch | Digikey | 2 | 1.719 | 3.438 |
8 | Red SMD LED, 0603 | Digikey | 2 | N/A | 0.00 |
9 | 100 Ohm SMD resistor, 0603 | Digikey | 1 | 0.30 | 0.30 |
10 | 300 Ohm SMD resistor, 0603 | Digikey | 1 | 0.066 | 0.066 |
11 | 2.2 kOhm SMD resistor, 0603 | Digikey | 2 | 0.024 | 0.048 |
12 | 3.3 kOhm SMD resistor, 0603 | Digikey | 2 | 0.024 | 0.048 |
13 | 4.7 kOhm SMD resistor, 0603 | Digikey | 4 | 0.30 | 1.20 |
14 | 0.1uF ceramic capacitor, 0603 | Digikey | 2 | 0.038 | 0.076 |
15 | SMD Air Quality sensor | Digikey | 1 (optional) | 12.88 | 0.00 |
16 | 2-pin jumper, .1in pitch | Digikey | 1 (optional) | 0.45 | 0.00 |
Total: $14.72
Design & Implementation
The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.
Hardware Design
The project is based around the SJ one board, which uses an LPC1758 Arm Core M3 microcontroller. The system design consists of two main devices: a wireless master with a display and a wireless sensor node (of which there are several).
Wireless Master
The master board's role is to drive the LED matrix, and receive and log the sensor data. The majority of the functionality of the master can be handled with the default hardware on the SJ One board. The only addition necessary was an antenna for the wireless chip, and a custom connector board.
The custom connector board mounts to the 17x2 header on the SJ One board, and the pins were routed to the appropriate pins of a 2x8 pin header, which the matrix plugged into.
Wireless Slave Node
Each slave node has to interface with each of its sensors and
Hardware Interface
In this section, you can describe how your hardware communicates, such as which BUSes used. You can discuss your driver implementation here, such that the Software Design section is isolated to talk about high level workings rather than inner working of your project.
LED Matrix
Nordic Wireless
The Nordic nRF24L01+ wireless sensor is a highly integrated, ultra low power (ULP) 2Mbps RF transceiver IC for the 2.4GHz ISM (Industrial, Scientific and Medical) band. The nRF24L01+ is designed for operation in the frequency band of 2.400 - 2.483GHz. The high air data rate combined with two power saving modes make the nRF24L01+ very suitable for ultra-low power designs. This chip is interfaced with LPC1758 microcontroller of SJOne Board using SPI pins (MOSI, MISO, CLK, CS). It is the on-board chip in SJOne Board, so no breakout board connections are required for this project. We had to attach a RP-SMA Adapter as well as antenna to communicate between the multiple nodes and the master board.
Sensors
Light Sensor
Light Sensor is an on-board sensor in SJOne Board which interfaces with LPC1758 microcontroller at Port 0, pin 25 analog signal. This sensor shall give the raw value to the controller which will be processed by 12-bit microcontroller ADC. The output of the sensor is shown in a form of 'bulb' indication in LED Matrix
Temperature, Pressure & Humidity (BME280)
BME280 supports both SPI and I2C bus communication. In our wireless mesh project we have used I2C bus over SPI as I2C can read and write registers very easily in compare to SPI and Nordic Wireless is already using SPI bus.Here we are using BME280 sensor of Bosch which has a facility to measure Temperature, Pressure and Humidity. It uses 3.6 microAmps of current at 1Hz and requires 3.3V of voltage which SJOne provides it.
Operating Range : Temperature (-40C to +85C), Pressure (300 to 1100hPa), Humidity (0% to 100%) with +- 1% of tolerance.
The sensor facilitates the user with various modes of operation which can be selected as per preferred environmental conditions. There are basically 3 modes for which range of IIR filter is varied. Those modes are - Indoor Navigation, Weather Monitoring and Gaming Mode. We have facility to switch between those modes, but here for our project we are using Indoor mode as our project is designed to test laboratory environment.
Air Quality Sensor
MQ135 is used for air quality measurement in this project. MQ135 is a low cost semiconductor sensor which can detect Carbon-Dioxide(CO2), Benzene, Smoke, Ammonia(NH3), Mono-nitrogen oxide. Sno2 is used as sensitive material in this sensor and it's conductivity is low in clean air. As the concentration of these sensing gases increases, sensor conductivity also increases. This module can give both analog and digital outputs. For this project we are using analog output. Analog output can go upto 5V, but our SJ-One board can support maximum 3.3V as input, so we need voltage divider circuit which can convert 5V output from module to 3.3V. As we are using analog pin output from module we will configure ADC driver of SJ-One board to read that ADC value and calculate ppm for CO2. Note that in this project we will calibrate our value such that we will get CO2 ppm.
Software Design
Master node with LED Matrix
General Layout
We basically made a bit pattern on the matrix for the 4 screens and each of them displays:
Screen# | Row (0:7) | Row (8:15) |
---|---|---|
1 | Temperature | Humidity |
2 | Temperature(Sun) | Temperature(Sun) |
3 | Pressure | Air Quality |
4 | Light bulb with bars | Light bulb with bars |
It’s the layout of how the display would look for all the screens. We made use of a lookup table for units tens and hundreds positions to update the sensor value on the led matrix. For the LED matrix control signals, as mentioned above in the hardware part, we are making use of SJOne boards 12 GPIO pins.
MatrixTask:
This task that will perform functions like initializing these GPIO pins to output. Here we are scanning the led matrix at a rate of about 500Hz. We have a row_selection function that will go through each and every row one by one. The OE(Output Enable) will be set to high to keep the display off while the data is being buffered to the matrix. We have an ev_switch function inside the matrix task that will buffer the data along with different colors for all the different sensors. Also the ev_switch function when displaying the temperature will switch to temp_color task which will choose different colors for various temperature ranges. The data is being buffered with a duty cycle just like the PWM to control the brightness of the matrix. After pushing the data on to a single row we turn the OElow to turn the display ON and then set the LAT(Latch) high to mark the end of the data for the row.
SwitcherTask:
Its has a medium priority and it will cycle between four screens for about 2 seconds for each screen thereby blocking this task for 2 seconds. We have 2 pointers top and bottom that will fetch the layout from the lookup table and based on the value of the switcher variable it will update layout that it has to display. If the value of the switcher variable is 1, top and bottom will fetch temperature and humidity layout for the top and the bottom portion of LED Matrix respectively.
Matrix_Value_Update_Task
Here we have a matrix_value_update function that will parse the sensor values received from the nodes using value_extractor function and assign it to a values struct object which has 0-9 value for the struct members units, tens and hundreds. These values are then passed to a lookup_switch function which will lookup a matrix of 5x3 that matches the 0-9 digit value and assign it to a pointer. The data indicated by the pointer will overwrite the general layout for each sensor value thereby updating the sensor values on the LED Matrix. The switching between the nodes has been implemented in this task. We scan the switches and based on which switch is pressed we display the respective sensor values.
Slave Node (Sensor reading)
Pseudo-code
- Initialize ADC
- Initialize BME280:
- Create wireless transmit task
- Start task scheduler
- Start wireless transmit task
- Initialize wireless parameters
- Initialize Air quality sensor variables
- Start while 1 loop
- Start Calibrating ADC readings according to atmosphere CO2 value
- Calculation:
MQ_135 = adc0_get_reading(3); __resistance=((4095./(float)MQ_135) - 1.); temp = __resistance/33; air_quality = (PARA*pow(temp,-PARB));
- Get temperature data in form of float from the sensor by reading 0xFA through 0xFC and using it to calculate raw temperature data.
- Raw data is converted into degree C using some mathematical calculation as shown below
temp = (temp * 5 + 128) >> 8; tempf = (float)temp; return (tempf/100.0f);
- Get pressure data in form of float from the sensor by reading 0xF7 through 0xF9 and combining it to get raw pressure data.
- This raw pressure data is converted into actual pressure data in form of kPa.
press = (((1048576 - press_raw) - (var2 >> 12))) * 3125; var1 = ((int32_t)dig_P9 * ((int32_t)(((press >> 3) * (press >> 3)) >> 13))) >> 12; var2 = (((int32_t)(press >> 2)) * (int32_t)dig_P8) >> 13; press = (press + ((var1 + var2 + dig_P7) >> 4)); return (pressf/1000.0f);
- Get humidity data in form of float from the sensor by reading 0xFD through 0xFF and combining it to get raw humidity data.
- This raw humidity data is converted into real value in percentage format.
v_x1 = (v_x1 > 419430400 ? 419430400 : v_x1); humf = (float)(v_x1 >> 12); return (humf/1024.0f);
Implementation
This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.
Testing & Technical Challenges
Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.
Include sub-sections that list out a problem and solution, such as:
<Bug/issue name>
1.Merging the sensor data into a single packet and transmitting the packet at Tx section.
2.Incorrect values received at the Rx section with significant delay.
3.Ensuring the receipt of packets from the correct node without data corruption.
4.Calibration of Air Quality Sensor and Temperature/Humidity/Pressure sensor is a challenging part.
5.Unstable/inconsistent display on LED matrix. Suspect it is due to high frequency and poor connections with jumper cables, planning to make simple header breakout for more robust connection.
- Header breakout did not help, investigating possibility of an issue with the matrix itself.
- Issue resolved. The breakout board did end up fixing the connection issue, but an erroneous line of code which set the latch too early was the main problem.
Conclusion
Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?
Project Video
Project Source Code
References
Acknowledgement
Any acknowledgement that you may wish to provide can be included here.
References Used
List any references used in project.