Elektroda.com
Elektroda.com
X

D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak

TechEkspert 30618 43
This content has been translated flag-pl » flag-en View the original version here.
  • D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
    Module D1 mini compatible with Wemos facilitates the use of a WiFi module ESP8266-12E incl. thanks to the built-in USB RS-232 converter and the output of signals to connectors with dimensions compatible with the contact plates. ESP8266-12E module complete with relay board appeared as a gadget available for order on elektroda.pl the module will be ready to work with the Arduino environment. The kit allows you to easily start experimenting with IoT. If you plan to use D1 mini Shields modules it will be convenient to use female strips, if you want to place the D1 mini on the contact plate, male strips may be more convenient (three types available in the set) . During installation, it is worth taking care of the lack of metal elements near the printed antenna. Although the system can be powered from USB with 5V, ESP8266 ports work with 3.3V. The micro USB connector allows you to power the system from a USB port or, for example, from a power bank or USB charger.


    Arduino environment.
    The module has been tested with the latest available version of the 1.8.2 environment www.arduino.cc to facilitate work with https://github.com/esp8266/Arduino run the Arudino environment and choose:
    File-> Preferences-> Additional URLs to the tile manager - paste: http://arduino.esp8266.com/stable/package_esp8266com_index.json
    next:
    Tools-> Tile-> Tile Manager-> and search for "wemos" and then install the package in Wemos D1 mini with ESP8266:
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
    After connecting the D1 mini to the USB port, a new serial port should appear in the system:
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
    After these treatments, we can select the D1 mini board and indicate the active COM port:
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak

    Relay board.
    The relay board requires 5V power supply (relay coil). The attached relay consumes about 60mA. The relay is activated with a low level and the high state of 3.3V of the D1 mini module may be misinterpreted by the relay board (as a low state, in the tested unit, lowering the voltage to 3.5V caused the relay to trip, the relay turned off at about 3.8V). You can redo the board or solve the problem programmatically. With the software solution, to start the relay, set the selected ESP8266 output as the output in the low state, and for switching off the relay as the input in the high pullup state.
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak

    Controlling the relay via a browser - example.
    Based on the examples available in the Arduino environment for D1 mini, you can easily start trials with the launch of the WEB interface, which will allow you to control the relay via a browser, enter the Wi-Fi login parameters (ssid and password) in the code:
    Code: c
    Log in, to see the code


    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak

    The sample code sends information about the operation of the device using the serial console (USB-RS232) so we know, among others MAC address and IP address of the module. In the final solution, it is worth for the module to have a fixed IP address (e.g. DHCP settings or manual module IP configuration).
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
    By extending the code, we can add, for example, a simple basic WEB authorization, to which the login parameters will be saved in the clear text:

    Code: c
    Log in, to see the code


    To communicate with the device, all you need is a web browser running on a network segment that supports a Wi-Fi access point to which the ESP8266 module connects.
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
    Some routers do not allow traffic between Wi-Fi clients then you will not be able to access the logged in ESP8266. Thanks to port forwarding on the router, theoretically, you can enable access from the Internet, but even after improving the code, for security reasons, the cloud model will work better here than direct communication.

    Cloud solutions.
    In such a solution, IoT devices connect to the service provider's server by sending information and downloading instructions, wanting to control our devices, we also connect to the service using a browser or an application installed on a smartphone.

    Blynk.
    To use http://www.blynk.cc in the Arduino environment, choose:
    Sketch-> attach library -> manage libraries we search and install the blynk library.
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
    We install the Blynk application on a smartphone, create a new account and a new project, the application is intuitive and "guides you by the hand" through the next steps. We receive a token on the e-mail provided.

    We use the example ESP8266_Standalone and enter the login details for our Wi-Fi network and the Blynk token:
    Code: c
    Log in, to see the code


    In the new project, we add a button that we assign to the module's D1 output, in Blynk we can easily control more advanced devices (e.g. servos) as well as receive data (e.g. temperature) and set notifications to e-mail twitter or smartphone notifications.
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
    After running the example on the D1 mini board, we will get diagnostic information on the serial console,With the help of an application on a smartphone, we will be able to control the status of the relay from anywhere in the world with access to the Internet.

    In a simplified way, we will solve the problem with the relay board, which when powered with 5V requires low state control and may cause problems when controlling 0 and 3.3V voltages. In series on the connection of the IN signal and the D1 output of the module, we turn on the LED (with the cathode towards the module), the voltage drop should ensure correct operation (the zener diode with a voltage of ~ 3V should also be checked).
    It is best to make a permanent modification on the relay board.
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
    In the video below you can see the variable delay between sending a command and changing the state of the relay.
    [movie: 3fb7278bcb] https://filmy.elektroda.pl/74_1493808196.mp4 [/ movie: 3fb7278bcb]

    Supla.
    You can find a Polish project similar to Blynk here: https://www.supla.org/pl/

    Sending data to thingspeak.
    Thingspeak is one of the exemplary services that allows you to receive data from IoT devices. After creating an account, we read our API Key, create a new channel and read its ID. We add the ThingSpeak library to the Arduino environment.
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
    Below is an example code that allows you to send to the created channel temperature data from a sensor with analog output TMP36 .

    Code: c
    Log in, to see the code


    The sensor is powered from 3.3V (pin 1 of the sensor), pin 3 is connected to GND, and the signal from pin 2 is sent to the analog input of the A0 module. The use of sensors with digital output (eg DS18B20) will allow for easy operation of more sensors by one D1 mini module.
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak

    After a while, we can see the history of transmitted data on thingspeak. The device consumes several milliamperes in the breaks between transmissions:
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak

    Energy saving and built-in clock.
    The power consumption of the D1 mini, depending on the program being performed and the constantly set up WiFi connection, can reach even tens of milliamps: http://bbs.espressif.com/viewtopic.php?t=133
    We can put the ESP module to sleep and use the internal clock to give the module reset signal after a certain time. After the reset, the variables in the program will not be saved, but we can achieve quite large energy savings and adjustable long sleep times (e.g. 24h). To use ESP.deepSleep () deep sleep function, pin D0 must be connected to Reset, otherwise RTC will not be able to reset the module:
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
    Sample code below:
    Code: c
    Log in, to see the code

    It is worth mentioning the possibility of changing the firmware in the ESP, e.g. on the nodemcu or another one: https://github.com/nodemcu/nodemcu-flasher this can be a good solution to expand the existing device with a WiFi module communicating via UART or an opportunity to get acquainted with LUA.

    It is worth getting acquainted with the services that allow the collection, presentation and analysis of data from IoT devices:
    https://www.pubnub.com/
    https://io.adafruit.com/
    http://dweet.io/
    http://freeboard.io/
    https://data.sparkfun.com/
    http://ubidots.com

    ESP8266 can be used to perform much more complicated tasks than turning the relay on and off, we can, for example, run a single-channel LoRaWAN gateway https://www.youtube.com/watch?v=ZV_ZY-0Q1lo or send an image from the camera http: // www. arducam.com/arducam-supports-esp8266-arduino-board-wifi-websocket-camera-demo/

    What is your idea of using ESP8266?
    I will use the module in conjunction with blynk for a very simple solution, remotely resetting a VPN sharing router, which can hang sometimes. The D1 mini module has such an effective antenna that it was able to log into the WiFi network of a friend in the same building, thanks to which the module's connectivity with the Internet will be maintained even if the controlled router stops responding.
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak

    Cool? Ranking DIY
    Do you have a problem with Arduino? Ask question. Visit our forum Arduino.
    About Author
    TechEkspert
    Editor
    Offline 
    TechEkspert wrote 4925 posts with rating 4026, helped 12 times. Been with us since 2014 year.
  • #2
    @GUTEK@
    Level 31  
    Is this an original Wemos module? Because the ones I saw had the manufacturer's logo:
    D1 mini module - ESP8266 WIFI launch, start from IoT, Blynk, Thingspeak
  • #3
    TechEkspert
    Editor
    Good question, but I don't know the answer to it, but looking at the documentation on the wemos website, I can see that it is a fully compatible module with the D1 mini. It would be nice if the people who receive the modules presented the effects they have achieved. Getting started with IoT is surprisingly simple today.
  • #4
    gulson
    System Administrator
    It is a clone that is completely compatible with the Wemos D1 mini. Unfortunately, Wemos withdrew from the D1 mini and focused only on the mini pro. Thanks for paying attention.

    This is an experiment so that in the future there will be more and more interesting modules in the gadgets, so it will be appreciated to share your opinion.
  • #5
    szymon122
    Level 38  
    In my opinion, this is a great idea, it will definitely encourage users to create projects and post them on the forum. I will wait this month and report on the fun with the module myself ;)
    gulson wrote:
    Unfortunately, Wemos withdrew from the D1 mini

    But he created the LoLin32 board ;)

    On alliexpress there is a LoLin32 board (clone) with a built-in OLED display. A great proposition if someone, apart from collecting data from sensors, wants to display / present them immediately.
  • #6
    @GUTEK@
    Level 31  
    gulson wrote:
    This is an experiment so that in the future there will be more and more interesting modules in the gadgets, so it will be appreciated to share your opinion.

    Unfortunately, I lack points to get this module. However, on the ESP-12F itself that I have with AE, I plan to do something like a weather station. The display will be connected (I don't know what yet). The module will connect to the server - placed on the Orange Pi PC and download data. Temperature, pressure, coal condition in the furnace, among others. I want to power it from 18650, so the module will have to go to sleep. What will come of it remains to be seen. Certainly this Wemos is more convenient to program than ESP itself, but we can do it :)

    And as for the interesting things to the gadget shop:

    Raspberry Zero (without WiFi) I can see that it is very cheap now available:
    https://botland.com.pl/moduly-i-zecja-raspberry-pi-zero/5215-raspberry-pi-zero-512mb-ram.html

    Transistor tester - great equipment, makes servicing very easy. Additionally, you can upload modified software that increases the possibilities of:
    https://www.aliexpress.com/item/Digital-ESR-Meter-Mega328-Transistor-Tester-Diode-Triode-Capacitance-MOS-PNP-NPN-LCR-TESTER-METER/32740536071.html

    Headlamp powered by 18650 with built-in charger. A very good solution because you do not need to buy an additional charger to charge this type of batteries. The flashlight additionally has a smooth brightness adjustment and the possibility of proximity switching by the ir sensor. True brightness is around 300 lumens.
    https://www.aliexpress.com/item/1000Lm-3W-LED-1-Mode-Headlight-USB-Rechargeable-Bike-Head-Lamp-Torch-Light-Headlamp-linternas-frontales/32384302670.html

    A cheaper and very nice gadget is also the USB Tester, which displays the voltage and current that is consumed by, for example, a phone while charging.
    https://www.aliexpress.com/item/USB-tester-DC-Digital-voltmeter-amperimetro-current-voltage-meter-amp-volt-ammeter-detector-power-bank-charger/32773261577.html
  • #7
    TechEkspert
    Editor
    The aforementioned indicator of the current drawn from USB is useful when starting modules such as Wemos,
    although the accuracy of such a device is not stunning, but as an indicator of what is happening (in what mode) with the device connected to the USB, it's OK.
  • #8
    @GUTEK@
    Level 31  
    It depends on what you hit. I have two, one is cheaper and it is indeed inaccurate and has a large voltage drop. On the other hand, the second one, just like the one from the link, is doing very well and shows exactly what I checked. It also measures from a low current, e.g. detects the charging of the Mi Band, which the cheaper does not want to show.
  • #9
    gulson
    System Administrator
    @GUTEK@ wrote:
    Transistor tester - great equipment, makes servicing very easy. Additionally, you can upload modified software that increases the possibilities of:
    https://www.aliexpress.com/item/Digital-ESR-M...MOS-PNP-NPN-LCR-TESTER-METER/32740536071.html


    I was not supposed to write, but this tester will be in the shop soon :)
    There were also USB meters and they will be again.

    The Raspberry Zero is fun and good value for money, unfortunately you need some accessory hardware to get it running. Personally, I prefer the Wifi version. In my opinion, this Zero model is a bit useless compared to the WiFi version or the normal Raspberry.
  • #10
    george2002

    Level 21  
    Hello, Chicken, I did not even know that the electrode has such a program :D cool thing, out of curiosity whether the electrode also trades such modules, if so, what price :) ? (I know that it is possible with ali) and about the accessories, maybe the so-called third hand electronics is a nice thing personally and it helps a lot when soldering :) regarding the lamps, I recommend such Boruit T6 headlamp in googles, not expensive and very good head lamps powered by 2x18650 with 3 Cree T6 LEDs :) regarding the meter, the LCR-T5 is cool, but also more expensive than indicated by a colleague :)
  • #11
    gulson
    System Administrator
    george2002 wrote:
    cool thing, out of curiosity whether the electrode also trades such modules, if so, what price :) ?


    800 points, maybe 700 points as new things appear :)
  • #12
    george2002

    Level 21  
    gulson wrote:
    george2002 wrote:
    cool thing, out of curiosity whether the electrode also trades such modules, if so, what price :) ?


    800 points, maybe 700 points as new things appear :)



    Hmm, we didn't really understand each other because I meant whether the electrode also sells such modules in PLN and not for points :)
  • #13
    gulson
    System Administrator
    You have to go to Allegro or aliexpress :)
  • #14
    george2002

    Level 21  
    I get it, in short, only for points :) and for posterity it is exactly what version it is, since wemos is not original, I mean the size of flash because the rest probably does not differ ;)
  • #15
    rafcio_21
    Level 29  
    And what will we gain after updating this wemos module on nodemcu. Will i2c communication be available then, or will we gain more inputs / outputs.
  • #16
    Marek_Ertew
    Level 16  
    @ rafcio_21 as far as I know, inside the board there is a bootloader (which theoretically cannot be changed) and the correct soft.

    The 'on arduino' programming method presented in the article consists in compiling the correct software and uploading it to the module. The soft executes and its functionality depends on the libraries available at compile time. Just like the classic uC.

    NodeMcu is a bit of a different toy, because in addition to the proper soft, the memory also contains a certain working space reserved for code / data / ... and the correct soft is a command interpreter and allows you to edit the working space, something like an operating system or BASIC interpreter in 8-bit computers .
    With NodeMcu you theoretically upload the "base" only once, and when updating the software you only overwrite part of the program code - the libraries are still in memory.
  • #17
    rafcio_21
    Level 29  
    Theoretically, it can not be changed, but somewhere on the net I saw how to win other software, the esp module is the same in wemos as in nodmcu. So theoretically it should be expandable.
  • #18
    suarez23
    Level 2  
    I have a question for the experts. Do I have to add anything to the code when adding the "button shield" question to the above set (D1 mini + relay shield)? Specifically, I mean control via BLYNK. Will BLYNK recognize the state of a switch if I change its state using a physical button? I was looking for this case on the web for quite a long time and unfortunately, apart from photos with such a combination, I could not find a specific description of such use.
  • #19
    TechEkspert
    Editor
    @ suarez23 do you have a schematic of this button board? I understand that this is about Blynk receiving a button press on the shield?
    The board with the relay made of material is not the original Wemos "shield", so if you have a diagram of your "relay shield" board, you can add it too.
  • #20
    suarez23
    Level 2  
    TechEkspert wrote:
    @ suarez23 do you have a schematic of this button board? I understand that this is about Blynk receiving a button press on the shield?
    The board with the relay made of material is not the original Wemos "shield", so if you have a diagram of your "relay shield" board, you can add it too.



    This button and relay and wemos D1 mini come to me from China:
    button: https://www.aliexpress.com/item/One-Button-Shield-For-WeMos-D1-Mini-Button/32770784800.html?spm=a2g0s.9042311.0.0.It22PT
    switch: https://www.aliexpress.com/item/Free-shipping-1-channel-Relay-Shield-for-Wemos-D1-mini-Relay-Module-Smart-Electronics/32721579483.html?spm=a2g0s. 9042311.0.0.It22PT
    D1 mini: https://www.aliexpress.com/item/D1-mini-Mini-NodeMcu-4M-bytes-Lua-WIFI-Internet-of-Things-development-board-based-ESP8266-by/32774564353.html ? spm = a2g0s.9042311.0.0.It22PT

    And from all this, something like this is to come out:
    https://i0.wp.com/waschto.eu/wp-content/uploads/2016/06/WeMos-Relais.jpg

    I know that I can cover it with a ready-made example of "ESP8266 Standalone", the question is how will the button work with it? I would like the physical pressing of the button to change the state into BLYNK as well. I am not sure if the above example will work this way without corrections.
  • #21
    TechEkspert
    Editor
    Physically for the relay it will be the D1 pin, for the button it will be D3 (short to ground when active).
    Interesting example, kind of simple, but I didn't test such synchronization during my trials with Blynk.

    I think it will be necessary to modify the code and introduce a virtual line.
    Its state can be changed from the level of Blynk and from the level of the pressed physical button.
    The relay status will depend on the virtual line.
    The application should synchronize the state of the virtual line.

    You will have to test how this idea works.

    Or maybe it is enough to base the program only on modifying and reading the D1 state?
    We will see.

    When the equipment comes, experiment and let us know about the results,
    if there is any problem, write something here and post it in the topic.
  • #22
    tos18
    Level 41  
    rafcio_21 wrote:
    Will i2c communication be available then, or will we gain more inputs / outputs.


    After all, communication over I2C on this module works - I have MCP9808 connected and an oled display. They work on a common bus and do not interfere with each other. Program written in arduino.
  • #23
    rafcio_21
    Level 29  
    I have already found out about it myself, thanks to the electrode gadgets, I had a little fun with this module, the only thing that did not want to work was the support of the dht11 sensor, I tried different libraries and I do not see the sensor and the sensor is definitely functional because the same library works without a problem on the arduino nano. After I2C, everything is flashing, I have a 2x16 LCD display on I2C, plus 2 TC74 sensors on I2C and I display everything on the LCD and BLINK.
  • #25
    rafcio_21
    Level 29  
    Ok, I didn't know about it, I probably connected to pin d2 and then d3 and it didn't work for me in my free time, I will test it again based on your links. Thank you and best regards.
  • #26
    tos18
    Level 41  
    D1 and D2 are hardware I2C so if you are using I2C none of these pins will be usable. I suggest D5, D6 or D7
  • #27
    rafcio_21
    Level 29  
    Of course, I did not use the i2c and the dht11 sensor at the same time, I only had the dht sensor connected.
  • #28
    TDA2593
    Level 9  
    Hello.
    I need to dig up the topic from 2 years ago.
    I have a MINI D1 module (Wemos_a clone). Not with ESP8266 12E. Mine has a 12MOD version on board. This is probably the next higher version with more memory. Maybe that's where my problems come from.
    Unfortunately, I cannot connect to the module via the browser. The first soft (relay control) loads the module and that's it. There is no response on the cell and the laptop does not want to connect to this network. For the test, I loaded the blinking LED and it works.
    Arduino IDE version 1.8.12, installed board 8266 version 2.6.3.
    Please help.
    Best regards.
  • #29
    TechEkspert
    Editor
    Does the example from Blynk work?

    Is it possible to see on the WiFi AP whether the module gets IP from DHCP, and is the "wireless client isolation" option disabled?
    You can also check from another device in the network whether the module responds to the ping.
  • #30
    TDA2593
    Level 9  
    Before loading Blynk_a, I had to download the library. I haven't found this more precisely >> BlynkSimpleEsp8266.h . I seem to have installed: Blynk and Blynk_ESP8266_WM . Unfortunately, after uploading Blynk_a, the cell from the test board does not see the WIFi signal ... I tried to come back with the 1st example (relay control) and it does not see either. Test LED Flashing is working.
    I checked the WIFi settings before. DHCP was on in the module, I changed it to manual, but it didn't improve anything. Where to find "wireless client isolation"? I haven't seen anything like that.

    Best regards.