A Simple Sensor Server Using Cy8ckit-062-wifi-bt

About the project

A CY8CKIT-062-WiFi-BT ModusToolbox project, using BME280 sensor module.

Project info

Difficulty: Moderate

Platforms: Cypress

Estimated time: 1 week

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

Cy8ckit-062-wifi-bt Psoc 6 Pioneer Kit Cy8ckit-062-wifi-bt Psoc 6 Pioneer Kit x 1
BME280 Sensor Module BME280 Sensor Module Some jumper wires and a bread-board x 1

Software apps and online services

ModusToolbox 2.2 ModusToolbox 2.2
Cygwin Cygwin Need C compiler and Bash
Tera Term Tera Term
Google Chrome Google Chrome A web browser which work on your PC

Story

Preface

Although submitting to “The Great PSoC 6 Design Challenge”,

this project is not a great project.

But I hope that this can give some hints for newcomers of

PSoC 6 and/or ModusToolbox.

This program uses a BME280 sensor module as data source via I2C interface

and display Temperature, Humidity, Pressure in a Web Browser.

A onboard LED can be toggled by using the “Toggle LED” button,

and the status of the LED will be also reflected with color Red/Black.

Since this project is using Wi-Fi connection, the sensor and LED can be accessed

from a PC or an iPhone. (I have not tried with an Android but hopefully it will also work)

To build the project, 

(1) Create a new project from ModusToolbox Template Application AnyCloud_HTTPS_Server

(2) Replace the following files

main.c

secure_http_server.h

secure_http_server.c

generate_ssl_certs.sh

(3) Add  the following files to the project

html.h

i2c_utils.h

i2c_utils.c

bme280.h

bme280.c

(4) Modify secure_http_server.h for

WIFI_SSID

WIFI_PASSSED

(5) Generate certifications (cygwin)

Run generate_ssl_certs.sh

(6) compile ssl2c.c (cygwin)

$ cc ssl2c.c -o ssl2c

(7) Convert certifications into C strings filse (cygwin)

$ ssl2c s3.local.crt local_crt.h

$ ssl2c s3.local.key local_key.h

$ ssl2c rootCA.crt rootCA_crt.h

(8) Copy and paste the contents of local_crt.h in the secure_keys.h keySERVER_CERTIFICATE_PEM definition

(9) Copy and paste the contents of local_key.h in the secure_keys.h keySERVER_PRIVATE_KEY_PEM definition

(10) Copy and paste the contents of rootCA_crt in the secure_keys.h  keyCLIENT_ROOTCA_PEM definition

(11) compile html2c.c (cygwin)

$ cc html2c.c -o html2c

(12) Convert test.html to test_html.h

$ html2c test.html test_html.h

(13) Copy and paste the contents of test_html.h in the html.h  HTTPS_STARTUP_WEBPAGE definition

(14) Build and Run the project.

Schematics, diagrams and documents

Connection of CY8CKIT-062-WiFi-BT and BME280 sensor module

Connection diagram between CY8CKIT-062-WiFi-BT and BME280 Sensor module

A Simple Sensor Server.pdf

A brief pdf explanation of how to prepare/build/run the project

Code

html2c.c

A cygwin program to convert a HTML file into C strings to be placed in the html.h. Note: This is not a part of the application, but to be used to generate C strings files.

i2c_utils.h

I2C utility API to hide the difficulty of PDL API.

bme280.c

bme280 interface API program

(modified) main.c

main.c from the ModusToolbox Template application AnyCloud_HTTPS_Server modified for this project

i2c_utils.c

I2C utility to hide the difficulty of PDL API

test.html

html file for the web page Edit and test this html file then convert it into C String file using html2c.

(modified) secure_http_server.c

secure_http_server.c from ModusToolbox Template Application AnyCloud_HTTPS_Server, modified for this project.

ssl2c.c

A cygwin program to convert generate_ssl_certs.sh generated crt and key files into C strings. Note: This is not a part of the Application, but to be used to create required C strings files from <servername>.local.crt, <servername>.local.key, rootCA.crt to C strings to be placed in secure_keys.h

html.c

The HTML page to be displayed via Wi-Fi connection. The HTML is converted in to C Strings using ssl2c program.

test_html.h

C string files converted from test.html using html2c. Copy and paste the contents into html.h

(modified) secure_http_server.h

secure_http_server.h from ModusToolbox Template Project AnyCloud_HTTPS_Server modified for this project.

bme280.h

header for bme280 interface program

Credits

Leave your feedback...