Ideas needed please

Hehe, quiet ... although I think some of this stuff can run autonomously (once configured) and the Sonoff switches can be remote controlled by a fob (that will be further away than the real lightswitch of course). ;-)

Cheers, T i m

Reply to
T i m
Loading thread data ...

Hi Tim,

I crawled through your code and could not find anything about reading the analogue value and displaying it. I don't know of it is particularly difficult but several of the web site tutorials featuring this device give code for digital i/o but avoid analogue. I even contacted Random Nerd about their training Ebook and video course but he steers clear of analogue too.

Bob

Reply to
Bob Minchin

No, there wasn't Bob, that's why I included the code (that wasn't mine btw) so that one of the coders here could add it in for you. ;-)

Oh? It's pretty easy ... or at least is was on the Arduinos. I believe it uses a divider as the chip uses 1V so that 3.3v gives you a 1025 reading (10 bit).

formatting link

formatting link

How strange?

My board looks like this:

formatting link

formatting link

"To read external voltage applied to ADC pin, use analogRead(A0). Input voltage range is 0 ? 1.0V." (or 3.3V on my 12E)

And a sketch that includes analogue read is here:

formatting link

No reason why you couldn't copy and paste the right bit into your first On/Off sketch.

Cheers, T i m

Reply to
T i m

When your ESP (or whatever) arrives, shout-up if you don't get anywhere...

Reply to
Andy Burns

formatting link

Reply to
dennis

formatting link

Reply to
dennis

Much appreciated.

Bob

Reply to
Bob Minchin

FWIW, I put the following code on one of my ESP's and it worked ok, returning a random value (I had nothing connected to A0 so that was to be expected) on a browser (manual refresh):

"Sensor to Node MCU Web Server Data:

18.00"

This is what I used:

formatting link

----------------------------------------------------------- #include #include #include // Replace with your network credentials const char* ssid = ""; const char* password = ""; ESP8266WebServer server(80); //instantiate server at port 80 (http port) String page = ""; double data; void setup(void){ pinMode(A0, INPUT); delay(1000); Serial.begin(115200); WiFi.begin(ssid, password); //begin WiFi connection Serial.println(""); // Wait for connection while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); server.on("/", [](){ page = "Sensor to Node MCU Web ServerData: "+String(data)+""; server.send(200, "text/html", page); }); server.begin(); Serial.println("Web server started!"); } void loop(void){ data = analogRead(A0); delay(1000); server.handleClient(); }

----------------------------------------------------------------------------

Cheers, T i m

Reply to
T i m

Thanks Tim,

Looks straightforward enough. I appreciate your time!

Bob

Reply to
Bob Minchin

You are more than welcome. ;-)

Hmm ... I have to really 'study' code to even get a feel of what it does, let alone how it does it so I'll take your word for that. ;-(

Np's ... especially as I have some projects in mind myself involving some of the features you need. ;-)

Cheers, T i m

Reply to
T i m

HomeOwnersHub website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.