Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[request] support for DS18B20 temp sensor #4

Open
keematic opened this issue Dec 23, 2014 · 10 comments
Open

[request] support for DS18B20 temp sensor #4

keematic opened this issue Dec 23, 2014 · 10 comments

Comments

@keematic
Copy link

Hi,

First of all, the homeduino plugin is working great for sending and receiving 433Mhz! Thank you.

I'd like to add more stuff to my pimatic installation, including a DS18B20 temp sensor. I see DHT11/22 sensors are included in the Homeduino support. Also, I noticed a DS18B20 plugin for pimatic. I wonder why there's a separate plugin?
I would love to connect my temp sensor to the arduino to keep it simple.

Thanks.

@sweetpi
Copy link
Contributor

sweetpi commented Dec 23, 2014

Do you have some programming skills? It shouldn't be hard to extend the sketch with DS18B20 support. If you submit a pull request for this. I will do the coffeescript part for pimatic.

@keematic
Copy link
Author

I have a bit of experience with Arduino code. I found the standard OneWire (http://playground.arduino.cc/Learning/OneWire) library.
Also some example code for the Dallas Temp sensor from http://milesburton.com/Dallas_Temperature_Control_Library#Example

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

void setup(void)
{
Serial.begin(9600);
sensors.begin(); // IC Default 9 bit.
}

void loop(void)
{ 
  sensors.requestTemperatures(); // Send the command to get temperatures  
}

I wish I could help, but I'm not familiar with HEX values, bits and other raw code.

@ronaldsteen
Copy link
Contributor

Hi,

I've just built the new functionality for this sensor. There's a pull request waiting :)
I'm also extending pimatic-homeduino and homeduinojs, so it should be easy to use for everyone.

Cheers,
Ronald

@tomansi
Copy link

tomansi commented Feb 17, 2015

Hi,

The DST command only read a first temperature on the 1-wire bus.

I suggest send the sensor number (0, 1, 2...) like that:

Example
Send: DST sensor_number
Responds with: ACK temperature_sensor_number.

Otherwise, the use of pins is confusing because the OneWire sensor needs to be connected to digital pin 2 and the digital pin 2 is also used as receiverPin (default), see https://github.com/pimatic/pimatic-homeduino/blob/development/pins-nano.png in https://github.com/pimatic/pimatic-homeduino.

Ideal solution would be to send the bus on command and so could be used more than one bus (I use really two because the number of sensors and the long distance is a limit to use a 1-wire).

In this case the example will be:
Send: DST sensor_number bus_pin ..... (or bus_number if is necessary fix the pin)
Responds with: ACK temperature_sensor_number.

Regards...
and apologize for my poor English.

@ronaldsteen
Copy link
Contributor

Hi,

Thanks for your feedback.

Configurable pins in the command requires quite some changes. I might do
that on the longer term.

Including the sensor number is easier, but I don't know if they're always
in the same order, each time the arduino boots.
Using addresses might be more robust, but harder. You'll need to figure out
addresses first..

What do you think?

Cheers,
Ronald

On wo 18 feb. 2015 at 00:15 tomansi [email protected] wrote:

Hi,

The DST command only read a first temperature on the 1-wire bus.

I suggest send the sensor number (0, 1, 2...) like that:

Example
Send: DST sensor_number
Responds with: ACK temperature_sensor_number.

Otherwise, the use of pins is confusing because the OneWire sensor needs
to be connected to digital pin 2 and the digital pin 2 is also used as
receiverPin (default), see
https://github.com/pimatic/pimatic-homeduino/blob/development/pins-nano.png
in https://github.com/pimatic/pimatic-homeduino.

Ideal solution would be to send the bus on command and so could be used
more than one bus (I use really two because the number of sensors and the
long distance is a limit to use a 1-wire).

In this case the example will be:
Send: DST sensor_number bus_pin ..... (or bus_number if is necessary fix
the pin)
Responds with: ACK temperature_sensor_number.

Regards...
and apologize for my poor English.


Reply to this email directly or view it on GitHub
#4 (comment).

@tomansi
Copy link

tomansi commented Feb 18, 2015

Hi, thanks for your kind reply.

I think you can make many improvements and make them as different possibilities.

1.- Simple solution
Attached sensors to a 1-wire bus are always read in the same order. This is true while the addresses of the sensors do not change.
Therefore, the easy and fast solution is:
When the arduino setup it sends message with the sensors numbers and their address (for information only). This arduino code will be like this:

  //Serial.print("Locating DS18B20 devices...");
  sensors.begin();

  DeviceAddress sensor_address;
  int numberOfDevices = sensors.getDeviceCount();
  Serial.print("Found ");Serial.print(sensors.getDeviceCount(), DEC);Serial.print(" devices.\r\n");

  Serial.print("Parasite power is: ");   // report parasite power requirements
  if (sensors.isParasitePowerMode()) Serial.print("ON\r\n");
  else Serial.print("OFF\r\n");

  for(int i=0;i<sensors.getDeviceCount(); i++)
  {
    sensors.getAddress(sensor_address, i);
    for (uint8_t i = 0; i < 8; i++)
    {
      if (sensor_address[i] < 16) Serial.print("0");
      Serial.print(sensor_address[i], HEX);
    }
    Serial.print("\r\n");
  }

Request the value of each sensor by sensor number. (ie. DST number_sensor)

Disadvantages: When new sensors are included or change any of them, we need to manually update the file config.json.

2.- One more step.
Addresses are configured in config.json and sensors are read by sending the address as a parameter.

It's a robust solution.

3.- Add others 1-wire bus.
It's a possibility but it is not necessary for most.
For future development or special needs should be reserved the second parameter to indicate the bus.

Finally, I worry about the pins used. I quote what I said above:

Otherwise, the use of pins is confusing because the OneWire sensor needs to be connected to digital pin 2 and the digital pin 2 is also used as receiverPin (default), see https://github.com/pimatic/pimatic-homeduino/blob/development/pins-nano.png in https://github.com/pimatic/pimatic-homeduino.

To avoid confusion, I propose that the pin 2 is not used for 1-wire. (12 could be).

Kind regards!

@ronaldsteen
Copy link
Contributor

Hi tomansi,

Thanks for your detailed reply. I'll give it a try tonight. Changing the
pin is a no-brainer, I'll do that right away.

It's also fine by me if you contribute code to the repository directly.

@pimatic: Maybe we can get a branch with write access to do this?

Cheers,
Ronald

On Wed Feb 18 2015 at 12:51:13 PM tomansi [email protected] wrote:

Hi, thanks for your kind reply.

I think you can make many improvements and make them as different
possibilities.

1.- Simple solution
Attached sensors to a 1-wire bus are always read in the same order. This
is true while the addresses of the sensors do not change.
Therefore, the easy and fast solution is:
When the arduino setup it sends message with the sensors numbers and their
address (for information only). This arduino code will be like this:

//Serial.print("Locating DS18B20 devices...");
sensors.begin();

DeviceAddress sensor_address;
int numberOfDevices = sensors.getDeviceCount();
Serial.print("Found ");Serial.print(sensors.getDeviceCount(), DEC);Serial.print(" devices.\r\n");

Serial.print("Parasite power is: "); // report parasite power requirements
if (sensors.isParasitePowerMode()) Serial.print("ON\r\n");
else Serial.print("OFF\r\n");

for(int i=0;i<sensors.getDeviceCount(); i++)
{
sensors.getAddress(sensor_address, i);
for (uint8_t i = 0; i < 8; i++)
{
if (sensor_address[i] < 16) Serial.print("0");
Serial.print(sensor_address[i], HEX);
}
Serial.print("\r\n");
}

Request the value of each sensor by sensor number. (ie. DST number_sensor)

Disadvantages: When new sensors are included or change any of them, we
need to manually update the file config.json.

2.- One more step.
Addresses are configured in config.json and sensors are read by sending
the address as a parameter.

It's a robust solution.

3.- Add others 1-wire bus.
It's a possibility but it is not necessary for most.
For future development or special needs should be reserved the second
parameter to indicate the bus.

Finally, I worry about the pins used. I quote what I said above:

Otherwise, the use of pins is confusing because the OneWire sensor needs
to be connected to digital pin 2 and the digital pin 2 is also used as
receiverPin (default), see
https://github.com/pimatic/pimatic-homeduino/blob/development/pins-nano.png
https://github.com/pimatic/pimatic-homeduino/blob/development/pins-nano.png
in https://github.com/pimatic/pimatic-homeduino
https://github.com/pimatic/pimatic-homeduino.

To avoid confusion, I propose that the pin 2 is not used for 1-wire. (12
could be).

Kind regards!


Reply to this email directly or view it on GitHub
#4 (comment).

@tomansi
Copy link

tomansi commented Feb 18, 2015

I forgot to mention that I can not find where to set the interval data read.

pimatic-homeduino

DST Dallas DS18B20 sensor example:

{
  "id": "homeduino-temperature-dst",
  "name": "DST",
  "class": "HomeduinoDSTSensor"
}

and may also set other attributes of the class (precision 9, 12 bits ...) see example (include processing to correct a value):

   "attributes": [
     {
       "name": "temperature"
       "unit", "ºC"
       "label": "Temperature"
       "precission": 12,
       "interval": 20000,
       "processing": "($ value / 10) + 1.5"
     }

(edited to add)
... and also if the value is Celsius or Fahrenheit

@tomansi
Copy link

tomansi commented Feb 19, 2015

Hi Ronald,

I have some skills in arduino but I haven't coded anything in js
(coffescript & others). Also, I am a newbie in Github.
And finally I am not English-speaking and put across is harder for me.

But I would work for this project because I think is excellent.

My first propose file change is about locales (es.json is a year old, only
83/216 lines translated). I think I sent the file but I'm not sure. Can you
check this? (https://github.com/tomansi/pimatic/blob/master/locales/es.json).

I am writing about DS18B20 post.

I will answer asap.

Kind regards!

2015-02-18 13:16 GMT+01:00 Ronald [email protected]:

Hi tomansi,

Thanks for your detailed reply. I'll give it a try tonight. Changing the
pin is a no-brainer, I'll do that right away.

It's also fine by me if you contribute code to the repository directly.

@pimatic: Maybe we can get a branch with write access to do this?

Cheers,
Ronald

On Wed Feb 18 2015 at 12:51:13 PM tomansi [email protected]
wrote:

Hi, thanks for your kind reply.

I think you can make many improvements and make them as different
possibilities.

1.- Simple solution
Attached sensors to a 1-wire bus are always read in the same order. This
is true while the addresses of the sensors do not change.
Therefore, the easy and fast solution is:
When the arduino setup it sends message with the sensors numbers and
their
address (for information only). This arduino code will be like this:

//Serial.print("Locating DS18B20 devices...");
sensors.begin();

DeviceAddress sensor_address;
int numberOfDevices = sensors.getDeviceCount();
Serial.print("Found ");Serial.print(sensors.getDeviceCount(),
DEC);Serial.print(" devices.\r\n");

Serial.print("Parasite power is: "); // report parasite power
requirements
if (sensors.isParasitePowerMode()) Serial.print("ON\r\n");
else Serial.print("OFF\r\n");

for(int i=0;i<sensors.getDeviceCount(); i++)
{
sensors.getAddress(sensor_address, i);
for (uint8_t i = 0; i < 8; i++)
{
if (sensor_address[i] < 16) Serial.print("0");
Serial.print(sensor_address[i], HEX);
}
Serial.print("\r\n");
}

Request the value of each sensor by sensor number. (ie. DST
number_sensor)

Disadvantages: When new sensors are included or change any of them, we
need to manually update the file config.json.

2.- One more step.
Addresses are configured in config.json and sensors are read by sending
the address as a parameter.

It's a robust solution.

3.- Add others 1-wire bus.
It's a possibility but it is not necessary for most.
For future development or special needs should be reserved the second
parameter to indicate the bus.

Finally, I worry about the pins used. I quote what I said above:

*Otherwise, the use of pins is confusing because the OneWire sensor needs
to be connected to digital pin 2 and the digital pin 2 is also used as
receiverPin (default), see

https://github.com/pimatic/pimatic-homeduino/blob/development/pins-nano.png
<
https://github.com/pimatic/pimatic-homeduino/blob/development/pins-nano.png

in https://github.com/pimatic/pimatic-homeduino
https://github.com/pimatic/pimatic-homeduino.*

To avoid confusion, I propose that the pin 2 is not used for 1-wire. (12
could be).

Kind regards!


Reply to this email directly or view it on GitHub
#4 (comment).


Reply to this email directly or view it on GitHub
#4 (comment).

@keematic
Copy link
Author

Hi guys,

I've been reading along. Good to see progress in supporting DS18B20 sensors in homeduino! How far is the development doing now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants