Arduino Forum

Using Arduino => Sensors => Topic started by: superJj on Dec 13, 2018, 03:54 pm

Title: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: superJj on Dec 13, 2018, 03:54 pm
Hi everyone, please share your thoughts on this with me.

Is it possible to use one ds18b20 temperature sensor to send data to Arduino pro mini 5v and to an ESP8266 module? I will program the two devices separately with appropriate libraries but what puzzles me is the pull up resistor 4.7k between the data line and the Vcc. Arduino pro mini is 5v and the esp8266 is 3.3v. I am powering the two devices independently with appropriate current and the idea is to send the sensor's data line to an appropriate pin on the esp8266 and the again the same sensor's data line to an appropriate pin on the Arduino. Should the sensor with 3.3 and then just send the data line to the two devices?
Will that work or will i fry things up? What do you think? 
Title: Re: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: Nick_Pyner on Dec 13, 2018, 04:43 pm
will i fry things up?
Quite likely. You power the devices with the appropriate voltage, not current. One has to wonder why you would want to do this anyway, so some clear explanation of your intentions might be in order. As things are, the Pro Mini is very probably redundant. If you must use one, why not use a 3.3v version? It would make far more sense to to have DS18B20 connected to one MCU and that passes the data to the other.
Title: Re: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: superJj on Dec 13, 2018, 05:15 pm
High Nick,

Yes for some reason I wrote current, apologies... I have so far successfully programmed the Arduino pro mini which reads temperature from the ds18b20 and sends the data through TTL-rs485 module. I was wondering if I could add in the above setup the esp8266 and after proper programming, have it read temperatures from the same ds18b20 sensor. Indeed you are correct in saying that the mini is redundant but I am experimenting on whether such a connection would be physically ok.

P.S. What if I power ds18b20 with 3.3v (which works on esp8266) run between Vcc and Data the 4.7k resistor and then send that data line to pin2 on esp8266 and pin 2 on the mini?
Title: Re: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: GolamMostafa on Dec 13, 2018, 05:37 pm
@OP

I have tested the following setup, and it works for me. The ESP keeps the MEGA OFF while it acquires signal from the DS18B20 sensor.
(https://forum.arduino.cc/index.php?action=dlattach;topic=584953.0;attach=285722)

MEGA Serial Monitor:
(https://forum.arduino.cc/index.php?action=dlattach;topic=584953.0;attach=285724)

ESP Serial Monitor:
(https://forum.arduino.cc/index.php?action=dlattach;topic=584953.0;attach=285726)

BTW:  Do you like to have the copies of the sketches for MEGA and ESP?
Title: Re: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: Nick_Pyner on Dec 14, 2018, 03:32 am
Indeed you are correct in saying that the mini is redundant but I am experimenting on whether such a connection would be physically ok.

P.S. What if I power ds18b20 with 3.3v (which works on esp8266) run between Vcc and Data the 4.7k resistor and then send that data line to pin2 on esp8266 and pin 2 on the mini?
If you really want to do this just as a pointless intellectual exercise, OK, but don't show it to your mother. DS18B20 can run on 3.0v and I believe it uses the same pullup 4.7k. As I said, it makes more sense to have one device read the sensor and distribute the data.
Title: Re: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: superJj on Dec 14, 2018, 02:48 pm


BTW:  Do you like to have the copies of the sketches for MEGA and ESP?
[/quote]

Thank you GolamMostafa, yes please that would be great! I will get back to you with the results!
Title: Re: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: GolamMostafa on Dec 15, 2018, 05:50 am
BTW:  Do you like to have the copies of the sketches for MEGA and ESP?

Thank you GolamMostafa, yes please that would be great! I will get back to you with the results!
Connection Diagram (repeated) among MEGA, ESP, and DS18B20
(https://forum.arduino.cc/index.php?action=dlattach;topic=584953.0;attach=285722)

MEGA Codes:
Code: [Select]
//12-bit default resolution; external power supply
#include<OneWire.h>
#define OneWireBusPin 11
OneWire ds(OneWireBusPin);  //2
byte addr1[8];         //to hold 64-bit ROM Codes of DS1
byte data[9];        //buffer to hold data coming from DS18B20
float celsius;
byte busStatus;

void setup()
{
  Serial.begin(9600);
  ds.reset();
  ds.search(addr1);  //collect 64-bit ROM code from sensor (DS1)
}

void loop()
{
  ds.reset();       //bring 1-Wire into idle state
  ds.select(addr1); //slect with DS-1 with address addr1
  ds.write(0x44);    //conversion command
  do   //let sensor take as much time as it needs to finish conversion
  {
    busStatus = ds.read();
  }
  while (busStatus != 0xFF);
  //---------------------------
  ds.reset();
  ds.select(addr1);  //selectimg the desired DS18B20
  ds.write(0xBE);    //Function command to read Scratchpad Memory (9Byte)
  ds.read_bytes(data, 9); //data comes from DS and are saved into buffer data[8]
  //---------------------------------

  int16_t raw = (data[1] << 8) | data[0]; //---data[0] and data[1] contains temperature data : 12-bit resolution-----
  celsius = (float)raw / 16.0;  //12-bit resolution
  Serial.println(celsius);
  delay(1000);
}



ESP Codes:
Code: [Select]
//12-bit default resolution; external power supply
#include<OneWire.h>
#define OneWireBusPin 5
OneWire ds(OneWireBusPin);  //2
byte addr1[8];         //to hold 64-bit ROM Codes of DS1
byte data[9];        //buffer to hold data coming from DS18B20
float celsius;
byte busStatus;

void setup()
{
  Serial.begin(115200);
  pinMode(4, OUTPUT);
  ds.reset();
  ds.search(addr1);  //collect 64-bit ROM code from sensor (DS1)
}

void loop()
{
  digitalWrite(4, LOW); //MEGA OFF
  ds.reset();       //bring 1-Wire into idle state
  ds.select(addr1); //slect with DS-1 with address addr1
  ds.write(0x44);    //conversion command
  do   //let sensor take as much time as it needs to finish conversion
  {
    busStatus = ds.read();
  }
  while (busStatus != 0xFF);
  //---------------------------
  ds.reset();
  ds.select(addr1);  //selectimg the desired DS18B20
  ds.write(0xBE);    //Function command to read Scratchpad Memory (9Byte)
  ds.read_bytes(data, 9); //data comes from DS and are saved into buffer data[8]
  //---------------------------------

  int16_t raw = (data[1] << 8) | data[0]; //---data[0] and data[1] contains temperature data : 12-bit resolution-----
  celsius = (float)raw / 16.0;  //12-bit resolution
  Serial.println(celsius);
  digitalWrite(4, HIGH); //MEGA ON
  delay(3000);
  
}
Title: Re: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: jackthom41 on Dec 15, 2018, 06:19 am
Connection Diagram (repeated) among MEGA, ESP, and DS18B20
I don't think there's any need to use Arduino Pro Mini or Mega, as the above member said it's really a redundant. Instead interface 18B20 with NodeMCU (https://www.theengineeringprojects.com/2018/10/introduction-to-nodemcu-v3.html) directly and upload data to some server via ESP8266 (https://www.theengineeringprojects.com/2018/08/introduction-to-esp8266.html). If you need help with the code, let me know I'll help you out.
Title: Re: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: GolamMostafa on Dec 15, 2018, 11:44 am
I don't think there's any need to use Arduino Pro Mini or Mega, as the above member said it's really a redundant.
If you really want to do this just as a pointless intellectual exercise, OK, but don't show it to your mother.
As @Nick_Pyner has nicely remarked that the project could be an intellectual exercise for the OP; it is not my project; I am just along with the journey of OP.
Title: Re: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: jackthom41 on Dec 15, 2018, 04:39 pm
As @Nick_Pyner has nicely remarked that the project could be an intellectual exercise for the OP; it is not my project; I am just along with the journey of OP.
Oh my bad, I didn't read that before ..... :D

In that case you should try PIC Microcontroller too .... :P
Title: Re: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: GolamMostafa on Dec 15, 2018, 05:03 pm
In that case you should try PIC Microcontroller too .... :P
Does Arduino IDE support PIC MCUs?
Title: Re: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: jackthom41 on Dec 17, 2018, 03:14 pm
Does Arduino IDE support PIC MCUs?
For a pointless intellectual exercise, we can test it as well ....
Title: Re: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: Nick_Pyner on Dec 17, 2018, 04:33 pm
Indeed... you might as well...
Title: Re: ds18b20 + arduino pro mini 5v + ESP8266 3.3v
Post by: jackthom41 on Dec 17, 2018, 04:50 pm
Indeed... you might as well...
Hmmmm but why am I getting a feeling that you will never ..... :P

You should keep trying new things ....