This repository contains source code necessary to launch an Node.js server and NodeMCU with ESP8266 and DHT22.
HTTP proxy server that redirects all requests from the address "szustakowses.nazwa.pl" on port 80 to the address of the Node.js server implemented on port 3400.
This is a design environment based on Google's V8 JavaScript engine. In this environment, we create a web server, server scripts and any auxiliary functions of web applications.
This module acts as a web server and extends the Node.js environment to provide several key components to handle web requests.
It is an efficient NoSQL database with very efficient scalability. In this database we collect data such as temperature and humidity, which are sent from the NodeMCU module by HTTP request - GET.
NodeMCU is an open source IoT platform. It includes firmware which runs on the ESP8266 Wi-Fi SoC.
Module collects data from the DHT22 sensor and sends them with a GET request to the WWW server. The correct data recording is signaled by blinking of the green diode and failure by red. In addition, the current temperature status is signaled by the color of the RGB diode.
...
const char* nodejs_ip = "szustakowses.nazwa.pl";
....
res_status = send_get(cl, "saveData?temp=" + temperature + "&humidity=" + humidity);
...
bool send_get(WiFiClient cl, String msq_GET){
HTTPClient http;
http.begin("http://" + (String)nodejs_ip + "/" + (String)msq_GET);
http.addHeader("Content-Type", "text/plain");
int httpCode = http.GET(); //Get the server response (if correct -> httpCode=200)
http.end();
...
Temperature and Humidity Sensor. Here are the pin definitions:
Pin | Symbol | NodeMCU pin | Descriptions |
---|---|---|---|
1 | VCC | 3V3 | Power supply 3.3V from NodeMCU |
2 | DOUT | D1 + 3V3 | D1 - Data output, 3V3 - 4,7kΩ Resistor to Power |
3 | NC | - | Not use |
4 | GND | G | Ground |
RGB diode with common anode is activated by pwm signal on particular pins corresponding to the color of light.
void setup() {
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
}
//Only red color is powered
analogWrite(red, 0);
analogWrite(green, 1000);
analogWrite(blue, 1000);
Pin | Symbol | NodeMCU pin | Descriptions |
---|---|---|---|
1 | RED | D3 | Resistor 150Ω |
2 | GND | G | Ground |
3 | BLUE | D5 | Resistor 100Ω |
4 | GREEN | D4 | Resistor 100Ω |