Feedback on "Things" example

(Lg Lindstrom) #1


I’ve decided to make a “Thing”. I have a nodeMcu and installed PlatformIO.
From github I’ve copied the PlatformIO version of LED.cpp and all other necessary files.

Compiling it gives a lot of warnings, so I guess the example not are up to date.

Running the example I can, by using “RestMan” turn Led on and off and read status. When asking for properties from the “Thing” result is not according to API specification.

Worse is my “Thing” crashes after running for a while …

Exception (28):
epc1=0x4020c7a9 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000028 depc=0x00000000

ctx: sys
sp: 3fffdac0 end: 3fffffb0 offset: 01a0

3fffdc60: 3fff1a24 3fffdca0 00000008 000005b4
3fffdc70: 00000010 3fff1a60 3fff1a60 4020ae03
3fffdc80: 3ffe93e4 00000000 3fff1a60 4020ae4f
3fffdc90: 00000000 3fff1afc 3fff1a60 4020ae81

Now I planning to write a Adapter (or copy example adapter) for my “Thing”
I would like some rekommendation on how to set up a development environment for this work. I really would like to have a debugging environment where I can set breakpoints and step through my adapter. Using “printf” as only mean of debugging, :frowning:

(Rzr) #2

Do you know the exact reference of your MCU on your board?

My ESP8266 was stable enough for me, I used the RGBlamp example during days…

(Lg Lindstrom) #3


I am using nodeMcu2 with ESP-12E,

I’ve have worked more on this project. My conclusion is that it is during “pairing” with gateway the module crashes, Otherwise it seems okay.

I have seen some other reports about that …

(Rzr) #4

please link reports and see if there is a way to reproduce

(Lg Lindstrom) #5

Sorry, link reports ??

I doing like this.

  1. create a new project in platformIO.
  2. Copy led example

 * Simple server compliant with Mozilla's proposed WoT API
 * Originally based on the HelloServer example
 * Tested on ESP8266, ESP32, Arduino boards with WINC1500 modules (shields or
 * MKR1000)
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at

#include <Arduino.h>
#include "Thing.h"
#include "WebThingAdapter.h"

//TODO: Hardcode your wifi credentials here (and keep it private)2
const char* ssid = "";
const char* password = "";

#if defined(LED_BUILTIN)
const int ledPin = LED_BUILTIN;
const int ledPin = 13;  // manually configure LED pin

WebThingAdapter* adapter;

const char* ledTypes[] = {"OnOffSwitch", "Light", nullptr};
ThingDevice led("led", "Built-in LED", ledTypes);
ThingProperty ledOn("on", "", BOOLEAN, "OnOffProperty");

bool lastOn = false;

void setup(void){
   pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
  Serial.print("Connecting to \"");
  #if defined(ESP8266) || defined(ESP32)
  WiFi.begin(ssid, password);

  // Wait for connection
  bool blink = true;
  while (WiFi.status() != WL_CONNECTED) {
      digitalWrite(ledPin, blink ? LOW : HIGH); // active low led
      blink = !blink;
 digitalWrite(ledPin, HIGH); // active low led

 Serial.print("Connected to ");
 Serial.print("IP address: ");
 adapter = new WebThingAdapter("w25", WiFi.localIP());

  Serial.println("HTTP server started");

void loop(void){
 bool on = ledOn.getValue().boolean;
 digitalWrite(ledPin, on ? LOW : HIGH); // active low led
 if (on != lastOn) {
    Serial.print(": ");
  lastOn = on;

  1. Modify platformIo.ino

; PlatformIO Project Configuration File
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
; Please visit documentation for the other options and examples

lib_deps =

 platform = espressif8266
 board = nodemcuv2
 framework = arduino
 lib_deps =
     ESP Async WebServer
 lib_ignore =
 lib_ldf_mode = deep+
 monitor_port = COM4
  monitor_speed = 115200
  1. Connect nodeMcu to USB on computer and upload application

  2. Attach serial monitor

  3. Use Restman to turn led on/of a couple of times. Works.

  4. Wait, 10 min,30 min 90 min, what ever. Stack dump is shown in the terminal window. nodeMcu not responding to RestMan

Beginning of dump below.

    --- Miniterm on COM4  115200,8,N,1 ---
    --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
    Connected to atHome
    IP address:
    MDNS responder started
    HTTP server started
    led: 1

Exception (28):
epc1=0x4020c831 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000028 depc=0x00000000

ctx: sys
sp: 3fffdac0 end: 3fffffb0 offset: 01a0

3fffdc60:  3fff1a1c 3fffdca0 00000008 000005b4
3fffdc70:  00000010 3fff1a58 3fff1a58 4020ae8b
3fffdc80:  3ffe9394 00000000 3fff1a58 4020aed7
3fffdc90:  00000000 3fff1af4 3fff1a58 4020af09

(Lg Lindstrom) #6


I still have problem with instability. Since last I have build a breadboard for my nodeMcu so I have control of all not used io ports.

Nothing have changed. I can run 10 minutes, 1 hour, 1 day, but soner or later it crashes.

Can anybody please verify/object to what I am saying???
For me stability is quite fundamental if I am going to trust this…

(Kathy Giori) #7

Instead of using RestMan for sending commands to toggle the LED, have you tried running the Mozilla Things Gateway on your laptop or installed it on an RPi? You could set up some clock based rules to test on then off every five min or so while having the serial monitor connected. Perhaps update the printf output to put a time stamp on the toggle state. I have not seen issues when controlling the NodeMCU from a Raspberry Pi running the Things Gateway application, but I have not done extensive testing.

(Lg Lindstrom) #8

My experience how to find this kind of problems, is to reduce “unknowns”. That’s why I have disconnected the gateway from the device, (using restman once to set state of device), no serial debug port connected etc. Just running the device in a “defined” state and expecting it to stay in that state for a long time… (we are talking days).

If community states that “it works for them”, I will get more nodeMcu modules and test. It can be bad soldering or simular problems on my module.

(James Hobin) #9

There appears to be an issue where some boards have too little memory to support the massive staticjsonbuffers I use in the adapter. If you switch some StaticJsonBuffers to DynamicJsonBuffers you may get better results and I’ll be looking into this further whenever I get time.