Posts mit dem Label esp8266 werden angezeigt. Alle Posts anzeigen
Posts mit dem Label esp8266 werden angezeigt. Alle Posts anzeigen

2019-07-14

Update: ESP8266 based SensorNode V2

I updated the circuit and pcb design of my Esp based SensorNode.
Further details in the github repository.

ESP Programmer

I put together an adapter board to attach a CP2104 board to ESP8266 and provide auto programming mode.


For further details see the github repository.

2019-04-29

ESP8266 based SensorNode

In last weeks I put together a Sensor-Node based on ESP8266. The software part provides:
  • the standard WiFiMonitor to setup the WiFi credentials
  • a web page to configure the connected sensors
  • a web service to read the configuration and current sensor values
  • the data are published via MQTT in a format to be feed into a influxdb
The following sensors are supported:
  • DS18B20 (multiple)
  • BME280
  • Si7021

SensorNode config page
SensorNode configuration page

I designed a board to be put into a USB port with a temperature and a humidity sensor. 
SensorNode circuit
SensorNodeUSB circuit

SensorNode pcb bottom side
SensorNodeUSB PCB bottom side

SensorNode pcb top side
SensorNodeUSB PCB top side
More information can be found in the GitHub repo SensorNode.




2018-03-25

ESP8266 - Convert from human readable date/time to epoch timestamp in Lua

For my current ESP8266 NodeMCU project I need a Lua function to convert the date/time returned by the DS3231 to epoch timestamp.

Update: I also wrote a function to verify the validity of the input parameter (see this github gist)

2017-01-07

Wifi Scanner with ESP8266 + TFT ST7735B (NodeMCU)

After successful connect the ESP8266 with the ST7735 display I want to do more than the demo - so here comes a Wifi Scanner.

Same hardware setup as in the previous blog post.



And here is the source code:

2017-01-02

ESP8266 (NodeMCU) + 1.8 Inch TFT LCD Display Modul 128X160 SPI Serial ST7735B

Some notes how to connect a "1.8 Inch TFT LCD Display Modul 128X160 SPI Serial ST7735B IC SD Card für Arduino" to a ESP8266 running with NodeMCU.




You need a NodeMCU firmware with (at least) the modules bit and UCG (with st7735 display option).

NodeMCU custom build  options.

NodeMCU custom build
options.
[Update] Also SPI must be selected! (Thanks to Lorenz)


Pinout/Connection

The display has a 8-pin and 16-pin interface. The TFT interface in both are the same. You can choose either of the two interfaces for wiring.

     ESP8266 --             DISP             -- ESP8266
     OPTION 1                                   OPTION 2
                 --------------------------
                |      ST7735B 1.8 TFT     |
                |                          |
         GND -- | GND  (1)                 |
         3V3 -- | VCC  (2)                 |
                | NC   (3)                 |
         3V3 -- | BL   (4)         (1) RST | -- GPIO16 (D0)
                | NC   (5)         (2) CS  | -- GPIO15* (D8) 
GPIO16  (D0) -- | RST  (6) TFT     (3) D/C | -- GPIO02 (D4)
GPIO02  (D4) -- | RS   (7) TFT     (4) DIN | -- GPIO13 (D7)
GPIO13  (D7) -- | SDA  (8) TFT     (5) CLK | -- GPIO14 (D5)
GPIO14  (D5) -- | SCK  (9) TFT     (6) VCC | -- 3V3
GPIO15* (D8) -- | CS   (10)TFT     (7) BL  | -- 3V3
                | CLK  (11)SD      (8) GND | -- GND
                | MISO (12)SD              |
                | MOSI (13)SD              |
                | CS   (14)SD              |
                | NC   (16)                |
                | NC   (15)                |
                 --------------------------

*) pull-down 10k to GND

ESP8266 NodeMCU dev board connected to 16pin interface of TFT
ESP8266 NodeMCU dev board connected to 8pin interface of TFT

Test

I use the GraphicsTest.lua to test the connection. GraphicsTest is part of the NodeMCU examples (you have to upload also all GT_*.lua files to run the test).


2016-12-29

Flash ESP8266-12/12E

Steps to flash new firmware:
  1. (optional) Backup flash
    esptool.py --port port-of-esp8266 --baud 115200 read_flash 0x000 4194304 fw_backup.bin
  2. Erase flash
    esptool.py --port port-of-esp8266 --baud 115200 erase_flash
  3. Write esp init data (see SDK Init Data)
    esptool.py --port port-of-esp8266 --baud 115200 write_flash 0x3fc000 esp_init_data_default.bin
  4. Write firmware
    esptool.py --port port-of-esp8266 --baud 115200 write_flash 0x0000 fw.bin

2016-04-10

ESP-01 + DHT22: Send data to influxdb

My first ESP-01 "system" is running now. It measures temperature and humidity using a DHT22 every 20 seconds and send the data to an influxdb database.


The influxdb is then used by a Grafana instance where I define a panel for the temperature and humidity. Here are the first measurements:


Looks like there where a glitch at about 12:30 - I will have a look how often this happen.
And here is the corresponding ESP code:

2016-04-07

First Steps with ESP-01 on OS X El Capitan - Part 2

In part 1 I described how I setup my my environment. In this part I will show my first lua programming steps with the ESP8266 using the Lua based NodeMCU firmware.

First I create an init script (init.lua). This will be loaded by the firmware after each boot/restart.
As last step in the boot/restart process the firmware loads and executes the script init.lua (you can see a corresponding error message in the last screenshot in part 1).
It is recommended to provide an opportunity to interrupt the execution of init.lua to be able to change anything. Otherwise it may happen e.g. if your code contains a fatal error which cause a reboot that you are unable to deactivate/fix the code - and finally have to reflash the firmware to be break the loop.

I'm looking around an found a post about Methods of Interrupting init.lua during boot. My init.lua code based mainly on the ideas described there. But here it is:
  1. it calls firmwareInfo() to output information about the firmware. For the moment it just inform if it is a FLOAT or INTEGER version
  2. after a delay of BootTimeout ms (to give the NodeMCU some time to initialize it self) init() is called
  3. in init() the serial port is initialized and configured to watch for a transmitted ENTER key
  4. if an ENTER is received the function abort() is called, which set the abortFlag to true.
  5. After AbortTimeoutms startup() is called. There the abortFlag is checked and the startup is canceled or executed by trying to load and execute 'user.lua'
The output of such a run without interrupt is shown below:


Next step was to wrote a script to read out a DHT22 sensor. The user_dht22.lua script shown below reads temperature and humidity every 2 sec and prints both values. Depending on the used firmware the output is generated using different format and in case of integer also further values.

Output running the script

2016-03-29

First Steps with ESP-01 on OS X El Capitan

Environment: MacBook Pro Mid 2010, OS X El Capitan 10.11.4
ESP-01 Module + Simple DIY Dev Board (based on this)

  1. Install esptool to backup/change/update ESP8266 firmware
    1. Clone git repository https://github.com/themadinventor/esptool
      $ git clone https://github.com/themadinventor/esptool.git
      Cloning into 'esptool'...
      ...
      
    2. cd esptool
    3. run install routine
      $ sudo python setup.py install
      Password:
      running install
      ...
      Installing esptool.py script to /usr/local/bin
      
  2. Connect ESP8266 ESP-01 Board via CH340G Converter to MBP
    1. Install CH340G driver (WCH provides a signed driver)
    2. Identify the tty port
      $ ls /dev/tty.w*
      /dev/tty.wchusbserial410
    3. activate ESP boot loader (needs to be repeat before each esptool command) by reset ESP and pull GPIO 0 to GND meanwhile.
    4. Check communication
      $ esptool.py --port /dev/tty.wchusbserial410 --baud 115200 flash_id
      Connecting...
      Manufacturer: c8
      Device: 4013
      
      $ esptool.py --port /dev/tty.wchusbserial410 --baud 115200 chip_id
      Connecting...
      Chip ID: 0x009b82bc
      
      
  3. (optional) make a backup of the original firmware - takes about 48sec
    $ time esptool.py --port /dev/tty.wchusbserial410 --baud 115200 
    read_flash 0x000 524288 fw_backup.bin
    Connecting...
    Please wait...
    
    real 0m47.721s
    user 0m0.762s
    sys 0m0.344s
    
    (Note: ESP12-E has a bigger flash - 4MB = 4194304)
  4. Flash alternative firmware - I want to give NodeMCU firmware a try
    1. Use standard NodeMCU firmware (download from github) or
    2. Config your own customized NodeMCU firmware 
    3. Get the download links (integer and float version) about 2min later (you can also use the preconfigured
    4. Flash it to the ESP-01 (I start with the integer version)
      $ time esptool.py --port /dev/tty.wchusbserial410 --baud 115200 
      write_flash 0x00000 nodemcu-master-9-modules-2016-03-29-19-22-38-integer.bin
      Connecting...
      Erasing flash...
      Took 1.22s to erase flash block
      Wrote 403456 bytes at 0x00000000 in 48.2 seconds (66.9 kbit/s)...
      
      Leaving...
      
      real 0m50.195s
      user 0m0.383s
      sys 0m0.126s
      
  5. Connect to ESP. I use SerialTools (AppStore Link) - Note: Baud Rate is 76800