Creating a node to activate the web server in NodeMCU 8266

I’m in a learning process to create a node for the above purpose. In case anyone can help us to create a node that can handle a way to activate the web server in the board, it will be very great, we can manipulate our sensors through web service (browser). I’m thinking of converting/modifying the following C++ code to become a XOD node:


My skill is not strong enough to do this. I really appreaciate any help.

I was trying to write something based on another example… it is not working yet… in case someone can help me to understand it better…

To make it more reusable, you probably want to make the SSID & password input pins rather than hard-coding them. Same for IP info (but those are future fixes when debug is done).

Some possible reasons for failure:

  • If you didn’t delete SSID & password to post your code, it probably can’t connect to wifi…
  • That is not standard way to represent IP/gateway/subnet (but could be correct for this code). If it is correct for this code, it might making passing info by input pin more difficult…
  • Gateway & local_ip can’t be the same. Local_ip needs to be an IP that is not already in use on your network.

Generally the code looks OK, but I don’t use these specific calls, so I can’t verify that they are indeed correct.

1 Like

For now I just want to make the device can perform as an AP webserver.

I’m not sure your first point of deleting SSID & password, since my intention is just to activate the AP mode (standalone WiFi mode).

I changed as follow, but the errors are still there:


The compiler indicate the error/bugs are at line 36 & 43:

C:\Users\uum\AppData\Local\Temp\xod_temp_sketchbookifGV7o\xod_1585707516962_sketch\xod_1585707516962_sketch.ino:1193:13: error: ‘output_AP’ was not declared in this scope
emitValue<output_AP>(ctx, str1);

C:\Users\uum\AppData\Local\Temp\xod_temp_sketchbookifGV7o\xod_1585707516962_sketch\xod_1585707516962_sketch.ino:1193:33: error: no matching function for call to ‘emitValue(xod::____webserver_apwifi2::ContextObject*&, const char*&)’ emitValue<output_AP>(ctx, str1);

C:\Users\uum\AppData\Local\Temp\xod_temp_sketchbookifGV7o\xod_1585707516962_sketch\xod_1585707516962_sketch.ino:1137:33: note: template argument deduction/substitution failed:

C:\Users\uum\AppData\Local\Temp\xod_temp_sketchbookifGV7o\xod_1585707516962_sketch\xod_1585707516962_sketch.ino:1193:33: error: template argument 1 is invalid
emitValue<output_AP>(ctx, str1);
I really appreciate any help.

Is because you have emitValue<output_AP>(ctx, str1);, but you don’t have an output pin named AP. One of the output pins below not-implemented-in-xod node needs to be named “AP”

The other errors may just be a result of this error confusing the compiler.

1 Like

It seems the compiler also pointed the error to the string handling. Second parameter of the emitValue is not matching with Lines 31 & 36. It indicates something like char*. I tried change to XString, it does not help.

I don’t know if XOD looks at future use for auto declaration. You may need to specify variable type when storing output data instead of using auto.

1 Like

Pls guide me further:

The error is at line 32 method/function length is seems requires another datatype:
error: no matching function for call to ‘length(char*&)’
Number myIPLength = length(myIP);

C:\Users\uum\AppData\Local\Temp\xod_temp_sketchbookENPAFN\xod_1585842887744_sketch\xod_1585842887744_sketch.ino:585:29: note: template size_t xod::length(xod::List)
template size_t length(List xs) {
C:\Users\uum\AppData\Local\Temp\xod_temp_sketchbookENPAFN\xod_1585842887744_sketch\xod_1585842887744_sketch.ino:585:29: note: template argument deduction/substitution failed:

C:\Users\uum\AppData\Local\Temp\xod_temp_sketchbookENPAFN\xod_1585842887744_sketch\xod_1585842887744_sketch.ino:1170:34: note: mismatched types ‘xod::List’ and ‘char*’
Number myIPLength = length(myIP);

Sorry…I’m weak on handling of strings in C++ myself. All I can tell you is the 1st error is complaining that there is no length() function that knows how to find length from a pointer to a character. You can probably use “int” instead of “Number” for myIPLength. Not sure how to help you beyond that…

1 Like

Ask Mitch to help, he’s C++ and a XOD newbie too

1 Like

My only problem now is how to convert traditional C++ string to XOD XString (or List<char>) thus emitValue can accept my string to be displayed. I’ve tried many ways but yet to get any solution:

The only error is at line 30:
error: conversion from ‘String’ to non-scalar type ‘xod::XString {aka xod::List}’ requested
XString myIP = WiFi.softAPIP().toString(); //Get IP address

pls help.

Probably the best help is to look at existing nodes to see how they deal with it. format-number is a node that stores an array of char and emits a string. My guess would be WiFi…toString is returning an array of char (or a pointer to char, which might need copied to your array of char). Like I said…strings in C++ are not my strong point.

1 Like

I “resolved” the problem of string conversion by outputting/emitValue as an IPAddress datatype (and link it to output-ip-address node) [Lines 47 & 48]. However the IP address is not displayed yet, the bug has gone for the time being.


Now, I’m trying to create a node to activate the webserver in nodemcu 8266 with Wifi mode. I will use connect node from xod-dev/esp8266-mcu/connect. The following code is the ref C++ I intend to use:

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);

const char* ssid = "WiFi_SSID"; //Enter Wi-Fi SSID
const char* password =  "WiFi_Password"; //Enter Wi-Fi Password
void setup() {
  Serial.begin(115200); //Begin Serial at 115200 Baud
  WiFi.begin(ssid, password);  //Connect to the WiFi network
  while (WiFi.status() != WL_CONNECTED) {  //Wait for connection
      Serial.println("Waiting to connect...");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());  //Print the local IP
  server.on("/", handle_index); //Handle Index page
  server.begin(); //Start the server
  Serial.println("Server listening");

void loop() {
  server.handleClient(); //Handling of incoming client requests

void handle_index() {
  //Print Hello at opening homepage
  server.send(200, "text/plain", "Hello! This is an index page.");

I plan to do something like this:

and this is my converted code:

My C++ nodes will look like this:

a) Currently the serial println is not displayed :

void evaluate(Context ctx) {
  Serial.println("Entering webserver node... ");  

b) What is the correct way to implement the following c++ arduino ide & webserver function/method in XOD:

void loop() {
  server.handleClient(); //Handling of incoming client requests

This is due to this loop is meant for c++ arduino ide implementation.

Any suggestion?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.