Saturday 27 April 2019

First impressions LoLin NodeMCU V3

The LoLin NodeMCU v3 is a breadboard compatible development board combining the popular ESP8266 Wifi module with an USB connector for power and serial programming.


LoLin NodeMCU v3

LoLon NodeMCUv3 pinout

 

Connecting to the serial port

Connect the LoLin NodeMCU to a PC via the USB serial port and use serial console software at 115200 baud to connect e.g. PuTTY or the Arduino IDE serial monitor.

Press reset and the LoLin NodeMCU v3 will display some garbage (this is a boot message which uses a different baud rate during boot) followed by 'Ready' once booted, depending on the firmware installed. 

Firmware

There are several different 'standard' firmwares available for ESP2866 based devices which can be confusing.

Two of which are the AI-thinker firmware which supports AT commands and the NodeMCU firmware which includes a LUA interpreter.     

Out of the box my NodeMCU device did not respond to any AT commands but did provide an wi-fi Access Point and DHCP service for connecting wireless devices but offered no open ports. Possibly it is running the NodeMCU firmware?

Serial port output on first boot


Flashing with ai-thinker-0.9.5.2-115200.bin firmware

ESP38266 devices can be flashed with a different firmware. To flash with the ai-thinker firmware


1) Download the NodeMCU Flasher Master software
2) Download the ai-thinker firmware
3) Start nodemcu-flasher-master > Win64 > Release > ESP8266Flasher software
4) Select the firmware to flash. Config > first wheel > select ai-thinker firmware
5) Flash the ESP8266. Operation > Flash
6) Once complete. Reset the LoLin

Running the ai-thinker firmware the ESP8266 now responds to AT commands on the serial port. 

Serial port output after flashiing with AI-thinker firmware

 

The following website is a good source of supported AT commands.

A port scan of the newly flashed firmware revealed no open ports. Running the commands AT+CIPMUX=1 and  AT+CIPSERVER=1,80 configures a web server and the serial output will show debug details of received requests. The web server is not very useful as it servers no web-pages and you can't configure the device via it.

Using the Arduino IDE

The best way to use the device is to program it with your own programs (sketches) using the Arduino IDE and ESP8266 board managers.


If you receive the following error message when flashing the board ensure NodeMCU 0.9 (ESP-12 Module) is selected in Tools > Board.  The Arduino IDE uses the selected board type to perform a board specific reset procuedure when flashing.

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed



Monday 22 April 2019

Prototype IoT Plant Monitor

The prototype IoT Plant Monitor measures temperature, humidity and soil moisture levels and transmits the data to the Blynk IoT cloud.

A mobile phone app can then be used to monitor the data and view both historical and real-time updates.

The prototype is built using 


Prototype IoT Plant Monitor




Prototype IoT Plant Monitor iOS app

GitHub:

https://github.com/pdj102/PlantMonitor

AM2302 Humidity and Temperature Sensor Module

The AM2302 (DHT22) is a calibrated relative humidity and temperature sensor module with a single data line for data exchange.  It has a small micro controller which uses a proprietary protocol.

AM2302 sensor module


Pin Out:
1. VDD 3.3V to 6V
2. DATA
3. N/C (not connected)
4. GND

Measurement:
  • Humidity: 0 to 100% 
  • Temperature: -40 to 125 degrees Celsius

Accuracy:
  • humidity+-2%RH(Max+-5%RH)
  • temperature+-0.2Celsius

In applications, an external pull-up resistor, about 10 - 5kΩ, is often required. Sometimes this resistor is already integrated in the module, sometimes its necessary to add it.


Arduino IDE

Numereous Arduiono IDE libraries exist for the DHTxx family of modules.  For ESP8266 try https://github.com/beegee-tokyo/DHTesp which disables task switching during reads to ensure timings are not affected.






Soil Moisture Sensor - MH-Sensor Series, Flying-Fish


The Soil Moisture Sensor from MH-Sensor Series, Flying-Fish, provides both a Digital (High or Low) and an Analogue output.

The module has four pins
  •     VCC: For power (2V to 36V)
  •     A0: Analog output
  •     D0: Digital output
  •     GND: Ground
The module also contains a potentiometer which will set the threshold value and then this threshold value will be compared by the LM393 comparator. The output LED will light up and down according to this threshold value.

Soil Humidity Sensor (MH-Sensor Series Flying-Fish)
 Connected to a 5V supply the analogue output measured as follows
  • In air - 5V
  • Wet soil - 2V
  • Water - 1.9V


Saturday 20 April 2019

Programming ESP8266 Arduino Shield using Arduino IDE


The ESP8266 Arduino Shield can be programmed using the Arduino IDE.

Install the ESP8266 board Managers

Go "To File > Preferences", and set Additional Boards Manager URLs: to include http://arduino.esp8266.com/stable/package_esp8266com_index.json 

NB multiple board manager URLs can be seperated with a comma

Go to "Tools -> Board -> Boards Manager", type "ESP8266" and install it.

Go to "Tools -> Board" and select "Generic ESP8266 Module".

Connect ESP8266 to PC 

Connect ESP8266 Shield debug port to PC via USB to TTL Serial board.
  • RX to TX
  • TX to RX
  • GND to GND
  • 3V3 to 3V3

Set DSP8266 to flash mode

Set DIP switches 3 (flash mode) and 4 (DFU) ON

Upload sketch program

Open sketch program and select upload

Set DSP8266 to normal operation and run sketch program

Set DIP switches 3 (flash mode) and 4 (DFU) OFF


Sunday 14 April 2019

Connecting to an Arduino ESP8266 Shiald v1.0



The Arduino ESP8266 Shiald v1.0 is an Arduino UNO format shield for an ESP8266 WiFi module.

The ESP8266 WiFi module is a self contained SOC from Espressif Systems with TCP/IP stack and WiFi capability enabling any microcontroller to access a WiFi network. Out of the box the ESP8266 Shiald module is capable of operating independently without an Arduino Uno being attached

There are many different Arduino ESP8266 Shialds out there that look almost identical but come with different default software installed and variances in circuitry.


This article is about two such Shialds and describes initial findings when connecting to the board debug port from a PC and the default Access Point.

The vendor of the first Shiald is AI-THINKER and the second DOIT.AM. The names are marked on the ESP8266 module case.
AI-THINKER and DOIT.AM ESP8266 shialds

Shiald DIP settings

The Shiald has 4 DIP switches as follows (when ON):
  1.  Connect ESP8266 TX to pin D0
  2.  Connect ESP8266 RX to pin D1
  3.  Enable ESP8266 bootloader mode
  4.  Enable DFU led (purpose?)
To run the programmed software ensure DIP 3 is OFF.  To flash new software to the ESP8266 ensure DIP 3 is ON.

NB the debug TX and RX pins are permenantly connected to the ESP8266 TX and RX.

Connecting Shiald to PC via USB to TTL serial adapter

To connect to the Shiald debug port from a PC use a USB to TTL serial adapter.

USB to TTL serial adapter

Ensure voltages are matched e.g both USB to TTL serial adapter set to 5V

Connect as follows:

  • Shiald Debug RXD <-> TX

  • Shiald Debug TXD <-> RX

  • Shiald Debug GND <-> GND

  • Shiald Debug 5 V <-> VCC

PuTTY connection to Shiald Debug port

To interact with the Shiald Debug port from your PC use software like PuTTY.

Use the following serial settings
  • COM port to the USB to TTL serial adapter COM port
  • baud 115200

Shiald AI-Thinker


Connecting to Shiald Board debug

Pressing reset on Shiald results in the following output

Debug output from THINKER-AI Shiald

In this case the Shiald is running SDK version 0.9.2. It is using the network 192.168.4.0/24 for the wLAN, the server itself is using the IP address 192.168.4.1 and providing a DHCP service for wLAN client devices.

Many web pages state the AI-THINKER software is capable of processing AT commands. For example, sending the command 'AT' the shiald will respond with an 'OK' message.

The AT commands must end with "\r\n".  By default, PuTTY sends CR (\r) when the Enter Key is pressed therefore press Ctrl+M to send CR (\r) and Ctrl+J to send LF (\n).

Unfortunately, I was unable to get my AI-THINKER shiald to response to any AT commands. I checked the wiring and confirmed the commands were being sent but the board was unresponsive.

Connecting to AI-Thinker Shiald  Access Point wLAN

By default the board acted as an Access Point with SSID AI-THINKER and default password ai-thinker. In the debug window you see output indicating when a client wLAN deviceconnects. 

iPhone connected to Shiald wLAN

The AI-Thinker shiald web server

The AI-Thinker Shiald runs a web browser on port 80  (this is the only open port on the shiald)

To test wifi connection from your wifi device go to  http://192.168.4.1/client?command=0

Web page http://192.168.4.1/client?command=0

I could not find any other web pages supported by the web server.

DOIT.AM Shield

There are some boards out there with the wrong components installed preventing the D0 and D1 pins operating correctly as transistors marked J3Y have been installed instead of the required J1Y 3.3V/5V logic convertors.

The DOIT.AM I have is an example of a board with this problem. Testing with a multimeter for continuity between the TX / RX pins and D0 and D1 pins confirmed there was no connection. For testing purposes I used the debug TX / RX pins.

Connecting to DOIT.AM Shiald Board debug 

Connecting to the debug board and pressing reset on Shiald results in the following output. The default software on this board responds to AT commands. 

Debug output from DOIT.AM Shiald

Connecting to DOIT.AM Shiald  wLAN

The SSID is ESP_2834A6.No password required. 

The DOIT.AM Shiald web server

The DOIT.AM Shiald has no open ports which is a problem that needs further investigation (to be continued).