Sublime Forum

Arduino Sublime NodeMCU issue on macOS


Hello! I have a simple script for DHT11 sensor working with Cayenne ioT.

"#define CAYENNE_PRINT Serial
"#include <CayenneMQTTESP8266.h
"#include <DHT.h

char ssid[] = “xxxxxxxxxxxxxxx”;
char wifiPassword[] = “xxxxxxxxxxxxx”;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = “xxxxxxxxxxxxxxx”;
char password[] = “xxxxxxxxxxxxxxx”;
char clientID[] = “xxxxxxxxxxxxxxx”;

DHT dht(D2, DHT11);

void setup() {

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

void loop() {
float temp = dht.readTemperature();
float hum = dht.readHumidity();
Cayenne.virtualWrite(1, temp, TYPE_TEMPERATURE, UNIT_CELSIUS);
Cayenne.virtualWrite(2, hum, TYPE_RELATIVE_HUMIDITY, UNIT_PERCENT);

digitalWrite(2, getValue.asInt());

Here are my settings for board, programmer, build etc…

I can without any problem compile and upload this sketch with Arduino IDE but Sublime throws at me these errors:

[96.1%] Compiling uart.c…
[97.4%] Compiling cont.S…
[98.7%] Linking everything together…
[100.0%] Creating binary files…
/Users/raf/Library/Arduino15/build/ESP8266new/ undefined reference to CayenneParseTopic' /Users/raf/Library/Arduino15/build/ESP8266new/ undefined reference toCayenneParsePayload’
/Users/raf/Library/Arduino15/build/ESP8266new/ In function MQTTMessageArrived': /Users/raf/Documents/Arduino/libraries/Cayenne-MQTT-ESP/src/CayenneMQTTClient/CayenneMQTTClient.c:386: undefined reference toCayenneParseTopic’
/Users/raf/Documents/Arduino/libraries/Cayenne-MQTT-ESP/src/CayenneMQTTClient/CayenneMQTTClient.c:386: undefined reference to CayenneParsePayload' /Users/raf/Library/Arduino15/build/ESP8266new/ undefined reference toCayenneBuildTopic’
/Users/raf/Library/Arduino15/build/ESP8266new/ undefined reference to CayenneBuildDataPayload' /Users/raf/Library/Arduino15/build/ESP8266new/ In functionCayenneMQTTPublishDataArray’:
/Users/raf/Documents/Arduino/libraries/Cayenne-MQTT-ESP/src/CayenneMQTTClient/CayenneMQTTClient.c:386: undefined reference to CayenneBuildTopic' /Users/raf/Documents/Arduino/libraries/Cayenne-MQTT-ESP/src/CayenneMQTTClient/CayenneMQTTClient.c:386: undefined reference toCayenneBuildDataPayload’
/Users/raf/Documents/Arduino/libraries/Cayenne-MQTT-ESP/src/CayenneMQTTClient/CayenneMQTTClient.c:386: undefined reference to CayenneBuildResponsePayload' /Users/raf/Library/Arduino15/build/ESP8266new/ In functionCayenneMQTTPublishResponse’:
/Users/raf/Documents/Arduino/libraries/Cayenne-MQTT-ESP/src/CayenneMQTTClient/CayenneMQTTClient.c:386: undefined reference to CayenneBuildTopic' /Users/raf/Documents/Arduino/libraries/Cayenne-MQTT-ESP/src/CayenneMQTTClient/CayenneMQTTClient.c:386: undefined reference toCayenneBuildResponsePayload’
/Users/raf/Library/Arduino15/build/ESP8266new/ In function CayenneMQTTSubscribe': /Users/raf/Documents/Arduino/libraries/Cayenne-MQTT-ESP/src/CayenneMQTTClient/CayenneMQTTClient.c:386: undefined reference toCayenneBuildTopic’
/Users/raf/Library/Arduino15/build/ESP8266new/ In function `MQTTClientInit’:
/Users/raf/Documents/Arduino/libraries/Cayenne-MQTT-ESP/src/CayenneMQTTClient/MQTTClient.c:586: undefined

/ reference to `MQTTSerialize_disconnect’
collect2: error: ld returned 1 exit status
[Build] Error occurred.

The weird thing is that same sketch would perfectly work with Arduino IDE and AND any other sketch that uploaded on Board Uno also works without any problem. The issue triggers when building sketch for NodeMCU.

Any IDEAS???
Thank you in advance for any help!



I don’t know from Arduino things, but the error you’re getting is a link error about missing symbols, so my first avenue of investigation would be to review the command that it’s running to see if it’s including an appropriate library on the link line.



Thank you for an idea. But is that usual that Sublime require different code for the same command? Do they have different compilers with Arduino IDE or something?Is it normal?



In most cases the command can be the same. In some rare cases you command need to be a little different due Sublime Text does not emulate a full featured terminal, you may need to change you command into making Sublime Text to launch a new terminal. See the issue: (Full/complete terminal features on Sublime Text) for reference.

But this does not seen to be your case. The probable problem is that Sublime Text is not nice into interpreting your command, so what is the command you run on the command line and what is the contents of your .sublime-build file?

Usually the changes required are like this; on the command line you can type cd mydir, but on Sublime Text you need to enter ["cd", "mydir"].

You may look into these links for reference:



For that you’d have to ask whoever wrote the package/build system that you’re using, but it’s entirely possible in the general case that building different software using different features would require extra libraries and tooling for support code.

For example, the library that provides the CayenneParsePayload function/method/class may not be required for all programs, so not linking with it works just fine in those cases but causes problems for programs that need it.

Whether that applies here or not, I don’t know since I’m not an Arduino guy. Do programs that work fine also use whatever Cayenne is?



Thank you for being helpful, first of all!
Now, after spending 3hrs looking for .sublime-build file :slight_smile: (I’m more of an electronic sider, not developer) I finally found out that I don’t even have these files in my SublimeText3 folder(yup, I know they are hidden). So after a short research i found this little nice add-on and merged it to my SublimeText3/User folder, changing the content of .sublime-build file to this

“shell_cmd”: ““python” -u “$packages/User/SublimeNodeMCU/” “$file””,
“file_regex”: “^(.\.lua):([0-9]):”,
“syntax”: “Packages/Lua/Lua.tmLanguage”,

And checked the builder as NodeMCU

After another building try with F7 , I got this error:

/Users/raf/.bash_profile: line 8: hub: command not found
[SublimeNodeMCU] Uploading…
Opening serial port COM4:115200…Traceback (most recent call last):
File “/Users/raf/Library/Application Support/Sublime Text 3/Packages/User/SublimeNodeMCU/”, line 113, in
ser = serial.Serial(port, baud, timeout=1)
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/serial/”, line 282, in init
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/serial/”, line 289, in open
self.fd =, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK)
OSError: [Errno 2] No such file or directory: ‘COM4’
[Finished in 0.9s with exit code 1]
[shell_cmd: “python” -u “/Users/rafik/Library/Application Support/Sublime Text 3/Packages/User/SublimeNodeMCU/” “/Users/rafik/Desktop/ESP8266new/ESP8266new.ino”]
[dir: /Users/raf/Desktop/ESP8266new]
[path: /Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/Users/rafik/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/]

I noticed that in file, port was set as COM4
I wanted to add image but As a new user I can upload only one image at a time…

but my port is /dev/cu.wchusbserial1d1140 and I will most probably to change it with your help(Do I have to simply copy/paste my port’s name instead of COM4?).
But still… I don’t even have to think now about uploading because I am not even successful in building a proper load.

Any ideas?



here is it



That’s a point. Everything is working perfectly but NodeMCU. And since almost all of my projects are based on smart home base, Cayenne ioT libraries and NodeMCU used in all of these projects. And when i am trying to build, Sublime simply gets confused with all these Cayenne libraries .

Since it was mentioned by you, that some libraries may not be required and some of them actually may, I think there is some kind of conflict or misallocation between Arduino and Sublime folders, cause Sublime getting these files from Arduino folders.



It seems to be working correctly, you should change the port to it to an valid one. Now I do not know how the port should be named. You can try just put /dev/cu.wchusbserial1d1140 or COM1, 2, 3.

Outside Sublime Text, what is the command you run to build it?



Sorry, I don’t really understand your question. I use only GUI IDEs for coding. I never use a terminal. In these IDE’s it’s a simple button for building or uploading sketches.
I have a feeling I will code sketches on Sublime and upload/ compile them on Arduino :smirk:



For Sublime Text, you will need to know what is the command your IDE is running or what it is doing, so only then you can do the same thing within Sublime Text.

Usually the easy way is to create a shell script which do the building and call it from your Sublime Text build system. Sublime Text is just a plain text editor. By himself it does not have integrated extra nice IDE feature support.

In order to do the same thing you do in a usual IDE, you need to know what the IDE is doing behind the scenes and implement the same thing for Sublime Text.

If you are lucky, someone already had implemented it for Sublime Text, then you just need to figure out how to use. On this case, is seems that the package SublimeNodeMCU was already implemented and could help you. But unfortunately it does not seem to be very easy to use as you cannot figure out what is the COM port you should use, or perhaps it is not even working on MAC OS because the original author could have written it using the Windows, and it still not working for other platforms.

If you cannot make it work, I would suggest to you use Sublime Text to write the code, and keep you IDE open only for building the code. This is what I currently do while programming in Java, because until now I could not figured out how to make Sublime Text build any java code without make me writing an Ant or Maven build script, or building a fully complicated javac command line.

You can try to open an issue on the SublimeNodeMCU package issue tracker perhaps the original author can help.



Thanks a lot. I guess that’s exactly what I am going to do.