I’ve been working on this for awhile, I’m down to the last part. I want to count how many times an event happens. I’ve looked all over for an example, and haven’t really seen one.
I’ve copied and pasted a few things together, that should work, but I am getting an error when trying to load it, seems it’s a missing element in the programing.
//working on chip 1 ,all 4- DS18b20's and the DTH11 and A0 voltage sensor reading correct
// ***************** Trying to add counter on pin D5 and V11 *********************
//
// pin D2 is connented to ds1820's
// pin D7 is DTH11
// Pin D6 is Led Out Horn Button
// A0 Pin is battery voltage pin
// Pin D5 is Pump Counter
// V1 = Bilge Water Temp
// V2 = Port Side Temp
// V3 = Starboard Temp
// V4 = Engine Room Temp
// V5 =
// V6 = Humidity
// V7 = Inside temp
// V13 = Adjusted Battery Voltage
// V11 = Counter
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <Wire.h>
#include <DHT.h>
#include <OneWire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
SimpleTimer timer;
#define DHTPIN 13
#define b1pin 15
#define DHTTYPE DHT11
#define VT_PIN A0
#define ONE_WIRE_BUS 4
DHT dht(DHTPIN, DHTTYPE);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// Assign the addresses of your 1-Wire temp sensors.
DeviceAddress Probe01 = { 0x28, 0xff, 0x40, 0x93, 0x3c, 0x04, 0x00, 0x96 }; //S1
DeviceAddress Probe02 = { 0x28, 0xff, 0x82, 0x93, 0x3c, 0x04, 0x00, 0x37 }; //S2
DeviceAddress Probe03 = { 0x28, 0xff, 0xe6, 0x70, 0x3b, 0x04, 0x00, 0x82 }; //S3
DeviceAddress Probe04 = { 0x28, 0xff, 0x8d, 0x51, 0x3a, 0x04, 0x00, 0xb7 }; //S4
//DeviceAddress Probe05 = { 0x28, 0xAB, 0x58, 0x2D, 0x17, 0x13, 0x01, 0x2B }; //S5
boolean isButtonPressed1 = false;
int COUNT =0;
BLYNK_WRITE(V11);
//Blynk token
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // boat2
// WiFi credentials.
//char ssid[] = "lvl1";
//char pass[] = "xxxxxxxxxxx";
char ssid[] = "lockadoc";
char pass[] = "xxxxxxxxxxx";
//char ssid[] = "LOCKMASTER";
//char pass[] = "xxxxxxxxxxxxxx";
//DHT Sensor
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature(true);
Blynk.virtualWrite(V6, h);
Blynk.virtualWrite(V7, t);
}
{
int Value = param.asInt(); // assigning incoming value from pin V11 to a variable
if (Value=1)
}
COUNT=0;
isButtonPressed1 = true;
COUNT++; //the COUNT increases when D5 is grounded
}
attachInterrupt(D5, handleKey1, FALLING);
SPI.begin();
// temp sensor
void getTempData()
{
sensors.requestTemperatures();
Blynk.virtualWrite(V1, sensors.getTempFByIndex(0));
Blynk.virtualWrite(V2, sensors.getTempFByIndex(1));
Blynk.virtualWrite(V3, sensors.getTempFByIndex(2));
Blynk.virtualWrite(V4, sensors.getTempFByIndex(3));
Blynk.virtualWrite(V8, sensors.getTempFByIndex(4));
}
BLYNK_WRITE(V11)
// Voltage Sensor
//void getVoltage()
{
//8888888888888
// this is where the missing element is----------------------------------------------
int vt_read = analogRead(VT_PIN);
//8888888888888
// Blynk.virtualWrite(V10, voltage);
// Blynk.virtualWrite(V11, voltage2);
// Blynk.virtualWrite(V12, voltage3);
// Blynk.virtualWrite(V13, vt_read / 65.3);
}
void setup()
{
Blynk.begin(auth, ssid, pass);
//DHT Sensor
dht.begin();
//watertemp sensor
sensors.begin();
sensors.setResolution(10);
timer.setInterval(1000L, sendSensor);
timer.setInterval(1500L, getTempData);
timer.setInterval(2000L, getVoltage); // no need to add another of these!
timer.setInterval(500L, sendUptime);
}
}
void sendUptime(){
//send to the smartphone the value COUNT
Blynk.virtualWrite(11, " count= ");
Blynk.virtualWrite(11, COUNT);
}
void loop() {
Blynk.run();
timer.run();
}