Go Down

Topic: ds18b20 + arduino pro mini 5v + ESP8266 3.3v (Read 1 time) previous topic - next topic

superJj

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? 

Nick_Pyner

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.

superJj

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?

GolamMostafa

#3
Dec 13, 2018, 05:37 pm Last Edit: Dec 13, 2018, 05:42 pm by GolamMostafa
@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.


MEGA Serial Monitor:


ESP Serial Monitor:


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

Nick_Pyner

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.

superJj



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!

GolamMostafa

#6
Dec 15, 2018, 05:50 am Last Edit: Dec 15, 2018, 05:52 am by GolamMostafa
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


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);
  
}

jackthom41

#7
Dec 15, 2018, 06:19 am Last Edit: Jan 21, 2019, 03:03 am by jackthom41
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 directly and upload data to some server via ESP8266. If you need help with the code, let me know I'll help you out.
Technopreneur

GolamMostafa

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.

jackthom41

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
Technopreneur

GolamMostafa

In that case you should try PIC Microcontroller too .... :P
Does Arduino IDE support PIC MCUs?

jackthom41

Does Arduino IDE support PIC MCUs?
For a pointless intellectual exercise, we can test it as well ....
Technopreneur

Nick_Pyner


jackthom41

#13
Dec 17, 2018, 04:50 pm Last Edit: Dec 17, 2018, 04:51 pm by jackthom41
Indeed... you might as well...
Hmmmm but why am I getting a feeling that you will never ..... :P

You should keep trying new things ....
Technopreneur

Go Up