Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Programming Questions / DHT11 sensor for yogurt maker? on: September 02, 2014, 06:22:16 pm
Hello,
I would like to know if it would be possible to use a DHT11 type sensor (with an arduino uno) to regulate the temperature inside a yogurt maker... I am not able to find any helpful example code for this type of thing, which seems pretty easy... Anyway I would like to have something like this:

Code:
if dht11 temperature > 43

heaterpin low

else

heaterpin high

Here is the basic example code:
Code:
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

#include "DHT.h"

#define DHTPIN 2     // what pin we're connected to

// Uncomment whatever type you're using!
#define DHTTYPE DHT11   // DHT 11
//#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
 
 
  dht.begin();
}

void loop() {
  // Wait a few seconds between measurements.
  delay(1500);

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit
  float f = dht.readTemperature(true);
 
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Compute heat index
  // Must send in temp in Fahrenheit!
  float hi = dht.computeHeatIndex(f, h);

  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.println(" *C ");
 
}

Is it possible to acheive this?

Thanks!
2  Using Arduino / Programming Questions / Re: Problem with 433Mhz rf link code on: July 15, 2014, 08:58:07 am
Ok. Could you do a bit of experimenting please, if you have the time?
3  Using Arduino / Programming Questions / Re: Problem with 433Mhz rf link code on: July 15, 2014, 08:14:54 am
I have removed the HEX from the line:

Code:
for (i = 0; i < buflen; i++)
{
    Serial.print(buf[i]);
    Serial.print(' ');
}

Instead of

Code:
for (i = 0; i < buflen; i++)
{
    Serial.print(buf[i]HEX);
    Serial.print(' ');
}

But now it gives me the letters in DEC (decimal)

Code:
Got: 104 101 108 108 111 32 128
 

What can I do?

Oh and I don't have a PTT on this setup
4  Using Arduino / Programming Questions / Re: Problem with 433Mhz rf link code on: July 15, 2014, 08:02:10 am
So how could I "convert" the HEX to the good characters?
5  Using Arduino / Programming Questions / Problem with 433Mhz rf link code on: July 15, 2014, 07:28:46 am
Hello,
I've been tyring this code out with a cheap 433mhz transmitter/receiver kit from ebay.
Transmitter code (Arduino Mega):
Code:
// transmitter.pde
//
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@airspayce.com)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>

const int led_pin = 13;
const int transmit_pin = 12;
const int receive_pin = 11;
const int transmit_en_pin = 3;

void setup()
{
    // Initialise the IO and ISR
    vw_set_tx_pin(transmit_pin);
    vw_set_rx_pin(receive_pin);
    vw_set_ptt_pin(transmit_en_pin);
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);       // Bits per sec
    pinMode(led_pin, OUTPUT);
}

byte count = 1;

void loop()
{
  char msg[7] = {'h','e','l','l','o',' ','#'};

  msg[6] = count;
  digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
  vw_send((uint8_t *)msg, 7);
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(led_pin, LOW);
  delay(1000);
  count = count + 1;
}

Receiver code (Arduino Uno):
Code:
// receiver.pde
//
// Simple example of how to use VirtualWire to receive messages
// Implements a simplex (one-way) receiver with an Rx-B1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@airspayce.com)
// Copyright (C) 2008 Mike McCauley
// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>

const int led_pin = 13;
const int transmit_pin = 12;
const int receive_pin = 11;
const int transmit_en_pin = 3;

void setup()
{
    delay(1000);
    Serial.begin(9600); // Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
    vw_set_tx_pin(transmit_pin);
    vw_set_rx_pin(receive_pin);
    vw_set_ptt_pin(transmit_en_pin);
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000); // Bits per sec

    vw_rx_start();       // Start the receiver PLL running

    pinMode(led_pin, OUTPUT);
}

void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
int i;

        digitalWrite(led_pin, HIGH); // Flash a light to show received good message
// Message with a good checksum received, dump it.
Serial.print("Got: ");

for (i = 0; i < buflen; i++)
{
    Serial.print(buf[i], HEX);
    Serial.print(' ');
}
Serial.println();
        digitalWrite(led_pin, LOW);
    }
}

The transmitter and receiver communicate clearly together. When the transmitter transmits, the onboard led blinks, and when the receiver receives, it's onboard led blinks. But when I open the serial monitor, instead of seeing  "Hello" (because I think that's what the code is supposed to send), I get this (in the serial monitor):
Code:
setup
Got: 68 65 6C 6C 6F 20 3
Got: 68 65 6C 6C 6F 20 4
Got: 68 65 6C 6C 6F 20 5
Got: 68 65 6C 6C 6F 20 6
Got: 68 65 6C 6C 6F 20 7
Got: 68 65 6C 6C 6F 20 8
Got: 68 65 6C 6C 6F 20 9
Got: 68 65 6C 6C 6F 20 A
Got: 68 65 6C 6C 6F 20 B
Got: 68 65 6C 6C 6F 20 C
Got: 68 65 6C 6C 6F 20 D
Got: 68 65 6C 6C 6F 20 E
Got: 68 65 6C 6C 6F 20 F
Got: 68 65 6C 6C 6F 20 10
Got: 68 65 6C 6C 6F 20 11
Got: 68 65 6C 6C 6F 20 12
Got: 68 65 6C 6C 6F 20 13
Got: 68 65 6C 6C 6F 20 14
Got: 68 65 6C 6C 6F 20 15
Got: 68 65 6C 6C 6F 20 16
Got: 68 65 6C 6C 6F 20 17
Got: 68 65 6C 6C 6F 20 18
Got: 68 65 6C 6C 6F 20 19
Got: 68 65 6C 6C 6F 20 1A
Got: 68 65 6C 6C 6F 20 1B
Got: 68 65 6C 6C 6F 20 1C
Got: 68 65 6C 6C 6F 20 1D
Got: 68 65 6C 6C 6F 20 1E
Got: 68 65 6C 6C 6F 20 1F
Got: 68 65 6C 6C 6F 20 20
Got: 68 65 6C 6C 6F 20 21
Got: 68 65 6C 6C 6F 20 22
Got: 68 65 6C 6C 6F 20 23
Got: 68 65 6C 6C 6F 20 24

Why an I not getting hello in the serial monitor? What is the problem?
Thanks!
6  Using Arduino / Programming Questions / Re: 1 pushbutton to control 3 leds sketch problem on: July 04, 2014, 11:40:26 am
Ah thanks, I was about to ask that!
7  Using Arduino / Programming Questions / Re: 1 pushbutton to control 3 leds sketch problem on: July 04, 2014, 10:08:16 am
Thank you! Very helpful!
8  Using Arduino / Programming Questions / 1 pushbutton to control 3 leds sketch problem on: July 04, 2014, 09:10:56 am
Hello,
I am trying to make a simple sketch that does the following: When you push a push-button once, it prints "Led1" on the serial monitor; when you push the same button a second time, it prints "Led2" on the serial monitor, etc. The code is based off the State-Change example.
Here is the code:
Code:
//Constants
const int  buttonPin = 2;    // the pin that the pushbutton is attached to

// Variables
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

void setup() {
  // initialize the button pin
  pinMode(buttonPin, INPUT);
  // initialize serial
  Serial.begin(9600);
}


void loop() {
  // read the pushbutton input pin:
  buttonState = digitalRead(buttonPin);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == HIGH) {
      // if the current state is HIGH then the button
      // wend from off to on:
      buttonPushCounter++;
     
      {
     
      if(buttonPushCounter == 1)
      {
      Serial.print("Led1");
     
       if(buttonPushCounter == 2)
      {
      Serial.print("Led2");
     
       if(buttonPushCounter == 3)
      {
      Serial.print("Led3");

    }
    else {
 
    }
  }

  lastButtonState = buttonState;}

    }
 
}}
}

It works fine for the first push (it indicated Led1 when the button has been pushed once), but it stops working after that. When I push it a second or a third time, the serial monitor doesn't indicate Led2 or Led3...
Does anybody know what the problem is? If so, how can I fix it?
9  Using Arduino / Programming Questions / Re: Make an led blink a specific amount of times in void-loop? on: April 02, 2014, 08:32:45 pm
OK thanks, I will try some things with the website.
10  Using Arduino / Programming Questions / Re: Make an led blink a specific amount of times in void-loop? on: April 02, 2014, 07:56:52 pm
Start with blink without delay. Add a variable which records the number of blinks that have been completed. Initialise this to zero in code which executes at the start of your blink sequence. Each time you complete a blink cycle, increment the count. If the count has reached the required number of blinks, don't perform any more blinks.

I am kinda bad at this... Could you please make a quick example sketch (just a few lines to clear that up)?
11  Using Arduino / Programming Questions / Re: Make an led blink a specific amount of times in void-loop? on: April 02, 2014, 07:16:31 pm
For this application, I need to have a buzzer and led blink 5 times when a toggle SWITCH (and not a button as I said earlier, sorry) is first toggled to the on position, after the 5 led/buzzer blinks, the led has to stay on continuously (that is until the switch is toggled again). So I would need the blink without delay... How should I proceed?
12  Using Arduino / Programming Questions / Make an led blink a specific amount of times in void-loop? on: April 02, 2014, 06:50:15 pm
How could I make an led blink a specific amount of times in the void-loop part of a sketch (Lets day 5 times when I first push a button)? I think I would have to use the button state detection sketch, but I don't understand it... Could someone explain it to me (or does anybody have a good link somewhere on the internet)?
Thank you!

Oh and here is the Arduino example sketch...
Code:
// this constant won't change:
const int  buttonPin = 2;    // the pin that the pushbutton is attached to
const int ledPin = 13;       // the pin that the LED is attached to

// Variables will change:
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

void setup() {
  // initialize the button pin as a input:
  pinMode(buttonPin, INPUT);
  // initialize the LED as an output:
  pinMode(ledPin, OUTPUT);
  // initialize serial communication:
  Serial.begin(9600);
}


void loop() {
  // read the pushbutton input pin:
  buttonState = digitalRead(buttonPin);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == HIGH) {
      // if the current state is HIGH then the button
      // wend from off to on:
      buttonPushCounter++;
      Serial.println("on");
      Serial.print("number of button pushes:  ");
      Serial.println(buttonPushCounter);
    }
    else {
      // if the current state is LOW then the button
      // wend from on to off:
      Serial.println("off");
    }
  }
  // save the current state as the last state,
  //for next time through the loop
  lastButtonState = buttonState;

 
  // turns on the LED every four button pushes by
  // checking the modulo of the button push counter.
  // the modulo function gives you the remainder of
  // the division of two numbers:
  if (buttonPushCounter % 4 == 0) {
    digitalWrite(ledPin, HIGH);
  } else {
   digitalWrite(ledPin, LOW);
  }
 
}
13  Using Arduino / Programming Questions / Re: How do I add 2 buttons with example sketch? on: March 05, 2014, 07:43:07 pm
What should I do now?
14  Using Arduino / Programming Questions / Re: Fireworks controller LED sketch HELP!!! on: March 05, 2014, 05:23:29 pm
I think I will order some relays, much simpler! Thanks for your help and time!
15  Using Arduino / Programming Questions / Re: Fireworks controller LED sketch HELP!!! on: March 05, 2014, 04:16:14 pm
I will explain:

As I mentioned, I am building a fireworks controller like this one http://www.instructables.com/id/Fireworks-Controller/
On the controller, there is a SPDT switch that activates either it's test or armed mode. I want to add a buzzer to it so I can have audio cues when it is: Turned on (in the void setup, when the chip will receive power), put in armed mode, and finally in test mode. The controller runs on a 12volt battery (or power adapter). I will put the final code (if ever I succeed) on an Attiny85 chip powered by a 5 volt regulator connected to the power source.

I want to add one wire to each of the three terminals on the SPDT switch, so the Arduino can detect when the armed and test modes are activated. I cannot connect the wires directly to the Arduino, because this would damage it. Would it be simpler to use some relays? I already have some transistors on hand, but no relays. I would have to order some.

I hope that clears it up.

Pages: [1] 2 3 4