Creation of a pulsation counter

I’m sorry but I had already tried, and serialprint = 0.00

can you share your code?

How can i share my code ?

copy and paste i guess.

The code was already pasted in another answer

#include <EEPROM.h>
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <OneWire.h>
#include <DallasTemperature.h>
#include <CayenneMQTTEthernet.h>

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “3f12e5f0-b73d-11e6-b51c-abe30c418779”;
char password = “388d4c05edd69614cb7f6438685a3cdfcb3643d2”;
char clientID = “7d5c11a0-4854-11ea-b73d-1be39589c6b2”;

#define CAYENNE_DEBUG
#define SENSOR_PIN 2 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL6 6
#define LEDR_PIN 6 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.

OneWire oneWire(SENSOR_PIN);
DallasTemperature sensors(&oneWire);

// constants won’t change. They’re used here to set pin numbers:
const int BUTTON_PIN = 5; // the number of the pushbutton pin

// variables will change:
int BUTTON_PINState; // variable for reading the
int value;
int countTours;
float Kilos;

int addr = 0;
int addr1 = 1;

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

Cayenne.begin(username, password, clientID);
sensors.begin();
pinMode(BUTTON_PIN, INPUT);
pinMode(LEDR_PIN, OUTPUT);

}

void loop()
{
Cayenne.loop();
//float Kilos =(countTours/3);
Kilos =(countTours/3);
int BUTTON_PINState = digitalRead(5);

if ( BUTTON_PINState == 1)
{
countTours++;
ecrireEEprom();
}
lireEEprom();
Serial.print("countTours= " );
Serial.println(countTours);
Serial.print("Kilos = " );
Serial.println(Kilos);
}

CAYENNE_OUT(2)
{
// Send the command to get temperatures.
sensors.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Channel.
Cayenne.celsiusWrite(2, sensors.getTempCByIndex(0));

}
CAYENNE_OUT(5)
{
Cayenne.virtualWrite(5, digitalRead(BUTTON_PIN), “digital_sensor”, “d”);
// read the state of the pushbutton value:
BUTTON_PINState = digitalRead(BUTTON_PIN);
}

CAYENNE_IN(VIRTUAL_CHANNEL6)
{
if (getValue.asInt() == 0)
{
digitalWrite(LEDR_PIN, HIGH);
}
else
{
digitalWrite(LEDR_PIN, LOW);
}
}

CAYENNE_OUT(7)
{
Cayenne.virtualWrite(7, Kilos); //virtual pin1

}
CAYENNE_OUT(8)
{
Cayenne.virtualWrite(8, countTours); //virtual pin1
}
CAYENNE_CONNECTED()
{
//if (isFirstConnect) {
Cayenne.syncAll();

}

void ecrireEEprom()
{
EEPROM.write(addr, countTours);
EEPROM.write(addr1, Kilos);

}
void lireEEprom()
{
countTours = EEPROM.read(addr);
Kilos = EEPROM.read(addr1);
}
void UpdateEEprom()
{
EEPROM.update (addr, countTours);
EEPROM.update (addr1, Kilos);
}

Miracle, now it works, yet I haven’t changed anything

Thanks for your help

1 Like