Storing data


#1

Hi,
I made a project with nodeMCU ESP8266 and DS18b20 and relay. It is working fine. i can switch the relay and can see the temperatures. The problem is that temperatures are stored in the cloud only when i am login in. There is no data when i am no login in to mydevice. What could be the problem?


#2

When you say there is no data when you are not logged in, what are you logging in to?


#3

To the web page https://cayenne.mydevices.com/
See included file.

Thanks

Marcin


#4

Are you using the sleep function in your sketch? Is anything shown on hour/day?


#5

Not that I know about. I don’t think so but i am using wifi nodemcu.
The code look like below
Sometimes i can see the live view and minute view but don’t know whats the key for displaying.
Right now i can see the day and week view but with strange hour view

#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space

#include <ESP8266WiFi.h>
#include "CayenneDefines.h"
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"

#include <Wire.h>
//Wirtualne porty dla cayenne
#define VIRTUAL_PIN V1
#define VIRTUAL_PIN V2

#include <DallasTemperature.h>
#include<OneWire.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "mytoken";

char ssid[] = "xxxxx";
char password[] = "xxxxx";

IPAddress ip;
unsigned long previousMillis = 0;
unsigned long lastTempUpdate = 0;

int mq2 = A0;

void setup()
{
  Serial.begin(115200);
  sensors.begin();
  delay(10);
  pinMode(mq2, INPUT);

  sensors.begin();
  Cayenne.begin(token, ssid, password);

}



// ==============( Void Loop  ) ====================================

void loop() {
  Cayenne.run();
  sensors.requestTemperatures();
  int temp1 = sensors.getTempCByIndex(0);
  int mq2read = analogRead(mq2);

  delay(200);
  unsigned long now = millis();

  if ( now - lastTempUpdate > 600 ) {
    String MyIp;
    String Both;
    MyIp =  "IP: " + String(WiFi.localIP()[0]) + "." + String(WiFi.localIP()[1]) + "." + String(WiFi.localIP()[2]) + "." + String(WiFi.localIP()[3]);
    String MyWiFi;
    MyWiFi = "WiFi: " + String(WiFi.RSSI());
    Serial.println(MyIp);
    Serial.println(MyWiFi);

    Serial.println(temp1);
    Serial.println(mq2read);
    Cayenne.virtualWrite(V1, temp1);
    Cayenne.virtualWrite(V2, mq2read);

    lastTempUpdate = now;
  }

}


ESP8266-01 with DS18d20
#6

Try this:

#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space

#include <ESP8266WiFi.h>
#include "CayenneDefines.h"
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"

#include <Wire.h>
//Wirtualne porty dla cayenne
#define VIRTUAL_PIN V1
#define VIRTUAL_PIN V2

#include <DallasTemperature.h>
#include<OneWire.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "mytoken";

char ssid[] = "xxxxx";
char password[] = "xxxxx";

IPAddress ip;
//unsigned long previousMillis = 0;
unsigned long lastTempUpdate = 0;

int mq2 = A0;

void setup()
{
  Serial.begin(115200);
  sensors.begin();
  delay(10);
  pinMode(mq2, INPUT);

  sensors.begin();
  Cayenne.begin(token, ssid, password);

}



// ==============( Void Loop  ) ====================================

void loop() {
  Cayenne.run();
  sensors.requestTemperatures();
  int temp1 = sensors.getTempCByIndex(0);
  int mq2read = analogRead(mq2);

  delay(200);
  //unsigned long now = millis();

  //if ( now - lastTempUpdate > 600 ) {
    if ( millis() - lastTempUpdate > 600 ) {
	    lastTempUpdate = millis();
	
    String MyIp;
    String Both;
    MyIp =  "IP: " + String(WiFi.localIP()[0]) + "." + String(WiFi.localIP()[1]) + "." + String(WiFi.localIP()[2]) + "." + String(WiFi.localIP()[3]);
    String MyWiFi;
    MyWiFi = "WiFi: " + String(WiFi.RSSI());
    Serial.println(MyIp);
    Serial.println(MyWiFi);

    Serial.println(temp1);
    Serial.println(mq2read);
    Cayenne.virtualWrite(V1, temp1);
    Cayenne.virtualWrite(V2, mq2read);

    //lastTempUpdate = now;
  }

}

#7

Thanks, will try it tomorrow. its midnight in Poland
But its great to have someone to help!
Thanks kreggy


#8

Thanks @kreggly! Keep us updated @marcin with how things turn out :slight_smile:
-B