NodeMCU - error 'http' not declared in this scope

I am using Arduino 1.6.13 (Windows) to write and send sketches to NodeMCU. I have a custom NodeMCU built against the master branch. It includes file, gpio, http, mdns, mqtt, net, node, tmr, uart, websocket, wifi - using nodemcu-build.com. It was flashed without problem using esptool.py.

I have a simple sketch, which reacts on button press with a flashing led and runs a small PHP script on server side).

#include <ESP8266WiFi.h> const char* ssid = "blahblahblah"; const char* password = "blahblahblahblah"; const int ledPin = D7; const int buttonPin = D2; void setup() { pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT_PULLUP); Serial.begin(115200); delay(10); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); } } void loop() { if (digitalRead(buttonPin) == LOW) { digitalWrite(ledPin, HIGH); delay(1000); http.get(""); digitalWrite(ledPin, LOW); } } 

Result of verification is:

In function 'void loop()': button_check_yapp:24: error: 'http' was not declared in this scope http.get(""); ^ exit status 1 'http' was not declared in this scope

What's wrong? What I did miss?

Thank you.

2 Answers

You either program in the Arduino IDE using Arduino code (as you have above) OR your program against the NodeMCU firmware using Lua code but not both. It's either or.

For NodeMCU you'd use something like ESPlorer to upload the Lua code. This allows for really fast prototyping as you only need to flash the firmware once. With Arduino you compile your own code with the chip maker SDK into a new binary every time you change your code.

Disclaimer: I'm biased as I'm one of the current NodeMCU firmware maintainers.

The compiler gets an error, because it doesn't know the http function or variable. You either have to create the http variable or you need a other variable that knows the http function.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like