Arduino: 1.6.8 (Windows 10), TD: 1.28-beta1, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz optimized (overclock), US English"
Build options changed, rebuilding all
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:14:4: error: expected constructor, destructor, or type conversion before '(' token
ISR(WDT_vect)
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp: In member function 'int WatchdogAVR::enable(int)':
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:25:21: error: 'wdt_enable' was not declared in this scope
wdt_enable(_wdto);
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp: In member function 'void WatchdogAVR::reset()':
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:31:15: error: 'wdt_reset' was not declared in this scope
wdt_reset();
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp: In member function 'void WatchdogAVR::disable()':
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:36:17: error: 'wdt_disable' was not declared in this scope
wdt_disable();
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp: In member function 'int WatchdogAVR::sleep(int)':
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:46:5: error: 'uint8_t' was not declared in this scope
uint8_t wdps = ((sleepWDTO & 0x08 ? 1 : 0) << WDP3) |
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:46:13: error: expected ';' before 'wdps'
uint8_t wdps = ((sleepWDTO & 0x08 ? 1 : 0) << WDP3) |
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:52:9: error: 'cli' was not declared in this scope
cli();
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:54:5: error: 'MCUSR' was not declared in this scope
MCUSR &= ~(1<<WDRF);
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:54:19: error: 'WDRF' was not declared in this scope
MCUSR &= ~(1<<WDRF);
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:59:5: error: 'WDTCSR' was not declared in this scope
WDTCSR |= (1<<WDCE) | (1<<WDE); // Set WDCE and WDE to enable changes.
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:59:19: error: 'WDCE' was not declared in this scope
WDTCSR |= (1<<WDCE) | (1<<WDE); // Set WDCE and WDE to enable changes.
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:59:31: error: 'WDE' was not declared in this scope
WDTCSR |= (1<<WDCE) | (1<<WDE); // Set WDCE and WDE to enable changes.
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:60:14: error: 'wdps' was not declared in this scope
WDTCSR = wdps; // Set the prescaler bit values.
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:61:19: error: 'WDIE' was not declared in this scope
WDTCSR |= (1<<WDIE); // Enable only watchdog interrupts.
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:63:9: error: 'sei' was not declared in this scope
sei();
^
In file included from %UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:8:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/avr/sleep.h:36:23: error: expected primary-expression before 'asm'
#define sleep_cpu() (asm("wfi"))
^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/avr/sleep.h:38:23: note: in expansion of macro 'sleep_cpu'
#define sleep_mode() sleep_cpu()
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:67:5: note: in expansion of macro 'sleep_mode'
sleep_mode();
^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/avr/sleep.h:36:23: error: expected ')' before 'asm'
#define sleep_cpu() (asm("wfi"))
^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/avr/sleep.h:38:23: note: in expansion of macro 'sleep_cpu'
#define sleep_mode() sleep_cpu()
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:67:5: note: in expansion of macro 'sleep_mode'
sleep_mode();
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:77:25: error: 'wdt_enable' was not declared in this scope
wdt_enable(_wdto);
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp: In member function 'void WatchdogAVR::_setPeriod(int, int&, int&)':
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:89:20: error: 'WDTO_8S' was not declared in this scope
wdto = WDTO_8S;
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:93:20: error: 'WDTO_4S' was not declared in this scope
wdto = WDTO_4S;
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:97:20: error: 'WDTO_2S' was not declared in this scope
wdto = WDTO_2S;
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:101:20: error: 'WDTO_1S' was not declared in this scope
wdto = WDTO_1S;
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:105:20: error: 'WDTO_500MS' was not declared in this scope
wdto = WDTO_500MS;
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:109:20: error: 'WDTO_250MS' was not declared in this scope
wdto = WDTO_250MS;
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:113:20: error: 'WDTO_120MS' was not declared in this scope
wdto = WDTO_120MS;
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:117:20: error: 'WDTO_60MS' was not declared in this scope
wdto = WDTO_60MS;
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:121:20: error: 'WDTO_30MS' was not declared in this scope
wdto = WDTO_30MS;
^
%UserProfile%\Documents\Arduino\libraries\Adafruit_SleepyDog_Library\utility\WatchdogAVR.cpp:125:20: error: 'WDTO_15MS' was not declared in this scope
wdto = WDTO_15MS;
^
Error compiling for board Teensy 3.2 / 3.1.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Man, every time I did a search for Teensy 3 watchdog I only ever found the few posts about manually doing it. Adding this to my list of libraries to use.I only did the watchdog.
An update: while working, the NodeMCU solution was very hard to use/modify.
I have set to a new solution, which is much stable and do not require to flash anything on the ESP8266:
Amazing library that uses AT commands to emulate a "client" library: https://github.com/bportaluri/WiFiEsp
A simple MQTT library that works for me: https://github.com/knolleary/pubsubclient
HTH
WiFiEspClient net;
PubSubClient client(net);
// undefine this if WIFI settings are hardcoded into nodemcu lua script
#include <RF24.h>
#include <SPI.h>
#include "WiFiEsp.h"
#include "WiFiEspClient.h"
#include <PubSubClient.h>
// WIFI settings to pass towards esp
char SSIDNAME[] = "myssid";
char SSIDPASS[] = "mypassword";
// baudrate towards computer (USB) and towards esp
#define USB_BAUDRATE 19200
#define ESP_BAUDRATE 19200
int status = WL_IDLE_STATUS; //
WiFiEspClient net;
PubSubClient client(net);
void messageReceived(char *topic, char *payload, unsigned int length) {
Serial.print("incoming: ");
Serial.print(topic);
Serial.print(" - ");
Serial.print(payload);
Serial.println();
}
// periodically send data to esp (in milliseconds)
unsigned long interval = 1000;
// general consts
const uint8_t PIN_ESP_ENABLE = 6;
// stop unless you want to modify the code :)
int x = 0;
static char sreg = 0;
static unsigned long previousMillis = 0;
static unsigned long currentMillis = 0;
static boolean connected = 0;
// positions
const uint8_t POS_BASE = 1;
const uint8_t POS_WORKING_GREEN = 2;
const uint8_t POS_WORKING_YELLOW = 3;
const uint8_t POS_WORKING_RED = 4;
const uint8_t POS_LEARNING = 5;
const uint8_t POS_OTHER = 6;
const uint8_t POS_NADA = 7;
uint8_t curPos=POS_NADA;
//radio
RF24 myRadio (14, 16);
byte addresses[][6] = {"1Cube"};
const uint32_t RF_MAGIC_NUMBER = 136768103;
const uint8_t RF_CHANNEL = 119;
const uint16_t RF_MILLIS_PACE = 2000;
const uint8_t RF_MISSING_BITS_COUTNER = 20;
typedef struct {
uint32_t magic = RF_MAGIC_NUMBER;
uint8_t pos;
} tRFData;
tRFData rfData;
unsigned long prevRF = 0;
uint8_t missingBits = RF_MISSING_BITS_COUTNER;
void printPosName(uint8_t pos){
const char *posNames[8];
posNames[0] = "NONE";
posNames[POS_BASE] = "BASE";
posNames[POS_WORKING_GREEN] = "GREEN";
posNames[POS_WORKING_YELLOW] = "YELLOW";
posNames[POS_WORKING_RED] = "RED";
posNames[POS_LEARNING] = "LEARNING";
posNames[POS_OTHER] = "OTHER";
posNames[POS_NADA] = "NADA";
Serial.print(posNames[pos]);
}
void setup() {
// Serial = USB (console)
// Serial3 = tx3/rx3 - esp
Serial.begin(USB_BAUDRATE);
Serial3.begin(ESP_BAUDRATE);
// wait for serial hardware to finish setup
while (!Serial3);
pinMode(PIN_ESP_ENABLE, OUTPUT);
digitalWrite(PIN_ESP_ENABLE,LOW);
delay(500);
digitalWrite(PIN_ESP_ENABLE,HIGH);
delay(1000);
WiFi.init(&Serial3);
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue
while (true);
}
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(SSIDNAME);
// Connect to WPA/WPA2 network
status = WiFi.begin(SSIDNAME, SSIDPASS);
}
client.setServer("myMQTTServerAddress", 1883);
Serial.println("You're connected to the network");
printWifiData();
printCurrentNet();
// if not connected and stuff then restart and init
Serial.flush();
myRadio.begin();
myRadio.setChannel(RF_CHANNEL);
myRadio.setPALevel(RF24_PA_HIGH);
myRadio.openReadingPipe(0, addresses[0]); // Use the first entry in array 'addresses' (Only 1 right now)
myRadio.startListening();
Serial.println("After RF init");
MQTT_connect();
}
void MQTT_connect() {
Serial.print("checking wifi...");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(1000);
}
Serial.print("\nconnecting...");
while (!client.connect("taskCubeMQTTz")) {
Serial.print(".");
delay(1000);
}
Serial.println("\nconnected!");
// client.unsubscribe("/example");
}
void printWifiData()
{
// print your WiFi shield's IP address
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print your MAC address
byte mac[6];
WiFi.macAddress(mac);
char buf[20];
sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]);
Serial.print("MAC address: ");
Serial.println(buf);
}
void printCurrentNet()
{
// print the SSID of the network you're attached to
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print the MAC address of the router you're attached to
byte bssid[6];
WiFi.BSSID(bssid);
char buf[20];
sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X", bssid[5], bssid[4], bssid[3], bssid[2], bssid[1], bssid[0]);
Serial.print("BSSID: ");
Serial.println(buf);
// print the received signal strength
long rssi = WiFi.RSSI();
Serial.print("Signal strength (RSSI): ");
Serial.println(rssi);
}
void loop() {
if(!client.connected()) {
MQTT_connect();
}
currentMillis = millis();
// RF24
if (currentMillis - prevRF >= RF_MILLIS_PACE) {
if (myRadio.available()) {
myRadio.read(&rfData, sizeof(rfData));
if (rfData.magic == RF_MAGIC_NUMBER) {
printPosName(rfData.pos);
curPos=rfData.pos;
Serial.println(' ');
} else {
Serial.println("Error in receiving");
}
//read rest of buffer
while(myRadio.available()) {
myRadio.read(&rfData, sizeof(rfData));
}
missingBits = RF_MISSING_BITS_COUTNER;
} else {
if (missingBits == 0) {
curPos = POS_NADA;
} else {
missingBits--;
}
}
//convert int to char
char buf[5];
String(curPos).toCharArray(buf,5);
client.publish("taskCube/status",buf);
prevRF = currentMillis;
}
}