× This is the optional category header for the Suggestion Box.

ESP8266 DS18B20 temperature sensor node

6 years 8 months ago #397 by VasilijHCN
Its possible to create arduino+esp8266+ds18b20 temperature sensor node ?
Thank U for great job !!!

Please Log in or Create an account to join the conversation.

6 years 8 months ago #398 by EasyIoT

VasilijHCN wrote: Its possible to create arduino+esp8266+ds18b20 temperature sensor node ?
Thank U for great job !!!


Yes of course. Use ESP temperature/humidity example, replace DHT library with DC18B20 library and remove HUM sensor.
The following user(s) said Thank You: VasilijHCN

Please Log in or Create an account to join the conversation.

6 years 8 months ago - 6 years 8 months ago #408 by VasilijHCN
/*
 V1.0 - first version
 
 Created by Igor Jarc <igor.jarc1@gmail.com>
 See http://iot-playground.com for details
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 version 2 as published by the Free Software Foundation.
 */
#include <Esp8266EasyIoT.h>
#include <SoftwareSerial.h> 
#include <OneWire.h>
#include <DallasTemperature.h>


#define CHILD_ID_TEMP 1
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);



Esp8266EasyIoT esp; 

SoftwareSerial serialEsp(10, 11);


float lastTemp;

//Esp8266EasyIoTMsg msgHum(CHILD_ID_HUM, V_HUM);
Esp8266EasyIoTMsg msgTemp(CHILD_ID_TEMP, V_TEMP);


void setup()
{
  serialEsp.begin(9600);
  Serial.begin(115200);  
  sensors.begin();

  Serial.println("EasyIoTEsp init");


  esp.begin(NULL, 3, &serialEsp, &Serial);
  //esp.begin(NULL, &serialEsp);
  

  pinMode(13, OUTPUT);



//  Serial.println("present S_TEMP");
  esp.present(CHILD_ID_TEMP, S_TEMP);

}

void loop()
{  
  while(!esp.process());

  delay(1000);

  while(!esp.process());
  sensors.requestTemperatures();
  float temperature = (sensors.getTempCByIndex(0));
  if (isnan(temperature)) {
    Serial.println("Failed reading temperature from DS18B20");
  } 
  else if (temperature != lastTemp) 
  {
    lastTemp = temperature;
    esp.send(msgTemp.set(temperature, 1));
    Serial.print("T: ");
    Serial.println(temperature);
  }

  
}


Please Log in or Create an account to join the conversation.

6 years 8 months ago #412 by lewys.martin
Heres mine, working fine currently :)

blog.lewys.eu/?p=130
The following user(s) said Thank You: VasilijHCN

Please Log in or Create an account to join the conversation.

Time to create page: 0.418 seconds

Forum latest

  • No posts to display.