DS18B20 value -127º, but only when connecting to Blynk, on ESP32

I tested psoro’s code just and I get about 1 in 50 good readings. If I comment out the Blynk starts and run that all readings are good all the time. The only difference is I am using Pin 14 instead of Pin 12 because I get a bunch of resets and script doesn’t run. I am also using DFRobot ESP-Wroom-32.

Hi!
I’m still thinking about this issue and I had the idea to use the two cores of the ESP32 for different purposes, the Core 1 to do Blynk Stuff and the Core 0 to read the sensor and update a few virtual pins… easy…

The result is that the sensor is giving me always -127.00, obviously I’m doing something wrong but I can’t see where…

@Gunner, you were interested about the two cores and their loops time ago, could you please be so kind to have a look and let me know where the mistake is located?

The sketch of the code goes like this:

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include _Sensor libraries and other stuff...._
. 
.
void setup()
{ 
sensors.begin();// Sensor  
.
.
_Blynk stuff_ 
.
.
xTaskCreatePinnedToCore(loop1, "loop1", 4096, NULL, 1, NULL, 0);
xTaskCreatePinnedToCore(loop2, "loop2", 4096, NULL, 1, NULL, 1);

}


void loop1(void *pvParameters) //Core 0
{
while (1){
sensors.requestTemperatures();
temp = sensors.getTempCByIndex(0);
.
.
Updating Vpins
.
.
delay(2000); //Core 0, nothing to do with Core1, delays are allowed.
}

void loop2(void *pvParameters) //Core 1
{
while (1){
if (Blynk.connected()){
  Blynk.run(); 
  } 
timer.run();
delay(1);
}
}

void loop()
{
// Emtpy loop!
}

Using this code the Virtual pins are updated every 2 seconds so loop1 is working. On the other hand, Blynk is up and running so loop2 is fine also…
Despite this statements, the sensor is not working…it should be the way I have to “start” the sensor or something similar but I can’t see it…

Do I have to write an extra setup for the other core?

Any help will be appreciated…

Unfortunately I haven’t pursued multi core testing since… I have to pick my mental focus battles, and this one hadn’t come up again :stuck_out_tongue: (I am currently focusing on non-Blynk RPi video streaming via user proof kiosk options for my dad’s viewing of his security cameras in his living room - Linux, my nemesis, has left me with almost no functional brain cells remaining :confounded: but if I suddenly get a burst of energy/focus I will see what I can see).

I still think this OP issue has to do with basic ESP32 IDE Core issues causing possible Onewire/WiFi conflict… I think best option is to keep testing with each new release from espressif. Possibly take Blynk out of the picture, but still have somthing WiFi related actively running… OTA perhaps?.. just to see if that makes a difference. Process of trial, error and elimination.

No worries Gunner, I really appreciate your support in this forum and my question is not directly Blynk related…
I’ll try to find the way to do it properly somehow… Positive thinking! :smiley: At least at the moment… :wink:

+1 here. That’s the reason I wanted to split the code using the two cores, one for Wifi (Blynk) stuff and the other to take measurements. Not sure if this statement has sense or not to be honest… The ESP32 is still unknown for me.

Thank you anyway!

I’ve been working with programming the two cores and multi-tasking. I have Blynk running on ESP32 and reading two DS18B20 temperature sensors. It’s working good but still working on it. One thing that doesn’t work so good is the Blynk timer so multi-tasking must be used with a different approach. I should have something to post over the next few days.

2 Likes

Note that .requestTemperatures() takes about 750 ms to complete when using the default resolution of 12 bits. But setting .setWaitForConversion(0) (false) you just initiate the sensors temperature conversation and don’t get stuck waiting for it to complete, i.e. freeze the program. Then check back later and just do the actual reading.

You could look at my project and the RF433_Master.ino-sketch how I use 2 timers to do a reading every 10 minute. The DS18B20 has a limited number of EEPROM writes, that’s why I don’t check it all that often. Some more details can be read in the code:

Hi @Northernboy,
I tried reading the DS18B20 without success using the two cores, could you please be so kind to post the main tips to achieve it?

Thanks in advance!!

Below is the basic code that has worked for me. I get about one bad reading in 50 and I’m still working on perfection, but this works good. Instead of using timer, instead create more tasks and modify the delay.
I am testing a bigger project that does communicates with the Blynk server as well has a touch screen on SPI that has been working great. Also I am still learning about the FreeRTOS so my code might not be the best way but it works and I am still learning.

Also the below example uses the DallasTemperature library and simple code to read the temperature, however I find this slow and creates more errors than the code I normally use which requires the addresses of the sensors. But use whatever code works for you to read temperatures.

Good Luck
NB

#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <OneWire.h>
#include<DallasTemperature.h> 
#define ONE_WIRE_BUS 15 
 
char auth[] = "***********************************"; //
const char* ssid = "***";
const char* pass = "************";

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);

float temp;
float buff;


void setup() {
  
        Serial.begin(115200);
        Serial.println();
        Serial.println();
      
        DS18B20.begin();
        
        xTaskCreatePinnedToCore(WifiTask,"WifiTask ",4000,NULL,2,NULL,0); //Task for Core 0 priority set at 2
        // xTaskCreatePinnedToCore(####Task,"####Task ",4000,NULL,1,NULL,0); //Example of another task pinned to Core 0 at a lower priority

        xTaskCreatePinnedToCore(tempTask,"tempTask ",4000,NULL,5,NULL,1); //Task for Core 1 priority set at 5
        // xTaskCreatePinnedToCore(####Task,"####Task ",4000,NULL,1,NULL,1); //Example of another task pinned to Core 1 at a lower priority
}

void loop() {
  vTaskDelete( NULL );
  }

void tempTask( void * pvParameters )  //Task for reading Temperature on Core 1
{

  while(1){                           //Use whatever code you use to measure temperature
    DS18B20.requestTemperatures(); 
    buff = DS18B20.getTempCByIndex(0);
    if(buff!=-127.00){temp=buff;}
    Blynk.virtualWrite(V10, temp);
    vTaskDelay( 1000 / portTICK_PERIOD_MS);  //Delay for this task allows the core to do other tasks 
  }
}

void WifiTask( void * pvParameters )  //Wifi&Blynk tasks on Core 0
{ 
  WiFi.disconnect();                  //Code here runs once same as setup
  Blynk.begin(auth, ssid, pass);
  while (Blynk.connect() == false) {}

  while(1){                           //Code here runs continously same as loop
    Blynk.run();                       
    vTaskDelay( 500 / portTICK_PERIOD_MS);  //Little delay here is necessary
    }
}
2 Likes

Many thanks @Northernboy,
Your sketch is really similar to the one I posted without success, except for the priorities and delays…
I’ll give it a try once at home.

Regards!

@psoro from what I have learnt delays are necessary to allow other tasks to be done. The project I am working on now I have 5 or 6 tasks running on each core and different delays.

@Northernboy I ran your code with a few cosmetic changes and it’s pretty good.

4	25.94
5	25.94
6	25.94
7	25.94
8	25.94
9	26.00
10	25.94
11	25.94
12	26.00
13	26.00
14	26.00
15	26.00
16	-127.00
17	26.00
18	26.00
19	-127.00
20	26.00
21	26.00
22	26.00
23	26.00
24	26.00
25	26.00
26	26.00
27	-127.00
28	26.00
29	26.00
30	26.00
31	26.00
32	26.00
33	26.00
34	26.00
35	25.94
36	25.94
37	25.94
38	25.94
39	25.94
40	25.94
41	25.94
42	25.94
43	25.94
44	25.87
45	-127.00
46	25.87
47	25.87
48	25.87
49	25.87
50	25.87
51	25.87
52	25.87
53	-127.00
54	25.87
55	25.87
56	25.87
57	25.87
58	25.87
59	25.81
60	25.81
61	25.87
62	25.87
63	25.87
64	25.87
65	25.94
66	25.94
67	25.94
68	25.94
69	25.94
70	25.94
71	25.94
72	25.94
73	25.94
74	25.94
75	25.94
76	25.94
77	25.94
78	25.94
79	25.87
80	25.87
81	25.87
82	25.87
83	25.81
84	25.81
85	25.81
86	25.81
87	25.81
88	25.81
89	25.75
90	25.81
91	25.75
92	25.75
93	25.75
94	25.75
95	25.75
96	25.75
97	25.75
98	25.69
99	25.69
100	25.69
101	25.69
102	25.69
103	25.69
104	25.69
105	25.69
106	25.69
107	25.69
108	25.69
109	25.69
110	25.69
111	25.69
112	25.69
113	25.69
114	25.69
115	25.69
116	25.69
117	25.69
118	25.69
119	25.69
120	25.69
121	25.62
122	25.62
123	25.62
124	25.62
125	25.62
126	25.62
127	25.62
128	25.62
129	25.62
130	25.62
131	25.62
132	25.62
133	25.62
134	25.62
135	25.62
136	25.62
137	25.69
138	25.69
139	25.69
140	25.69
141	25.69
142	25.69
143	25.69
144	25.69
145	25.69
146	25.75
147	25.69
148	25.69
149	25.75
150	25.75
151	25.75
152	25.75
153	25.75
154	25.75
155	25.75
156	25.75
157	25.81
158	25.81
159	25.81
160	25.81
161	25.81
162	25.81
163	25.87
164	25.87
165	25.87
166	25.87
167	25.87
168	25.87
169	25.87
170	-127.00
171	25.94
172	25.94
173	25.94
174	25.94
175	25.94
176	25.94
177	25.94
178	25.94
179	26.00
180	25.94
181	26.00
182	25.94
183	25.94
184	25.94
185	25.94
186	25.94
187	25.94
188	26.00
189	26.00
190	26.00
191	26.00
192	26.00
193	-127.00
194	26.00
195	26.00
196	26.00
197	26.06
198	-127.00
199	26.06
200	26.06

Just 8 false results in the 200 requests and none between request 54 and 169. As you have it in your sketch you can code around the odd bad result.

Come on… It’s not fair… I have to wait for a few hours to be able to “play” a little bit with the Esp32! :wink:

It seems the bad result is always there somehow…

1 Like

@Costas I’m glad it worked for you. I am looking into how to modify the tick frequency to try to give the Onewire function more time to complete. I believe the bad readings are because the task is existing before it has time to get a value. I’ll report back once I get some more testing and tuning.

1 Like

I don’t know if my previous post was overlooked or just ignored :wink: but I still believe its valid and worth looking into.

Use two timers instead of waiting for the temperature conversation to finish!

Following @Costas example I did a run for 200 reading, with three sensors in parasitic mode, with a total cable lenght of 17 meters, only powered by the Arduino and got ZERO errors. Albeit not a dual core MCU, but all my timing issues are gone with this setup!


The best is yet to come!
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.88
1
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
2
Bedroom: 21.50
Livingroom: 22.25
Extra: 21.94
3
Bedroom: 21.50
Livingroom: 22.25
Extra: 21.94
4
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
5
Bedroom: 21.50
Livingroom: 22.25
Extra: 21.94
6
Bedroom: 21.50
Livingroom: 22.25
Extra: 21.94
7
Bedroom: 21.50
Livingroom: 22.25
Extra: 21.94
8
Bedroom: 21.50
Livingroom: 22.25
Extra: 21.94
9
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
10
Bedroom: 21.50
Livingroom: 22.25
Extra: 21.94
11
Bedroom: 21.50
Livingroom: 22.25
Extra: 21.94
12
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
13
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
14
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
15
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
16
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
17
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
18
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
19
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
20
Bedroom: 21.57
Livingroom: 22.19
Extra: 22.00
21
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
22
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
23
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
24
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
25
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
26
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
27
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
28
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
29
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
30
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
31
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
32
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
33
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
34
Bedroom: 21.57
Livingroom: 22.19
Extra: 22.00
35
Bedroom: 21.50
Livingroom: 22.19
Extra: 21.94
36
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
37
Bedroom: 21.57
Livingroom: 22.19
Extra: 22.00
38
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
39
Bedroom: 21.57
Livingroom: 22.19
Extra: 22.00
40
Bedroom: 21.57
Livingroom: 22.19
Extra: 22.00
41
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
42
Bedroom: 21.57
Livingroom: 22.19
Extra: 22.00
43
Bedroom: 21.57
Livingroom: 22.19
Extra: 22.00
44
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
45
Bedroom: 21.57
Livingroom: 22.19
Extra: 22.00
46
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
47
Bedroom: 21.57
Livingroom: 22.19
Extra: 22.00
48
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
49
Bedroom: 21.57
Livingroom: 22.19
Extra: 22.00
50
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
51
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
52
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
53
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
54
Bedroom: 21.57
Livingroom: 22.19
Extra: 22.00
55
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
56
Bedroom: 21.57
Livingroom: 22.19
Extra: 22.00
57
Bedroom: 21.50
Livingroom: 22.19
Extra: 22.00
58
Bedroom: 21.57
Livingroom: 22.19
Extra: 22.00
59
Bedroom: 21.57
Livingroom: 22.25
Extra: 22.00
60
Bedroom: 21.57
Livingroom: 22.38
Extra: 22.00
61
Bedroom: 21.57
Livingroom: 22.44
Extra: 22.00
62
Bedroom: 21.50
Livingroom: 22.50
Extra: 22.00
63
Bedroom: 21.50
Livingroom: 22.63
Extra: 22.00
64
Bedroom: 21.50
Livingroom: 22.69
Extra: 22.00
65
Bedroom: 21.50
Livingroom: 22.75
Extra: 22.00
66
Bedroom: 21.57
Livingroom: 22.75
Extra: 22.00
67
Bedroom: 21.50
Livingroom: 22.82
Extra: 22.00
68
Bedroom: 21.50
Livingroom: 22.82
Extra: 22.00
69
Bedroom: 21.57
Livingroom: 22.88
Extra: 22.00
70
Bedroom: 21.50
Livingroom: 22.88
Extra: 22.00
71
Bedroom: 21.50
Livingroom: 22.88
Extra: 22.00
72
Bedroom: 21.57
Livingroom: 22.94
Extra: 22.00
73
Bedroom: 21.50
Livingroom: 22.94
Extra: 22.00
74
Bedroom: 21.57
Livingroom: 22.94
Extra: 22.00
75
Bedroom: 21.57
Livingroom: 22.94
Extra: 22.00
76
Bedroom: 21.57
Livingroom: 22.94
Extra: 22.00
77
Bedroom: 21.50
Livingroom: 23.00
Extra: 22.00
78
Bedroom: 21.57
Livingroom: 23.00
Extra: 22.00
79
Bedroom: 21.57
Livingroom: 23.00
Extra: 22.00
80
Bedroom: 21.50
Livingroom: 23.07
Extra: 22.00
81
Bedroom: 21.50
Livingroom: 23.07
Extra: 22.00
82
Bedroom: 21.57
Livingroom: 23.07
Extra: 22.00
83
Bedroom: 21.50
Livingroom: 23.07
Extra: 22.00
84
Bedroom: 21.50
Livingroom: 23.13
Extra: 22.00
85
Bedroom: 21.57
Livingroom: 23.13
Extra: 22.00
86
Bedroom: 21.50
Livingroom: 23.13
Extra: 22.00
87
Bedroom: 21.57
Livingroom: 23.13
Extra: 22.00
88
Bedroom: 21.50
Livingroom: 23.19
Extra: 22.00
89
Bedroom: 21.57
Livingroom: 23.19
Extra: 22.00
90
Bedroom: 21.50
Livingroom: 23.19
Extra: 22.00
91
Bedroom: 21.50
Livingroom: 23.19
Extra: 22.00
92
Bedroom: 21.50
Livingroom: 23.19
Extra: 22.00
93
Bedroom: 21.50
Livingroom: 23.19
Extra: 22.00
94
Bedroom: 21.50
Livingroom: 23.19
Extra: 22.00
95
Bedroom: 21.57
Livingroom: 23.19
Extra: 22.07
96
Bedroom: 21.57
Livingroom: 23.25
Extra: 22.13
97
Bedroom: 21.57
Livingroom: 23.38
Extra: 22.19
98
Bedroom: 21.50
Livingroom: 23.50
Extra: 22.32
99
Bedroom: 21.57
Livingroom: 23.63
Extra: 22.38
100
Bedroom: 21.57
Livingroom: 23.75
Extra: 22.50
101
Bedroom: 21.50
Livingroom: 23.88
Extra: 22.57
102
Bedroom: 21.50
Livingroom: 23.94
Extra: 22.63
103
Bedroom: 21.50
Livingroom: 24.00
Extra: 22.69
104
Bedroom: 21.50
Livingroom: 24.07
Extra: 22.75
105
Bedroom: 21.50
Livingroom: 24.13
Extra: 22.75
106
Bedroom: 21.57
Livingroom: 24.25
Extra: 22.82
107
Bedroom: 21.50
Livingroom: 24.32
Extra: 22.88
108
Bedroom: 21.50
Livingroom: 24.38
Extra: 22.88
109
Bedroom: 21.50
Livingroom: 24.44
Extra: 22.94
110
Bedroom: 21.50
Livingroom: 24.50
Extra: 22.94
111
Bedroom: 21.57
Livingroom: 24.57
Extra: 23.00
112
Bedroom: 21.57
Livingroom: 24.57
Extra: 23.07
113
Bedroom: 21.57
Livingroom: 24.57
Extra: 23.07
114
Bedroom: 21.50
Livingroom: 24.63
Extra: 23.13
115
Bedroom: 21.57
Livingroom: 24.63
Extra: 23.13
116
Bedroom: 21.50
Livingroom: 24.63
Extra: 23.19
117
Bedroom: 21.57
Livingroom: 24.63
Extra: 23.25
118
Bedroom: 21.57
Livingroom: 24.63
Extra: 23.25
119
Bedroom: 21.57
Livingroom: 24.57
Extra: 23.32
120
Bedroom: 21.50
Livingroom: 24.44
Extra: 23.32
121
Bedroom: 21.50
Livingroom: 24.44
Extra: 23.32
122
Bedroom: 21.57
Livingroom: 24.38
Extra: 23.38
123
Bedroom: 21.50
Livingroom: 24.32
Extra: 23.32
124
Bedroom: 21.57
Livingroom: 24.19
Extra: 23.32
125
Bedroom: 21.57
Livingroom: 24.13
Extra: 23.25
126
Bedroom: 21.50
Livingroom: 24.00
Extra: 23.19
127
Bedroom: 21.50
Livingroom: 23.88
Extra: 23.13
128
Bedroom: 21.57
Livingroom: 23.82
Extra: 23.13
129
Bedroom: 21.57
Livingroom: 23.75
Extra: 23.07
130
Bedroom: 21.57
Livingroom: 23.69
Extra: 23.07
131
Bedroom: 21.57
Livingroom: 23.63
Extra: 23.00
132
Bedroom: 21.57
Livingroom: 23.57
Extra: 23.00
133
Bedroom: 21.50
Livingroom: 23.57
Extra: 22.94
134
Bedroom: 21.50
Livingroom: 23.50
Extra: 22.94
135
Bedroom: 21.57
Livingroom: 23.44
Extra: 22.88
136
Bedroom: 21.50
Livingroom: 23.44
Extra: 22.88
137
Bedroom: 21.57
Livingroom: 23.38
Extra: 22.82
138
Bedroom: 21.50
Livingroom: 23.38
Extra: 22.82
139
Bedroom: 21.57
Livingroom: 23.38
Extra: 22.82
140
Bedroom: 21.63
Livingroom: 23.32
Extra: 22.75
141
Bedroom: 21.75
Livingroom: 23.32
Extra: 22.75
142
Bedroom: 21.88
Livingroom: 23.32
Extra: 22.69
143
Bedroom: 22.00
Livingroom: 23.25
Extra: 22.69
144
Bedroom: 22.19
Livingroom: 23.25
Extra: 22.69
145
Bedroom: 22.32
Livingroom: 23.25
Extra: 22.63
146
Bedroom: 22.44
Livingroom: 23.19
Extra: 22.63
147
Bedroom: 22.50
Livingroom: 23.19
Extra: 22.63
148
Bedroom: 22.63
Livingroom: 23.19
Extra: 22.57
149
Bedroom: 22.69
Livingroom: 23.13
Extra: 22.57
150
Bedroom: 22.69
Livingroom: 23.13
Extra: 22.57
151
Bedroom: 22.75
Livingroom: 23.13
Extra: 22.57
152
Bedroom: 22.75
Livingroom: 23.07
Extra: 22.50
153
Bedroom: 22.75
Livingroom: 23.07
Extra: 22.50
154
Bedroom: 22.75
Livingroom: 23.00
Extra: 22.50
155
Bedroom: 22.75
Livingroom: 23.00
Extra: 22.50
156
Bedroom: 22.75
Livingroom: 23.00
Extra: 22.50
157
Bedroom: 22.75
Livingroom: 23.00
Extra: 22.44
158
Bedroom: 22.75
Livingroom: 22.94
Extra: 22.44
159
Bedroom: 22.69
Livingroom: 22.94
Extra: 22.44
160
Bedroom: 22.69
Livingroom: 22.88
Extra: 22.44
161
Bedroom: 22.69
Livingroom: 22.88
Extra: 22.44
162
Bedroom: 22.69
Livingroom: 22.88
Extra: 22.44
163
Bedroom: 22.69
Livingroom: 22.88
Extra: 22.38
164
Bedroom: 22.63
Livingroom: 22.88
Extra: 22.38
165
Bedroom: 22.63
Livingroom: 22.88
Extra: 22.38
166
Bedroom: 22.63
Livingroom: 22.82
Extra: 22.38
167
Bedroom: 22.63
Livingroom: 22.82
Extra: 22.38
168
Bedroom: 22.57
Livingroom: 22.82
Extra: 22.38
169
Bedroom: 22.57
Livingroom: 22.82
Extra: 22.38
170
Bedroom: 22.57
Livingroom: 22.82
Extra: 22.38
171
Bedroom: 22.50
Livingroom: 22.82
Extra: 22.38
172
Bedroom: 22.50
Livingroom: 22.75
Extra: 22.38
173
Bedroom: 22.50
Livingroom: 22.75
Extra: 22.32
174
Bedroom: 22.50
Livingroom: 22.75
Extra: 22.32
175
Bedroom: 22.50
Livingroom: 22.75
Extra: 22.32
176
Bedroom: 22.44
Livingroom: 22.69
Extra: 22.32
177
Bedroom: 22.44
Livingroom: 22.69
Extra: 22.32
178
Bedroom: 22.44
Livingroom: 22.69
Extra: 22.32
179
Bedroom: 22.44
Livingroom: 22.69
Extra: 22.32
180
Bedroom: 22.38
Livingroom: 22.69
Extra: 22.32
181
Bedroom: 22.38
Livingroom: 22.69
Extra: 22.32
182
Bedroom: 22.38
Livingroom: 22.69
Extra: 22.32
183
Bedroom: 22.38
Livingroom: 22.69
Extra: 22.32
184
Bedroom: 22.38
Livingroom: 22.69
Extra: 22.32
185
Bedroom: 22.32
Livingroom: 22.69
Extra: 22.32
186
Bedroom: 22.32
Livingroom: 22.63
Extra: 22.25
187
Bedroom: 22.32
Livingroom: 22.63
Extra: 22.25
188
Bedroom: 22.32
Livingroom: 22.63
Extra: 22.25
189
Bedroom: 22.32
Livingroom: 22.63
Extra: 22.25
190
Bedroom: 22.25
Livingroom: 22.63
Extra: 22.25
191
Bedroom: 22.25
Livingroom: 22.63
Extra: 22.25
192
Bedroom: 22.25
Livingroom: 22.63
Extra: 22.25
193
Bedroom: 22.25
Livingroom: 22.57
Extra: 22.25
194
Bedroom: 22.25
Livingroom: 22.57
Extra: 22.25
195
Bedroom: 22.25
Livingroom: 22.57
Extra: 22.25
196
Bedroom: 22.19
Livingroom: 22.57
Extra: 22.25
197
Bedroom: 22.25
Livingroom: 22.57
Extra: 22.25
198
Bedroom: 22.19
Livingroom: 22.50
Extra: 22.25
199
Bedroom: 22.19
Livingroom: 22.50
Extra: 22.25
200

Got more errors on the ESP32 with this setting than the test without it.

Just running another test at 9 bit resolution.

95	23.81	Errors: 5
96	23.81	Errors: 5
97	23.87	Errors: 5
98	23.87	Errors: 5
99	23.87	Errors: 5
100	23.87	Errors: 5
101	23.87	Errors: 5
102	-127.00	Errors: 6
103	23.87	Errors: 6
104	23.87	Errors: 6
105	23.81	Errors: 6

Already 6 errors from 105 readings. 12 errors from 200 readings.

@distans I’ve used the wait for conversion in the past and it does work great. However I believe it is not problem with the ESP32. FreeRTOS freezes tasks and switches to another if there is one with a higher priority, I feel that this momentary pause effects some of timing in onewire function. If you look at the library there are delays in the microSeconds and it also disables interrupts during this timing. I could be wrong but it seems this way is working for now and I am still researching and learning.

Mkay, that’s seems weird! :crazy_face:

Well yes (and no) :stuck_out_tongue_winking_eye: When I use setWaitForConversion(false), it takes requestTemperature() less than 2 ms to send the command to the sensors. When I check back, the reading takes about 30 ms.

Have you tried using deviceAddress instead of getTempCByIndex? It’s a little bit faster.

@distans are you testing on a ESP32 with wifi enabled?

No, I only have Arduino UNO’s at the moment and using W5100 Ethernet shield (only outdated cheap stuff hehe). I had a fair amount of issues with disconnects before. I even tapped the network connection and dumped all traffic thru Wireshark. It seemed like the problem was due to the W5100’s small RX buffer got full when left unattended for a period of time (i.e. the program was stuck on a functions delay).

But after I rearranged how I call the sensors and a more modest polling for external data (time and connection) I haven’t had any problem.

I’ve been thinking about buying an ESP32 or two, but I’m not so sure anymore :laughing: But I hope you figure it out!

If you want something that works buy an ESP8266.

2 Likes