Jump to content
Sign in to follow this  
L293D

[Energia Library] LadyAda's DHT Library Ported

Recommended Posts

Hi,

 

Work great with DHT11 and DHT22 both on the MSP430G2553 and MSP430G2452.

I am planning to build some kind of weather stations remote sensors using cheap On-Off Keying 433 MHz modules.

I will try to port VirtualWire library but perhaps starting from scratch will be easier for what I need.

I will publish my work as soon as it is "usable".

 

Yan.

Share this post


Link to post
Share on other sites

I've built a climate control station featuring: temperature, relative humidity, pressure, light and clock.

 

Everything with only 2 wires thanks to I2C. It works on Arduino, Wiring and chipKIT platforms.

 

I haven't ported yet to Energia.

Share this post


Link to post
Share on other sites

Well that's impressive.

As pressure sensors are expensive I will not offer them at first.

It is not fixed yet but what I think is to have :

- one wireless sensor using DHT22 + MSP430G2452 + 433MHz TX

- one "weather station" with one local DHT22 + 433MHz RX + LCD + Ethernet. The controller should be an Arduino nano because it has 1ko EEPROM to do some statistics and 1ko of SRAM enough to run a small web server for accessing the measurements.

I'd like to keep things rather cheap so many people can start to play with it learning how to program micro-controllers. Code will be open to owners and well commented (I hope)...

 

It will be the base for another professional project with a friend who want to supervise some kind of "factory" with sensors connected to several Arduino/Launchpad and a Raspberry Pi as server for logging and statistics...

 

Yan.

Share this post


Link to post
Share on other sites

For an inexpensive installation, why not consider a MCU with a built-in RF?

 

There is the CC2511F32 from TI used by the Wixel from Pololu.

 

0J3343.200.jpg?9fbdd6ec7ce52a900fc8068cb

Another option is the new ZigBee RF BoosterPack by Anaren based on an CC2530.

 

boosterpack_kit.jpg

 

Good luck with your project :smile:

Share this post


Link to post
Share on other sites

Hi I am buying monodirectional 433 MHz RX + TX pairs at cheap price in Hong Kong. Real usable bandwidth is around 2kbps, enough for a sensor.

2,4 GHz bidirectional pairs of modules are a little bit more expensive and offer up to 2Mbps bandwidth but I have not tested them already...

 

A+,

Yan.

Share this post


Link to post
Share on other sites

Hi Rei Vilo,

 

There is a small error in the example. It tells :

if (isnan(t) || isnan(h)) {    Serial.println("Failed to read from DHT");

However in case of error the library returns 0 (not false) and 0 is an number so the "Failed to read" is neither reached...

So I replaced the conditions by

t == 0 && h == 0
since Temp could be 0 but humidity never and both showing 0 is nearly impossible under the sensor specs.

 

Yan.

Share this post


Link to post
Share on other sites

I dont know how NaN works in the arduino library, but if it is anything like how it works in javascript it should work fine. NULL not being a number, or 'a' also not being a number( depending on how you use the char value).

Share this post


Link to post
Share on other sites

Bonjour xv4y !

 

Actually, I didn't develop the library for the DHT11.

 

For the DHT22, there is one function to acquire temperature and humidity, which returns true for success and false for error:

 

 

  ///
  /// @brief Acquire temperature and humidity
  /// @return true=success, false=error
  /// @note sensor frequency = 0.5 Hz
  ///
  boolean get();

 

In case of success, the temperature and relative humidity are obtained by the specific functions

 

 

 

  ///
  /// @brief Temperature in Celsius
  /// @return return temperature x 10 to avoid float
  /// @code {.cpp}
  /// Serial.print(temperatureX10()/10, DEC); // integer part
  /// Serial.print(".");                      // decimal separator
  /// Serial.print(temperatureX10()%10, DEC); // decimal part
  /// @endcode
  ///
  int32_t temperatureX10();
  
  ///
  /// @brief Relative humidity in %
  /// @return return relative humidity x 10 to avoid float
  /// @code {.cpp}
  /// Serial.print(humidityX10()/10, DEC); // integer part
  /// Serial.print(".");                   // decimal separator
  /// Serial.print(humidityX10()%10, DEC); // decimal part
  /// @endcode
  ///
  int32_t humidityX10();

 

Implementing the same logic for the DHT11 is easy.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×