Esp8266

So close, yet so far away-


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.


Here’s a screen grab of the serial monitor.

I see some things in Craig’s code that I think may be the problem with my code. I’ll do some tweaking and see what I can come up with.

@kreggly @ats1080s Thanks guys!

Ian

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.

What code do you think is conflicting?

I never set a pinMode in my code, as I recall that is important.

Also, humidity is now showing on the dashboard. I did nothing, number just appeared.

Ian

Cool. I was using it to test the virtual stuff.

I don’t want Cayenne to be the master of my IO. In fact, I’d like a switch to explicitly state that.

I want to stage IO sequences with Virtual IO, and letting Cayenne do it will not be able to handle the timing or complexity easily.

Maybe your device does not have the blue led on gpio2.

Putting my automotive hat on and swapping oil and tires… may not respond foe a bit :stuck_out_tongue:

Craig

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.

Assuming you have debug on- are you seeing the vr# (read) and vw# (write) commands. At least that’s what I think they are.

Craig, I wasn’t using your code, just learning from it :+1: . 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.

-Ian

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.

Cheers,

Craig

1 Like

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];
}

Cheers,

Craig

What version flash eap8266 for make it run?

NodeMCU. You can get a current build here http://nodemcu-build.com/ just select the options you need.

The Arduino IDE and ESP library don’t need the Node MCU stuff, you are writing the flash through the bootloader with your own program.

Craig

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.

Craig

But i flash it before…

From -
https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/overview?view=all#using-arduino-ide

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.

My esp8266-01, isnt model in adafruit…:joy::joy::joy::joy:

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.

Ok , thx 4 ure attention…oops what this is make ashare project via videos? :sunglasses: