Digital read and digital devices
In last topic we saw how to read analogic sensors using the ADC pin with our esp transmissor. Now we will see how to read from digital devices that counts with an IC (integrated circuit) which provides a comunication bus and a standariced transmission protocol like One Wire Bus, I2c, SPI, etc. It means that we will need to build our code including the specific protocol for each device. Fortunately, there are some arduino libraries to make easy this job.
There are some advantages using digital transmision: like no accuracy losts by wire interferences, or the posibility to link a lot of devices and sensors using the same bus (in I2C or SPI).
Most popular digital sensors are: DHT11 and DHT22 temperature + humidity, Dallas ds18b20 only temperature, bmp180 (I2C) for atmospheric pressure, etc.
ESP8266 + DS18B20
Wiring up dallas ds18b20 sensor with pull-up resistor:
Just a note. It is not necessary to request the temperature inside the loop function. It can be done directly inside the [“temp”] resource. So the microcontroller doesn’t need to read the temperature every time, just when it is requested. This will save power consumption and will improve the overall response time =)
I’m quite new with all of this (meaning: Arduino, NodeMCU, Thinger.io and such) but have been tinkerer and overall electronic enthusiast for very long time. Now, I was able to pull some great stuff with NodeMCU and Thinger.io and this tutorial helped me a lot in making tiny weather station for my back yard using this very same sensor. However, I’ve noticed that since I’ve uploaded this sketch, NodeMCU became somewhat sluggish and it seems that it is always “working” something this it’s being a bit unresponsive. Now, since I’m using the same microcontroller for some other purposes (unlocking the strike lock, lights through the backyard) I’ve noticed that, when I have added this solution to my original sketch, controlling of the relays became pretty unreliable and often with quite a bit of latency.
You sketch seems to be fine, however you have two resources duplicated (that could be a problem) and also the dallas reading could be improved a bit to avoid requesting all connected sensors (assuming you have just one sensor). Also, the thing type should be ThingerESP8266 if you are using such device, so you can get SSL connections by default. Something like:
Thank you so much for the quick response.
I’ve ended up changing just thing [“Temperature”] part in my sketch and it worked like a charm.
Now, the other thing I’m struggling to make happen is to display temperature on the dashboard without decimals. Currently, if I’m using Text/Value widget the value has four decimals and if I’m using Dount/Chart (just for aesthetics) it displays two decimals. Ideally, I would like it without decimals but I understand that this is nitpicking and I don’t mind leaving it as-is for now. Then again, I believe that there must be some kind of easy solution for this but I just can’t seem to find it.
Once again, thank you for the great support and great platform.