Showing posts with label 1-Wire. Show all posts
Showing posts with label 1-Wire. Show all posts

Monday, June 12, 2017

Extend your analog inputs




Intro

Is yours too small? You want to get more? No, that is no advertisement for a penis enlargement product. It's for a board to extend the numbers of analog inputs to your microcontroller.
It's quite rare that you run out of analog inputs, when using an Arduino Uno, Nano, Micro, etc. Even a ATTiny is already equipped with 4 analog inputs. BUT if you are so keen in using a ESP8266, like I am, you'll find your self in the position having only 1 (!)  analog in. This is where a digital to analog converter comes into play.


It's all about libraries

The name of the sensor (ADS1115) already can lead to the conclusion that the board is developed by Adafruit. And of course, if you'll open the library manager in the Arduino IDE and search for ADS1X15. There you have it all. Ready-To-Use library, good commented examples.

I2C on your NodeMcu board

The default pins for I2C on the NodeMcu board are pins D1 (SCL) and D2 (SDA). But the cool thing with the NodeMcu board is, you can define for yourself where the I2C has to be.

With the command:
Wire.begin();
You usually start the Wire-library, that is responsible for the I2C bus. But you can also add the pins for SDA and SCL as parameters:
Wire.begin(D2, D1); // Wire.begin([SDA-Pin],[SCL-Pin]);

There can be more than one

The ADC1115 has a fixed I2C address, like any other I2C device. Fixed? Not quite! It has up to five different I2C addresses. The default one, and four more addresses, that you can select by connecting the address pin (ADDR) with either SDA, SCL, GND or VDD.


Video


Wire up

Normal wiring


Wiring with two modules on I2C



Links

Adafruit Library
https://github.com/adafruit/Adafruit_ADS1X15

Amazon
ADS1115
NodeMcu

Tuesday, March 14, 2017

Dallas 18B20 temperature sensor



Intro

The Dallas 18B20 is probably the most common temperature sensor in the Arduino community. It's cheep, it's small and part of many Arduino startet kits.

Wiring


The left pin is the Ground (GND) pin. The middle is the data line. We connect the data line to digital pin 2 (D2). The right pin can be connected to 3V3 or to 5V. And since this sensor works on the 1-wire bus, we have to connect the data line also to VCC though a 4.7kOhm resistor.

Video


Here is the Video of the process.


Code

 Just install a library for the Dallas sensor and open the simple sketch
DallasTemperature library

The simple sketch
 If you run the serial monitor, you can see the actual temperature.

Thursday, March 9, 2017

DHT22 temperature and humidity sensor



Intro

The DHT11/DHT22 is a quite popular sensor in the maker scene. It's a temperature and humidity sensor.
Easy-to-use, quite accurate and also affordable. If you're looking for examples of self made weather stations, you'll find that many makers use exactly this sensor. There are many different temperature sensors on the market. But only few, cheap humidity sensors.

Wiring

Code

 I didn't develop any code for this. Since, when you search for DHT in the Library Manager and install a fitting library, you can load an example and it will work. (see video).

Video


1-Wire bus

While searching the internet I found several different datasheets to this sensor and many different tutorials to this sensor and how to implement a pullup resistor to this. So I tested different configuration myself. And I found out that the sensor would even work without any resistors. The sensor using the 1-Wire bus. So I would recommend using a resistor. About the correct value I'm unsure. But it seems everything between 1kOhm and 10kOhm will work just fine.

Links

Amazon
DHT22 Sensor
Arduino Nano
Breadboard
Resistors