<commit_before>![](http://res.cloudinary.com/jollen/image/upload/h_110/v1455862763/devify-logo_rh63vl.png)

ESP8266 over the Web: Getting started with IoT System Architecture

## Project Goal

The use scenario of this project.

* Connect an Air Quality sensor with ESP8266
* Programming ESP8266 in Lua programming language
* Setup a CoAP server at your host PC
* Print the data on the screen when CoAP server receives the data from ESP8266

## Quickstart

1. **Device side**. Connect your ESP8266 to WiFi AP, the Lua source code shown at the following section.

2. **Server side**. Run *server.js* of this project at your host PC, your host PC needs [Node.js](https://nodejs.org) runtime.

```
$ npm install
$ export HOST=<server-ip-address>
$ export PORT=<listening-port>
$ npm start
```

## Getting Started

For IoT developers, *Devify* is a software framework which makes it easy to build IoT server using CoAP and WebSocket. It minimizes the time to write a **Hello, World** IoT server. The following explains how ```esp8266-coap-server.js``` works.

First, it requires ```devify-server``` library and get a CoAP server instance.

```
var server = require('devify-server').coapBroker;
```
Then, it invokes ```start()``` method to start the server.

```
server.start();
```

## Use *onmessage* callback

The ```server.js``` demo doesn't print any thing on the screen. To print data received from NodeMCU at the terminal console, you need to implement the ```onmessage``` callback function. 

To print the data sent from NodeMCU, give a ```onmessage``` function callback to ```start()```.
<commit_msg>Update docs<commit_after>![](http://res.cloudinary.com/jollen/image/upload/h_110/v1455862763/devify-logo_rh63vl.png)

ESP8266 over the Web: Getting started with IoT System Architecture

## Project Goal

The use scenario of this project.

* Connect an Air Quality sensor with ESP8266
* Programming ESP8266 in Lua programming language
* Setup a CoAP server at your host PC
* Print the data on the screen when CoAP server receives the data from ESP8266

## Quickstart

### Device side

* Connect your ESP8266 to WiFi AP
* Run [esp8266/coap-air-quality.lua](esp8266/coap-air-quality.lua] of this project

### Server Side

Run *server.js* of this project at your host PC:

```
$ npm install
$ export HOST=<server-ip-address>
$ export PORT=<listening-port>
$ npm start
```

## Getting Started

For IoT developers, *Devify* is a software framework which makes it easy to build IoT server using CoAP and WebSocket. It minimizes the time to write a **Hello, World** IoT server. The following explains how ```esp8266-coap-server.js``` works.

First, it requires ```devify-server``` library and get a CoAP server instance.

```
var server = require('devify-server').coapBroker;
```
Then, it invokes ```start()``` method to start the server.

```
server.start();
```

## Use *onmessage* callback

The ```server.js``` demo doesn't print any thing on the screen. To print data received from NodeMCU at the terminal console, you need to implement the ```onmessage``` callback function. 

To print the data sent from NodeMCU, give a ```onmessage``` function callback to ```start()```.

{'fraction_non_alphanumeric': 0.11223203026481715, 'fraction_numerical': 0.027742749054224466, 'mean_word_length': 4.606007067137809, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2272447', 'n_tokens_mistral': 1013, 'n_tokens_neox': 927, 'n_words': 403}