Lua Code
print(adc.read(0))
NodeMCU Flasher
esptool.py –port COMx
Resources
Documentation
https://nodemcu.readthedocs.io/en/release/
print(adc.read(0))
esptool.py –port COMx
https://nodemcu.readthedocs.io/en/release/
ESP8266 ESP-01/ESP-01S
#include <ESP8266WiFi.h>
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.print("Setting soft-AP ... ");
boolean result = WiFi.softAP("ESPsoftAP_01", "pass-to-soft-AP");
if(result == true)
{
Serial.println("Ready");
}
else
{
Serial.println("Failed!");
}
}
void loop()
{
Serial.printf("Stations connected = %d\n", WiFi.softAPgetStationNum());
delay(3000);
}
boolean result = WiFi.softAP("ESPsoftAP_01", "pass-to-soft-AP"); edit the above bold word with your own SSID name and password. Save and recompile your code again.
#include "FS.h"
#include "DHT.h"
#define DHTPIN 2 // the digital pin we are connected to
#define DHTTYPE DHT11 // define type of DHT sensor we are using
DHT dht(DHTPIN, DHTTYPE); // create DHT object
void setup() {
Serial.begin(115200);
dht.begin(); // intialize DHT object
// always use this to "mount" the filesystem
bool ok = SPIFFS.begin();
if (ok) {
Serial.println("SPIFFS initialized successfully");
}
else{
Serial.println("SPIFFS intialization error");
}
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
//read temperature as Celcius
float t = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
//open log.txt file
File f = SPIFFS.open("/log.txt", "a");
if (!f) {
Serial.println("file open failed");
}
// save temperature reading
f.print(t);
f.println("deg C");
//close file
f.close();
delay(8000);
}
https://arduino-esp8266.readthedocs.io/en/latest/filesystem.html
https://thebigpotatoe.github.io/Effortless-SPIFFS/
https://www.arduino.cc/reference/en/libraries/effortless-spiffs/
There are some pins on the ESP8266 board that are used for reset functions and for boot mode functions. Therefore, ensure that:
CH_PD
(EN) is always pulled high because it will disable the ESP8266 when it is pulled low