Help with my coding DS18B20

im having problem display the output on serial monitor cant figure out why

#define BLYNK_TEMPLATE_ID           "TMPLEMJi8XeT"
#define BLYNK_DEVICE_NAME           "Quickstart Device"
#define BLYNK_AUTH_TOKEN            "q0o0UDBNYuX2ttDvGYgxNerDzeUe91Rg"
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>

// Replace YOUR_AUTH_TOKEN with your Blynk auth token
char auth[] = "q0o0UDBNYuX2ttDvGYgxNerDzeUe91Rg";

// Replace your_ssid and your_password with your WiFi credentials
char ssid[] = "bb";
char pass[] = "amirizzani12";

// Data wire is connected to D3 on the Wemos D1 Mini
#define ONE_WIRE_BUS D3

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// Define a Blynk timer
BlynkTimer timer;

// This function will be called every time the timer expires
void sendTemperature()
 // Request a temperature reading from the DS18B20

 // Get the temperature from the DS18B20
 float temperature = sensors.getTempCByIndex(0);

 // Send the temperature to Blynk via virtual pin V1
 Blynk.virtualWrite(V1, temperature);

void setup()
 // Initialize the serial port

 // Connect to WiFi
 WiFi.begin(ssid, pass);
 while (WiFi.status() != WL_CONNECTED) {

 // Connect to Blynk
 Blynk.begin(auth, ssid, pass);

 // Initialize the DallasTemperature library

 // Set the timer to send a temperature reading every 60 seconds
 timer.setInterval(60000, sendTemperature);

void loop()
 // Run the Blynk timer;
only dotted line is displayed output on serial monitor

Post your serial monitor output. Without seeing the output, its hard to say what’s wrong.

But dotted lines being displayed is

Your board is trying to connect to the wifi router but unable to connect because of wrong credentials. Check your wifi credentials. This should solve your problem.

You’re missing #define BLYNK_PRINT Serial from near the top of your sketch, and; from your void loop.

You also need to check that your serial monitor is set to the same baud rate as the Serial.begin command in your sketch (9600 in this case). However, it’s usually best to use 74880 for the NodeMCU as this is usually the native baud rate for the board, and you can see the boot messages from the board as well as the debug messages.

Also, these lines of code are redundant when you use Blynk.begin…


Thanks! it worked

1 Like