mydevicesiot / cayenne-mqtt-esp Goto Github PK
View Code? Open in Web Editor NEWCayenne MQTT ESP8266, ESP32 & NodeMCU Library
Home Page: https://cayenne.mydevices.com
License: Other
Cayenne MQTT ESP8266, ESP32 & NodeMCU Library
Home Page: https://cayenne.mydevices.com
License: Other
Arduino: 1.8.5 (Windows 10), Плата:"NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"
C:\Program Files (x86)\Arduino\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp: In function 'void wifi_wps_status_cb(wps_cb_status)':
C:\Program Files (x86)\Arduino\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp:623:14: error: 'WPS_CB_ST_UNK' was not declared in this scope
case WPS_CB_ST_UNK:
^
exit status 1
`
// This example shows how to connect to Cayenne using an ESP8266 and send/receive sample data.
// Make sure you install the ESP8266 Board Package via the Arduino IDE Board Manager and select the correct ESP8266 board before compiling.
//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
// WiFi network info.
char ssid[] = "HomeWifi";
char wifiPassword[] = "**";
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "";
char password[] = "";
char clientID[] = "**";
unsigned long lastMillis = 0;
void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}
void loop() {
Cayenne.loop();
}
// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
Cayenne.virtualWrite(0, millis());
// Some examples of other functions you can use to send data.
//Cayenne.celsiusWrite(1, 22.0);
//Cayenne.luxWrite(2, 700);
//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
}
// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}
`
I'm using NodeMCU.
I tried to upload this example code from here:
File > Example > Cayenne-MQQTT-ESP > esp8266
with proper ssid[], wifiPassword[], username[], password[] and clientID[].
But the serial monitor shows:
$€ÿ�€ÿ-Süþ[765] Connecting to TechShop 2G
[18766] Connected to WiFi
[18767] IP: 192.168.137.90
[18767] Connecting to mqtt.mydevices.com:1883
[25060] Network connect failed
[32384] Network connect failed
[39684] Network connect failed
[47008] Network connect failed
...
And the dashboard shows "waiting for board to connect".
Tried your getting sarted video on youtube. Didn't work. using the same ssid and wifiPassword i was able to connect to blynk app but unable to do so with Cayenne.
I am using wemos d1 mini, and arduino ide (version .13).
Consider the following code:
float temperature = g_temperature.getTemp();
itoa(temperature, g_szTemp, 10);
Cayenne.virtualWrite(3, temperature, TYPE_TEMPERATURE, UNIT_CELSIUS);
Cayenne.virtualWrite(4, g_szTemp, TYPE_TEMPERATURE, UNIT_CELSIUS);
Cayenne.virtualWrite(5, int(temperature), TYPE_TEMPERATURE, UNIT_CELSIUS);
this produces the following result in the dashboard:
sending of the string and int values works as expected, but sending of the float value does not work.
If I use celsiusWrite its the same issue.
Please note that sprintf("%2.3f") does not work on arduino, printf-ing floats is not supported, maybe this could the problem?
I am attaching to the Cayenne network and passing data but it appears I am missing an exception handler...
Here is the error
-------------------Serial Monitor------------------------
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x3e (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:956
load:0x40078000,len:0
load:0x40078000,len:13076
entry 0x40078a58
[D][WiFiGeneric.cpp:293] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:293] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:293] _eventCallback(): Event: 7 - STA_GOT_IP
Guru Meditation Error: Core 0 panic'ed (IllegalInstruction)
. Exception was unhandled.
Register dump:
PC : 0x4011b649 PS : 0x00060730 A0 : 0x80113a9d A1 : 0x3ffd4880
A2 : 0x3ffc6d54 A3 : 0x00000000 A4 : 0x00000005 A5 : 0x1e000107
A6 : 0x00000020 A7 : 0x00000001 A8 : 0x3ffc1cc8 A9 : 0x00000000
A10 : 0x3ffd33a0 A11 : 0x00060021 A12 : 0x800850f8 A13 : 0x3ffc0540
A14 : 0x00000003 A15 : 0x00060023 SAR : 0x00000020 EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff
Backtrace: 0x4011b649:0x3ffd4880 0x40113a9a:0x3ffd48b0 0x40113fac:0x3ffd48f0 0x401142f5:0x3ffd4920 0x401194ba:0x3ffd4950
Rebooting...
-------------------End Monitor--------------------------
-------------------Decoder-------------------------------------------------------------
0x4011b649: rcReachRetryLimit at ?? line ?
0x40113a9a: lmacTxFrame at ?? line ?
0x40113fac: lmacProcessAckTimeout at ?? line ?
0x401142f5: lmacProcessTxComplete at ?? line ?
0x401194ba: ppTask at ?? line ?
---------------------------------------------------Code---------------------------------
#include "CayenneMQTTESP32.h"
bool WiFiFound = 1, NetworkFound = 1;
const char* ssid = "xxxxxxxxxx";
const char* wifiPassword = "xxxxxxxxxxxxxxxxxx";
const char* DevID = "xxxxxxxxxxxxxxxx";
//Cayenne Authentication
char username[] = "xxxxxxxxxxxxxxxxxxxx";
char password[] = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
char clientID[] = "xxxxxxxxxxxxxxxxxxxxxxxx";
int ledPinRED = GPIO_NUM_0;
int ledPinGRN = GPIO_NUM_2;
int ledPinBLU = GPIO_NUM_4;
void setup() {
Serial.begin(115200);
ledSetup();
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}
int value = 0;
void loop() {
Cayenne.loop();
}
// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
Cayenne.virtualWrite(0, millis());
// Some examples of other functions you can use to send data.
Cayenne.celsiusWrite(1, 22.0);
//Cayenne.luxWrite(2, 700);
//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
}
// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}
//Initialize Status LED's
void ledSetup() {
pinMode(ledPinRED, OUTPUT);
pinMode(ledPinGRN, OUTPUT);
pinMode(ledPinBLU, OUTPUT);
digitalWrite(ledPinRED, LOW);
digitalWrite(ledPinGRN, LOW);
digitalWrite(ledPinBLU, LOW);
}
---------------------------------------------End Code----------------------------------
Hi,
I am making a device that can use wifi (esp32) or gsm, it works well with:
#ifdef USE_GSM
#include <CayenneMQTTGSM.h>
#else
#include <CayenneMQTTESP32.h>
#endif
however it would be nice to switch from wifi to gsm while the device is running, or at least at boot if wifi timeouts. If I include both libraries there is a conflict because the begin
is different:
#ifdef USE_GSM
Cayenne.begin(username, password, clientID, SerialAT, apn, gprsLogin, gprsPassword, pin);
#else
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
#endif
Any idea how to deal with this?
Thanks
Arduino: 1.8.5 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled, 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
Build options changed, rebuilding all
In file included from C:\Program Files (x86)\Arduino\libraries\WiFi\src/WiFi.h:32:0,
from C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTESP32.h:21,
from C:\Users\xadon\AppData\Local\Temp\arduino_modified_sketch_77880\ESP32.ino:7:
C:\Program Files (x86)\Arduino\libraries\WiFi\src/WiFiServer.h:37:14: error: invalid abstract return type for member function 'WiFiClient WiFiServer::available(uint8_t*)'
WiFiClient available(uint8_t* status = NULL);
^
In file included from C:\Program Files (x86)\Arduino\libraries\WiFi\src/WiFi.h:31:0,
from C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTESP32.h:21,
from C:\Users\xadon\AppData\Local\Temp\arduino_modified_sketch_77880\ESP32.ino:7:
C:\Program Files (x86)\Arduino\libraries\WiFi\src/WiFiClient.h:27:7: note: because the following virtual functions are pure within 'WiFiClient':
class WiFiClient : public Client {
^
In file included from C:\Program Files (x86)\Arduino\libraries\WiFi\src/WiFiClient.h:24:0,
from C:\Program Files (x86)\Arduino\libraries\WiFi\src/WiFi.h:31,
from C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTESP32.h:21,
from C:\Users\xadon\AppData\Local\Temp\arduino_modified_sketch_77880\ESP32.ino:7:
C:\Users\xadon\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta3\cores\esp8266/Client.h:29:21: note: virtual int Client::connect(const IPAddress&, uint16_t)
virtual int connect(CONST IPAddress& ip, uint16_t port) =0;
^
C:\Users\xadon\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta3\cores\esp8266/Client.h:37:22: note: virtual bool Client::flush(unsigned int)
virtual bool flush(unsigned int maxWaitMs = 0) = 0;
^
C:\Users\xadon\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta3\cores\esp8266/Client.h:38:22: note: virtual bool Client::stop(unsigned int)
virtual bool stop(unsigned int maxWaitMs = 0) = 0;
^
In file included from C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTESP32.h:23:0,
from C:\Users\xadon\AppData\Local\Temp\arduino_modified_sketch_77880\ESP32.ino:7:
C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTWiFiClient.h:123:13: error: cannot declare field 'CayenneMQTTWiFiClient::_wifiClient' to be of abstract type 'WiFiClient'
WiFiClient _wifiClient;
^
In file included from C:\Program Files (x86)\Arduino\libraries\WiFi\src/WiFi.h:31:0,
from C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTESP32.h:21,
from C:\Users\xadon\AppData\Local\Temp\arduino_modified_sketch_77880\ESP32.ino:7:
C:\Program Files (x86)\Arduino\libraries\WiFi\src/WiFiClient.h:27:7: note: since type 'WiFiClient' has pure virtual functions
class WiFiClient : public Client {
^
In file included from C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTESP32.h:23:0,
from C:\Users\xadon\AppData\Local\Temp\arduino_modified_sketch_77880\ESP32.ino:7:
C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTWiFiClient.h: In member function 'void CayenneMQTTWiFiClient::begin(const char*, const char*, const char*, const char*, const char*)':
C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTWiFiClient.h:46:8: error: 'class WiFiClass' has no member named 'mode'
WiFi.mode(WIFI_STA);
^
C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTWiFiClient.h:46:13: error: 'WIFI_STA' was not declared in this scope
WiFi.mode(WIFI_STA);
^
C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTWiFiClient.h:55:33: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
WiFi.begin(ssid, wifiPassword);
^
In file included from C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTESP32.h:21:0,
from C:\Users\xadon\AppData\Local\Temp\arduino_modified_sketch_77880\ESP32.ino:7:
C:\Program Files (x86)\Arduino\libraries\WiFi\src/WiFi.h:79:9: error: initializing argument 1 of 'int WiFiClass::begin(char*, const char*)' [-fpermissive]
int begin(char* ssid, const char *passphrase);
^
In file included from C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTESP32.h:23:0,
from C:\Users\xadon\AppData\Local\Temp\arduino_modified_sketch_77880\ESP32.ino:7:
C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTWiFiClient.h:58:19: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
WiFi.begin(ssid);
^
In file included from C:\Users\xadon\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTESP32.h:21:0,
from C:\Users\xadon\AppData\Local\Temp\arduino_modified_sketch_77880\ESP32.ino:7:
C:\Program Files (x86)\Arduino\libraries\WiFi\src/WiFi.h:60:9: error: initializing argument 1 of 'int WiFiClass::begin(char*)' [-fpermissive]
int begin(char* ssid);
^
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
If Cayenne.begin()
failed, board will hang at here.
Could it add retry times and return t/f?
Right now, the wifi client variable name is WiFi, which isn't too complex to do a find and replace all the "client" in my sketch to "WiFi".
In file included from Cayenne_example_ESP8266_5-30-2020.ino:6:0:
C:\Users\boyan.biandov\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master\src/CayenneMQTTESP8266.h:21:25: fatal error: ESP8266WiFi.h: No such file or directory
#include <ESP8266WiFi.h>
^
compilation terminated.
Error compiling.
I am using the latest 8266 board and I have many sketches working and NONE requires the import of ESP8266WiFi.h but for some reason the CayenneMQTTESP8266 does?
For what reason? I've never had to do that and my 8266 sketches work just fine?
As a result I can not use the CayenneMQTTESP8266 library for the Cayenne example sketh?
Any input will be apprciated!
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.