- Joined
- Aug 29, 2021
- Messages
- 399
- Reputation
- 451
- Reaction score
- 1,997
- Points
- 0
- Currently Smoking
- Bread
Yeah that might be some issue with formatting, I can post a screenshot instead.. anyway thanks a lot I’ll try it out as soon as possible …
Hey Don,
Don't know if it's because of formatting on the forum, but that code won't compile in a 100 years bro...
I've reedited it and added some comments.
Try it out and let me know.
C++:// Comment this out to disable prints and save space #define BLYNK_ PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> char auth[] = "BLYNK_AUTHL_TOKEN"; char ssid[] = "Name of your WiFi"; // Your WiFi credentials. char pass[] = "Pass of your WiFi"; const int analogInPin = A0; //You need to use the GPIO pin number for a ESP device. Also, only one 'Analog' pin on the ESP chip. --> https://www.electronicshub.org/wp-content/uploads/2021/02/ESP8266-NodeMCU-ADC-Pin.jpg BlynkTimer timer; void setup() { Serial.begin(115200); Blynk.begin(auth, ssid, pass); timer.setInterval(1000L, myTimerEvent); } void loop() { Blynk.run(); //These two need to be put in the loop function. timer.run(); } void myTimerEvent() { int humidity = ((1024 - analogRead(analogInPin)) * 100) / (1024 - 610); //Don't know if the calculation is right, but usually you find some example code for a certain sensor... if (humidity >= 100) { humidity = 100; } else if (humidity <= 0){ humidity = 0; } Blynk.virtualWrite(V1, humidity); //You write the value humidity to 'virtual pin 1, then in your blynk app you select V1 from the drop down list and bob's your uncle ;) Serial.print(humidity); Serial.println("%"); }