User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Fri Sep 21, 2018 3:06 pm

tlfong01 wrote:
Fri Sep 21, 2018 2:52 pm
tlfong01 wrote:
Fri Sep 21, 2018 2:38 pm
NodeMCU DEVKIT
I googled further and found that actually I don't need to use the stupid esptool.py in the newbie unfriendly linux terminal - there is the GUI NodeMCU DEVKIT to save the newbies.
NodeMCU DEVKIT V1.0 A development kit for NodeMCU firmware
It is an open hardware, with ESP-12-E core [32Mbits(4MBytes) flash version.
It is designed by Altium Designer, and fully open–source. Now everyone can make their own NODEMCU.
Top 6 Esp8266 modules
TOP 6 ESP8266 MODULES FOR IOT PROJECTS - Losant April 19, 2016
https://www.losant.com/blog/top-6-esp8266-modules

CH340 Drivers for ... Linux
http://www.wch.cn/download/CH341SER_LINUX_ZIP.html

I also read the following advice from the article below.

Getting Started with NodeMCU - Losant
https://www.losant.com/blog/getting-sta ... 66-nodemcu

Drivers are almost certainly built into your Linux kernel already and it will probably just work as soon as you plug it in. If not you can download the Linux CH340 Driver (but I’d recommend just upgrading your Linux install so that you get the “built in” one).
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Sat Sep 22, 2018 1:25 am

tlfong01 wrote:
Fri Sep 21, 2018 3:06 pm
I also read the following advice from the article below.
Getting Started with NodeMCU - Losant
https://www.losant.com/blog/getting-sta ... 66-nodemcu

More NodeMCU References and Videos

I still found things confusing. So I googled more and also watching videos.

EEVblog #998 - How To Program ESP8266 WiFi With Arduino IDE WeMOS D1 Mini - David Jones 188,093 views
https://www.youtube.com/watch?v=Q6NBnPfPhWE&t=13s
Very good.

Quickly getting started with NodeMCU/ESP8266 12E In 7 mins! Beginner Friendly! Arduino - 171,385 views
https://www.youtube.com/watch?v=NEo1WsT5T7s
Very boring.

Getting started with NodeMCU (ESP8266 tutorial #1) - 160,283 views
https://www.youtube.com/watch?v=p06NNRq5NTU
Boring and commercial.

Appendix - References

ESP8266 Wikipedia
https://en.wikipedia.org/wiki/ESP8266

Features

ESP-01 module wireframe
Processor: 32-bit RISC Tensilica Xtensa 80 MHz
Memory:
32 KiB instruction RAM
32 KiB instruction cache RAM
80 KiB user-data RAM
16 KiB ETS system-data RAM
Flash: up to 16 MiB is supported (512 KiB to 4 MiB typically included)
IEEE 802.11 b/g/n Wi-Fi
Integrated TR switch, balun, LNA, power amplifier and matching network
WEP or WPA/WPA2 authentication, or open networks
16 GPIO pins
SPI
I²C (software implementation)[6]
I²S interfaces with DMA (sharing pins with GPIO)
UART on dedicated pins, plus a transmit-only UART can be enabled on GPIO2
10-bit ADC (successive approximation ADC)

ESP-01 module pinout

The pinout is as follows for the common ESP-01 module:

VCC, Voltage (+3.3 V; can handle up to 3.6 V)
GND, Ground (0 V)
RX, Receive data bit X
TX, Transmit data bit X
CH_PD, Chip power-down
RST, Reset
GPIO 0, General-purpose input/output No. 0
GPIO 2, General-purpose input/output No. 2

SDKs

Espressif SDKs one based on FreeRTOS, one based on callbacks, ESP-Open-SDK

NodeMCU – A Lua-based firmware.

Arduino – A C++-based firmware. With this core, the ESP8266 CPU and its Wi-Fi components can be programmed like any other Arduino device. The ESP8266 Arduino Core is available through GitHub.

MicroPython – A port of MicroPython (an implementation of Python for embedded devices) to the ESP8266 platform.


Espressif modules

...

Ai-Thinker modules

by Ai-Thinker and remains the most widely available.

Novice ESP8266 developers are encouraged to consider NodeMCU

Other boards

Modern ESP8266 boards like the NodeMCU are easier to work with and offer more GPIO pins. Most of the boards listed here are based on the ESP-12E module, but new modules are being introduced seemingly every few months.

NodeMCU DEVKIT 14 0.1 in 2×15 DIL LED 49 × 24.5 Uses ESP-12 module; includes USB to serial interface.

Adafruit Huzzah 14 0.1 in 2×10 DIL LED 25 × 38 Uses the ESP-12 module.

SparkFun Thing 12 0.1 in 2×10 DIL LED 58 × 26 FTDI serial header, Micro-USB socket for power, includes Li-ion battery charger.

NodeMcu Lua WIFI V3 ESP8266 serial wifi module model CEE0007 NT$126
http://www.playrobot.com/nodemcu-esp826 ... -wifi.html

Features

Uses CH340G instead of CP2102.
built-in USB-TTL serial with CH340G
Communication interface voltage: 3.3V.
Built-in PCB antenna
Wireless 802.11 b/g/n standard
WiFi at 2.4GHz, support WPA / WPA2 security mode
Support STA/AP/STA + AP three operating modes
Built-in TCP/IP protocol stack to support multiple TCP Client connections (5 MAX)
D0 ~ D8, SD1 ~ SD3: used as GPIO, PWM, IIC, etc., port driver capability 15mA
AD0: 1 channel ADC
Power input: 4.5V ~ 9V (10VMAX), USB-powered
Current: continuous transmission: ≈70mA (200mA MAX), Standby: <200uA
Transfer rate: 110-460800bps
Support UART / GPIO data communication interface
Remote firmware upgrade (OTA)
Support Smart Link Smart Networking
Working temperature: -40 ℃ ~ + 125 ℃
Drive Type: Dual high-power H-bridge driver
ESP8266 has IO Pin
Don't need to download resetting
A great set of tools to develop ESP8266
Flash size: 4MByte

Zerynth Zerynth Studio
https://docs.zerynth.com/latest/officia ... index.html
https://docs.zerynth.com/latest/officia ... index.html

.END
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Sat Sep 22, 2018 7:18 am

tlfong01 wrote:
Sat Sep 22, 2018 1:25 am
More NodeMCU References and Videos
I still found things confusing. So I googled more and also watching videos.

Programming in Lua 5.0 1st ed, free online version for personal use - Roberto Ierusalimschy 2003dec last update: 2018jul
http://www.lua.org/pil/contents.html

Now I am reading the Lua book, but only the preface, audience, and other resources. I found reading the preface of this book very useful, as always, and also entertaining.

Preface

1. help solve problem with only hundreds of lines, or even less, by extensibility.

2. a tiny and simple language, integrated with software written in C, relying on C for performance, low-level operations, or interface with third-party software.

3. a glue language, supporting a component-based approach to software development, creating application by gluing together existing high-level components, usually, written in a compiled, statically typed language, such as C or C++. components or objects representing more concrete, low-level concepts that are not subject to many changes during program development and that take the bulk of the CPU time of the final program.

4. gives the final shape of the application, which will probably change a lot during the life cycle of the product.

5. also a full-fledged language, not only to glue components, but also to adapt and reshape them, or even to create whole new components.

7. similar to other scripting languages Perl, Tcl, Ruby, Forth, and Python, with the following differences: Extensibility, Simplicity, Efficiency, Portability.

8. extensibility by libraries through new types and functions: Dynamic typing allowing a great degree of polymorphism, automatic memory management (allocation, delocation, overflow) simplifies interfaces, higher-order functions and anonymous functions allowing high degree of parametrization, making functions more versatile.

9. a small set of standard libraries for pattern matching and string handling, for embedded systems

Users

1. Lua users typically fall into three broad groups: those that use Lua already embedded in an application program, those that use Lua stand alone, and those that use Lua and C together.

2. use as a stand-alone language, mainly for text-processing and one-shot little programs

3. use basic control structures, also advanced iterators and coroutines.

4. use standard libraries: mathematical, table, string, I/O, operating system, debug library.

5. use as an interface to C API.

Other Resources

1. reference manual, shows examples or a rationale for the constructs of the language, at http://www.lua.org.

2. Lua users site at http://lua-users.org, offering a tutorial, a list of third-part packages and documentation, and an archive of the official Lua mailing list.

3. The book's web page for differences between versions: http://www.inf.puc-rio.br/~roberto/book/
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Sat Sep 22, 2018 12:43 pm

tlfong01 wrote:
Fri Sep 21, 2018 4:33 am
CH340 NodeMcu V3 Lua WIFI ESP8266

CH340 NodeMcu V3 Lua WIFI ESP8266

My toy ordered Friday morning arrived Saturday evening.
Attachments
esp8266_ch430_2018sep2202.jpg
esp8266_ch430_2018sep2202.jpg (145.65 KiB) Viewed 547 times
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Sat Sep 22, 2018 1:33 pm

tlfong01 wrote:
Sat Sep 22, 2018 12:43 pm
tlfong01 wrote:
Fri Sep 21, 2018 4:33 am
CH340 NodeMcu V3 Lua WIFI ESP8266
CH340 NodeMcu V3 Lua WIFI ESP8266
My toy ordered Friday morning arrived Saturday evening.
And detection test OK.
Attachments
nodemcu_test_2018sep2201.jpg
nodemcu_test_2018sep2201.jpg (151.05 KiB) Viewed 541 times
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Sat Sep 22, 2018 1:56 pm

tlfong01 wrote:
Sat Sep 22, 2018 1:33 pm
And detection test OK.

What Next?

But I don't know what to do next. I want to use eLUA to print 'Hello World' but I don't know how. So I googled the following article which I think is very good to NodeMCU newbies.

Getting to know NodeMCU and its DEVKIT board - Michael Yuan, IBM 2017jun12 Updated 2017aug17
https://www.ibm.com/developerworks/libr ... index.html
https://www.ibm.com/developerworks/libr ... se-pdf.pdf

NodeMCU using ESplorer IDE
http://www.electronicwings.com/nodemcu/esplorer-ide

NodeMCU Sensors/ Modules Interfacing example, Edited 03 Sep 2018
http://www.electronicwings.com/nodemcu/interface

Set up and get started programming for this open source IoT development environment

This article introduces the open source IoT development board called NodeMCU. One of its most unique features is that it has built-in support for wifi connectivity, and hence makes IoT application development much easier. While Arduino boards might provide greater flexibility, NodeMCU boards provide a more consistent and accessible experience for IoT developers.

Development boards, such as Arduino and Raspberry Pi, are common choices when prototyping new IoT devices. Those development boards are essentially mini-computers that can connect to and be programmed by a standard PC or Mac. After it has been programmed, the development boards can then connect to and control sensors in the field.

Because the "I" in IoT stands for internet, the development boards need a way to connect to the internet. In the field, the best way to connect to the internet is by using wireless networks. However, Arduino and Raspberry Pi do not have built-in support for wireless networks. Developers will have to add a wifi or cellular module to the board and write code to access the wireless module.

In this article, I will introduce an open source IoT development board called NodeMCU. One of its most unique features is that it has built-in support for wifi connectivity, and hence makes IoT application development much easier.

What is NodeMCU?

The NodeMCU (Node MicroController Unit) is an open source software and hardware development environment that is built around a very inexpensive System-on-a-Chip (SoC) called the ESP8266. The ESP8266, designed and manufactured by Espressif Systems, contains all crucial elements of the modern computer: CPU, RAM, networking (wifi), and even a modern operating system and SDK. When purchased at bulk, the ESP8266 chip costs only $2 USD a piece. That makes it an excellent choice for IoT projects of all kinds.

However, as a chip, the ESP8266 is also hard to access and use. You have to solder wires, with the appropriate analog voltage, to its PINs for the simplest tasks such as powering it on or sending a keystroke to the "computer" on the chip. And, you have to program it in low-level machine instructions that can be interpreted by the chip hardware. While this level of integration is not a problem when the ESP8266 is used as an embedded controller chip in mass-produced electronics, it is a huge burden for hobbyists, hackers, or students who want to experiment with it in their own IoT projects.

Borrowing a page from the successful playbooks of Arduino or a Raspberry Pi, the NodeMCU project aims to simplify ESP8266 development.

It has two key components.

An open source ESP8266 firmware that is built on top of the chip manufacturer's proprietary SDK. The firmware provides a simple programming environment based on eLua (embedded Lua), which is a very simple and fast scripting language with an established developer community. For new comers, the Lua scripting language is easy to learn.

A DEVKIT board that incorporates the ESP8266 chip on a standard circuit board. The board has a built-in USB port that is already wired up with the chip, a hardware reset button, wifi antenna, LED lights, and standard-sized GPIO (General Purpose Input Output) pins that can plug into a bread board.

...

The NodeMCU DEVKIT board that comes preloaded with the firmware can be purchased for $8 USD a piece, which makes it a very economical device for prototyping and even for production use.

But, what about Arduino, you ask? The Arduino project creates an open source hardware design and software SDK for a versatile IoT controller. Similar to NodeMCU, the Arduino hardware is a microcontroller board with a ready USB connector, LED lights, and standard data pins. It also defines standard interfaces to interact with sensors or other boards. But unlike NodeMCU, the Arduino board can have different types of CPU chips (typically an ARM or Intel x86 chip) with memory chips, and a variety of programming environments. In fact, there is an Arduino reference design for the ESP8266 chip as well. However, the flexibility of Arduino also means significant variations across different vendors. For example, most Arduino boards do not have wifi capabilities and some even have a serial data port instead of a USB port. I feel that NodeMCU provides a more consistent and accessible experience for IoT developers.

1 Getting Started with NodeMCU

While this article assumes that the user uses a late model Mac OS X computer, if you use a Linux machine, the instructions are essentially the same. For Windows users, you'll need to install Python and pip first.

1a Install a USB-to-serial-port driver

Download and install a USB-to-serial-port driver application on your computer. I used one from the Silicon Labs website. You need this driver application for your computer to communicate with the NodeMCU board by using a standard USB cable.

1b Create your custom NodeMCU firmware

Create your own custom NodeMCU firmware. Go to the NodeMCU Custom Builds web site, and choose the options that you want.

...

Besides the standard (default) choices, below are some interesting options that you might want to choose:

ADC: Support for measuring analog input (voltage level) on the NodeMCU board's A0 pin.

HTTP: Support for writing code to handle HTTP requests.

SSL / TLS: Support for HTTPS secure connections.

MQTT: Support for the MQTT protocol to send data to other devices or servers using a publish/subscribe model over TCP/IP.

Websocket: A convenience library to access websocket-based web services.

DHT: A convenience library to read data from DHT family of environmental sensors.

Enduser setup: Support a "capture portal" to let the user enter her own wifi password, without having to hardcode wifi credentials in application code.

After the firmware is created, the system will email you a link to download your firmware binary file. Choose the build with float number support unless you know that your application will deal with integer numbers only.

1c Flash the firmware to the NodeMCU device

Install the esptool Python library, and use it to flash the firmware that you just downloaded to the NodeMCU device.

Using Python and pip, run the following command to install esptool and all its dependencies.

sudo pip install esptool

Connect the NodeMCU device to the computer using a USB cable. The blue light on the NodeMCU will flash briefly upon connection. Then, run the following command to flash the firmware that you just downloaded (the *.bin file) to the NodeMCU.

esptool.py --port=/dev/cu.SLAB_USBtoUART write_flash -fm=dio -fs=32m 0x00000 nodemcu-master-10-modules-2017-01-28-02-40-34-float.bin

On a Mac, the port is /dev/cu.SLAB_USEtoUART as described above; on Windows, the port might be COM8; on Linux, the port might be /dev/ttyUSB0.

1d Run some Lua code

Connect to your NodeMCU, and run some Lua code. Fortunately, when you installed esptool, the system also installed miniterm as a dependency. So, go ahead and run the following command.

miniterm.py /dev/cu.SLAB_USBtoUART

Now, press the RESET button on the NodeMCU board, and then press the RETURN key on your computer keyboard a few times. You will first see some random characters, and then finally you'll see an interactive command prompt.

--- Miniterm on /dev/cu.SLAB_USBtoUART 9600,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
␒�␁@����␆�G��p��������␟␅]␝bvFD����������
>
>

On the command prompt, you can now run Lua scripts. Try this command:

print ("Hello World")

Now, you can experiment with it. A good place to start is simple code snippets from the "Examples" section of the NodeMCU website.

As an alternative to miniterm, you can use the ESPlorer GUI tool. However, you'll need to have Java installed on your computer.

1e Update the init.lua script

Whenever the NodeMCU board powers up or resets, it executes the init.lua script. This script is the starting point of your application. Below is an example init.lua script, which flashes the on-board red LED light every second.

-- D0 is the LED on the NodeMCU board
lpin = 0
-- timer to run every 1000ms
tmr.alarm(1, 1000, tmr.ALARM_AUTO, function()
-- Turn on the LED
gpio.write(lpin, gpio.LOW)
-- Keep it on for 100ms
tmr.delay(100000)
-- Turn off the LED
gpio.write(lpin, gpio.HIGH)
end)

Use the luatool program to install the init.lua script onto the device. You can download luatool from this GitHub repo. Then, run the following command from the same folder as the init.lua file.

python luatool.py --port /dev/cu.SLAB_USBtoUART --src init.lua --dest init.lua --verbose

From my experience, you will need to run miniterm first and see the Lua command line prompt. Then, use CTRL-] to exit miniterm, and then run luatool.py. The reason is that luatool is less tolerant to noise in the serial port. So, we should run miniterm first to clear up the channel.

2 NodeMCU programming basics

Thus far, you have seen how to load and run Lua applications on NodeMCU. In this section, let's review some basic techniques for running NodeMCU apps.

2a Getting on wifi

A key feature of the NodeMCU is its out-of-the-box wifi capabilities. In the init.lua script, you can connect the NodeMCU device to any wifi network with a few lines of code.

-- setup Wifi

wifi.setmode(wifi.STATION)

wifi.sta.config("SSID","password")

Notice that you will need to know the network name and password in order to join. A common technique is to loop through a list of known network name and password pairs if the device might be placed in several different environments.

2b Connecting to the internet

The NodeMCU SDK contains an HTTP module for making HTTP requests over the internet. When you build your NodeMCU firmware, you will need to select the HTTP options to include this module. The code snippet below shows how to make an HTTP GET request, and execute some code upon completion of this request. In the callback function, the code argument is the HTTP return value (for example, 200 indicates success and 404 indicates that the URL is not accessible), and the data argument is the content in the HTTP response message.

geturl = "http://www.ibm.com/"
http.get(geturl, nil, function(code, data)
-- Turn off the red LED on NodeMCU board
end)

2c Accessing the GPIO pins

The General Purpose Input Output (GPIO) pins are digital pins on the NodeMCU DEVKIT board. Each pin can have only two states: a low voltage state and a high-voltage state, representing 0 and 1 respectively. From the NodeMCU Lua application, you can read the state from each pin, and then set the state.

-- Read the state of GPIO PIN #5. The val value is 0 or 1
gpio.mode(5, gpio.INPUT)
val = gpio.read(5)

-- Set the state of GPIO PIN #5 to be HIGH
gpio.mode(5, gpio.OUTPUT)
gpio.write(5,gpio.HIGH)

2d Reading analog signals

While the GPIO pins are digital pins, some IoT sensors send in data as analog signals. That is, the voltage of the input wire represents the data. For example, the actual voltage level from a temperature sensor might indicate the temperature reading. On the NodeMCU DEVKIT board, the A0 pin can function as an ADC (Analog to Digital Convertor) pin. When an input wire is connected to the A0, its voltage level between 0 to 3.3V will be converted to an integer number between 0 and 1024. The code snippet below shows how to read an analog value from A0 pin.

-- Read the voltage level on A0. The v value is from 0 to 1024

adc.force_init_mode(adc.INIT_ADC)
v = adc.read(0)

The ADC pin can convert voltage from 0 to 3.3V only. If your sensor produces an analog voltage outside of this range (such as from 0 to 5V), you will need to add a resistor between the input wire and the A0 pin. It is easy to add this resistor when you wire the NodeMCU DEVKIT board on to a breadboard.

Conclusion

In this article, I introduced you to the NodeMCU DEVKIT. It is a powerful, easy to use, and yet very low-cost solution for IoT application development. For IoT beginners, I feel the NodeMCU is one of the best options to go from prototyping all the way to production.

In my next article, I use NodeMCU as an example to show you how to develop a complete IoT sensor solution with back-end MQTT services.

Downloadable resources
PDF of this content
Related topic
Here's another developerWorks tutorial that uses a NodeMCU board in its IoT prototype.


.END
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Sun Sep 23, 2018 4:44 am

tlfong01 wrote:
Sat Sep 22, 2018 1:56 pm
Getting to know NodeMCU and its DEVKIT board - Michael Yuan, IBM[/color]
https://www.ibm.com/developerworks/libr ... index.html
... choose the build with float number support
... flash the firmware to the NodeMCU device by the following command:
esptool.py --port=/dev/cu.SLAB_USBtoUART write_flash -fm=dio -fs=32m 0x00000 nodemcu-master-10-modules-2017-01-28-02-40-34-float.bin

Rpi3B+ flashing custom built firmware to NodeMcu

So I have successfully flashed my custom built firmware to the NodeMcy board.

I found that I needed to change the following parameters:

--port = /ttyUSB0

--fs=4MB
Attachments
nodemcu_flashing_2018sep2301.jpg
nodemcu_flashing_2018sep2301.jpg (182.94 KiB) Viewed 515 times
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Sun Sep 23, 2018 7:42 am

tlfong01 wrote:
Sun Sep 23, 2018 4:44 am
tlfong01 wrote:
Sat Sep 22, 2018 1:56 pm
Getting to know NodeMCU and its DEVKIT board - Michael Yuan, IBM[/color]
https://www.ibm.com/developerworks/libr ... index.html
... choose the build with float number support
... flash the firmware to the NodeMCU device by the following command:
esptool.py --port=/dev/cu.SLAB_USBtoUART write_flash -fm=dio -fs=32m 0x00000 nodemcu-master-10-modules-2017-01-28-02-40-34-float.bin
Rpi3B+ flashing custom built firmware to NodeMcu
So I have successfully flashed my custom built firmware to the NodeMcy board.
I found that I needed to change the following parameters:
--port = /ttyUSB0
--fs=4MB

NodeMCU to print 'Hello World'

So I followed IBM Michael Yuan's tutorial to try to print "Hello World". But I struggled for two hours or so but still could not use miniterm.py to talk to NodeMCU.

I could run 'esptool chip_ID' without any problem.
I could use miniterm.py to set /dev/ttyUSB0 baudrate to 115200, 78440, 9600, but still NodeMCU would not respond with any of the above baudrates. See update below.

So I gave up and try my luck with Windows 10 Java based ESPlorer. I could install ESPlorer OK, installed CH340 driver and found serial port COM5 detected.

Then I ran ESPlorer and found things a bit confusing. It appears that microPython is the default, not LUA as I expected. Errata - Actually the default is LUA. It happens that LUA print statement looks the same as Python.

Anyway, tried to print 'Hello World' and found it very user friendly to upload the one line program to run it, got the results in the results window.

I also found that the default baudrate of the NodeMCU is 115200.

Perhaps I should go back to the very newbie unfriendly Rpi linux text terminal and try my luck again. It appears for now ESPlorer can only use microPython, and LUA could only run in Rpi text terminal window.


Errata 2018sep23hkt1559

Actually for ESPlorer, the default language for NodeMCU is LUA. I used the following silly example of function as variable to show that LUA is indeed doing the interpretation.

a = {p = print}
a.p("Hello World")


prints "Hello World".

Update 2018sep14hkt2031

Build firmware from Marcel’s NodeMCU custom build cloud service
https://wiki.wemos.cc/tutorials:get_sta ... in_nodemcu

Flash firmware by esptool-ck

For the Wemos D1 Mini, under Linux, the ESPtool.py may not flash a bootable image unless -fm dio -ff 20m -fs detect is provided

If you miss these parameters, then the command miniterm.py /dev/ttyUSB0 74880 either stops with csum err or scrolls an endless error

One possible command line for a potential custom build, against the /dev/ttyUSB0 device:

port=/dev/ttyUSB0

esptool.py --chip esp8266 --port $port \
write_flash -fm dio -ff 20m -fs detect \
0x0000 nodemcu-master-24-modules-2017-06-09-03-44-29-integer.bin
Attachments
esplorer_2018sep2301.jpg
esplorer_2018sep2301.jpg (187.94 KiB) Viewed 503 times
Last edited by tlfong01 on Mon Sep 24, 2018 12:34 pm, edited 1 time in total.
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Sun Sep 23, 2018 8:44 am

petermeigs wrote:
Wed Sep 19, 2018 12:46 pm
1. Rather than long I2C cable, perhaps it might be feasible to use something like esp8266 Huzzah from Adafruit, https://www.adafruit.com/product/2471.

2. I believe it can connect i2c, it is cheap, low power, and can connect to wifi.

3. By placing this right next to your i2c device, the long cable issues would go away.

4. This would turn a hardware problem into a software problem if you are near enough to your wifi hub. If you are worried about security, it supports ssl encrypted communications.

5. If you load nodemcu, you can program it with javascript-like scripting language. I've had good luck with this even though I had never used this language before. I have used nodejs and it's close to the same flavor.

6. Otherwise, you could program it like an arduino with the c programming language. (Which I have not tried yet). I think there is a python that runs on it, also not used by me

7. I suppose you would have to worry about interference with wifi but the communications protocol should have sorted that out.

Again some quick answers.

1. Ada esp8266 Huzzahis looks OK, though as usual, three times more expensive than I can get from TaoBao or AliPexress. One problem with Huzzahis is that it is using the the old CP210X USB to serial driver. I read that NodeMcu DEVKIT V2 board used CP210X. Now all V3 boards are using the new CF340 driver. I think CF340 should be better, but just a guess.

2, 3, 4. I agree, except one complication - I found I2C not reliable for even one or two meters long wire, so I am experimenting with I2C extender and I2C differential buffers. But I am still experimenting, far from any conclusion. One possibility is that my cheap MCP23017 are all reject items.

5. I once spent a couple of hours reading about javascript. My impression is that it is a simple and easy to learn scripting language, especially for web applications. I never had a chance playing with web applications, so I have not used it. I heard and briefly read about node.js and node.red. I noticed that they are event driven and a flow of "nodes". This reminds me of a couple of years back I learned about MIT App Inventer which also have a graphs of nodes. My conclusion is that they are OK to teach children ideas, but not useful for big projects. Of course node.red nodes should be much more powerful, for both web server client and server side app development.
BTW, I also spent some time learning Windows Visual Studio, C/C++/C# (but not F#), but all for fun and curiosity, no big programs completed.

Update 2018sep13hkt1915

6. I read that the Arduino IDE now has a board manager that can manage the NodeMCU/esp8266 type of boards. Of course users can use the Arduino C/C++ tool chain, and perhaps also microPython. But I had a bad experience with Arduino (too little memory, not well technically supported etc). So I will not go back to Arduino.

I read that there are now many more NodeMCU/esp8266 types of IDE coming out. One such IDE I am interested is a plug in for Gleany. But I still think the ESPlorer which is dedicated to esp8266 should be the most powerful (this IDE seems to be developed by a Russian guy or team,not sure if this means anything.)

7. I don't know what is the possibility of electromagnetic interface to WiFi, but I agree with you that for toy projects like mine, there should be easy solutions.

Now I am planning to play with LUA, then decide later whether to use LUA only, or some boards with LUA, some boards with microPython. So far I only skimmed through the first couple of pages of the LUA ebook. I need to program for at least 100 hours before I can decide what to do next.
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Sun Sep 23, 2018 12:38 pm

tlfong01 wrote:
Sun Sep 23, 2018 8:44 am
I read that the Arduino IDE now has a board manager that can manage the NodeMCU/esp8266 type of boards. Of course users can use the Arduino C/C++ tool chain, and perhaps also microPython. But I had a bad experience with Arduino (too little memory, not well technically supported etc). So I will not go back to Arduino.

Difference in using ESPlorer and Arduino IDE

I read another very important reason that I should not use Arduino IDE for NodeMcu boards.

NodeMCU Development Kit/Board - electronic wings
http://www.electronicwings.com/nodemcu/ ... t-kitboard

Introduction to NodeMCU - Electronic Wings
http://www.electronicwings.com/nodemcu/ ... to-nodemcu

NodeMCU Interfaces (sensors, motor controllers, etc)
http://www.electronicwings.com/nodemcu/interface

Writing Lua script for NodeMCU using ESPlorer IDE.
http://www.electronicwings.com/nodemcu/esplorer-ide

Difference in using ESPlorer and Arduino IDE
http://www.electronicwings.com/nodemcu/ ... to-nodemcu

Well, there is a programming language difference we can say while developing application for NodeMCU using ESPlorer IDE and Arduino IDE.

We need to code in C\C++ programming language if we are using Arduino IDE for developing NodeMCU applications and Lua language if we are using ESPlorer IDE.

Basically, NodeMCU is Lua Interpreter, so it can understand Lua script easily. When we write Lua scripts for NodeMCU and send/upload it to NodeMCU, then they will get executes sequentially. It will not build binary firmware file of code for NodeMCU to write. It will send Lua script as it is to NodeMCU to get execute.

In Arduino IDE when we write and compile code, ESP8266 toolchain in background creates binary firmware file of code we wrote. And when we upload it to NodeMCU then it will flash all NodeMCU firmware with newly generated binary firmware code. In fact, it writes the complete firmware.

That’s the reason why NodeMCU not accept further Lua scripts/code after it is getting flashed by Arduino IDE. After getting flashed by Arduino sketch/code it will be no more Lua interpreter and we got error if we try to upload Lua scripts. To again start with Lua script, we need to flash it with NodeMCU firmware.

Since Arduino IDE compile and upload/writes complete firmware, it takes more time than ESPlorer IDE.
I am an electronics, smart phone, and smart home hobbyist.

petermeigs
Posts: 57
Joined: Thu Mar 23, 2017 1:34 pm
Location: Los Altos, California

Re: GPIO.input voltage levels vs edge detection

Sun Sep 23, 2018 3:05 pm

For using esp8266 I like using esplorer, the java program. I can use it from linux, windows, or Mac. It has a nice set of little tools to test things.

I have had to go out of town for a few weeks as a favorite Auntie passed away and it has been my job to help with her final arrangements so I am away from my notes to give specifics but it looks like you have found all the things I learned from (and much more quickly than I did, by the way). If there are still tips that are relevant when I get home, I'll add them.

I have had good luck from windows using the adafruit ftdi friend https://www.amazon.com/Adafruit-FTDI-Fr ... JQO74J587C
It also provides power to the esp8266 so no need for more cables.

You have already found out about baud rate issues. The nodemcu you get preinstalled is older and a lower baudrate. Once you install the cloud-built nodemcu, the default baudrate is higher. My first bits of code was to just find out what the start baud rate was. I have also found code that will run at startup to initialize the wifi and then provide a telnet connection to the command line. That was very useful. I have been looking for an ftp/sftp that would work for file transfer.

esptool.py works ok but I have had issues with transfers not being 100% correct. Try turning off echo and it should be much better. I'm doing this from memory so perhaps there is some other tool that also needs echo turned off.

If you use a raspberry pi raspian as your interface to the esp8266, I have found this works very nicely. You can build a flat ribbon cable that carries gnd, vcc, rx tx and 1 other signal I forget. It just plugs in to some pins on rpi and others on the esp8266. If you try to use a windows serial port, you will have to deal with rs-232 voltage levels (+10 to -10). rpi rx/tx are just right for exp8266 tx/rx. Of course ftdi friend solves that. FTDI friend is not super cheap though.

With regard to javascript, it is definitely not a toy language. It is very powerful and robust and well worth the effort. nodejs is a very useful and powerful items and versions exist to run on rpi, windows, unix etc. With javascript and nodejs you can have minimal webserver logic that just returns datastructures and the javascipt in the brower can have all the rendering logic for the UI.

With regard to nodemcu, they have an event programming model as well. Basically, you just set up your code as events to do something when an event occurs. I really like this model much better than the Read Eval Print Loop kind of code.

Anyway, I hope these comments are helpful and I'm not telling a bunch of stuff folks already know.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Mon Sep 24, 2018 9:19 am

tlfong01 wrote:
Sun Sep 23, 2018 12:38 pm
Difference in using ESPlorer and Arduino IDE]
Since Arduino IDE compile and upload/writes complete firmware, it takes more time than ESPlorer IDE[/color].

Esp8266 Flash Firmware Download Tool

So I have decided to use ESPlorer and not the ArduinoIDE. I am also thinking of using the Esp8266 Download Tool V3.6.4 instead of the stupid linux text terminal based esptool.py

Yesterday I made a couple of newbie mistakes and found the firmware of one of my 4 NodeMcu boards corrupted. So I tried to use esptool.py to flash again. But the original command no longer worked. I was smart enough to find out the the UART channel has changed from /dev/ttyUSB0 to /dev/tty/USB1. I thought it was easy to solve the problem by changing the esptool command. But then I got the error message like "not allowed to use /dev/ttyUSB1". It was indeed annoying because it might mean I had to waste perhaps one hour to figure out why ttyUSB0 becomes ttyUSB1, and how to set the permission to allow using ttyUSB1.

I did not wish to take the risk of wasting another hour learning linux ttyUSB. I decided to give up going the linux way and try my luck on Windows 10. I googled Expressif's downloader and found it very userfriendly and I downloaded my custom built firmware without any problem.

Appendix - Espressif References

Expressif Downloader
https://www.espressif.com/en/support/do ... ther-tools

Esp8266Ex Datasheet
https://www.espressif.com/sites/default ... eet_en.pdf
Attachments
esp8266_downloader_2018sep2402.jpg
esp8266_downloader_2018sep2402.jpg (178.93 KiB) Viewed 449 times
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Mon Sep 24, 2018 12:11 pm

tlfong01 wrote:
Mon Sep 24, 2018 9:19 am
Appendix - Espressif References
Expressif Downloader
https://www.espressif.com/en/support/do ... ther-tools
Esp8266Ex Datasheet
https://www.espressif.com/sites/default ... eet_en.pdf

ESP8266EX NodeMCU D1 Mini Pro

https://es.aliexpress.com/store/product ... Title=true
https://detail.tmall.com/item.htm?_u=o3 ... 1850829878

I felt jealous that other guys have 16MB flash, and me only 4MB. So in order not to lose face, I am going to order the ¥28 16MB flash EPS8266 board.

WeMosD1 mini Pro Doc
https://wiki.wemos.cc/products:d1:d1_mini_pro

WeMosD1 mini Pro Schematics
https://wiki.wemos.cc/_media/products:d ... v2.0.0.pdf

Jealous Guy - John Lennon and The Plastic Ono Band - 11,947,462 views
https://www.youtube.com/watch?v=wADRRYNHhOA

Update 2018sep25hkt1921

The 16MB flash NodMCU esp8266 board reminds me of my past bad experience with Arduino with so little flash memory (Mega2560 = 256kB, Due = 512kB, Pro/Uno = 32kB, Diecimila/UNO = 16/32kB)

Arduino Uno SRAM Problem - Arduino Foundation
https://www.arduino.cc/en/Tutorial/Memory

Notice that there's not much SRAM available in the

Uno (2kB SRAM, 32kB flash, comparing to ESP8266EX 16MB flash, 50kB SRAM,Rpi3B+ 1GB SRAM).

It's easy to use it all up by having lots of strings in your program. For example, a declaration like:

char message[] = "I support the Cape Wind project.";

puts 33 bytes into SRAM (each character takes a byte, plus the '\0' terminator). This might not seem like a lot, but it doesn't take long to get to 2048, especially if you have a large amount of text to send to a display, or a large lookup table, for example.

If you run out of SRAM, your program may fail in unexpected ways; it will appear to upload successfully, but not run, or run strangely. To check if this is happening, you can try commenting out or shortening the strings or other data structures in your sketch (without changing the code). If it then runs successfully, you're probably running out of SRAM. There are a few things you can do to address this problem:

If your sketch talks to a program running on a (desktop/laptop) computer, you can try shifting data or calculations to the computer, reducing the load on the Arduino.
If you have lookup tables or other large arrays, use the smallest data type necessary to store the values you need; for example, an int takes up two bytes, while a byte uses only one (but can store a smaller range of values).

If you don't need to modify the strings or data while your sketch is running, you can store them in flash (program) memory instead of SRAM; to do this, use the PROGMEM keyword, ...
Attachments
d1_mini_pro_2018sep2401.jpg
d1_mini_pro_2018sep2401.jpg (190.27 KiB) Viewed 441 times
Last edited by tlfong01 on Tue Sep 25, 2018 12:06 pm, edited 2 times in total.
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Tue Sep 25, 2018 4:07 am

tlfong01 wrote:
Sat Sep 22, 2018 7:18 am
Programming in Lua - Roberto Ierusalimschy
http://www.lua.org/pil/contents.html
Now I am reading the Lua book, but only the preface, audience, and other resources. I found reading the preface of this book very useful, as always, and also entertaining.
Other Resources
1. reference manual, shows examples or a rationale for the constructs of the language, at http://www.lua.org.
2. Lua users site at http://lua-users.org, offering a tutorial, a list of third-part packages and documentation, and an archive of the official Lua mailing list.
3. The book's web page for differences between versions: http://www.inf.puc-rio.br/~roberto/book/

Lua Book Reading Notes

So I started reading the LUA book, thinking that a smart guy like me should finish the first few chapters in 30 minutes, then randomly read a few more chapters that interested me, before trying some demo programs. That was my experience teaching myself python a couple of years ago.

But after reading the first two chapters of the book, I was very surprised to find that LUA is a very complicated programming language. It took me two hours to finish the first chapter. The reason is that the chapter is a condensed form of many news things to me, even I am OK in functional programming using python.

So my first impression is that the authors of LUA must be many times smarter than me. I googled to find out who those super computing gurus are.
Attachments
lua_authors_2018sep2501.jpg
lua_authors_2018sep2501.jpg (177.87 KiB) Viewed 417 times
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Wed Sep 26, 2018 9:51 am

tlfong01 wrote:
Tue Sep 25, 2018 4:07 am
tlfong01 wrote:
Sat Sep 22, 2018 7:18 am
Programming in Lua - Roberto Ierusalimschy
http://www.lua.org/pil/contents.html
Lua Book Reading Notes
after reading the first two chapters of the book, I was very surprised to find that LUA is a very complicated programming language. It took me two hours to finish the first chapter. The reason is that the chapter is a condensed form of many news things to me, even I am OK in functional programming using python.

Arduino C++ vs Rpi Python vs Eps8266 Lua - Part One

After reading the first 2 chapters, I moved on to the remaining chapters. But I found there are too many more new things I don't understand or appreciate, and I started getting confused. So I decided to only skimmed all the remaining chapters, to get a vague but big picture of Lua, then perhaps start writing toy programs as a practice or warming up.

But I think it is a good idea now to make a first impression and quick and dirty conclusion of how esp8266 Lua in many ways is nicer than Python and C++ for developing embedded wireless computing, power electronics, IoT, web related, home automation applications projects. This can motivate me to endure the hard work of learning Lua. I do have a bad feeling that unlike Python, the road to Lua would be hell, like a chamber in Shaolin.

The 36th Chamber of Shaolin
https://www.youtube.com/watch?v=65GQtH6pzTY
https://www.imdb.com/title/tt0078243/
https://en.wikipedia.org/wiki/The_36th_ ... of_Shaolin
Attachments
lua_kung_fu_2018sep2601.jpg
lua_kung_fu_2018sep2601.jpg (139.52 KiB) Viewed 384 times
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Wed Sep 26, 2018 2:02 pm

tlfong01 wrote:
Wed Sep 26, 2018 9:51 am
Arduino C++ vs Rpi Python vs NodeMcu Lua - Part One - Introduction

Arduino C++ vs Rpi Python vs NodeMcu Lua - Part Two - Data Structure

When reading about Lua data structure, there are two things that very much surprised me.

1. Lau tables are not data structures, they are the data structure. There are no tuples, lists as in python, all are tables.

2. Lau tables can be indexed by anything: number, string, (or even table?)

I like python more than C++, because python is dynamic typing, meaning that variable types need not be declared before use, but only bound when use. That's the way I like it, because it makes coding more free, flexible, and innovative.

Now I like Lua more than Python, because Lua table can be indexed by anything, not just quoted strings as in python, which I found very messy and code not very readable. Furthermore Lua also has syntactic sugar to make table coding more readable, though a bit newbie error prone.

I have read the Lua book about tables again, particularly 2.5, 14 ~17. Lua's way of using tables is weird, but very powerful, and that's the way I like it.

I will start my first warm up exercise by writing a driver for I2C DS3231 Realtime Clock. I will be over killing or abusing the data structure table object as a way to learn, and that's the way I like it, aha, aha, ...

KC & The Sunshine Band - That's The Way I Like It - 13,720,858 views
https://www.youtube.com/watch?v=OM7zRfHG0no
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Wed Sep 26, 2018 3:16 pm

Now Lolin has a D32 Pro with WiFi + Blue Tooth and SD card! :o

LOLIN D32 Pro V2.0.0 - wifi & bluetooth board based ESP-32 esp32 Rev1 ESP32-WROVER 4MB FLASH PSRAM MicroPython US $8.80 Total US $11.72
https://www.aliexpress.com/store/produc ... 16057.html

Features
WIFI
bluetooth
4MB Flash
4MB PSRAM
Lithium battery interface, 500mA Max charging current
LOLIN I2C port
LOLIN TFT port
TF (Micro SD) Card slot, support SPI mode.
Compatible with Arduino, MicroPython
Default firmware: lastest MicroPython


Appendix - PSRAM

pseudostatic (random-access) memory (PSRAM)
https://www.jedec.org/standards-documen ... mory-psram

(1) A combinational form of a dynamic RAM that incorporates various refresh and control circuits on-chip (e.g., refresh address counter and multiplexer, interval timer, arbiter). These circuits allow the PSRAM operating characteristics to closely resemble those of an SRAM.

(2) A random-access memory whose internal structure is a dynamic memory with refresh control signals generated internally, in the standby mode, so that it can mimic the function of a static memory.

NOTE In practice, unlike so-called self-refresh DRAMs, PSRAMs have nonmultiplexed address lines and pinouts similar to those of SRAMs.
Attachments
lolin_d32_pro_2018sep21601.jpg
lolin_d32_pro_2018sep21601.jpg (168.67 KiB) Viewed 324 times
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Thu Sep 27, 2018 8:03 am

tlfong01 wrote:
Fri Sep 07, 2018 6:27 am
tlfong01 wrote:
Fri Sep 07, 2018 5:44 am
UPS and 18650 Lithium ion batteries
UPS and Panasonic Sealed Lead Acid (SLA) batteries
In those were my good old Arduino days (2008~2013) I played with lead batteries, but just for fun, and never used in any completed projects (well, almost all my Arduino and Rpi projects never completed! :) )
This lead battery is only 4AH, seems not efficient when comparing to the much smaller sized 16450 which is 3AH.
Appendix - Lead Battery
Panasonic Sealed Lead Acid Batteries Handbook 1998
https://media.digikey.com/pdf/Data%20Sh ... 8,99v2.pdf

UPS on KY019 relay box mobile station

https://www.raspberrypi.org/forums/view ... 0#p1370501
Attachments
ky019x4v1station_2018sep2702.jpg
ky019x4v1station_2018sep2702.jpg (149.61 KiB) Viewed 289 times
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Thu Sep 27, 2018 9:33 am

petermeigs wrote:
Sun Sep 23, 2018 3:05 pm
For using esp8266 I like using esplorer, the java program. I can use it from linux, windows, or Mac. It has a nice set of little tools to test things.
...

ESPlorer for PC Win10 and Rpi linux

Yes, I tried the java ESPlorer in both PC Win10 and Rpi Stretch and found it powerful and user friendly. Comparing the boring and stupid text mode esptool.py to GUI ESPlorer, it is like a blunt pencil knife and a Swiss army knife, with 8 layers and 30+ functions! :lol: .
Attachments
esplorer_2018sep2801.jpg
esplorer_2018sep2801.jpg (168.54 KiB) Viewed 241 times
Last edited by tlfong01 on Fri Sep 28, 2018 12:35 am, edited 1 time in total.
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Thu Sep 27, 2018 12:37 pm

petermeigs wrote:
Sun Sep 23, 2018 3:05 pm
1. ... it looks like you have found all the things I learned from (and much more quickly than I did, by the way). If there are still tips that are relevant when I get home, I'll add them.

2. ... You have already found out about baud rate issues. The nodemcu you get preinstalled is older and a lower baudrate. Once you install the cloud-built nodemcu, the default baudrate is higher. My first bits of code was to just find out what the start baud rate was. I have also found code that will run at startup to initialize the wifi and then provide a telnet connection to the command line. That was very useful. I have been looking for an ftp/sftp that would work for file transfer.

Baud rate and other things

1. Well, I did find things confusing in the beginning.

This reminds my experience when I started playing Arduino some 10 years ago, and the version I bought was Decimilla, with a FTDI thing built in. At that time I knew nothing about FTDI and what it meant to convert USB to TTL. I only found it very user friendly using an ordinary cable to connect PC to arduino, and everything can be done in Windows Arduino IDE.

I only later learnt that the versions before Decimilla did not have any FTDI and users (I guess) only communicated using PC COM port (UART). And not too many years later, Arduino no longer used FTDI chip and instead used their own Amtel chip to do the FTDI job.

So I am not so confused seeing nowadays Adafruit Huzzah (a bit old, I guess) needs to use a FTDI Friend cable, and most NodeMcu boards use plain USB cable because the USB to TTL is built into the board (I guess, using CH340, CP2102 chips).

2. I read that NodeMcu boards uses 9600, 115200, and even 74800 baud. It is a bit confusing. Every time I just use ESPlorer to open the connection by trial and error to find the correct baud rate. For now I found 115200 should work almost all the time, AFTER you flashed the firmware, but I am only 90% sure, ...

I read Wemos D1 Mini instructions and found that one possible reason that the miniterm does not work is because I did not set the correct parameter when flashing.

One other thing I learnt is that it is a good idea to slow down the flashing speed.

Just thinking aloud, sorry for the typo errors.

Appendix Wemos tutorial on flashing firmware

Wemos D1 Mini/MiniPro Get started in NodeMCU
https://wiki.wemos.cc/tutorials:get_sta ... in_nodemcu

...

Flash firmware by esptool

For the Wemos D1 Mini, under Linux, the ESPtool.py may not flash a bootable image unless -fm dio -ff 20m -fs detect is provided.

If you miss these parameters, then the command miniterm.py /dev/ttyUSB0 74880 either stops with csum err or scrolls an endless error


Tutorial - Returning a Wemos D1 Mini to Factory Firmware (AT)
https://wiki.wemos.cc/tutorials:get_sta ... t_firmware

If you decide the revert your Wemos D1 Mini to the factory default firmware, you will discover that it is more complicated than necessary.

... just slow down the flash process and it goes in more reliably.

It may be possible to make these both go a little faster, but most of us don't flash firmware six and seven times an hour. We don't mind waiting another 10 seconds to load a flash image.
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Thu Sep 27, 2018 1:51 pm

tlfong01 wrote:
Thu Sep 27, 2018 12:37 pm
Baud rate and other things

NodeMcu DEVKIT board pinout
Attachments
d1mini_pinout_2018sep2702.jpg
d1mini_pinout_2018sep2702.jpg (146.69 KiB) Viewed 256 times
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Fri Sep 28, 2018 2:59 am

petermeigs wrote:
Sun Sep 23, 2018 3:05 pm
1. it looks like you have found all the things I learned from (and much more quickly than I did, by the way).

2. I have had good luck from windows using the adafruit ftdi friend ... If you use a raspberry pi raspian as your interface to the esp8266, I have found this works very nicely. You can build a flat ribbon cable that carries gnd, vcc, rx tx and 1 other signal I forget. It just plugs in to some pins on rpi and others on the esp8266. If you try to use a windows serial port, you will have to deal with rs-232 voltage levels (+10 to -10). rpi rx/tx are just right for exp8266 tx/rx. Of course ftdi friend solves that. FTDI friend is not super cheap though.

FTDI cable confusion etc

I did learn a lot about ESP8266 from Goolge, but found things a bit confusing at the very beginning, much like what I experienced when started playing with Rpi 5V relay modules some months ago.

Now I know that because there are many models, from ESP8266 01 to 14 (I am using version 12), therefore many of the user guides for old models do not work for new models.

Recently I read about RoboIndia and their tutorials clarified much of my confused mind.

Appendix - RoboIndia ESP8266 Tutorials

RoboIndia
https://roboindia.com/

FTDI FT232 Installation Guide Step by Step FTDI's FT232 installation guide
https://roboindia.com/tutorials/FTDIs-f ... tion-guide

Introduction-ESP8266 ESP-12E/F module
https://roboindia.com/tutorials/tutoria ... ial_id=173

Introduction-ESP-01(ESP8266) module (Old Model)
https://roboindia.com/tutorials/tutoria ... al_id=167

RobotIndia ESP8266 ESP-01 (old model) Breakout Board (INR75 ~= USD1)
https://roboindia.com/store/esp8266-esp ... kout-board

How to Set Up ESP-01 (ESP8266) in programming mode (For ESP01 only)

Connect the FTDI to your PC through a USB port. The red led of the ESP module will switch on.

The button on the side of the breadboard is reset button, while the other button is the is GPIO0.
1) Press the reset button and keep it pressed
2) Press the GPIO0 button and keep it pressed.
3) Release the reset button
4) Release the GPIO0 button
If a blue light will switch on momentarily on the ESP module, then your ESP is in programming mode.


Update 2018sep28hkt1526

It appears that new models only need two signals Rx, Tx. I guess the older models might need one more signal, either one of the following: RTS, CTS (Request To Send, Clear To Send).

Update2018sep29hkt0811

RoboIndia is also selling the most up to date ESP32 Board.

RoboIndia ESP32 Wifi Bluetooth Development Board INR885 (~=USD12)
https://roboindia.com/store/internet-of ... tooth-wifi
Attachments
roboindia_esp8266_2018sep2802.jpg
roboindia_esp8266_2018sep2802.jpg (179.52 KiB) Viewed 237 times
Last edited by tlfong01 on Sat Sep 29, 2018 12:15 am, edited 1 time in total.
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Fri Sep 28, 2018 9:29 am

tlfong01 wrote:
Fri Sep 28, 2018 2:59 am
petermeigs wrote:
Sun Sep 23, 2018 3:05 pm
it looks like you have found all the things, ...

Only Scratching NodeMcu's Surface

Well, I guess I have found only about 5% of the things I need to find. And one problem is that I am not a regular linux user, so I always forgot the syntax of commands. For example, which directory is the ESPlorer program in and what exactly is command and the wierd parameters to use. I always forget the command syntax and waste time testing by trial and errors.

[email protected]:~/lua_programs/ESPlorer/ $sudo java -jar ESPlorer.jar
Attachments
lua_test_2018sep2803.jpg
lua_test_2018sep2803.jpg (159.89 KiB) Viewed 214 times
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Fri Sep 28, 2018 2:07 pm

tlfong01 wrote:
Fri Sep 28, 2018 9:29 am
Only Scratching NodeMcu's Surface
Well, I guess I have found only about 5% of the things I need to find.

Big Dan the Blogging Man on ESP8266

I have found Big Dan's blog interesting.
https://bigdanzblog.wordpress.com/test/#esp8266

I read his post on installing a new version of LUA. So I tried the same. I could install LUA 5.3 OK. But the terminal command lua still starts with LUA5.1.5. I googled and found that I need to change the path thing. But I know too little linux to do that. I tried to uninstall all LUA versions by hand but then I could no longer start any LUA! So I have to discard the no LUA SD card and replaced it by a backup. The lesson I learnt is that newbies should not be over ambitious to try too many new things.

Appendix - How to install LUA

*** Method 1 - Using curl

1. Build lua-5.3.5

curl -R -O http://www.lua.org/ftp/lua-5.3.5.tar.gz
tar zxf lua-5.3.5.tar.gz
cd lua-5.3.5
make linux test

Results - Fatal error - no readline.h

2. Install readline development libraries

sudo apt-get install libreadline-dev

3. make linux test

Results - make OK.

*** Method 2 - Using apt-get

sudo apt-get update
sudo apt-get install lua5.3

Results - Install OK.


Problem

The command lua still starts with version 5.1.5. I need to find out how to change the path thing, or use the LUA environmment variable to set to 5.3. This is too advanced for me now. I need to study the manual perhaps 20 more hours.

Update 2018sep29hkt1253

Big Dan's Profile - bigdanzblog
https://bigdanzblog.wordpress.com/about/

... I’ve created this blog to share some of my various projects in some detail so that I don’t bore Facebook friends with all of the details of what I’m building.

Google It!

I don’t get a ton of questions so I try to answer those I do. Some times I’m surprised at the questions that I’m asked because I find the answer immediately upon googling it (yeah, I rarely know the answer to questions I’m asked either).

Coming from the pre-internet days, Google is such an amazing tool, I cannot imagine life without it. And it seems very odd to think of never knowing life before it. It used to be when you had a problem, you read the manuals, the couple of books you might have, and ask coworkers. More often than not you had to work the solution out yourself and it would take entirely too much time.

Take advantage of this amazing tool! I very rarely post questions on any forum. Not because I don’t have a ton of them, because I do. But almost every question I can think of, someone has answered on Google, you just have to track it down, and typically that is way faster than waiting for a forum answer.

Alex P's Profile - StackOverflow
https://stackoverflow.com/users/1778421/alex-p

People asking questions need to understand that different people answering those questions might have different motives for doing it.

I come to StackExchange looking for questions I do not yet know the answers to but find interesting enough to do some research of my own. I do not mind sharing my findings with the community. But I do not feel obligated to make sure that any specific person completely understands the information I provide.

In fewer words - I enjoy solving puzzles, not explaining solutions to 3rd-graders.


Seamus' Profile - StackExchange Raspberry Pi Forum
https://raspberrypi.stackexchange.com/u ... 790/seamus

The trouble with the world is that the stupid are cocksure, and the intelligent are full of doubt. ~ Bertrand Russell

Blind Men and An Elephant - Jensen Liu, ChinaBlog
https://chinablog.cc/blind-men-and-an-elephant/
https://chinablog.cc/about/

... What I am trying to say is that being a blind man is not always an embarrassing losing position. Sometimes it is the no choice reality, such as in many science research situations. The subject is totally a black box. We are technically blind. We cannot see a big picture.

What we can do is only to tackle it part by part with small size experiments. We record the feedback readout from the black box one experiment after another. And eventually one day, we ... will realize, wow, the elephant actually looks like THAT!


"When eating an elephant take one bite at a time." - Creighton Abrams
(When you doing something that is difficult, do it slowly and be careful. )
Creighton Abrams (1914 – 1974) was a United States Army general who commanded military in the Vietnam War. He served as Chief of Staff of the United States Army from 1972 until shortly before his death in 1974.
Attachments
elephant_blind_men_2018sep2901.jpg
elephant_blind_men_2018sep2901.jpg (127.53 KiB) Viewed 175 times
Last edited by tlfong01 on Sat Sep 29, 2018 7:53 am, edited 7 times in total.
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 563
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: GPIO.input voltage levels vs edge detection

Sat Sep 29, 2018 3:44 am

tlfong01 wrote:
Fri Sep 28, 2018 2:07 pm
Big Dan the Blogging Man on ESP8266
I have found Big Dan's blog interesting.
https://bigdanzblog.wordpress.com/test/#esp8266
This is too advanced for me now. I need to study the manual perhaps 20 more hours.[/i][/color]

RoboIndia ESP8266 ESPlorer Tutorials

I found roboindia's LUA newbie tutorials good.

Appendix - RoboIndia Tutorials

Starting with LUA on ESP8266 Wifi module
https://roboindia.com/tutorials/startin ... ifi-module

LED Blinking using ESP8266 by LUA
https://roboindia.com/tutorials/esp8266 ... inking-lua

Home Automation using ESP8266 on LUA
https://roboindia.com/tutorials/esp8266 ... mation-lua

Robo India presents tutorial on how make HTTP server of ESP8266 wifi module in both station and access point mode. This server is being used to automatic control of LEDs. This tutorial can be implemented to automate home or industry.

RoboIndia Search ESP8266
https://roboindia.com/tutorials/search&q=ESP8266

Automatic water dispenser kit
https://roboindia.com/store/solenoid-valve

Blynk Board for Blynk App and IOT - Internet of Things
https://roboindia.com/store/blynk-board
I am an electronics, smart phone, and smart home hobbyist.

Return to “Python”

Who is online

Users browsing this forum: rpiMike and 16 guests