Dashboard does not appear

i ady install the cayenne library and upload the coding to nodeMCU ESP8266 V3, but the dashborad does not appear. i am using the coding provided in the example. Is the coding of this esp8266 need to put in with the main arduino coding?

#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

char ssid = “huimei”;
char wifiPassword = “ohm0098”;

char username = “dfaf54e0-b6ce-11eb-883c-638d8ce4c23d”;
char password = “de97db5e14c192eb268bb5d48ab40307553ec68a”;
char clientID = “787340b0-5ff8-11ec-bbfc-979c23804144”;

unsigned long lastMillis = 0;

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

void loop() {
Cayenne.loop();
}

CAYENNE_OUT_DEFAULT()
{
Cayenne.virtualWrite(0, millis());

}

CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG(“Channel %u, value %s”, request.channel, getValue.asString());
}

What does the serial debug say?

1 Like

Thank you, I ady found the error that I made, and now it works ady,

But now I facing another problem is how to send the data from arduino to nodemcu esp8266 WiFi module, so that I can monitor the value in cayenne dashboard

you can use serial communication for it Send Data From Arduino to NodeMCU and NodeMCU to Arduino... - Hackster.io

1 Like

i have read this before, by using software serial, the TX and RX pin on the arduino uno board still can use?
I am connecting the TX,RX pin of arduino to RX,TX pin of esp8266, but cant get the value.
This is my coding in arduino:

void loop() {
byte nitrogen_val,phosphorus_val,potassium_val;

nitrogen_val = nitrogen();
delay(100);
phosphorus_val = phosphorous();
delay(100);
potassium_val = potassium();
delay(100);

Serial.print(“N =”);
Serial.print(nitrogen_val);
Serial.println(“mg/kg”);

Serial.print(“P =”);
Serial.print(phosphorus_val);
Serial.println(“mg/kg”);

Serial.print(“K =”);
Serial.print(potassium_val);
Serial.println(“mg/kg”);
delay(250);

This is my esp coding:

#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

// WiFi network info.
char ssid = “huimei”;
char wifiPassword = “huimei0098”;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “dfaf54e0-b6ce-11eb-883c-638d8ce4c23d”;
char password = “de97db5e14c192eb268bb5d48ab40307553ec68a”;
char clientID = “dc282130-6178-11ec-ad90-75ec5e25c7a4”;
int nitrogen_val,phosphorus_val,potassium_val;

void setup() {
Serial.begin(4800);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}

void loop() {
Cayenne.loop();
if (Serial.available()) {
Serial.write(Serial.read());
}
}

CAYENNE_OUT_DEFAULT()
{
Cayenne.virtualWrite(0,nitrogen_val);
Cayenne.virtualWrite(1,phosphorus_val);
Cayenne.virtualWrite(2,potassium_val);
}

Dont use hardware serial pins TX RX. Try using software serial pins like from the tutorial above.

1 Like

Ok, i try use the software serial pin like the tutorial above, but still dint get the data by looking in my series motor. Because i plan to received the data from arduino by using esp8266,then send to the data from esp8266 to cayenne dashboard.

arduino coding :
`#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// For the i2c supported Oled display module which is 128x64
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(128, SCREEN_HEIGHT, &Wire, OLED_RESET);

//declare the digital to control the operation of RS-485 modbus
#define RE 8

// The following are the Inquiry frames which are send to the NPK sensor
//for reading the Nitrogen, Phosphorus, and Potassium values
// We defined three arrays with names nitro_inquiry_frame, phos_inquiry_frame, and pota_inquiry_frame
// Each inquiry frame have 8 values
const byte nitro_inquiry_frame = {0x01,0x03, 0x00, 0x1e, 0x00, 0x01, 0xe4, 0x0c};
const byte phos_inquiry_frame = {0x01,0x03, 0x00, 0x1f, 0x00, 0x01, 0xb5, 0xcc};
const byte pota_inquiry_frame = {0x01,0x03, 0x00, 0x20, 0x00, 0x01, 0x85, 0xc0};

byte values[11];
SoftwareSerial modbus(2,3);
SoftwareSerial esp(5,6);
String str;

void setup() {
Serial.begin(4800);
modbus.begin(4800);
esp.begin(4800);
pinMode(RE, OUTPUT);

display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)
delay(500);
display.clearDisplay();
display.setCursor(25, 15);
display.setTextSize(1);
display.setTextColor(WHITE);
display.println(" NPK Sensor");
display.setCursor(25, 35);
display.setTextSize(1);
display.print(“Initializing”);
display.display();

}

void loop() {
// we will need three variables of the type byte to store the values of
// Nitrogen, phosphorus, and Potassium.
byte nitrogen_val,phosphorus_val,potassium_val;
String myString;
String buf;
unsigned int len;
nitrogen_val = nitrogen();
delay(100);
phosphorus_val = phosphorous();
delay(100);
potassium_val = potassium();
delay(100);

Serial.print("N: “);
Serial.print(nitrogen_val);
Serial.print(” P: “);
Serial.print(phosphorus_val);
Serial.print(” K: ");
Serial.print(potassium_val);

str =String("coming from arduino: ")+String("N= ")+String(nitrogen_val)+String("P= ")+String(phosphorus_val)+String("K= ")+String(potassium_val);
esp.println(str);
delay(1000);

// The following code is used to display the data on the Oled display

display.clearDisplay();
display.setTextSize(2);
display.setCursor(0, 5);
display.print(“N: “);
display.print(nitrogen_val);
display.setTextSize(1);
display.print(” mg/kg”);

display.setTextSize(2);
display.setCursor(0, 25);
display.print(“P: “);
display.print(phosphorus_val);
display.setTextSize(1);
display.print(” mg/kg”);

display.setTextSize(2);
display.setCursor(0, 45);
display.print(“K: “);
display.print(potassium_val);
display.setTextSize(1);
display.print(” mg/kg”);

display.display();

}

byte nitrogen(){
digitalWrite(RE,HIGH);
delay(10);
if(modbus.write(nitro_inquiry_frame,sizeof(nitro_inquiry_frame))==8){
digitalWrite(RE,LOW);
// When we send the inquiry frame to the NPK sensor, then it replies with the response frame
// now we will read the response frame, and store the values in the values arrary, we will be using a for loop.
for(byte i=0;i<7;i++){
//Serial.print(modbus.read(),HEX);
values[i] = modbus.read();
// Serial.print(values[i],HEX);
}
Serial.println();
}
return values[5]; // returns the Nigtrogen value only, which is stored at location 4 in the array
}

byte phosphorous(){
digitalWrite(RE,HIGH);
delay(10);
if(modbus.write(phos_inquiry_frame,sizeof(phos_inquiry_frame))==8){
digitalWrite(RE,LOW);
for(byte i=0;i<7;i++){
//Serial.print(modbus.read(),HEX);
values[i] = modbus.read();
// Serial.print(values[i],HEX);
}
Serial.println();
}
return values[5];
}

byte potassium(){
digitalWrite(RE,HIGH);
delay(10);
if(modbus.write(pota_inquiry_frame,sizeof(pota_inquiry_frame))==8){
digitalWrite(RE,LOW);
for(byte i=0;i<7;i++){
//Serial.print(modbus.read(),HEX);
values[i] = modbus.read();
//Serial.print(values[i],HEX);
}
Serial.println();
}
return values[5];
}`

ESP8266 coding:
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

// WiFi network info.
char ssid = “huimei”;
char wifiPassword = “huimei0098”;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “dfaf54e0-b6ce-11eb-883c-638d8ce4c23d”;
char password = “de97db5e14c192eb268bb5d48ab40307553ec68a”;
char clientID = “4a62c6c0-6217-11ec-ad90-75ec5e25c7a4”;
String nitrogen_val,phosphorus_val,potassium_val;

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

Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}

void loop() {
if (Serial.available())
{
Serial.write(Serial.read());
}
String N = nitrogen_val;
Serial.println(N);
delay(1000);
//Cayenne.loop();
}

//CAYENNE_OUT_DEFAULT()
//{
// Cayenne.virtualWrite(0,nitrogen_val);
//Cayenne.virtualWrite(1,phosphorus_val);
//Cayenne.virtualWrite(2,potassium_val);
//}

You need to use software serial for the esp also.

alright, I try and see. I got another question, since only one software serial can work simultaneous when multiple software serial port is using.

I have try to use software serial for esp also, but does not work, the Nodemcu was connected to cayenne dashboard but the value is zero.

the first thing is to have serial communication working between arduino and nodemcu , without the cayenne code. Once done we can move to cayenne code.