มันขึ้นError compiling for board NodeMCU 1.0 (ESP-12E Module) ต้องแก้ยังไงคับ

Copy error มาวางหน่อยครับ

Arduino: 1.8.10 (Windows 7), Board: “NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200”

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x7855fb]

goroutine 1 [running]:
github.com/arduino/arduino-cli/legacy/builder.ResolveLibrary(0x124c05a0, 0x12890085, 0x5, 0x12890085)
/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-cli/legacy/builder/resolve_library.go:64 +0x14b
github.com/arduino/arduino-cli/legacy/builder.findIncludesUntilDone(0x124c05a0, 0x124ded80, 0x88ed00, 0x12864780, 0x126b5fa8, 0x1250b700, 0x0)
/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-cli/legacy/builder/container_find_includes.go:358 +0x3b6
github.com/arduino/arduino-cli/legacy/builder.(*ContainerFindIncludes).Run(0xdebc68, 0x124c05a0, 0xdebc68, 0x0)
/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-cli/legacy/builder/container_find_includes.go:152 +0x3e5
github.com/arduino/arduino-cli/legacy/builder.runCommands(0x124c05a0, 0x12433e1c, 0x20, 0x20, 0xffffff01, 0x409c17, 0x1f3a0b8)
/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-cli/legacy/builder/builder.go:210 +0xbd
github.com/arduino/arduino-cli/legacy/builder.(*Builder).Run(0x12461f40, 0x124c05a0, 0xdebbb4, 0x12406ca0)
/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-cli/legacy/builder/builder.go:117 +0xb9c
github.com/arduino/arduino-cli/legacy/builder.RunBuilder(...)
/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-cli/legacy/builder/builder.go:226
main.main()
/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-builder/main.go:398 +0x6d2
C:\Program Files\Arduino\arduino-builder returned 2
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.

ต้องแก้ตรงไหนครับ

Code ที่ใช้ด้วยครับ

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>

char auth[] = “pjgFEzrZ2-q1bCsfNxD2vwhwz4gaWLY6”;

char ssid[] = “NADTAWOOT 1”;
char pass[] = “0640968245”;

#define DHTPIN 2

#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321

DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;

void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(h) || isnan(t)) {
Serial.println(“Failed to read from DHT sensor!”);
return;
}

Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);

void setup()
{
Serial.begin(9600); //
Blynk.begin(auth, ssid, pass);

dht.begin();

timer.setInterval(1000L, sendSensor);
}

void loop()
{
Blynk.run();
timer.run();
}

วงเล็บปีกกาหายไปรึป่าวครับเช็คให้ครบครับ

โค้ดทั้งหมดเลยหรอคับ ที่ให้ไฮไลท์คับ

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>

char auth[] = “pjgFEzrZ2-q1bCsfNxD2vwhwz4gaWLY6”;

char ssid[] = “NADTAWOOT 1”;
char pass[] = “0640968245”;

#define DHTPIN 2

#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321

DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;

void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
}
if (isnan(h) || isnan(t)) {
Serial.println(“Failed to read from DHT sensor!”);
return;
}

Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);

void setup()
{
Serial.begin(9600); 
Blynk.begin(auth, ssid, pass);

dht.begin();

timer.setInterval(1000L, sendSensor);
}

void loop()
{
Blynk.run();
timer.run();
}

ลองแก้แล้วคับยังเป็นเหมือนเดิม

ทำไมถึงเอาไว้ข้างนอก loop ละครับ

ตรงนี้ก็ผิดใช้ สัญลักษณ์ผิดประเภท

image

'' x '' ==> " x "

“NADTAWOOT 1” ผิด

แก้ตามที่บอกมาแล้วก็เป็นเหมือนเดิมคับ

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>

char auth[] = "pjgFEzrZ2-q1bCsfNxD2vwhwz4gaWLY6";

char ssid[] = "NADTAWOOT 1";
char pass[] = "0640968245";

#define DHTPIN 2

#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321

DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;

void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(h) || isnan(t)) 
Serial.println("Failed to read from DHT sensor!");
return;

Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
}

void setup()
{
Serial.begin(9600); 
Blynk.begin(auth, ssid, pass);

dht.begin();

timer.setInterval(1000L, sendSensor);
}

void loop()
{
Blynk.run();
timer.run();
}

Copy error มาดูครับ

Arduino: 1.8.10 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x7855fb]

goroutine 1 [running]:
github.com/arduino/arduino-cli/legacy/builder.ResolveLibrary(0x124dc5a0, 0x127f63d1, 0x5, 0x127f63d1)
	/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-cli/legacy/builder/resolve_library.go:64 +0x14b
github.com/arduino/arduino-cli/legacy/builder.findIncludesUntilDone(0x124dc5a0, 0x124fc560, 0x88ed00, 0x1286e7b0, 0x12445df8, 0x12563500, 0x0)
	/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-cli/legacy/builder/container_find_includes.go:358 +0x3b6
github.com/arduino/arduino-cli/legacy/builder.(*ContainerFindIncludes).Run(0xdebc68, 0x124dc5a0, 0xdebc68, 0x0)
	/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-cli/legacy/builder/container_find_includes.go:152 +0x3e5
github.com/arduino/arduino-cli/legacy/builder.runCommands(0x124dc5a0, 0x12433e1c, 0x20, 0x20, 0x409a01, 0x1f, 0x0)
	/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-cli/legacy/builder/builder.go:210 +0xbd
github.com/arduino/arduino-cli/legacy/builder.(*Builder).Run(0x12473f40, 0x124dc5a0, 0xdebbb4, 0x12444c90)
	/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-cli/legacy/builder/builder.go:117 +0xb9c
github.com/arduino/arduino-cli/legacy/builder.RunBuilder(...)
	/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-cli/legacy/builder/builder.go:226
main.main()
	/home/jenkins/workspace/arduino-builder-all-cross-cli-inception/src/github.com/arduino/arduino-builder/main.go:398 +0x6d2
C:\Program Files\Arduino\arduino-builder returned 2
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

ผมลองไปลงโค้ดอื่นแล้ว มันลงได้ แต่พอลงโค็ดนี้แล้วก็ขึ้นสีแดงผิด
ผมอยากทราบว่าผมเขียนโค้ดรึป่าว

ผมลอง Copy code ของ คุณ armmm มาลองดูแล้ว Compile ผ่านครับ ผมใช้ Arduino V1.8.7 ยังไงลองย้อนกลับไปยังรุ่น V1.8.9 ดูครับ [บางทีรุ่น .10 อาจจะมีปัญหาอยู่หรือปล่าวครับ

1 Like

ได้แล้วคับ มันเป็นที่เวอร์ชั่นใหม่จริงๆด้วย ขอบคูณคับ

Confirm ว่าโค้ตนี้ถูกต้องแล้วครับ ผมใช้ IDE V.1.8.8

free
hit counter