Friday, 27 November 2015

Sketch for MQ-7 Carbon Monoxide Sensor

Right, in this post I'm going to share with you a Arduino sketch, by using the sketch you can get reading from the MQ-7 Carbon Monoxide Sensor and control many things as you like.

Before I share the sketch with you let me tell you what did I do when I got this sensor on my hand. Actually I bought this sensor by mistake. I wanted natural gas sensor which can detect the quality of the air so that it can tell me when the air gets polluted. Any way after getting this sensor I started looking for the sketch, so after some search I found a link on the Arduino website which was linked to another site, and when I clicked on it my Avast (antivirus software) didn't let me go (probably because of some kind of virus site). Then I have found another site with the sketch, but this time I didn't quite understand the sketch. So I opened my soil moisture sensor sketch and after making some changes I was able to get reading from this sensor, still I'm not sure how accurate is this but you can try it by yourself and have a look.

I think it works fine as I've tried it and got good result. :)

The sketch
int led = 5;
void setup() {
// initialize serial communication at 9600 bits per second:
 pinMode(led, OUTPUT);
 Serial.begin(9600);
}


void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);

if (sensorValue >=200){
Serial.println(sensorValue);
    digitalWrite(led, HIGH);
  }
  else {
Serial.println(sensorValue);
    digitalWrite(led, LOW);
  }
 
delay(500);
}

What does this sketch do?
Well, it measures level of the carbon monoxide in the air and turns the LED on when it reaches 200 or above. You can change it to what ever level you want and add more things to control with this sensor.

Things you need:
  • 1x MQ-7 Carbon Monoxide Sensor.
  • 1x Arduino board (in this case I've used Arduino Nano).
  • 1x LED.
  • 1x 10k Ohm resistor (just to make the LED a bit dimmer).
  • Few jumper wires.
Note:
This sketch gets readings twice a second if you want more then lower the number "delay(500);"
 according to your needs.

I hope this helps you. Thanks for reading. :)

Friday, 20 November 2015

Is trafficmsoon scam?


Well, don't get fooled by their adverts "Turn Your $10.00 Into $18.00 Every Hour" which is attention grabber and makes you fall into their trap, like I did. But luckily I didn't invest much in this seemingly scam site.

Let's see some evidence:
As you can see, I bought few adpacks here, two medium adpacks and one VIP Adpack on 2015-11-15, and even though they are different but growing up at the same rate, infact the top medium adpack is growing faster then VIP Adpack. Why is that? I thought you get more when your adpack amount is big, but over here something strange happening. I don't really know why.

Any way coming to the next question. They say "Turn Your $10.00 Into $18.00 Every Hour" but I've bought these adpacks on 15th November 2015 and today is 20th November 2015 and my $10.00 grew up to $0.13. wow, what a profit!!! I think their one hour must be our months or maybe years long.

It took 5 day to get $0.13 back then think about it, if it continues like this how long will it take to reach $18.00? well, if you divide 0.13 in 5 = 0.026 x 692= 17.992 It will take 692 days to reach $17.99 so do you call that one hour? When a company lies to its customers then that company is no longer trustworthy and reliable. Simple as that.

Before I was thinking 90% of this page (trafficmsoon) being scam, but now I'm 100% sure that this is a scam site. Let me give you another evidence. I posted this post link on the Facebook page of trafficmsoon and I told the admin not to delete the link (so that people know that trafficmsoon is not reliable) I even said to admin that if you delete this link that means you are really scammer, but he deleted the link and blocked me from commenting on that page.

If you have been fooled like me on any site like this, then please let know in comment below and help other people not to fall in any kind of trap like this. Thanks

Wednesday, 18 November 2015

Arduino doorbell with custom tunes and buttons


You might think what's so special about this doorbell.
Well, it might be not that special but think of it this way, you have three doorbell buttons and different tunes for each button. One is for your friends and family, one is for postman and one is for normal people.
Every time when postman comes he pushes the dedicated button, you will know that that's a postman, because of the different sound it (arduino doorbell) will make. So for example, you got something coming by post, you will be happy and rush to the door to open it.
Ad

You might aswel think what if post man hits the other button?
Com on, most of the time people don't play around like that, specially adults. So that means you will get the right kind of doorbell sounds most of the time.

Forget the doorbell for a moment, you can even use this sketch as a door or window alert. Something like if someone opens a door or window then it will notify you which door is open or which window is open. So this sketch could be helpful in many ways.

What do you need to make it work?
* 1× Arduino board.
* 1× Catalex Serial mp3 player with micro sd card.
* 3× Push button switches.
* 3× 10k ohm resistors.
* Some jumper wires.
* And finally the sketch, which you can find right below.
Note:
Remember you need to have three soundtracks in your sd card and rename it by 001, 002 and 003.

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

const int buttonPin1 = 8;
int buttonState1 = 0;

const int buttonPin2 = 9;     // the number of the pushbutton pin
int buttonState2 = 0;         // variable for reading the pushbutton status

const int buttonPin3 = 10;
int buttonState3 = 0;

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

     pinMode(buttonPin1, INPUT);
     pinMode(buttonPin2, INPUT);
     pinMode(buttonPin3, INPUT);
}

void loop() {
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
  buttonState3 = digitalRead(buttonPin3); 

  if (buttonState1 == HIGH) {
sendCommand(CMD_PLAY_W_VOL, 0X1E01);//This doorbell is for friends and family.
  }
 
else if (buttonState2 == HIGH) {
sendCommand(CMD_PLAY_W_VOL, 0X1E02);//This doorbell is for post men.
  }

else if (buttonState3 == HIGH) {
sendCommand(CMD_PLAY_W_VOL, 0X1E03);//This doorbell for is normal people.
  } 
}

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

That's all for this post, hopefully it helps you. :)

Ad


Wednesday, 11 November 2015

£45k Costly argument just to prove someone wrong


Never do this kind of silly things in your life to prove someone wrong as this guy has done and now got stuck in a huge problem. Let's see what he says..

"While arguing with the missus i claimed that i do what i want and told her if i wanted to buy a helicopter on ebay then i would. She told me you cant get helicopters on ebay so i proved her wrong. Turns out when you hit 'buy it now' you don't get a second chance or a 'are you sure you have £45,000 to spend on a helicopter' message before it actions your wish to purchase such a thing. I don't really want a helicopter but it seems i need £45,000 to make it disappear from my ebay basket."

Well, because he didn't want to buy the helicopter and doesn't have enough money to make the helicopter disappear from his basket, he turned toward crowd funding and opened a page to get some help, but the funny thing is that in 12 days he only managed to raise £10.00 and few people even helped him with some nice advise.

Caroline de'Berry says:
"You could have simply requested a mutual cancel and contacted the seller!? And like a previous comment you pressed buy then confirm. I smell something in your story and it's not a cinnamon bun!"

Duane Johnson says:
"When you click buy it now you get asked to confirm . You clicked buy it now then clicked confirm .. To me your just another timewaster... Sum1 won my caravan on ebay n didnt pay i didnt turn round to them n say cheers for wating my time heres a tenner for charity...."
-------
Someone commented on this post anonymously with an irrelevant link but because it came with helpful info so I'm sharing here with all.

"I think that everything said made a ton of sense. But, what about this? suppose you added a little information? I ain't suggesting your content is not solid., but suppose you added a post title that grabbed a person's attention? I mean "£45k Costly argument just to prove someone wrong." is a little boring. You might look at Yahoo's home page and watch how they write post headlines to grab people to open the links. You might add a video or a pic or two to grab readers interested about what you've got to say. Just my opinion, it could bring your posts a little bit more interesting. Here is my web site......"

Well, first of all thank you very much for a nice advice and suggestion. I don't really know if anyone shares my post or not, I thought I just write sometimes some tips (which most of it my own experiences) and sometimes just some common sense stuff, just to entertain and have some laugh or take some lesson from it.

You've said the title is boring and talked about how to grab people's attention.
Well, first of all I'm not a professional article writer, but hopefully I will become one some day if professional people like your self  keep advising me and suggesting me. So thanks a lot. :)

Thursday, 5 November 2015

How to play soundtracks with Catalex Serial MP3 Player


It took me long time (few hours a day for few days) to find out how this mp3 works. Let me tell you what really happened. I just wanted to play some sound tracks on command in Arduino, so I thought let me buy a serial mp3 player and put all the sound tracks in a micro SD card and then play them on command which ever I want.
Ad

That's why I bought the mp3 player above, but unfortunately they didn't send an user manual with it. So I started searching on the net as usual, but couldn't find it, after looking for long time finally I've found one, but the manual was so difficult to understand that I thought what's the point making this kind of manual if people can't understand easily.

Then I turned to one of my Arduino expert friend and asked him for help, but he was kind of busy and was not replying my massage for few days. So I thought you know what let me just try myself and experiment with the code, and then let's see what happens. So after working hard I came up with this simple sketch with few useful options.

Let's see some specification:


What to do?
1. Format your SD card @ Fat16 or Fat32

2. Rename all the sound tracks as 001, 002, 003 and so on. If you want to remember which track is which, then write the name after the numbers, for example 001soundofbird, 002dogbark and so on.
One thing keep in mind that when you write the name, never leave a space between the words, for example 001 sound of bird002 dog bark and so on.

3. Copy  those sound tracks and paste on the card. Remember not to make any folder/directory in SD card. Please see my other post if you want to play songs from other folders.


What does the sketch below can do?
  • If you have uploaded the sketch successfully then it will play the first sound track when you first open your serial monitor or press the reset button.
  • Play  soundtrack on command . That means it will play which ever soundtrack you tell it to play.
  •  Pause, it can pause the playing soundtrack.
  • Play, it will play the soundtrack after pausing.
  • Play next soundtrack.
  • Play previous soundtrack.

Ad

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, 0X1E01);//play the first song with volume 30 class
}
String str;
void loop() {
if(Serial.available())
{
str = Serial.readStringUntil('\n');

if(str == "2")
{
sendCommand(CMD_PLAY_W_VOL, 0X1E02);//play the second track with volume 30 class
Serial.println("Second sound track.");
}
if(str == "3")
{
sendCommand(CMD_PLAY_W_VOL, 0X1E03);//play the third track with volume 30 class
Serial.println("Third sound track.");
}
if(str == "4")
{
sendCommand(CMD_PLAY_W_VOL, 0X1E04);//play the forth track with volume 30 class
Serial.println("Forth sound track.");
}
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]) ;
  }
}

What are the  commands in this sketch?
  • If you send 2, 3 or 4 via the serial monitor then it will play the second sound track, third sound track or forth sound track. What ever number you choose it will play that track and the text will appear on monitor that which track is playing. For example if you send 3 then it will play the 3rd track and you will see "Third sound track." on the serial monitor.
  • ps is for pause. If you want to pause any sound track which playing right now, then just send ps and it will pause straight way.
  • pl is for play. If you want to play it again after pausing then send pl it will start playing the same track again from where you left from.
  • pr is to play the previous track.
  • nx is to play next track.

Which Arduino board does it support?
Well, in the manual it says "Compatible with Arduino UNO / Leonardo / Mega2560 / DUE" but I have tried with Arduino Nano and it's works perfectly, so I hope it will work with other board too.

Places to edit:
* If you don't want to hear the first sound track automatically, when ever you open the serial monitor or press the reset button, then delete this (sendCommand(CMD_PLAY_W_VOL, 0X1E01);//play the first song with volume 30 class) line from the sketch.

*
if(str == "2")
{
sendCommand(CMD_PLAY_W_VOL, 0X1E02);//play the second track with volume 30 class
Serial.println("Second sound track.");
}
As you can see number 2 in "2" which you can change to somthing else to play second sound track. For example "track 2" or "my love" in which ever way it will play the same soundtrack and that is soundtrack number two. You can change the serial print "Second sound track." to what ever you want.

Note: You can do this to other functions too. For example ps, pl, pr, nx and so on.
 
* Choosing sound track to play.  For this simply change the number at th end of this (0X1E02).

* Play with volume. Unfortunately I only know two level of volume in this 15 and 30 the code is below.
sendCommand(CMD_PLAY_W_VOL, 0X0F01);//play the first song with volume 15 class
sendCommand(CMD_PLAY_W_VOL, 0X1E01);//play the first song with volume 30 class

Can you send commands by using mobile phone? 
Of course you can. There is an app called BlueSerial Beta which is very useful, I use a lot.

That's all for now, if I find out more options I will try to add on and in the meantime you can let me know if you didn't understand anything in this post or if you have found out some new function code. Thanks a lot. :)
Ad