Possible to use Sonoff si7021 with Arduino?

I am trying to measure humidity and temperature using the sonoff si7021 and an Arduino UNO but have so far been failing, so I'm wondering whether this is possible at all. The sonoff si7021 sensor is quite different from the "pure" si7021. Sonoff added a microcontroller but I cant seem to find information on what protocol it uses. This post suggests it might be compatible with DHT11/22 sensors:

pylon:
There are some indicators on the Itead Wiki that this single wire bus is compatible with DHT11/22 sensors. So try to read the sensor using that protocol but you won't be successful if you request data as if it was a directly connected SI7021.

I have a functioning setup with a DHT11 on my breadboard but when I replace the DHT11 with the sonoff sensor, I get no readings.

At the same time, I realized that the sonoff sensor takes a maximum of 3.6v and I have been testing it with 5V :-/ so I'm not sure if it is still intact. Is there a simple way of checking? (There is no visible damage on the sensor board).

When I realized my mistake, I used the 3.3 V pin on the UNO, but I'm not even sure whether that pin can be used in that way (I know it can be used as reference voltage, but as supply voltage? As you will have guessed, I'm quite a beginner in the Arduino world...)

So, since I'm having so many uncertainties that make it difficult to continue, I'm posting here, hoping you might be able to help me eliminate some of those unknowns.

I would suggest adding your code to your post inside code tags [code]your code here[/code].

Might have a look at the second hit in THIS SEARCH. They use a library specific to that module.

DangerToMyself:
I would suggest adding your code to your post inside code tags [code]your code here[/code].

I’m not sure which code that would be. I’ve tried lots of different ones and the reason I posted under “Project Guidance” is that my question is at a more general level of feasibility. I’ll go back to coding once I have confirmation that my hardware setup is not complete nonsense (and that I didn’t destroy my sensor with the 5V).

Are you implying that the sonoff sensor can actually be used with an Arduino UNO?

DangerToMyself:
Might have a look at the second hit in THIS SEARCH. They use a library specific to that module.

That hit is about what I called the “pure” Si7021. There is lots of documentation out there about that sensor. But the Sonoff Si7021 sensor is very different in that it doesn’t communicate via I2C.

In addition to the post I quoted in the OP, I also found a post on Github that seems to confirm that the Sonoff sensor uses the same protocol as the DHT21/22 sensor. But it also states that it is “a little different”. I suppose that little difference is (part of) the reason why I’m not getting it to work, not using #include <DHT.h> (which is the Ardafruit library) and not using #include <TroykaDHT.h> (which was mentioned here).

So before I waste my (and everyone else’s time), I think the most basic question here is: can I use a sensor that wants 3.3VCC with a 5V UNO board? I suppose this sounds incredibly trivial to most people here, but I’m really not sure. I’m guessing that this is the purpose of the 3.3V pin on the UNO but if it is that easy, I don’t understand why different board voltages seem to cause so much discussion online. Is it because there is a 50mA limit on the 3.3V pin? Anyway, this is just an aside. So let me restate my main questions here:

  • Is it possible to use the Sonoff Si7021 on an Arduino UNO?
  • Is it likely that I broke the Sonoff sensor when connecting it to 5V for a total of maybe 10-15 minutes?
  • How do I read the Sonoff sensor on the UNO?

Oh my gosh. Just look at that butt!

Answer to number 1:
A search on the internet using the words "Sonoff Si7021 on an Arduino UNO" bring up things like:

How to interface a Si7021 humidity and temperature sensor with Arduino

and more!

Answer to number 2: yes.

Answer to number 3, see number 1

Idahowalker:
Oh my gosh. Just look at that butt!

I'm not sure what you are talking about here. I take it that this comment is irrelevant to the questions discussed here.

Idahowalker:
Answer to number 1:
A search on the internet using the words "Sonoff Si7021 on an Arduino UNO"

I am new to Arduino, but I am not new to the internet. It goes without saying that I have spent considerable time searching the internet before posting my questions here (see the various links in my previous posts). Did you bother looking at the results that your suggested search yields? None of them answers my question.

Sorry if I didn't make this clear enough earlier: I am not talking about the generic Si7021 sensor but the Sonoff sensor by the same name.

I am making another assumption that this page is discussing the sensor you may have (or a similar one). I didn’t read it word for word, but it seems it is “possible”. However, it’s not exactly as easy as “plug-n-play”. If the page I linked is new to you, read through the comments. There may be something there to help.

I believe they are discussing this item

DangerToMyself:
I am making another assumption that this page is discussing the sensor you may have (or a similar one)

Yepp, that's the one. Interesting, that page seems to be the discussion before Tasmota supported the sensor. I hadn't seen that. What I'm currently looking at is this:

I believe, this is where the support for the Sonoff Si7021 has been implemented. As you can see, most of the code is common for the DHT sensors and the Si7021, but there are some differences and these are probably the little differences mentioned earlier.

More specifically, I'm referring to line 87 (longer delay), lines 152-155 (different structure of the data pulse, I suppose), and lines 172-176 (not sure what this does).

I'm sensing that this is quite close to what I need in terms of question 3...

Okay, I think I found the answers to my three questions:

  1. Is it possible to use the Sonoff Si7021 on an Arduino UNO?

Yes. I am seeing the measurements coming in right in front of me.

  1. Is it likely that I broke the Sonoff sensor when connecting it to 5V for a total of maybe 10-15 minutes?

Not sure about the likelihood but in my case it wasn't broken. In fact, if I use 5V instead of 3.3V it returns the same measurements, no problem. But I'm not gonna test how long it would continue doing so :wink:

  1. How do I read the Sonoff sensor on the UNO?

Here my answer is preliminary (but it works), and it's fascinatingly simple: All I needed to do is set the a 500 microsecond delay when waiting for the sensors response. The quick fix that makes this happen is to pretend define the sensor as a DHT22 and add the delay to the DHT library here so that it says:

case DHT22:
  delayMicroseconds(500);
  break;

So it looks like the only difference between the DHT22 and the Sonoff Si7021 is that delay. Maybe there is something else that I missed, but the temperature and humidity readings seem fine, so I'm going to assume that I didn't miss anything. However, I would like to be able to declare the Si7021 as such, rather than as a DHT22, but I'll figure that out some other time.