Go Down

Topic: [SOLVED} Is there a library for DHT22 sensor and a tiny 85 with software serial (Read 5632 times) previous topic - next topic

Docedison

For the DHT22 sensor and a tiny 85?  or an 84 and software serial.. Too?
By way of explanation I have a handful of BT's, 84's and 85's and DHT22's and I'd like to make remote temp and RH measurements.
low power things will come after I get the basics working to my satisfaction.
Being lazy clever I thought why not, the combination seems made in heaven.. so far...
just enough pins on a tiny 85 to control the radio power the sensor and the serial output.. Simple.

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Erni

#1
Jun 27, 2013, 12:03 pm Last Edit: Jun 27, 2013, 12:53 pm by Erni Reason: 1
This seems to work?

http://forum.arduino.cc/index.php?topic=124457.0

Update:

I got curious and tried it out, and it works as it should on a ATtiny85

Docedison

@ Erni... Thank You Sir it worked a charm... The DHT22 version worked very nicely. While I don't yet have the radio's connected, the control and sleep functions written yet, this code worked first time... Well almost.
I bought myself a Saleae logic for my B'day and it was great to see the device being read and the serial data returned accurate to .5 Deg. My error was a typo where I tried to set the baud rate to 9800 baud.
Thank You robtillaart for a fine library (class)
Code: [Select]
//  File name ATtiny_DHT22_BT_2.ino
//  FILE:  dht_test.pde  Author: Rob.Tillaart@gmail.com
//  PURPOSE: DHT library test sketch for Arduino
//  Re-PURPOSED for:  Outside DHT22 Temperature and Humidity remote radio operated
//  Modified to work with a Tiny 84 or 85 Tiny 85 and Maniacbug's RF24 class or
//  A pair of OOK 315 MHz transmitters or *(BlueTooth)* or RFM12 - 22
//  At this time (06/09/2013)... None is a requirement, what is required however
//  is that it fit in an 8K controller and work for 2 or 3 month's of substandard
//  solar charging on a 2800 mAH lithium cell and a 1/2 watt 6V solar cell
//
//  This code mercilessly hacked by Robert K. Johnson Sr.
//  6/09/2013 The goal here is to couple this to a Tiny 84 or 85
//  sleeping for 2 minutess and then wake up measure temp and humidity and transmit it.
//  Notes:
//  change instances of DHT22 to DHT11 for DHT11 sensor
//  Initially the program will output 9600 baud serial for transmission by a BT radio
//  Begin 06/09/2013 Last Edit 06/28/2013
//
//
//
//
//
//
//  This code is thoroughly in the public domain Do with it what you please
//  this is a small piece of the final code and works quite well.
/*************************(Begin Program)*****************************/
#include "dht.h"
#include <SoftwareSerial.h>
dht DHT;
const int rx=3;
const int tx=1;
SoftwareSerial BTserial(rx,tx);
#define DHT22_PIN 2
/************************************************************************/
void setup()
{
  // Serial.begin(9600);
  pinMode(rx,INPUT);
  pinMode(tx,OUTPUT);
  BTserial.begin(9600);  //Begin BT serial comms
  BTserial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");  // Remove, unnecessary   TODO
}
/**************************************************************************/
void loop()
{
  // READ DATA
  BTserial.print("DHT22, \t");
  int chk = DHT.read22(DHT22_PIN);

  // transmit DATA
  BTserial.print(DHT.humidity, 1);
  BTserial.print(",\t");
  BTserial.println(DHT.temperature, 1);

  //  Sensor shouldn't be checked more often than once every 1.5 seconds
  //  Use sleep to wake up every 2 minutess measure and report
  //  every 100 mS until 'ack'ed' by the receiving device

  delay(2000);  // Temp for test only replace with sleep code

}
//
//(*************************(END OF FILE)*************************)
//



Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

aarondc

Suggestion: change thread title to something like:

"Library for DHT22 sensor and a tiny 85 / 84 with software serial?"

emax2000

Please i get continuos checksum error from sensor and the value float, any ideas?
P. S.
I use a attiny84 device and dht11.

Go Up