Categories
Internet Of Things Microcontrollers MQTT

Getting Started with Docker Node-Red

https://nodered.org/docs/getting-started/docker

Categories
Dweet.IO Internet Of Things Microcontrollers

Dweet.IO Library

https://github.com/gamo256/dweet-esp

Categories
ESP8266 (ESP-01/01S) Internet Of Things Microcontrollers

WiFi Access Point

Requirements

ESP8266 ESP-01/ESP-01S

Arduino Sketch / Code

#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);
}

Access Point SSID name and password

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.
 

Categories
EasyEDA Microcontrollers PCB Design

Tutorial To Create a New Symbol

Categories
ESP32 ESP8266 (ESP-01/01S) Microcontrollers

Storing Data SPIFFS

Requirements

  • DHT11 Temperature and Humidity
  • USB to UART ESP01 Programmer
  • ESP8266 ESP01/01s (512KB / 1 Mbyte)
  • File System Uploader plug-in installed

Circuity

Code

#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);
}

Resources

https://arduino-esp8266.readthedocs.io/en/latest/filesystem.html

https://thebigpotatoe.github.io/Effortless-SPIFFS/

https://www.arduino.cc/reference/en/libraries/effortless-spiffs/

Categories
ESP8266 (ESP-01/01S) Microcontrollers

Troubleshooting ESP8266

The board stops working when things are connected to some pins

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
  • RST is always pulled high because it will disable the ESP8266 when it is pulled low
  • GPIO 0 is pulled high during power up/reset for the user program to run, otherwise the module will enter bootloader mode. It is normally pulled high by the red LED
  • GPIO 2 is pulled high on power up/reset
  • GPIO 15 is pulled low on power up/reset
Categories
ESP8266 (ESP-01/01S) Microcontrollers

NodeMCU (Lua Based Firmware) for ESP8266

ESP8266 Modules comes with NodeMCU firmware

  • WeMOS D1 Mini

Flash Size : 4MB / 32Mbit

Pin Out

PIN MAP

ADC Voltage Range (Analog Output pin A0) for modules

0 to 3.3V

Noted: With exception to ESP8266 chip-based (barebone), voltage range 0 to 1V

Categories
ESP32 ESP8266 (ESP-01/01S) Microcontrollers

Reading Digital Signal (GPIO Pin)

GPIO pin can be used to read values off from sensor devices and monitor sensor data.

Serial console to display the read of the value from GND/3.3V pins of ESP8266

Requirements

  • Breadboard
  • Jumper wires
  • USB cable
  • ESP8266 D1 Wemos Mini
  • CH340 Driver (USB-UART)
  • Arduino IDE (ESP8266 Library / Board : Lolin D1 Mini)

Layout

D1 Wemos Mini (GPIO 5 – D1 and GND)

Arduino IDE Sketch Code

// Setup the GPIO 5 Pin
// D1 Wemos Mini pin GPIO5
 
int inputPin = 5;
int val = 0;

void setup() {
  // Setup the serial console baud speed
  Serial.begin(115200);
  pinMode(inputPin, INPUT);
}

void loop() {
  // Read the value off GPIO 5 Pin
  val = digitalRead(inputPin);

  // Display state of input pin
  Serial.println(val);
  delay(1000);
}
Arduino IDE’s Serial console output (reading from GND pin)

Resource

https://www.wemos.cc/en/latest/d1/d1_mini.html

https://arduino-esp8266.readthedocs.io/en/latest/

Categories
Microcontrollers MicroPython

MicroPython (Python 3) for ESP8266 – ESP01 (512KB)

Requirements

v1.12 and earlier will work on modules with 1M or more of flash, while v1.13 requires 2M or more.

ESP8266 ESP01 (512K flash) supported by limited features.

ESP01/01s USB-UART Programmer and UART device drivers. For uploading firmware and Python REPL from the serial console

PC / Notebook (Windows/MacOS – Intel) has been installed with Python 3.x and esptools.py utility program. Try this to install esptools

Thonny and Visual Studio IDE for coding editor for python

pip3 install esptool

Download Firmware

https://github.com/micropython/micropython/tree/master/ports/esp8266

https://micropython.org/download/esp8266/

Upload lastest firmware to ESP8266 (512 KB) with esptools.py utility installed on the PC/Notebook (Window/MacOS – Intel) and ESP01/01s USB-UART Programmer

This image has an empty alt attribute; its file name is USB-ESP01-PROG%20(5)-800x800.jpg
Source: Cytron Technology

Using esptool.py you can erase the flash with the command (macOS):

esptool.py --port /dev/ttyUSB0 erase_flash

And then deploy the new firmware using esptools.py and filename of the latest binary ESP8266 firmware.

esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 esp8266-xxxxx.bin

Using MicroPython (REPL) via USB-UART (Serial) Programmer on MacOS (Intel) screen utility

screen /dev/tty.SLAB_UART 115200

Note: Press ENTER key when the blinking cursor is on the screen without the REPL prompt.

>>> print(“Hello MicroPython”)

Blink LED (build-in) and main.py filename

Tutorials

http://docs.micropython.org/en/latest/esp8266/tutorial/index.html

Tutorial of Thonny IDE installation (MacOS – Intel)

https://github.com/thonny/thonny/wiki/MacOSX

Troubleshooting Problem

http://docs.micropython.org/en/latest/esp8266/tutorial/intro.html#deploying-the-firmware

Resources

http://docs.micropython.org/en/latest/esp8266/quickref.html

https://micropython.org/unicorn/

https://micropython.org/

https://thonny.org/

Categories
ESP32 ESP8266 (ESP-01/01S) Microcontrollers Security

MAC Address Randomization

Resources

https://source.android.com/devices/tech/connect/wifi-mac-randomization#:~:text=MAC%20randomization%20prevents%20listeners%20from,and%20Wi%2DFi%20RTT%20operations.