Aquarium temperature sensing wemos d1arduino by danzig483 3d model
3dmdb logo
Thingiverse
Aquarium temperature sensing wemos d1arduino by danzig483

Aquarium temperature sensing wemos d1arduino by danzig483

by Thingiverse
Last crawled date: 3 years ago
This is my box to measure the water of aquarium beside It measures the temperature of house and humidity and send these measures to your smartphone.
The aquarium temperature is measured by DS18B20 sensor and the house temperature and humidity is measured by DHT22 sensor.
The file Wemosdht22ds18b20Thingspeak20180603.ino is all code to upload in wemos d1.
To read data from sensor firstly these are upload for wemos to thingspeak server and them with a app installed in the smartphone you can visualized. I installed IoT ThingSpeak Monitor Widget https://play.google.com/store/apps/details?id=ua.livi.thingspeakmonitor&hl=es
Code
// www.arduinesp.com
//
include
include
include //Se importan las librerías
include
// replace with your channel’s thingspeak API key,
String apiKey = "REOC43JCM4VUVVPH";
const char ssid = "MIWIFI_2G_rx74"; //YOUR WIFI RED NAME
const char password = "kna2m9hv43gw"; //YOUR WIFI RED PASSWORD
const char* server = "api.thingspeak.com";
define DHTPIN D2 // what pin we’re connected to
define Pin D3 //Se declara el pin donde se conectará la DATA
OneWire ourWire(Pin); //Se establece el pin declarado como bus para la comunicación OneWire
DallasTemperature sensors(&ourWire); //Se instancia la librería DallasTemperature
DHT dht(DHTPIN, DHT22,15);
WiFiClient client;
void setup() {
Serial.begin(115200);
delay(10);
dht.begin();
sensors.begin(); //Se inician los sensores
WiFi.begin(ssid, password);
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
}
void loop() {
float temp;
sensors.requestTemperatures(); //Prepara el sensor para la lectura
temp = sensors.getTempCByIndex(0);
//temp = analogRead(A0);
//temp = temp*0.31803;
float hwifi = dht.readHumidity();
float twifi = dht.readTemperature();
if (isnan(hwifi) || isnan(twifi)) {
Serial.println("Failed to read from DHT sensor!");
return;
//sensors.requestTemperatures(); //Prepara el sensor para la lectura
//Serial.print(sensors.getTempCByIndex(0)); //Se lee e imprime la temperatura en grados Celsius
Serial.println(" grados Centigrados");
}
if (client.connect(server,80)) { // "184.106.153.149" or api.thingspeak.com
String postStr = apiKey;
postStr +="&field1=";
postStr += String(twifi);
postStr +="&field2=";
postStr += String(hwifi);
postStr +="&field3=";
postStr += String(temp);
postStr += "\r\n\r\n";
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
Serial.print("Temperature Out: ");
Serial.print(twifi);
Serial.print("Humidity Out: ");
Serial.print(hwifi);
Serial.print("Temperature Out: ");
Serial.print(temp);
Serial.println("% send to Thingspeak");
}
client.stop();
Serial.println("Waiting…");
// thingspeak needs minimum 15 sec delay between updates
delay(700000);
}

Tags