Dear Experts,
I have a huge problem with my project.
If I connect to blynk server can’t read a temerature sensor values.
Please help me why or how can I do it.
If I delete this line Blynk.begin(auth, ssid, pass);
I can read a sensors but if I put it back, not possible to read.
THX
Steve
the good way to ask some help isn’t a link …
don’t forget to mask your auth !!
this is your code :
#include <OneWire.h>
#include <DallasTemperature.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
char ssid[] = "xxxx";
char pass[] = "xxxxxxxxxxxxxxx";
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 16
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
BlynkTimer timer;
void myTimerEvent()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, millis() / 1000);
}
void setup(void)
{
// start serial port
Serial.begin(115200);
// Start up the library
Blynk.begin(auth, ssid, pass); // <----------------------------------------------------------------------- ??????
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
sensors.begin();
Serial.println("Dallas Temperature IC Control Library Demo");
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
}
void loop(void)
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print(" Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");
Serial.print("Temperature0 is: ");
Serial.println(sensors.getTempCByIndex(0)); // Why "byIndex"?
Serial.print("Temperature1 is: ");
Serial.println(sensors.getTempCByIndex(1)); // Why "byIndex"?
Serial.print("Temperature2 is: ");
Serial.println(sensors.getTempCByIndex(2)); // Why "byIndex"?
Serial.print("Temperature3 is: ");
Serial.println(sensors.getTempCByIndex(3)); // Why "byIndex"?
// You can have more than one IC on the same bus.
// 0 refers to the first IC on the wire
delay(1000);
}
you have so many request in your loop, so you are flooding blynk server.
try this first :
void setup(void)
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
sensors.begin();
Serial.println("Dallas Temperature IC Control Library Demo");
timer.setInterval(5000L, myTimerEvent);
}
void loop(void)
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}
void myTimerEvent()
{
Serial.print(" Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");
Serial.print("Temperature0 is: ");
Serial.println(sensors.getTempCByIndex(0)); // Why "byIndex"?
Serial.print("Temperature1 is: ");
Serial.println(sensors.getTempCByIndex(1)); // Why "byIndex"?
Serial.print("Temperature2 is: ");
Serial.println(sensors.getTempCByIndex(2)); // Why "byIndex"?
Serial.print("Temperature3 is: ");
Serial.println(sensors.getTempCByIndex(3)); // Why "byIndex"?
Blynk.virtualWrite(V5, millis() / 1000);
Blynk.virtualWrite(V6, "Temperature0 is: " + String(sensors.getTempCByIndex(0));
}
If I put
Serial.print("Temperature0 is: ");
Serial.println(sensors.getTempCByIndex(0));
line before
Blynk.begin(auth, ssid, pass);
in the setup
result is
Temperature0 is:23.5
but if I put it after
Blynk.begin(auth, ssid, pass);
result is
Temperature0 is:-127
are you sure you are using my code ?
post your serial monitor listing so I could see what happened
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x16 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0010,len:4
load:0x3fff0014,len:956
load:0x40078000,len:0
load:0x40078000,len:11856
entry 0x40078a34
Dallas Temperature IC Control Library Demo
Requesting temperatures…DONE
Temperature0 is: -127.00
Temperature1 is: -127.00
Temperature2 is: -127.00
Temperature3 is: -127.00
Requesting temperatures…DONE
Temperature0 is: -127.00
Temperature1 is: -127.00
Temperature2 is: -127.00
Temperature3 is: -127.00
Requesting temperatures…DONE
Temperature0 is: -127.00
Temperature1 is: -127.00
Temperature2 is: -127.00
Temperature3 is: -127.00
Requesting temperatures…DONE
why so many error at start of your ESP32 ?
it seems to be stack error
Are you sure your are using my code ???
it seems that the issue is a timing error