Blink notify in two determinated hour

Hi blinkers, sorry for my english!
I have a problem with my arduino project, i do a sketch with a ds120bs probe and i want a notify from blynk at 8.15 and 18.15 if the temperature is higher to 30°!!
I try and try but i am not able!
My problem is notify only at two time not always!
Thank you

Alex

Add the RTC widget, get the time and make a conditional statement that if the time is 8.15 && temp is > 30 degrees, do the notify.

Or use the eventor widget, that would work too I think

1 Like

Agree, Eventor will do. Not sure how to tie time with temperature threshold without coding, though.

code removed

My example didn’t work when testing it myself for some reason, so I removed it. :thinking: :open_mouth:

One m-f wrong placed ; :rage: This should work better :slight_smile:

From Blynk lib:

BlynkTimer timer;
WidgetRTC rtc;

Simple function:

void checkTime() {
  if (hour() == 8 && minute() == 15) {
    checkTemp() {
      /../
      if (temp >= 30) {
        sendNotification();
      }
    }
  }
  if (hour() == 18 && minute() == 15) {
    /.../
  }
}

A timer running every 30 s:

timer.setInterval(30000L, checkTime);

A rtc.begin(); is needed in the void setup()

sudo su
set CodeFactory=distans
redirect CodeBeggers>>CodeFactory

Done!
@Gunner, I need to work on my Linux skills

1 Like

Pfff…!! I Needed to practice on how to use TimeLib for my own projects :slight_smile:

My Padawan @Gunner would have used sudo su - instead! :crossed_swords:

“I don’t like Linux. It’s coarse and rough and irritating and it gets everywhere.”

Please format your code so it’s readable:

https://community.blynk.cc/uploads/default/original/2X/4/4d722635e2b1c9e41ff54edc3cc58846c4c66ba5.PNG

Don’t poll your DS18B20 sensor once every second. You will most likely get disconnected. I’ve written about this numerous times, use the search function! :slight_smile:

Ok thank you! I format my code and repost!

Not to mention it will kill in it some days. It writes to eeprom on every read and has 50k write cycles :stuck_out_tongue:

Sorry guys, i try only to notify but it doesn t work! and i don t have use the RTC:unamused:

#include <Blynk.h>
BlynkTimer timer;
#include <Time.h>
#include <TimeLib.h>

#define BLYNK_PRINT Serial

#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>


char auth[] = "bdd2d8501c5b4583b65ae96aed132821";



#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);

#define W5100_CS  10
#define SDCARD_CS 4


float temp;

void setup()
{
  
  Serial.begin(9600);

  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

  Blynk.begin(auth);
  DS18B20.begin();
  timer.setInterval(1000L, getSendData);
 
}

void loop()
{
  timer.run(); // Initiates SimpleTimer
  Blynk.run();
}
void getSendData()
{
  DS18B20.requestTemperatures(); 
  temp = DS18B20.getTempCByIndex(0);
  Serial.println(temp);
  Blynk.virtualWrite(10, temp); //virtual pin V10
}
void notifyTemp()
{
  if (temp >= 20.00) 
    {
      Blynk.notify("Temperatura elevata");
    }
}

Fett, where did you get this info from?
why should it write to eeprom with every read cycle?
i never heard / read such information on the net…

Might have to take back that statement!
Can’t find my source where I read it once nor ca I find the corresponding info in the datasheet…
There is a 50k write limit. However it seems that you only write to eeprom if you change parameters like temp high low warning and configurations.

I remember reading the statement above when someone else was trying to read a ds18b20 very frequently. Something about it storing the previous read.

Read the datasheet more carefully :stuck_out_tongue:

The 50k write limit is MIN, no MAX is specified. I know people that have had these sensors running for years without problem, so the MAX value is probably much higher.

Being the self proclaimed Sensors Guy - It might have been in one of my previous posts :wink:

I tried to explain it in another post:

Or as stated in the datasheet:

To initiate a temperature measurement and A-to-D conversion, the master must issue a Convert T [44h] command. Following the conversion, the resulting thermal data is stored in the 2-byte temperature register in the scratchpad memory /.../

A separate command is then sent to the sensor asking it to reply with the value of its scratchpad. A quite sophisticated little sensor I think.

2 Likes

Add the RTC widget on your phone and include these libs in the code:

#include <TimeLib.h>
#include <WidgetRTC.h>

Define:

BlynkTimer timer;
WidgetRTC rtc;

In setup, start the RTC after Blynk.begin() (I think):

while (Blynk.connect() == false) { // Wait until connected
	rtc.begin();
}

I guess you didn’t use the search function OR read my reply! :stuck_out_tongue: :wink:

This IS suicide: timer.setInterval(1000L, getSendData); Each time you do this the program has to wait aprox 0.8 seconds before it can continue!

You need to add a separate timer for notifyTemp()

Good luck!

tl;dr :persevere:

1 Like