Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266WiFi.h>
- #include <LiquidCrystal.h>
- const char* ssid = "embarcados";
- const char* password = "embarcados";
- const int ledPin = 2;
- WiFiServer server(32000);
- void printWiFiStatus();
- void setup(void) {
- Serial.begin(115200);
- WiFi.begin(ssid, password);
- // Configure GPIO2 as OUTPUT.
- pinMode(ledPin, OUTPUT);
- // Start TCP server.
- server.begin();
- printWiFiStatus();
- }
- void loop(void) {
- // Check if module is still connected to WiFi.
- uint8_t command[30];
- if (WiFi.status() != WL_CONNECTED) {
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- }
- // Print the new IP to Serial.
- }
- WiFiClient client = server.available();
- if (client) {
- Serial.println("Client connected.");
- while (client.connected()) {
- if (client.available()) {
- //char command = client.read();
- String line = client.readStringUntil('/');
- Serial.println(line);
- display_data(line);
- /* if (command == 'H') {
- digitalWrite(ledPin, HIGH);
- Serial.println("LED is now on.");
- }
- else if (command == 'L') {
- digitalWrite(ledPin, LOW);
- Serial.println("LED is now off.");
- }
- Serial.println(command);*/
- }
- }
- Serial.println("Client disconnected.");
- client.stop();
- }
- delay(500);
- }
- void printWiFiStatus() {
- Serial.println("");
- Serial.print("Connected to ");
- Serial.println(ssid);
- Serial.print("IP address: ");
- Serial.println(WiFi.localIP());
- }
- void display_data(String temp){
- const int rs = 0, en = 15, d4 = 13, d5 = 12 , d6 = 14, d7 = 16; // temque mudar
- LiquidCrystal lcd(rs,en,d4,d5,d6,d7); // config
- lcd.begin(16,2);
- lcd.setCursor(0,0); // zero 1
- lcd.print(temp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement