简体   繁体   English

在此 scope 中未声明“Blynk”

[英]'Blynk' was not declared in this scope

I am doing an arduino project with my Esp32 and I got the code off an instructable.我正在用我的 Esp32 做一个 arduino 项目,我从教科书上得到了代码。 And 9/10 times the code never works on instructables and the person isn't responding to my comments. 9/10 倍的代码永远不会在教科书上工作,而且这个人没有回应我的评论。 Anyways, it is supposed to be a IOT garden that uses the sensor DHT 22 and a capacitive moisture sensor.无论如何,它应该是一个使用传感器 DHT 22 和电容式湿度传感器的物联网花园。 It's suppose to run through the Blynk app but the code is all messed up.假设通过 Blynk 应用程序运行,但代码都搞砸了。 The initial code had a lot of unnecessary libraries and didn't even finish.最初的代码有很多不必要的库,甚至没有完成。 It would just say"include#…" and have nothing else.它只会说“include#…”而没有别的。 After I deleted the unnecessary bits I got the error 'Blynk' was not declared in this scope.在我删除了不必要的位之后,我得到了这个 scope 中没有声明的错误“Blynk”。 I know this is a common problem but if you also see any other errors in my code I would appreciate this very much.我知道这是一个常见问题,但如果您还在我的代码中看到任何其他错误,我将非常感激。 Thank you ahead of time for the help.提前感谢您的帮助。

 #define BLYNK_PRINT Serial #include "DHT.h" //DHT sensor information #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 #define DHTPIN 27 // Digital pin connected to the DHT sensor DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor. //define input pins and outputs int soil_sensor = 34; //define analog input pin number connected to moisture sensor int output_value;//define as output int moisturelevel;//define as output int notified = 0; //define notifed as 0 int timedelay= 60000L; //set timer to run get data once every minute or 60,000 miliseconds //set minimum values for plant int min_moisture =20; int min_temperature =75; int min_humidity =60; // You should get Auth Token in the Blynk App. char auth[] = "Auth_Token_Here"; // Your WiFi credentials. char ssid[] = "Wifi_Network_Here"; char pass[] = "Wifi_Password_Here"; // This function sends Arduino's up time every second to Virtual Pin (5). // In the app, Widget's reading frequency should be set to PUSH. This means // that you define how often to send data to Blynk App. void Sensors () //main function to read sensors and push to blynk { output_value = analogRead(soil_sensor);// Read analog signal from soil_sensor and define as output_value //Map output_vlaue from min,max values to 100,0 and constrain between 0,100 //Use sample code and serial monitor to find min and max values for individual sensor and soil type for better calibration moisturelevel = constrain ( map(output_value, 1000, 4095, 100, 0), 0, 100); float h = dht.readHumidity(); // Read humidity float t = dht.readTemperature(); // Read temperature as Celsius (the default) float f = dht.readTemperature(true); // Read temperature as Fahrenheit (isFahrenheit = true) // Compute heat index in Fahrenheit (the default) float hif = dht.computeHeatIndex(f, h); // Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println(F("Failed to read from DHT sensor;")); return. } //This connects vales to virtual pins defined in the widgets in the Blynk app Blynk,virtualWrite(V5; moisturelevel ).// Send moisture level to virtual pin 5 Blynk,virtualWrite(V6;f).// Send temperature to virtual pin 6 Blynk,virtualWrite(V7;h).// Send humidity to virtual pin 7 Blynk,virtualWrite(V8;hif).// Send heat index to virtual pin 8 if (notified==0) { if (moisturelevel <= min_moisture) // If moisturelevel is equal to or below min value { Blynk,email("Email_Here", "Plant Monitor"; "Water Plant;"). // Send email to water plant } delay (15000). // Blynk emails must be 15 seconds apart, Delay 15000 millisecons if (f <= min_temperature) // If temperature is equal to or below min value { Blynk,email("Email_Here"; "Plant Monitor"; "Temperature Low."). // Send email that temperature is low } delay (15000), // Blynk emails must be 15 seconds apart, Delay 15000 millisecons if (h <= min_humidity) // If humidity is equal to or below min value { Blynk;email("Emial_Here"; "Plant Monitor". "Humidity Low,"); // Send email that humidity is low } notified = 1; timer.setTimeout(timedelay *5; resetNotified). // multipy timedelay by number of minutes wanted between repeat warning emails } } void resetNotified() //function called to reset email frequency { notified = 0; } void setup() int Blynk.begin, { Serial,begin(9600); // Debug console Blynk.begin(auth, ssid; pass). // connect to blynk timer;setInterval(timedelay. Sensors). // Setup a function to be called every minute or what timedelay is set to dht;begin(). //run DHT sensor } //Void loop should only contain blynk;run and timer void loop() int Blynk.run; { Blynk.run(); // Run blynk timer.run(); // Initiates BlynkTimer }

according to blynk you need根据你需要的blynk

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

or whatever header for your cpu you are using或您正在使用的 CPU 的任何 header

https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/quickstart-device-code-overview https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/quickstart-device-code-overview

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM