My first Wemos D1 + Easy ESP: need help in wiring

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

My first Wemos D1 + Easy ESP: need help in wiring

#1 Post by adrianmihalko » 16 Sep 2016, 21:43

Hello all,

Finally they are arrived: my Wemos D1 minis. This is my first experience in ESP8266/and overall in Arduino world/.

After some bugs between Mac and ESP8266 I finally uploaded ESP Easy firmware, configured and it's working.

I connected my first sensor a Lux meter, BH1750 to D1/D2 pins:
Untitled.jpg
Untitled.jpg (197.69 KiB) Viewed 24017 times
Nice, it's working.

I have here more sensors, for example: BMP280, SHT21. The manual says something about a pull-up resistor. Could you please help me with a wiring diagram how to connect BMP280, SHT21, BH1750 sensors in parallel with a pull up resistor (if it is necessary)?

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: My first Wemos D1 + Easy ESP: need help in wiring

#2 Post by costo » 16 Sep 2016, 22:10

It is very simple.
If all sensors are I2C then connect all SDA together and all SCL together.
Also there must be a a pullup resistor on SDA and one on SCL but probably one or more of your sensor boards do already have a pullup resistor. In that case the external pullups are not needed anymore.

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#3 Post by adrianmihalko » 16 Sep 2016, 22:26

Hi Costo, thank you for the fast response.

Is this wiring with pull up resistors correct (4K7 resistor is between SDA/VCC and SCL/VCC)?
new.jpg
new.jpg (168.39 KiB) Viewed 24012 times
I have this BNP280 board, there are some resistors: http://www.ebay.com/itm/201538104303

...and there are words about to use logic level converter, what's the truth?

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: My first Wemos D1 + Easy ESP: need help in wiring

#4 Post by costo » 16 Sep 2016, 22:30

The BH1750 boards that are common , like GY-302, do already have their own pullup resistors, so first try without extra resistors.

If your sensor boards work on 3.3V you never need a level converter. If your sensor boards work at 5V you can most of the time do without levelconverters but you must check that your 5V sensor boards do not have pullup resistors on the board that are connected to 5V. In that case you better use a level converter.

BMP280 works perfectly at 3.3V

edit:
By the way, I see a dangerous connection in your fritzl schematic. You have connected the 5V to the power rails, you should not use that voltage for 3.3V sensors, only for sensors that do not work with 3.3V
Last edited by costo on 16 Sep 2016, 22:44, edited 1 time in total.

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#5 Post by adrianmihalko » 16 Sep 2016, 22:43

Thanks for the explanation.

At this moment I am connecting my BH1750 sensor on 5V. It would be better to use with 3.3V -or it is does not matter?

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: My first Wemos D1 + Easy ESP: need help in wiring

#6 Post by costo » 16 Sep 2016, 22:49

Your wemosD1 likes 3.3V on the GPIO pins and the BH1750 will work perfectly well with 3.3V. So it is good practise to use only 3.3V for all the sensors. Only when sensors do not work with 3.3V you can use 5V on the sensor. Then you may face the fact that pullup resistors on this 5V sensor board are connected to 5V. In that case you can remove the pullups and connect them to 3.3V or you use a level converter.

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#7 Post by adrianmihalko » 17 Sep 2016, 00:32

I got 3 sensors working. :)

1,Interesting that there is an 1C difference between BMP280 and SI7021. I think this is too much.
Screen-Shot-2016-09-17-00-23-54.png
Screen-Shot-2016-09-17-00-23-54.png (132.35 KiB) Viewed 23994 times
2, Pressure value coming from BMP280 looks like a Raw Pressure Value. Is there any way to get Normalized Sea Level Pressure (it's a more common value, for example in meteorology)?

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#8 Post by adrianmihalko » 17 Sep 2016, 19:24

...so it's running from last night:
Screen-Shot-2016-09-17-18-59-44.png
Screen-Shot-2016-09-17-18-59-44.png (101.68 KiB) Viewed 23943 times
  • BMP280: seem to be totally inaccurate, the temperature is 1C above of the actual temperature.
  • SI7021: OK / it's showing similar values as my weather station
  • BMP085: OK / it's showing similar values as my weather station
BMP280:
What is the big difference in the temperature reading?
There is also a difference in the pressure reading. As I checked on the local meteorology site the BMP280's reading is closer to the reality.
Is there any formula to convert pressure reading to the more used sea level value? Like here: sea level pressure converter.

Drum
Normal user
Posts: 300
Joined: 07 Feb 2016, 11:56

Re: My first Wemos D1 + Easy ESP: need help in wiring

#9 Post by Drum » 19 Sep 2016, 16:38

Assuming your BMP280 is not next to something a little warmer and nothing on the module itself is generating heat (for example 5V feeding a 3.3v module) they are not completely accurate. Check the data sheets,absolute accuracy for temp can be off by as much as +-.5 at 25C and pressure as much as 1.7 hPa. Relative accuracy is +-0.12 hPa or 1m.

Absolute Accuracy of the BMP085 is +-2.5 hPa and +- 1.5C at 25C.
The SI7021 is +-0.4C

If you have access to Lab quality instruments which have been calibrated with a NIST or comparable traceable standard, you can use the formula to adjust the value as the BMP280 has great relative accuracy, but I think the change is pressure is what really matters and they should be close there. Dump the readings from a day or 2 to a spreadsheet and look them.

In any case I think they are within their specifications. I don't remember any of these having "Lab use" in the application section.


You can convert hPa to inhg, the formula is on the internet, google says "How many hpa in 1 inhg? The answer is 33.8638866667."

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#10 Post by adrianmihalko » 28 Sep 2016, 20:31

One more question: why is possible to configure only 4 devices in ESP Easy?

User avatar
bertrand
Normal user
Posts: 24
Joined: 30 Jun 2016, 10:22
Location: Hong Kong

Re: My first Wemos D1 + Easy ESP: need help in wiring

#11 Post by bertrand » 28 Sep 2016, 22:16

There's a second page ;)

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#12 Post by adrianmihalko » 28 Sep 2016, 23:12

Great, I just found it after 2 weeks. :) Thanks!

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#13 Post by adrianmihalko » 29 Sep 2016, 22:16

Back to my question for pressure conversion:

Is there any formula to convert raw pressure reading to the more used mean sea level?

(there was an answer for hPa to inHg conversion -> I am not looking for this)

Here is what I mean:

Mean sea level pressure calculator (converter) – Simple formula

On the page is the formula too:

p0 = Calculated mean sea level pressure
p1 = Measured/barometric pressure
T = Measured air temperature:
?? = Elevation of measured data

p0 =p1 (1-0,0065h / (T + 0,0065h +273,15))^-5,257

Is there any way to implement this calculation to ESP Easy or use as a formula in the device settings? Or I don't need this formula at all just the offset between calculated mean sea level pressure and raw pressure?
Screen-Shot-2016-09-29-22-02-12.jpg
Screen-Shot-2016-09-29-22-02-12.jpg (153.19 KiB) Viewed 20345 times
Offset is 12.6 in this case.

Drum
Normal user
Posts: 300
Joined: 07 Feb 2016, 11:56

Re: My first Wemos D1 + Easy ESP: need help in wiring

#14 Post by Drum » 30 Sep 2016, 14:04

As I understand it, the offset is based on the temperature so you would have to calculate it for different temperatures, but I don't think you can put that formula in as it is.
I think you would have to have the calculation hard coded in the plugin, or do it externally.

I generally am only looking at the absolute change in pressure locally, but I can see where this would be needed to be able to compare to other locations, which would make it more useful in my opinion.
On that basis they might be willing to update the plugin. Or they might suggest you try to update it in the playground. ;)

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#15 Post by adrianmihalko » 30 Sep 2016, 19:46

Thanks Drum, you are right. Yesterday I forget about temperature. If I got more time I am going to look on the plugin, maybe I can modify it to include the conversion formula. :)

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#16 Post by adrianmihalko » 01 Oct 2016, 00:50

I successfully implemented the formula in the BMP085 plugin, but one thing is not working. How do I save custom variable in EspEasy?

Code: Select all

case PLUGIN_WEBFORM_SAVE:
    {
      String plugin1 = WebServer.arg("_p006_bmp085_sea");
      Settings.TaskDevicePluginConfig[event->TaskIndex][0] = (plugin1 == "on");
      String plugin2 = WebServer.arg("_p006_bmp085_elev");
      Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
      success = true;
      break;

    }  
I am now trying SaveTaskSettings(event->TaskIndex); but this function is undocumented and I don't know that this is the right way to save config or not.
There is also an another function: SaveCustomTaskSettings.

Edit: SaveTaskSettings(event->TaskIndex) - doesn't seem to work. It holds the value for a while, then lose it.

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#17 Post by adrianmihalko » 01 Oct 2016, 15:47

After few hours of researching... I can save input type textbox value, but not checkbox.

Code: Select all

boolean Plugin_006(byte function, struct EventStruct *event, String& string)
{
  boolean success = false;
  struct P006Struct
    {
      char enabled;
      unsigned int elevation;
    };

case PLUGIN_WEBFORM_LOAD:
      {
        struct P006Struct seaConfig;
        LoadCustomTaskSettings(event->TaskIndex, (byte*)&seaConfig, sizeof(seaConfig));

        string += F("<TR><TD>Mean sea level pressure:<TD>");
        if (seaConfig.enabled)
                string += F("<input type=checkbox name=_p006_bmp085_sea checked>");
              else
                string += F("<input type=checkbox name=_p006_bmp085_sea>");

        string += F("<TR><TD>Elevation (meter):<TD><input type='text' name='_p006_bmp085_elev' value='");
        string += seaConfig.elevation;
        string += F("'>");
        success = true;
        break;
             
      }

case PLUGIN_WEBFORM_SAVE:
    {
    struct P006Struct seaConfig;
      String plugin1 = WebServer.arg("_p006_bmp085_sea");
      seaConfig.enabled = (plugin1 == "on");
      strncpy(seaConfig.enabled, plugin1.c_str(), sizeof(seaConfig.enabled));

      String plugin2 = WebServer.arg("_p006_bmp085_elev");
      seaConfig.elevation = plugin2.toInt();

      Settings.TaskDeviceID[event->TaskIndex] = 1; // temp fix, needs a dummy value

      SaveCustomTaskSettings(event->TaskIndex, (byte*)&seaConfig, sizeof(seaConfig));

      success = true;
      break;

    }  
The error is:

Code: Select all

In function 'boolean Plugin_006(byte, EventStruct*, String&)':
_P006_BMP085:77: error: invalid conversion from 'char' to 'char*' [-fpermissive]
       strncpy(seaConfig.enabled, plugin1.c_str(), sizeof(seaConfig.enabled));
Any help appreciated... ;)

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#18 Post by adrianmihalko » 01 Oct 2016, 22:48

OK I've found the way to save custom values. It's working now.
Screen-Shot-2016-10-01-22-42-41.jpg
Screen-Shot-2016-10-01-22-42-41.jpg (49 KiB) Viewed 20173 times
I am trying to do a pull request to the original plugin.

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#19 Post by adrianmihalko » 03 Oct 2016, 23:04

I just received today a BME280 sensor and guess or not it's showing weird values as well as my other sensors.

I am comparing values to my weather station.

Summary:

BMP280 -> +1C above actual temp
HTU21D/SI7021 -> -0.5C below actual temp
BMP180 -> pretty accurate
DHT22 -> -0.5C /humidity totally inaccurate %value%+20/
BME280 -> +1C

I know that this is more or less in the specified accuracy, but I am little bit disappointed. For the money a DS18B20 temperature sensor is a better choice - if you need measure only the temperature.

What do you think?

pm_cz
Normal user
Posts: 10
Joined: 16 Mar 2016, 10:56

Re: My first Wemos D1 + Easy ESP: need help in wiring

#20 Post by pm_cz » 05 Oct 2016, 08:48

From all BMP280s I have the positive temperature shift is consistently present and the pressure differs between individual BMP280 boards (+/- 1,5 hPa). Maybe they are calibrated during manufacture and some external factors (soldering, transportation from seller in China) make the calibration invalid? Luckily we have the formula field, so we may adjust the temperature if it is consistently shifted in Temperature formula field by say

Code: Select all

%value% -1
On that note, can we make more complicated formulas than that, e.g. ax*x+bx+c? The code in Misc.ino seems to indicate this possibility, but I am not sure.

Concerning the DHT and humidity values:
  • they may be influenced by soldering (significant decrease in reported humidity) or on the other hand some manufacturers expect soldering and if you use the sensor placed in connector/bredboard the reported value may be higher
  • the weather station (esp. cheaper) may report inaccurate values as well - cheaper sensor, ageing

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#21 Post by adrianmihalko » 10 Oct 2016, 08:35

So I "calibrated" sensors using formula and they seem to be accurate now.

I still not understand when/why the blue LED is lighting on my Wemos D1 mini. My first tought was that this is connected to D4 min, but even If I moved from that pin to other it is still lighting.

pm_cz
Normal user
Posts: 10
Joined: 16 Mar 2016, 10:56

Re: My first Wemos D1 + Easy ESP: need help in wiring

#22 Post by pm_cz » 10 Oct 2016, 08:58

I do not own Wemos D1 mini, but if it has standard ESP-12 module (there seem to be two versions of D1 mini online, one using it and another having ESP on PCB), is it not connected to TX PIN (i.e. it blinks each time some log is written to TX line)? If so, you can disable it by turning off serial logging in Advanced Settings.

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#23 Post by adrianmihalko » 11 Oct 2016, 21:17

Ahhh, double checked everything and I had in Domoticz an ON/OFF command: http://192.168.1.4/control?cmd=GPIO,2,1.......which turned on the LED. ;)

Thanks for the help.

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#24 Post by adrianmihalko » 15 Oct 2016, 19:23

Hi,

I connected a relay module to my Wemos D1 (firmware Esp Easy):

VCC to 5V, GND to GND, In1 to GPIO14 (D5)

The problem: the relay is always on (the red led is lighting).

I tried to switch off:

$ curl 192.168.1.4/control?cmd=GPIO,14,0
{
"log": "GPIO 14 Set to 0",
"plugin": 1,
"pin": 14,
"mode": "output",
"state": 0
}

...it's still on. What can be the problem? Is it normal that the relay is hot /50-55C/ - at this moment nothing is connected to the relay?

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#25 Post by adrianmihalko » 15 Oct 2016, 19:37

Hmm, I connected to 3V output and now it's working fine. Interesting, because the relay is an 5V module. :roll:

Another interesting thing, that the relay switch on when GPIO is pulled down curl 192.168.1.4/control?cmd=GPIO,14,0 -> it has reverse logic?

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: My first Wemos D1 + Easy ESP: need help in wiring

#26 Post by adrianmihalko » 02 Nov 2016, 16:34

It is OK that my ESP modules (Wemos, NodeMCU) won't see my Wifi-N network? Only Wifi-G is available.

User avatar
aDub
New user
Posts: 3
Joined: 07 Oct 2017, 17:27

Re: My first Wemos D1 + Easy ESP: need help in wiring

#27 Post by aDub » 07 Oct 2017, 17:34

adrianmihalko wrote: 15 Oct 2016, 19:23 Hi,

I connected a relay module to my Wemos D1 (firmware Esp Easy):

VCC to 5V, GND to GND, In1 to GPIO14 (D5)

The problem: the relay is always on (the red led is lighting).

I tried to switch off:

$ curl 192.168.1.4/control?cmd=GPIO,14,0
{
"log": "GPIO 14 Set to 0",
"plugin": 1,
"pin": 14,
"mode": "output",
"state": 0
}

...it's still on. What can be the problem? Is it normal that the relay is hot /50-55C/ - at this moment nothing is connected to the relay?
The lamp often turns on after a reset or an upload. Not bothered to research this yet, but I turn the lamp off in setup() with
analogWrite(14,1024);
analogWrite(14,0);

I found that if I didn't turn it on to some value, I couldn't turn it off! The sledge-hammer approach worked well enough for my needs.

User avatar
aDub
New user
Posts: 3
Joined: 07 Oct 2017, 17:27

Re: My first Wemos D1 + Easy ESP: need help in wiring

#28 Post by aDub » 07 Oct 2017, 18:54

costo wrote: 16 Sep 2016, 22:10 It is very simple.
If all sensors are I2C then connect all SDA together and all SCL together.
Also there must be a a pullup resistor on SDA and one on SCL but probably one or more of your sensor boards do already have a pullup resistor. In that case the external pullups are not needed anymore.
I know that this post is a year old, but if I may clarify (for novice users)...
  • Actually, if all of your boards have pull-ups, you may need to remove some of them! Since they will be in parallel the effective resistance will be reduced!
    The actual resistance required for the buss to function is dependent upon buss speed and buss capacitance (however you may find any old value will work!).
    If we take the above, and we have three devices with resistors built in, at say 2k4 ohms then the effective resistance will be only 800 ohms
    since R= 1/(1/r1 + 1/r2 + 1/r3) or 1/(0.0004166667 * 3 ) = 1/0.00125) = 800 ohms
    at four we have just 600 ohms
  • Having several of the SAME sensor is not quite that simple of course! Many, but not all I2C devices will have (usually) 1, 2 or three additional connections, usually designated A0, A1, A2 (some may have more) Some are pulled up, some down to take effect (see manufacturers notes). These pins allow the I2C address to be changed.
    This allows two similar devices having the same base address to co-exist.
    Let's assume the device sits at the default address 0x80, if we tie A0 on one device to high, it's address will be 0x81. Thus if we have 3 Address bits A0, A1 & A2 we can have eight identical devices on the same buss (note that some devices of different types may share the same base address - don't assume, use a buss scanner. I use "i2c_scanner" which has been tweaked by several people and indeed I have my own mods that identify devices that I use, as well as their address)
    If we want to control more devices than the manufacturer allows, by supplying a limited number of address pins, then we usually use a second I2C port as the simplest option.

User avatar
aDub
New user
Posts: 3
Joined: 07 Oct 2017, 17:27

Re: My first Wemos D1 + Easy ESP: need help in wiring

#29 Post by aDub » 07 Oct 2017, 19:04

Further to the I2C Scanner reference above, this is what mine outputs for a BME 280

Code: Select all

######## I2C finder V 0.7  ########
Scanning..........................
        ..........................
        ..........................
        ..........................
        ..............
address 0x76  Dec 118  Bin 1110110
     EEPROM
  or Parallel Port
  or Temp/barometer
address 0x77  Dec 119  Bin 1110111
     EEPROM
  or Parallel Port
  or Temp/barometer

scanning complete

2 devices found
--------  from 1 to 127   --------

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: My first Wemos D1 + Easy ESP: need help in wiring

#30 Post by Shardan » 07 Oct 2017, 19:04

For more information about I²C see also:

https://www.letscontrolit.com/wiki/inde ... he_I²C_Bus

Regards
Shardan
Regards
Shardan

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 30 guests