Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Slotte
#45346 Hi I have a NodMCU 1.0ESP-12E

Trying to build a sous vide machine with a ds18b20 sensor a 16x2 lcd i2c and SSR float switch and some more parts.
But have gone back to bare minimum code to sort out the error.
When i boot with the sensor attached it dose not work it powers on but seems like its not able to skip out of the setup.
But if I connect the sensor when its booted up it displays correct and sends the temp (input).

This i how i wired the ds18b20 sensor.
Tried to connect the + to VIN taht is ~5V but I got scared i would burn anything so disconnected it quickly.

Data = D8 pin
GND = GND pin
+ = 3.3V
4,7 ohm resistor between + and data.

Board is power by a 2A USB charger or by the USB port on the computer.

Code: Select all#include <DallasTemperature.h>
#include <OneWire.h>
#include <ESP8266WiFi.h>

#define ONE_WIRE_BUS D8  // DS18B20 temp sensor

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress tempSensor;       // Arrays to hold device address

double SetPoint = 52.50;        // Variable for SetPoint
double Input;                  // Variable for input (temp sensor)

unsigned long DelayForConnect = 15000;
unsigned long TimeToConnect;

/************* WIFI ***************/
const char* server = "192.168.1.5";
const char* MY_SSID = "*****";
const char* MY_PWD = "*****";



void setup() {
  Serial.begin(115200);
  delay(10);

  // Start up the DS18B20 One Wire Temperature Sensor
  sensors.begin();
  sensors.setResolution(tempSensor, 12);
  sensors.setWaitForConversion(false);

  connectWifi();
}
void loop() {
  sensors.requestTemperatures(); // Send the command to get temperatures
  Input = sensors.getTempCByIndex(0);
  yield();
  if (TimeToConnect + DelayForConnect < millis()) {
    sendToServer(Input, SetPoint);
    TimeToConnect = millis();
  }
  yield();
}

void connectWifi()
{
  Serial.print("Connecting to ");
  Serial.println(MY_SSID);
  WiFi.begin(MY_SSID, MY_PWD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}//end connect

void sendToServer(double Input, double Setpoint)
{
  WiFiClient client;
  Serial.print("connecting to ");
  Serial.println(server);

  if (!client.connect(server, 80)) {
    Serial.println("connection failed");
    return;
  }
  String data = "input=" + (String)Input + "&setpoint=" + (String)Setpoint ;
  Serial.println(data);

  String url = "GET /add.php?" + data + " HTTP/1.1";
  client.println(url);
  client.println("Host: 192.168.1.5");
  client.println("Connection: close");
  client.println();
  delay(500);

  // Read all the lines of the reply from server and print them to Serial
  while (client.available()) {
    String line = client.readStringUntil('\r');
    Serial.print(line);
  }
  client.stop();
}

On the server side I have a small php script that stores the values in a MySQL database and the a plugin script that plots it in a graph. Everything is working fine except the sensor at startup.

Any thoughts?
User avatar
By DaniloFix
#51295 Same issue here - don't know of a solution yet - have you guys found one?

I would swear it was working just fine some time ago when I was last working on my project. Now it dont - what changed? Arduino is now 1.6.9 whereas I believe I was running 1.6.7 before. Perhaps also some libraries has been updated. I expect it to be a software issue.