Here’s the setup: ESP8266 and DHT11 (seems like #1 and #2 on the most wanted list)
Here’s the dashboard. Got the temp to add ok, but once I put the humidity on it started throwing command errors and reestablishing its connection to the server.
Hmm I wish I could remember what I was doing earlier, because I was getting errors with the IP address when I tried to use CayenneWiFiClient.h. I still can’t get the DS18B20 temp sensor to update the widget. I get more debug with your code, and I can see that the ESP is sending wrong values “< vw10temp,c=%.3f” If I try standalone code it will output the correct temp to the serial port every time.
I can’t get the ESP to send any temp to the dashboard in any virtual pin. I even tried to emulate using Cayenne.fahrenheitWrite(10, 74.97); and it just never makes it to the dashboard. But anyway, I can confirm that the code is reading the correct temp by printing it to the serial port. Must be a bug in the code.
Craig, I wasn’t using your code, just learning from it . I’m using the code I cobbled together using the Adafruit and Cayenne examples. I think I’m getting closer to something that works.
I’m back at work tomorrow, so I won’t have much time to play again until next weekend, good night all.
Note, I am using the ESP8266 ADC input, and have it reading using a direct read of the analog pin through Cayenne, as well as using a virtual pin where I do a median filter and convert to volts.
Something to note - In Cayenne, you need to read from the 3rd analog channel even though the channel is A0 in the Arduino sketch.
Also note, that for the ESP-07 at least, the ADC goes full scale from 0-3.3V. Woot. I’ve heard the ESP-01 only goes to 1. Mine goes to 3.3…
Also just received some ESP-12F modules. Will probably wire them up on the weekend.
Here is my median filter, if anyone cares to use it. Note that you don’t want thousands of measurements, but if you get the occasional glitch, this will cure your problem.
For fast changing measurements, you don’t want to use this.
CAYENNE_OUT(V0)
{
float m = MedianRead(A0);
//convert to voltage
m = 3.3 * m / 1024.0;
Cayenne.virtualWrite(V0, m);
}
//define how many measurements to make
#define MAX_BUF 11
int MedianRead(int chan)
{
int buffer[MAX_BUF];
int i, j;
int temp;
//get some data
for (i=0; i<MAX_BUF; i++)
{
buffer[i] = analogRead(chan);
delay(1);
}
//sort em
for (j=0; j<MAX_BUF-1; j++)
{
for (i=0; i<MAX_BUF-1- j;i++)
{
if (buffer[i]>buffer[i+1])
{
temp = buffer[i];
buffer[i]=buffer[i+1];
buffer[i+1] = temp;
}
}
}
//return the one in the middle
return buffer[(MAX_BUF-1)/2];
}
Hmm I didn’t know that. I assumed the Arduino IDE used NodeMCU to boot and and then runs the code you upload. Looks like NodeMCU is only for LUA scripts.
The way I understand it, and I could be wrong, is that NodeMCU is just another flash image, like you would create with Arduino.
Those WeMos thingies are pretty cool. I tried making a power supply with a CR2032, but the current kicks in the CR2032 current protection. My guess is it is some sort of polyfuse technology. I had to build a fixture to discharge the batteries before disposal because of this effect.
While the HUZZAH ESP8266 breakout comes pre-programmed with NodeMCU’s Lua interpretter, you don’t have to use it! Instead, you can use the Arduino IDE which may be more familar. This will write directly to the firmware, erasing the NodeMCU firmware, so if you want to go back to Lua, use the flasher to re-install it.
It doesn’t matter what model your ESP is, the Arduino IDE will flash what it needs to run the program.
Doing some more reading it looks like the Arduino IDE uses nodeMCU but it flashes the parts it needs and overwrites any current firmware that is on it, so it doesn’t matter what you have on it to begin with.