Im new to Blynk and Arduino and I’m trying to get a DHT 22 sensor to work with it and for some reason it keeps coming up with
[0]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
///_, /////_
/__/ v0.6.1 on Arduino Mega ADK
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
App project setup:
Value Display widget attached to V5
Value Display widget attached to V6
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <BlynkSimpleStream.h>
#include <DHT.h>
char auth[] = "0HYGVE5MuxEHATWVKaPJLtj7FcblRdGQ";
#define DHTPIN 2
#define DHTTYPE DHT22 // DHT 22
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
// 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 sendSensor()
{
float h = dht.readHumidity();
if (isnan(h))
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h);
}
void setup()
{
// Debug console
Serial.begin(9600);
// Blynk will work through Serial1
// Do not read or write this serial manually in your sketch
Serial1.begin(9600);
Blynk.begin(Serial, auth);
dht.begin();
// Setup a function to be called every second
timer.setInterval(10000, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}
@Mason please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
So, you’re trying to use the Blynk serial connection.
This requires you to edit the script to specify the correct COM port and to have the script running in a command prompt window all of the time. Have you done this?
Also, you are attempting to use the Serial port for both debug messages and the serial connection to Blynk via your PC. You can’t do this.
If you want to see serial debug messages with this connection method then you’ll need an FTDI adapter connected to a different hardware serial port on your Mega, and re-direct your debug messages to that port.
Yeah I’m trying to use the serial connection and I’ve changed the script to specify this but it keep coming up with different errors and I’ve also tried the CMD and it coming up with more errors.
and how do you change it so I can use the Serial port for just the serial connection to Blynk to the PC