DHT22 with sound alert Arduino


After testing Dht11 temperature and humidity sensor I thought why not try with the next one which is high quality and can get the measurement more precisely. And that is DHT22/AM2302 Temperature Humidity Sensor. Let me give you some specification of it then I'll go for the sketch and at end give you some explanations.

Ads

Specification of DHT22/AM2302:
  • Type: AM2302
  • Accuracy resolution: 0.1
  • Humidity range: 0-100%RH
  • Temperature range: -40~80℃
  • Humidity measurement precision: ±2%RH
  • Temperature measurement precision: ±0.5℃
  • 4-pin package
  • Ultra-low power
  • No additional components
  • Excellent long-term stability
  • All calibration, digital output
  • Completely interchangeable
  • Long distance signal transmission
  • Relative humidity and temperature measurement
What does the sketch do?
If you can successfully upload the sketch to your Arduino broad then it will measure the temperature and humidity. And on the certain degree (which ever you set) it will turn on the LEDs and at same time it will give you a sound alert (what ever audio file you've saved) so that you can hear without looking at it.

The sketch

#include <SoftwareSerial.h>
#define ARDUINO_RX 10 //should connect to TX of the Serial MP3 Player module
#define ARDUINO_TX 9 //connect to RX of the module
SoftwareSerial mySerial(ARDUINO_RX, ARDUINO_TX);
static int8_t Send_buf[8] = {0} ;

#define CMD_SEL_DEV 0X09
#define DEV_TF 0X02
#define CMD_PLAY_W_VOL 0X22
#include <dht.h>
dht DHT;
#define DHT22_PIN 2
int led1 = 3;
int led2 = 4;

void setup()
{
  mySerial.begin(9600);
  Serial.begin(9600);
  Serial.println("DHT TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");
  Serial.println(DHT_LIB_VERSION);
  Serial.println();
  Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");

pinMode (led1,OUTPUT);
pinMode (led2,OUTPUT);
delay(500);//Wait chip initialization is complete
        sendCommand(CMD_SEL_DEV, DEV_TF);//select the TF card
delay(200);//wait for 200ms
}

void loop()
{
  // READ DATA
  Serial.print("DHT22, \t");
  int chk = DHT.read22(DHT22_PIN);
  switch (chk)
  {
    case DHTLIB_OK:
        Serial.print("OK,\t");
        break;
    case DHTLIB_ERROR_CHECKSUM:
        Serial.print("Checksum error,\t");
        break;
    case DHTLIB_ERROR_TIMEOUT:
        Serial.print("Time out error,\t");
        break;
    default:
        Serial.print("Unknown error,\t");
        break;
  }
  // DISPLAY DATA
  Serial.print(DHT.humidity, 1);
  Serial.print(",\t");
  Serial.println(DHT.temperature, 1);

if (DHT.humidity >60){
   digitalWrite (led1, HIGH);
   sendCommand(CMD_PLAY_W_VOL, 0X1E002); //play the sound track
   delay(4000); // length of the sound track
 } else {
      digitalWrite (led1, LOW);
 }

  if (DHT.temperature >24){
   digitalWrite (led2, HIGH);
   sendCommand(CMD_PLAY_W_VOL, 0X1E001); //play the sound track
   delay(4000); // length of the sound track
 } else {
      digitalWrite (led2, LOW);
 }

  delay(1000); //set how much time you want between readings
}

void sendCommand(int8_t command, int16_t dat)
{
  delay(20);
  Send_buf[0] = 0x7e;
  Send_buf[1] = 0xff;
  Send_buf[2] = 0x06;
  Send_buf[3] = command;
  Send_buf[4] = 0x00;//0x00 = no feedback, 0x01 = feedback
  Send_buf[5] = (int8_t)(dat >> 8);//datah
  Send_buf[6] = (int8_t)(dat); //datal
  Send_buf[7] = 0xef; //ending byte
  for(uint8_t i=0; i<8; i++)//
  {
    mySerial.write(Send_buf[i]) ;
  }
}
//
// END OF FILE
//

Note:
You may need few files in the Arduino library so that this sketch can work properly. You can get it from http://playground.arduino.cc/Main/DHTLib. Once you go there you will find a sketch and one dht.h and dht.cpp grab those two files and put it in a folder and call that folder DHT and then put that folder in the Arduno libraries folder. Anyways, this post is combination of my other two other posts DHT11 and Catalex MP3 player  if you find this post hard to understand then please have a look at those two posts first I've explained it in detail.

Things you need:
  • 2x LEDs
  • Catalex mp3 player
  • 1x 10k ohm resistor
  • 1x speaker
  • Adruino board
  • 1x DHT22
  • 1x micro sd card with sound files named 001and 002
That's all I think, I hope it helps you. And special thanks to icstation.com for providing me DHT22 and they have got so many other interesting things about Arduino. If are interested then please have a look at their site you might as well like it. http://www.icstation.com/dht22am2302-digi-temperature-humidity-sensor-p-1469.html


Tags:
Temperature And Humidity, Arduino Humidity, digital temperature humidity sensor, humidity and temperature sensor. 
 Ads



Facebook is not showing comments on the right place


Ads

I don't really know if I'm the only one who is experiencing this problem or you as well going through the same.

Well, recently I have noticed that when I log in to Facebook (happened only on mobile devices) and click any of the news feed comments, then the comments are shown at the bottom of the page with the last post.

That's kind of very weird when it doesn't match with the post above them and make you think crazy. :(
After finding the solution I thought why not share with you so that it might make life much easier. :)

Solution:
It's simple, you can either set the browser as Desktop version or click on the comments and hold it for a second then click Open in new tab.

Note:
I've noticed this problem with Android tablet and Samsung S5 mini.

That's all, I hope it helps you.

Ads



Best text to speech app I've ever found


If you have reach here by searching then you probably don't like to  reading much, and you are right how much can a person read. Well, nowadays people are too busy in social media sites and apps, and don't have time to read much particularly when you see a wall of text front of you.

So in this post I'll show you an android app which is really helpful and I have used it myself and found amazing. The app is called @Voice Aloud Reader. 1 million downloads! If the app is not good enough then why would hundreds of thousands of people download it?

Ads
Helpful features:
  • After opening the app if you go to any website and just copy any text it will automatically read it out loud for you.
  • You can save the text as an audio format.
  • After opening the app if you go to google and search something then click on the link and copy it, it will read the whole page (the link you tried to go).
  • You can save links to hear them afterwards.
  • You can listen to full page.
  • Well, there are some more features but these are the most useful I thought which you might need quite often.
How can you hear the full page?
First go to the page that you want to listen to. Then click on the menu (3 dots) >> Then click Share after that you will see two icons of @Voice Aloud Reader. One for add to the list to listen to it afterwards and another is to listen to it straight away, choose which ever you would like to do.

How to save the text as an audio?
If you want t save the texts as an audio file then >> Open the app >> click on the menu (3 dots) >> click Record sound file >> Check the box says Record sound file the next time I press the "Play" button. That's it, now if you go back and press the "Play" button it will make all the texts in one audio file.

I hope this helps you and if it does then feel free to share this. Thanks

Ads



Will Li-Fi be available everywhere and work?


After watching the video you probably thinking that how slow your Wi-Fi is and feeling very upset about it, and at the same time thinking how crap the Wi-Fi is against the Li-Fi. Well, in the reality it is not like that. Of course there are some  good sides about the Li-Fi but there are some good sides of Wi-Fi too, and that is what I want to talk about in this post.

Li-Fi vs Wi-FI
Speed:
Of course in this case Wi-Fi is no way near to Li-Fi.

Connectivity through the wall:
Li-Fi can't transfer data through walls so in this case Wi-Fi gets wins.

Public internet connectivity:
People are saying that in the future they want Li-Fi to be in public places. Well, as you have seen in the video that to transfer data from your mobile phone to Li-Fi you have to have a receiver and emitter (in this case a light). So for example if you want to download a youtube video so you send a request to the Li-Fi, but it won't be able get the request until you show your emitter (light) towards the direction of Li-Fi receiver. How many times would you do that? How odd it will look if everyone start showing light towards the sensor. But with the Wi-Fi you can send a request and download the video even from inside your pocket.

Internet of Things
At the end of the video above you probably have seen that he's trying to say that in the future people will try to connect almost everything with Li-Fi. Well, what I'm thinking is that people are not that stupid, specially who wants to connect bridge sensors with Li-Fi? First of all you don't need lighting speed to get few kb or mb of data to the sensor and another thing is that the Li-Fi receiver will get dirty for staying outside and once it gets covered by dust or so it will stop receiving any data. It's better to use radio transceiver for this and not Li-Fi. To getting smart is good but to getting over smart is foolish (like Google glass, where are they now?).

Security:
He said that Wi-Fi sends radio waves through the wall so it's easily picked up by others and that's why it's not safe. Well, I think he forgot to mention that you can put password on it and there is something called encryption and decryption. If you send something via Wi-Fi encrypted then no one can find out untill they have the right decrypting software. And same thing goes to Li-Fi so in this one I think both are same.

My final thought about Li-Fi:
Only thing I liked about Li-Fi is the speed, other than that I haven't found any good use of it til now. The guy in the video might have made you think that Li-Fi is best, because that's how he gets more views and subscribers and therefore more money. Remember if you get something in a nice expensive box that doesn't mean that the object inside the box will be always nice and expensive. Please don't get me wrong, of course he must have done good research on it but I just can't agree everything what he said.

One more thing I would like to say (which seems that guy clearly doesn't know is) that Radio waves (which Wi-Fi uses) and Light travel as the same speed. So slowness of Wi-Fi is for some other factors.




Why should you see criticism positively


I know it is hard to take criticism positively but in this post I will share a story with you which might change your mind about that.

This is a story about a well known celebrity in Bangladesh, his name is Hero Alom (real name Ashraful Hossen Alom). He came from a poor family and because of his financial problem he couldn't study much and started working. And after some time he started selling and renting song and movie CDs/DVDs. But that didn't go for long and the DVD business started going down so he started (small) satellite dish business.

The business was going quite well until a video song producer came to his village to shoot a video song. And Hero Alom got inspired by that and thought why not start making video songs. So he started making video songs on his own and started showing them to local people through his his dish channel.

He made more than 500 video songs here are few of them.





As you probably guessed it, most people didn't take him seriously because he didn't have much knowledge about acting and his looks and other stuff wasn't up to the standard as people think. So people (specially youngsters) started  dissing him and sharing his videos on YouTube, Facebook and other social media sites and that's how he became popular in short period of time.

So once he became famous and popular people and even big big companies started coming to him to interview him and offering to work with them. Now he kind of super star in Bangladesh and a very busy actor.

Note:
Because people disliked him at the beginning and shared his videos as a joke and he got popularity by that, and once he became famous many people came to rescue and started liking him. And now he is one of the successful actor.  So work hard to reach your goal no matter what people say and the success will be yours at the end.




Apple launched a book costs $300


Well, I thought it was a joke but Apple really launched a book with just the photos of their products costs about $300.00 and people are getting crazy about the price. Read the comments and I hope you will like it.

*I think the Apple employees have a challenge amongst themselves as to who can sell the most useless shit for the highest price. And we might just have a winner here.

*Apple can sell horse shit wrapped in white paper and these idiots would pay $300 for it. this is more than ridiculous.

*iKids will still support this product and say things like "This is the most innovative product the world has ever seen" *claps*

*Bad news for book publishers. Apple will probably patend the rectangular shape and the concept of stacking sheets of paper into a device that will unfold from one side and will have pictures and/or text printed on them.

*Apple can even sell a pen-pineapple-apple-pen for $500.

*And girls will be Like- Aww I need this in my college course.

 *Now the people who get this book will have to buy description pages again.

Well, it seems like someone even came to justify.
*Stupid people that doesn't t realise what is for. Have you ever step into a library? I see nobody complaining about B&O doing the same thing years ago.

Anyway I hope you enjoyed it and if you are an iPhone user then please don't get angry because the comments I've collected are just for fun.



Did you know that you can find all the pictures on the internet and you don't even need to spend $1?


Your password front of everyone but no one can find out

Ads

As you know that nowadays we have got many accounts in many social media sites or even other sites where we have to use our user names and passwords, but how many passwords can you remember? If you have to remember 10 different passwords then of course you will get mixed up. But don't worry we've found the solution here. You can even send secret messages to friends and families and no one will ever find out what you have sent beside the person who know the main password. So you just need remember one password to find thousands of passwords.

How does it work?
It's just a Java script which encrypt the text into numbers according to password you put.

What to do?
If the iframe works in your browser (if not click here) then you will see 3 boxes .
  • First box, make your own password which you can remember all the time
  • Second box, in this box you write message or what ever you want to encrypt but remember to make the box clear of any text before writing. 
  • Third box, this is the box you will get the encrypted texts or you put encrypted texts to make it normal text.
  • Once you've done with first and second box click on the Encrypt button.
Note:
Remember you should never put your full real password to any unauthorised website including the website below.


Can you make it desktop version?
Well, yes you can by downloading the Java script and making a HTML file on your desktop then you will be able to use it without the internet.
Ads



This is why you should spend some times with your loved ones


Nowadays we waste so much time on social media and don't try to give a little bit of time with our loved one. Hopefully we can take a lesson from the video.

Comments:
*That's why I tell my loved ones I love them all the time, cause in a blink of the eye life can change for the worse. Life is a honor, and gift. Appreciate them when they still have breath in them.

*Indeed sham thanks for sharing this, hope Someone watched this and realized value of their life and love ones.

*Heart touching video. You really express in your videos that how our society behaves today. I appreciate you about your work against all these immoral behaviours.

*Exactly right. Never know what's gonna happens in next moment. Show your love to who you care for. Laugh, love and have fun with them. Change yourself if it's hard for you to show your love. Otherwise you will regret afterwards.

*Don't avoid at your family's need. When they ask you something nice, don't avoid at this. Family are important first. Not himself.

*Life is very short to worry about other things instead being with ur loved ones and treasure them while u are alive and it is very sad for what has happen.

Why you shouldn't plug anything and everything to your electronic devices

Ads

You probably already know if not than now you'll know that there is device called "USB Killer" which can kill your electronic devices like computer, laptop, phone TV and so on in matter of seconds.

How does it work?
Well, although it looks like normal USB (flash driver) but it doesn't have any memory in it, instead it has high voltage capacitors and some other stuff which step up the low (5v which the usb gets from the device) voltage to more than 200 volts (it depends how it made) and then sends that high voltage back to the device.

Why devices die?
It is quite obvious that when the high voltage current goes through the USB port it burns some of the components on the circuit board and then the whole system stops working.

Solution:
At the moment most of the electronic devices we see don't have protection against this killer usb built-in (in the future companies might add the protection feature) but in the meantime you can use USB adaptor which will hopefully protect your device.



Ads



How to play soundtracks from different folders in catalex mp3 player


I think I probably would not write this post if John Turcott did not ask me, so most of the things in this post will be dedicated to him but other people can get the idea too.
  • As far as I have understood from your (John Turcott) comment that you wanted to know how you can play sound from different folders (directories).
Answer: Well, you can do that by changing the code a bit which I will explain to you down below.
  • You've said something about changing names of the files like 001xxxxblablabla.mp3 which you might have found awkward.
Ans: Yes it is awkward for any human. We don't like numbers to short out files and we easily get mixed up with the files which one is which, but computers work differently than us. It's easier for computers to find/sort out stuffs with  numbers than letters and words so in that case I think we will just have to accept it unless someone comes up with any other way.

Ad

Note:
If you (other people) are new to catalex mp3 player and you looking for basic functions then please see my another post for that because over here I'm thinking not to go over them again.

Ok, now let's begin and start with the sketch.


#include <SoftwareSerial.h>
#define ARDUINO_RX 5//should connect to TX of the Serial MP3 Player module
#define ARDUINO_TX 6//connect to RX of the module
SoftwareSerial mySerial(ARDUINO_RX, ARDUINO_TX);
static int8_t Send_buf[8] = {0} ;
#define CMD_SEL_DEV 0X09
#define DEV_TF 0X02
#define CMD_PLAY_W_VOL 0X22
#define CMD_PLAY 0X0D
#define CMD_PAUSE 0X0E
#define CMD_PREVIOUS 0X02
#define CMD_NEXT 0X01


void setup(){
    mySerial.begin(9600);
      Serial.begin(9600);
      delay(500);//Wait chip initialization is complete
      sendCommand(CMD_SEL_DEV, DEV_TF);//select the TF card
      delay(200);//wait for 200ms
      sendCommand(CMD_PLAY_W_VOL, 0X0F01);//play the first song with volume 15 class
}

String str;
void loop() {
if(Serial.available()){
str = Serial.readStringUntil('\n');

if(str == "2"){
sendCommand(CMD_PLAY_W_VOL, 0X1E07);//play the 7th track with volume 30 class
Serial.println("Second sound track number 7 is playing.");
}

if(str == "3"){
sendCommand(CMD_PLAY_W_VOL, 0X1E99909);//play the third track with volume 30 class
Serial.println("Sound of a whale from folder number 999 file number 09.");
}

if(str == "4"){
sendCommand(CMD_PLAY_W_VOL, 0X1E1102);//play the forth track with volume 30 class
Serial.println("Sound of a bat from folder number 11 and file number 02.");
}

if(str == "ps"){
sendCommand(CMD_PAUSE, 0X0E);//pause the playing track
Serial.println("Pause");
}

if(str == "pl"){
sendCommand(CMD_PLAY, 0X0D);//play it again
Serial.println("Play");
}

if(str == "pr"){
sendCommand(CMD_PREVIOUS, 0X02);//play previous track
Serial.println("Playing previous track.");
}

if(str == "nx"){
sendCommand(CMD_NEXT, 0X01);//play next track
Serial.println("Playing next track.");
}
 }
}

void sendCommand(int8_t command, int16_t dat)

{

  delay(20);

  Send_buf[0] = 0x7e; //starting byte

  Send_buf[1] = 0xff; //version

  Send_buf[2] = 0x06; //the number of bytes of the command without starting byte and ending byte

  Send_buf[3] = command; //

  Send_buf[4] = 0x00;//0x00 = no feedback, 0x01 = feedback

  Send_buf[5] = (int8_t)(dat >> 8);//datah

  Send_buf[6] = (int8_t)(dat); //datal

  Send_buf[7] = 0xef; //ending byte

  for(uint8_t i=0; i<8; i++)//

  {
    mySerial.write(Send_buf[i]) ;
  }
}

As you can see the sketch is almost same as before beside only one thing, and that is you just need to change the folder number. I've tried with few folders 01, 02, 11, 99, and 999 as you can see in the picture at the top just to see how many folder can I add and it's seems like you can at least make 999 folders. And in every folder you can put 10 sound tracks, I've tried to add more than 10 but that didn't work.

Key notes:
  • Only 10 sound tracks in each folder.
  • After volume code *1E* add the folder number and then file number like this (0X1E99909) in this example 999 is a folder number and 09 is that sound track.
  • You might be able to make as many folder you wish but up 999 is for sure.
  • If you make folders and files like the picture at the top and upload this sketch to your Arduino you will be able to hear the sounds from different folders and text will appear on the serial monitor saying which track is playing currently.
  • Which ever song you play and which ever folder it's from all the functions (play, pause, previous, next) all will become automatically for that folder. For example if you play a song from folder 99 then you sent code for next so it will play the next song which you played from the folder number 99 recently.
That's all for this post, I hope it helps you.

Ad





Newly posted:
Reason why rich getting richer and poor getting poorer