New Features!

Great Job on the new features!
I tried the data feature and noticed the device is sending each sensor reading 4 times at each transmission. Is this normal or something funky in my sketch?
John

data

Its funky :smile: i have data sending in timed interval and it shows ok.

It’s working fine now too and I didn’t change anything. Maybe the good people at Cayenne fixed it or the ghosts have left the building. :thinking:
John

Update: The problem seems to be only on the Live feature. Looking at the 10 min or other all is fine. The funny part is now it’s showing each sensor 10 times, the same problem on 2 different ESP8266s.
John

I have checked my live view, it shows value just as it should every 60sec one value from each sensor.
Post your code here maybe we can find something.

It’s intermittent. Last time I checked it was back to 4 times. Other times it’s normal. Feel free to point out anything in the sketch that’s not quite right. I’m definitely new to this. :slightly_smiling_face:
Thanks!

//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
#include <DHT.h>
#include <DHT_U.h>
#define SENSOR_PIN 16 // Status
#define VIRTUAL_CHANNEL 8
#define ACTUATOR_PIN 12 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define DHT1PIN 2
#define DHT2PIN 5
#define DHTTYPE DHT22
DHT_Unified dht1(DHT1PIN, DHTTYPE);
DHT_Unified dht2(DHT2PIN, DHTTYPE);

Usual log in stuff:…

unsigned long lastMillis = 0;

void setup() {
Serial.begin(9600);
delay(5000);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);

pinMode(ACTUATOR_PIN, OUTPUT);
dht1.begin();
dht2.begin();
sensor_t sensor;
}

void loop() {
Cayenne.loop();
// Publish data every 10 seconds (10000 milliseconds). Change this value to publish at a different interval.
if (millis() - lastMillis > 10000) {
lastMillis = millis();

sensors_event_t event1;  // white cable
dht1.temperature().getEvent(&event1); 
Cayenne.celsiusWrite(1, event1.temperature);

sensors_event_t event2;  // black cable
dht2.temperature().getEvent(&event2);
Cayenne.celsiusWrite(3, event2.temperature);

Cayenne.virtualWrite(4, digitalRead(16), "digital_sensor", "d"); // status

}

}

// This function is called when data is sent from Cayenne.
CAYENNE_IN(VIRTUAL_CHANNEL)
{
int value = getValue.asInt();
CAYENNE_LOG(“Channel %d, pin %d, value %d”, VIRTUAL_CHANNEL, ACTUATOR_PIN, value);
// Write the value received to the digital pin.
digitalWrite(ACTUATOR_PIN, value);
}

Change this and similar parts of code to have only, just to make it simpler

Cayenne.virtualWrite(1, dht1.getTemperatureC(),“temp”,“c”);//or “f” if you need other SI unit
Cayenne.virtualWrite(2, dht2.getTemperatureC(),“temp”,“c”);

Also i compare code with screenshoot, screenshoot says you are using virtual pin 4 for humidity and code says

If that is corect change it to

Cayenne.virtualWrite(4, dht1.readHumidity(),“rel_hum”,“p”);

or dht2.readHumidity() depends on the sensor assigned to humidity reading, my guess is that this part of the code is causing your problem.

Thanks for the help Agroelektronik. The devices are out of town on a job for a few more days. When I get them back I’ll change the DHT code. I don’t know where the humid is coming from, the code & widget say digital input which it is.:thinking: I haven’t seen any dup entries for a while either. Go figure.
John

Mystery semi solved,
The multiple sensor entries in the new live data tab only appears to happen with Chromium.
Restarting the browser eliminates the problem for a while. Never had a problem with Firefox.
I can run them at the same time, Chromium a problem, Firefox not.
Chromium Version 64.0.3282.167 (Official Build) Built on Ubuntu , running on LinuxMint 17.3 (64-bit)
Just a bit of info in case it shows up for someone else.
John

1 Like

Ok, test the code when you have the opportunity.
Version 64.0.3282.186 (Official Build) (64-bit) here on Debian, no plugins or other fancy stuff since i use it only for html/css testing for work. No double entrys in live or other tables.

@margettepv @Agroelektronik thank you for providing your testing results and issues! It helps when we are able to read through. Very helpful!

I’ll pass this info to the team and see if we can find anything.

~Benny

Had to make a small change, works great and much simpler than my original code.
Thanks!

Cayenne.virtualWrite(1, dht1.readTemperature(),"temp","c"); 
Cayenne.virtualWrite(2, dht1.readHumidity(),"rel_hum","p"); 

Cayenne.virtualWrite(3, dht2.readTemperature(),"temp","c");  
Cayenne.virtualWrite(4, dht2.readHumidity(),"rel_hum","p");
1 Like