Giter Site home page Giter Site logo

123's People

Watchers

James Cloos avatar Pham Ba Tuan Chung avatar

123's Issues

1233232

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include "rgb_lcd.h"
#include "DHTesp.h"

DHTesp dht;
rgb_lcd lcd;

char auth[] = "74f55421d63f4d31bb5f3385ba033431";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Embedded";
char pass[] = "tu1den10";
int pinValue = 0;
int GreenValue = 0;
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
dht.setup(D4);
delay(1000);
}

BLYNK_READ(V3)
{
delay(dht.getMinimumSamplingPeriod());
//float humidity = dht.getHumidity();
float humidity = dht.getHumidity();
// Serial.print("temperature: ");
// Serial.println(humidity);
Blynk.virtualWrite(V3, humidity);
//lcd.print("Hello");
//Serial.print("temperature: ");
//Serial.println(temperature);
delay(2000);
}

BLYNK_READ(V4)
{
delay(dht.getMinimumSamplingPeriod());
float temperature = dht.getTemperature();
//float temperature = dht.getTemperature();
Blynk.virtualWrite(V4, temperature);
//Serial.print("humidity: ");
//Serial.println(humidity);
delay(2000);
}

void loop()
{
Blynk.run();
// delay(dht.getMinimumSamplingPeriod());
//float humidity = dht.getHumidity();
// float temperature = dht.getTemperature();
//Blynk.virtualWrite(V3, "Test");//temperature);

//delay(500);

}

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include "rgb_lcd.h"

rgb_lcd lcd;

char auth[] = "74f55421d63f4d31bb5f3385ba033431";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Embedded";
char pass[] = "tu1den10";
int pinValue = 0;
int GreenValue = 0;
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setRGB(pinValue, pinValue, pinValue);
lcd.clear();
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
lcd.setCursor(2,0);
lcd.print("Hello world!");
lcd.setCursor(0,1);
lcd.print("From Wemos D1 R2");
}
BLYNK_WRITE(V1)
{
pinValue = param.asInt();
//]GreenValue = param.asInt();
Serial.print("Slider value: ");
Serial.println(pinValue);
Serial.print("Green value: ");
Serial.println(GreenValue);
lcd.setRGB(pinValue, GreenValue, pinValue);
}

BLYNK_WRITE(V2)
{
//pinValue = param.asInt();
GreenValue = param.asInt();
Serial.print("Slider value: ");
Serial.println(pinValue);
Serial.print("Green value: ");
Serial.println(GreenValue);
lcd.setRGB(pinValue, GreenValue, pinValue);
}
void loop()
{
Blynk.run();
}

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "74f55421d63f4d31bb5f3385ba033431";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Embedded";
char pass[] = "tu1den10";

void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
}

#include <Wire.h>
#include "rgb_lcd.h"

rgb_lcd lcd;
String val = "";
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
lcd.begin(16, 2);

lcd.setRGB(255, 0, 0);

// Print a message to the LCD.
lcd.print("123");

delay(1000);

}

void loop() {
// put your main code here, to run repeatedly:
while (Serial.available()) {
val = Serial.readString();
//Serial.println(val);
delay(200);
}
lcd.setCursor(0, 1);
// print the number of seconds since reset:
//lcd.print(" ");
lcd.print(val);
}

/*
Hello World.ino
2013 Copyright (c) Seeed Technology Inc. All right reserved.

Author:Loovee
2013-9-18

Grove - Serial LCD RGB Backlight demo.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <Wire.h>
#include "rgb_lcd.h"
#include "DHTesp.h"

DHTesp dht;
rgb_lcd lcd;
int State = 0;
const int colorR = 0;
const int colorG = 29;
const int colorB = 255;

void setup()
{
//pinMode(D1, INPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);

lcd.setRGB(colorR, colorG, colorB);

// Print a message to the LCD.
lcd.print("Tem (C)\t\tHum");
dht.setup(D4);
//pinMode(D5, OUTPUT); 

delay(1000);

}

void breath(unsigned char color)
{
for(int i=0; i<255; i++)
{
lcd.setPWM(color, i);
delay(5);
}
delay(500);
for(int i=254; i>=0; i--)
{
lcd.setPWM(color, i);
delay(5);
}
delay(500);
}

void loop()
{

delay(dht.getMinimumSamplingPeriod());
//breath(REG_RED);
float humidity = dht.getHumidity();
float temperature = dht.getTemperature();
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(temperature);
lcd.print("\t\t");
lcd.print(humidity);
lcd.print("%");
delay(100);

}

/*********************************************************************************************************
END FILE
*********************************************************************************************************/

#include "DHTesp.h"
#include "ESP32Ticker.h"

//
/* Example how to read DHT sensors from an ESP32 using multi- /
/
tasking. /
/
This example depends on the ESP32Ticker library to wake up /
/
the task every 20 seconds /
/
Please install Ticker-esp32 library first /
/
bertmelis/Ticker-esp32 /
/
https://github.com/bertmelis/Ticker-esp32 */
/
/

DHTesp dht;

void tempTask(void *pvParameters);
bool getTemperature();
void triggerGetTemp();

/** Task handle for the light value read task /
TaskHandle_t tempTaskHandle = NULL;
/
* Ticker for temperature reading /
Ticker tempTicker;
/
* Comfort profile /
ComfortState cf;
/
* Flag if task should run /
bool tasksEnabled = false;
/
* Pin number for DHT11 data pin */
int dhtPin = 17;

/**

  • initTemp
  • Setup DHT library
  • Setup task and timer for repeated measurement
  • @return bool
  • true if task and timer are started
  • false if task or timer couldn't be started
    */
    bool initTemp() {
    byte resultValue = 0;
    // Initialize temperature sensor
    dht.setup(dhtPin, DHTesp::DHT11);
    Serial.println("DHT initiated");

// Start task to get temperature
xTaskCreatePinnedToCore(
tempTask, /* Function to implement the task /
"tempTask ", /
Name of the task /
4000, /
Stack size in words /
NULL, /
Task input parameter /
5, /
Priority of the task /
&tempTaskHandle, /
Task handle. /
1); /
Core where the task should run */

if (tempTaskHandle == NULL) {
Serial.println("Failed to start task for temperature update");
return false;
} else {
// Start update of environment data every 20 seconds
tempTicker.attach(20, triggerGetTemp);
}
return true;
}

/**

  • triggerGetTemp
  • Sets flag dhtUpdated to true for handling in loop()
  • called by Ticker getTempTimer
    */
    void triggerGetTemp() {
    if (tempTaskHandle != NULL) {
    xTaskResumeFromISR(tempTaskHandle);
    }
    }

/**

  • Task to reads temperature from DHT11 sensor
  • @param pvParameters
  • pointer to task parameters
    */
    void tempTask(void *pvParameters) {
    Serial.println("tempTask loop started");
    while (1) // tempTask loop
    {
    if (tasksEnabled) {
    // Get temperature values
    getTemperature();
    }
    // Got sleep again
    vTaskSuspend(NULL);
    }
    }

/**

  • getTemperature
  • Reads temperature from DHT11 sensor
  • @return bool
  • true if temperature could be aquired
  • false if aquisition failed
    */
    bool getTemperature() {
    // Reading temperature for humidity takes about 250 milliseconds!
    // Sensor readings may also be up to 2 seconds 'old' (it's a very slow sensor)
    TempAndHumidity newValues = dht.getTempAndHumidity();
    // Check if any reads failed and exit early (to try again).
    if (dht.getStatus() != 0) {
    Serial.println("DHT11 error status: " + String(dht.getStatusString()));
    return false;
    }
float heatIndex = dht.computeHeatIndex(newValues.temperature, newValues.humidity);

float dewPoint = dht.computeDewPoint(newValues.temperature, newValues.humidity);
float cr = dht.getComfortRatio(cf, newValues.temperature, newValues.humidity);

String comfortStatus;
switch(cf) {
case Comfort_OK:
comfortStatus = "Comfort_OK";
break;
case Comfort_TooHot:
comfortStatus = "Comfort_TooHot";
break;
case Comfort_TooCold:
comfortStatus = "Comfort_TooCold";
break;
case Comfort_TooDry:
comfortStatus = "Comfort_TooDry";
break;
case Comfort_TooHumid:
comfortStatus = "Comfort_TooHumid";
break;
case Comfort_HotAndHumid:
comfortStatus = "Comfort_HotAndHumid";
break;
case Comfort_HotAndDry:
comfortStatus = "Comfort_HotAndDry";
break;
case Comfort_ColdAndHumid:
comfortStatus = "Comfort_ColdAndHumid";
break;
case Comfort_ColdAndDry:
comfortStatus = "Comfort_ColdAndDry";
break;
default:
comfortStatus = "Unknown:";
break;
};

Serial.println(" T:" + String(newValues.temperature) + " H:" + String(newValues.humidity) + " I:" + String(heatIndex) + " D:" + String(dewPoint) + " " + comfortStatus);
return true;
}

void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println("DHT ESP32 example with tasks");
initTemp();
}

void loop() {
if (!tasksEnabled) {
// Wait 2 seconds to let system settle down
delay(2000);
// Enable task that will read values from the DHT sensor
tasksEnabled = true;
if (tempTaskHandle != NULL) {
vTaskResume(tempTaskHandle);
}
}
yield();
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.