433 MHz Wireless temperature Monitor with I2C LCD

Usinga 433 MHz transmitter and receiver ,  a Dallas DS18B20, and a 16×2 LCD with an  i2c / SPI character LCD backpack we can make a simple wireless temperature monitor. I’m not going to go into the construction of the hardware here since there is plenty of resources out there for that already.

!Antennas!

Antenna are a big deal! There is a ton of antenna theory and math out there for you to figure it out but it would be difficult for anyone not already involved in antennas. So, I’m going to tell you what I did.

I got 2 stainless steel whips and magnetic bases from a local 2-way radio supplier and cut the whips to 13 1/4 inches. No coil is needed for this. I get about 60 feet through walls and floors. On the transmitter I am using 12 volts so that I can transmit at full power. I am just using one of the 5 volt pins of the Uno to power the receiver.

 

Transmitter Code

#include <OneWire.h> //This temperature sensor requires a 4.7k Ohm resistor across its pins 2 and three!!!!
#include <DallasTemperature.h>
#include <Wire.h>
#include <VirtualWire.h>
int ledPin = 13;//Set up the TX indicator pin 13 as LedPin
int Sensor1Data;//initialize the use of the variable Sensor1Data
//int sensorValue = 0;  // variable to store the value coming from the sensor If using analog sensor
float currentTemp = 0;//to store decimal value coming from the temp sensor
// RF Transmission container
//char Sensor1CharMsg[4]; 
// Trying to use 5 instead to fit trailing null char 
// go back to 4 if this does not work. 
char Sensor1CharMsg[5]; 

//This temperature sensor requires a 4.7k Ohm resistor across its pins 2 and three!!!! Thats the middle pin and the GND pin
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

DeviceAddress insideThermometer = { 0x28, 0xE4, 0x10, 0x74, 0x03, 0x00, 0x00, 0xD5 };
// DeviceAddress outsideThermometer = { 0x28, 0x20, 0x04, 0xA8, 0x02, 0x00, 0x00, 0x4D };

void setup()
{
  pinMode(ledPin, OUTPUT);//Set the ledPin as an output
  Serial.begin(9600);//initialize serial communication
  Serial.print("TX Start");//Print TX Start in the serial terminal
  // VirtualWire 
    // Initialise the IO and ISR
    // Required for DR3100
    //vw_set_ptt_inverted(true); 
    // Bits per sec
    vw_setup(300);	//Set VirtualWire communication speed
// Start up the library
sensors.begin();
// set the resolution to 9 bit (good enough?)
sensors.setResolution(insideThermometer, 9);
// sensors.setResolution(outsideThermometer, 9);
}

void loop(void)
{

sensors.requestTemperatures();  //Get temperature from the temp Sensor

float tempC = sensors.getTempC(insideThermometer);
if (tempC == -127.00) {
Serial.print("Error");//Print Error if we read -127else {
// lcd.print(tempC);
// lcd.print("/");
Sensor1Data = (DallasTemperature::toFahrenheit(tempC));//Set Sensor1Data as the Celcius to Fahrenheit Conversion
Serial.print(Sensor1Data); //Print the converted temp in the serial terminal
// Integer to ASCII
itoa(Sensor1Data,Sensor1CharMsg,10);
digitalWrite(13, true); // Turn on a light to show transmitting
 vw_send((uint8_t *)Sensor1CharMsg, strlen(Sensor1CharMsg));//Send the data collected

 vw_wait_tx(); // Wait until the whole message is gone
 digitalWrite(13, false); // Turn off a light after transmission
 delay(200);//Wait 200 Milliseconds and then go back to program start
}

}

Receiver Code

 

#include <Wire.h>

#include <Adafruit_MCP23008.h>
#include <LiquidCrystal.h>

/* 

Sensor Receiver 
By Markus Ulfberg 2012-07-06

Gets a sensor reading 0-1023 in a char array
from RF Transmitter unit via VirtualWire 
converts char array back to integer

*/

#include <VirtualWire.h>

// LED's
int ledPin = 13;//Set up pin 13 as the recieve indicator
int ActionLED = 4;//Set up pin for LED 

// Connect via i2c, default address #0 (A0-A2 not jumpered)
LiquidCrystal lcd(0);
// Sensors 
int Sensor1Data;//initialize the variable Sensor1Data for use

// RF Transmission container
 char Sensor1CharMsg[4]; 
// Trying to use 5 instead to fit trailing null char 
// go back to 4 if this does not work. 
//char Sensor1CharMsg[5]; 

void setup() {
  lcd.begin(16, 2);
  Serial.begin(9600);//Initialize serial communication
  Serial.print("RX Start");//Print RX Start in the Serial Terminal 

  // sets the digital pin as output
  pinMode(ledPin, OUTPUT);//Set the ledPin as an Output
  pinMode(ActionLED, OUTPUT);//Se up the ActionLED pin as an Output
  digitalWrite(ActionLED, LOW);//Set the ActionLED LOW 'off'

    // VirtualWire 
    // Initialise the IO and ISR
    // Required for DR3100
    //vw_set_ptt_inverted(true); 
    // Bits per sec
    vw_setup(300);//Set up VirualWire Communication Speed	 

    // Start the receiver PLL running
    vw_rx_start();       

} // END void setup

void loop(){
  //Unsigned Integer of 8 bit length buffer Max Message Length
    uint8_t buf[VW_MAX_MESSAGE_LEN];
  //Unsigned Integer of 8 bit length buffer length Max Message Length
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    // Non-blocking
    if (vw_get_message(buf, &buflen)) 
    {
	int i;//initialize the variable i
        // Turn on a light to show received good message 
        digitalWrite(13, true); 
        lcd.setCursor(1, 0);
	lcd.print("Remote Temp: ");//Print Remote Temp: in the serial terminal
        // Message with a good checksum received, dump it. 
        for (i = 0; i < buflen; i++)//Use the variable i to store bytes from message and if i is less than the buffer length then increase byte storage.
	{            
          // Fill Sensor1CharMsg Char array with corresponding 
          // chars from buffer.   
         Sensor1CharMsg[i] = char(buf[i]);//Senso1CharMsg[i] is the variable to represent char(buf[i]);, char(buf[i]); is charactor buffer storage
	}

        // Null terminate the char array
        // This needs to be done otherwise problems will occur
        // when the incoming messages has less digits than the
        // one before. 
        Sensor1CharMsg[buflen] = '\0';//clear it to fill again.

        // Sensor1Data is atoi (ASCII to Integer) from Sensor1CharMsg
        Sensor1Data = atoi(Sensor1CharMsg);

        // DEBUG 

        lcd.println(Sensor1Data); //Print Sensor1Data in the serial Terminal

        // END DEBUG

        // Turn off light to and await next message 
        digitalWrite(13, false);
        //If Sensor1Data (temp) is less than 75 degrees turn on the ActionLED
        if (Sensor1Data < 75)
        {
          digitalWrite(ActionLED, HIGH);
        }
        delay(100);
    } //If Sensor1Data (temp)is more than 75 degrees turn off ActionLE
        else if (Sensor1Data > 75)
        {
          digitalWrite(ActionLED, LOW);
        }

    }

Bread board power wires

 

This may seem a little trivial for a post, but I did it so I thought I would share.

I took a regulated 12 volt power supply and added a regulated 5 volt and adjustable supplies to it. I used some old speaker terminals I had around for the facing connections on the power supply. I wanted to have some wires that I didn’t have to screw down so I got some banana clips and male header pins to make my own wires that will work with the bread board and the power supply easily.

I got the banana clips and male headers from Tayda Electronics.

 

 

How to use a Triac to switch AC Voltage on and off (Simple)

This is a simple explanation of how to use a triac and opto isolator to switch AC voltages on and off to a device (load). The opto isolator is used to give a physical separation between the low voltage and the high voltage circuits. The Arduino is optional. You can substitute the signal coming from the Arduino with any 5 volt DC signal voltage. This cannot be used for dimming lights.  The opto isolator I used is a M0c3041. Take notice that in the schematic the opto isolator has a triac and not just a switching transistor. This is essential piece. It allows current to flow in both directions when the opto isolator is switched on.  Please feel free to ask questions.

Triac_Schematic Triac_Switch_bb

Join the Forum discussion on this post

Review: Vintronics LCD, RTC, Button Shield

A good general purpose shield for incorporating an LCD, buttons and a real time clock (RTC) into any Arduino Uno or other compatible Arduino product.
 

vinduinoLCDShield_FrontjpgvinduinoLCDShield_Back

 

 

 

 

 

 

 

 

 

 

This neatly laid out  shield incorporates a 16×2 LCD shield with a white LED back light with stand offs for raising it above the other components on the board, a DS1307 RTC with battery backup for memory, and three tact switches.

The tact switches are set up for easy novice use. You don’t need to  debounce these because they each have a different resister value.  So they are read with analogRead(); to get the specific analog value associated with  each switch and then an if statement is used to create an action or function for the switch to control.

The LCD is also great for the novice Arduino programmer since it the most common LCD to use with an Arduino, uses the most common LCD library, and does not use I2C. Also, the LCD is easily interchangeable with other LCD’s that use  a 16 pin header. Just unscrew the stand offs and remove the LCD to replace with the one of your choice.

The RTC feature isn’t as novice friendly. However, that is no fault of this shield’s design. The DS1307 RTC uses I2C for its interface and has many libraries around the Web. Just choose the library that best suits your needs (with a little Googling), or use the one suggested by Vinduino of Vintronics. There is a little bit of a learning curve associated with the RTC, but it is worth your time if you ever want to incorporate time or timing into your Arduino project.

Personally, I prefer the LCD to use an I2C rather than directly connecting the 16 pin header to the Arduino. I like keeping the digital I|O ports for other peripherals. I2C saves those valuable I|O ports by only using the Arduino’s SCL and SDA ports (A5, and A4) for two wire communication.  Also, although this IS a great novice shield, the use of analog values to read a switch slows down things a bit. You have to press the tact switch for a little less than a half a second to get a read from it based on the example code provided for the shield. However, this may be sped up a bit with a little coding finesse.

So, if you are new to Arduino or just want a well made, easy to work with shield, then this is the one for you. So many board developers forget about building shields that are easier for a novice to get started with. Thanks Vincent Kok at Vintronics for this great shield . Good work!

Links to the developer:

 http://www.facebook.com/vinduino

 

http://vinduino.blogspot.com/

 

http://www.youtube.com/vick5821

 

 

How to properly detach/turn off a servo with arduino.

Lets say that you have a project that uses a servo and runs on battery. Currently there is no way in code to turn off an analog servo. Some say to use the detach command. This doesn’t work. Analog servos aren’t designed to be powered and not have a pulse being sent to them. So, what happens when you use the detach command with an analog servo?

When you do servo.detach(); you turn off the 5 volt pulses that control the servos position. When an analog servo looses pwm signal it will hold a position. The position held will vary from servo to servo. So, what we have is a servo constantly drawing power from our precious limited power source.

So, what can we do to mitigate this annoying issue?

Lets start with the code.

#include <servo.h>
int servoPin = 9;
int UsrBtn = 4; //Button to activate program loop
int tranPin = 7; //Transister base pin

Servo servo;

int angle = 0; // servo position in degrees

void setup()
{

pinMode(UsrBtn, INPUT);  //Set UsrBtn as an input
pinMode(tranPin, OUTPUT); //Set tranPin as an output
}

void loop()
{
servo.attach(servoPin); //Start the servo library on the servoPin
int letMeBe = digitalRead(UsrBtn); //letMeBe is a digital read of the UsrBtn

if (letMeBe == 1) //if letMeBe (UsrBtn) is high
{
digitalWrite(tranPin, HIGH); //make tranPin high

// scan from 0 to 180 degrees
for(angle = 0; angle < 180; angle++) { servo.write(angle); delay(4); } // now scan back from 180 to 0 degrees for(angle = 180; angle > 0; angle–)
{
servo.write(angle);
delay(2);
}
}
else if (letMeBe == 0) //else if letMeBe is low
{
delay(250);
digitalWrite(tranPin, LOW); //make the tranPin low

servo.detach(); //stop sending pulses to reserve power on the Arduino.

}
}

 

Now for the hardware. In order to completely turn off the servo so that it isn’t drawing unnecessarily on the battery, we need to use a general purpose NPN switching transistor. I used a 2N4401.

From the Arduino: Pin 7 goes to the base of the transistor.

From the transistor emitter: To the power pin of the servo.

From 5 volts: to the collector of the transistor.

From servo ground pin to ground.

What we have done is set a pin in code as an output (tranPin) that we activate right before we tell the servo what to do. This turns the power on to the power pin of the servo. Then when our servo has finished the job set in loop we set the tranPin low. That turns power to the servo back off.

Please comment with questions of head over to our forum to have a discussion.
Join the Forum discussion on this post

Use the FTDI Basic Breakout Board to program an Atmega328P-PU With Optiboot.

This is if you want to program your breadboard arduino and have an atmega328P-PU with the Optiboot bootloader already on the chip. The biggest issue I have found with breadboarding any chip is that they don’t always want to fully seat into the breadboard. In my experience, I find that pressing firmly down on the chip while uploading saves a ton of trouble!

The LED attached to pin 19 (D13) of the chip is there just as an example. I usually upload the example Blink sketch first to verify that I am able to upload a sketch since it gives me visual confirmation.

 

If you are using an oscillator.

Note: the caps with the oscillator are pF, NOT uF. Sorry.

FTDI_With_OSC

 

If you want to use the FTDI Basic Breakout Board for timing.

 

FTDI_No_OSC

Join the Forum discussion on this post

Tools to Clean Viruses From Your Computer… The Free Way!

I will not outline each and every step in this long process of virus removal. However, I will outline the tools to required to rid your computer of these pesky and dangerous inconveniences. In most cases it really is as simple as running these tools to clean your computer.

Disclaimer:::::::::::::::::::::::::

All actions you take are your own responsibilities! If you are worried that you may lose files or damage your operating then you are right to be worried. There is a definite risk of irreparable  damage to your files. If this is something that you can’t live with, get a trained technician to do it for you.

:::::::::::::::::::::::::::::::::::::::::

NOTE!!!! You can only run one antivirus on your PC at a time!!!!! The only exception to this that I know of is Avast. Just make sure that if you already have an antivirus program installed to install Avast in ‘Compatibility Mode’. This will be presented to you as an option during installation.

Free Virus removal software::::::::::::

1. Malwarebytes
2. Avast
2. Spybot Search and Destroy
3. Sophos

4. Ad-Aware

5. Kapersky

AS A LAST RESORT.. AND WITH ALL ANTIVIRUSES UNINSTALLED!!!!!

6. ComboFix

Convert SSL Certificate .crt to PEM in any OS that runs WinRAR

Most likely your certificate authority will send you your SSL certificate in a zip file containing one or more files with the file extension .crt. If you just downloaded the certificate unzipped then you will have to put into an archive using a utility like WinRAR. I wont go into archiving here, you can find plenty of information on the web for that. Once you have your certificate(s) in an archive, open the archive to view the enclosed files with WinRAR. Once you can see the certificate right click on it and select ‘view file’ from the context menu. The file will open allowing you to view the PEM output.

Setup a Buffalo WHR-300HP/WHR-HP-G300N as a Wireless Bridge or Repeater

 

This video walk through can be used for either the WHR-HP-G300N or the WHR-300HP Buffalo routers.

For setting up the Buffalo WHR-300HP as a Wireless Bridge follow the first video.
For setting it up as a repeater watch both videos.

Arduino 3.7 Volt LiPo Battery Meter

There is probably room for improvement here but this is what I have come up with for a 3.7 Volt LiPo battery meter. In the picture below I am charging my battery from a 5 volt source. All the charge controlling circuitry is built into the battery. I just wanted a way to monitor the charging progress, although, this could certainly be added to any project that uses a 3.7 volt LiPo battery for its power supply.
Hope this helps.

//3.7V LiPo Battery Meter
//3.7V LiPo Battery Meter
//Use two 1.2 K Ohm resisters as a voltage divider from the positive
//and negative terminal of the battery to read reference voltage from.
//we wouldnt want to send to much voltage to our Arduino.
//Make sure to tie the ground back to the Arduino. Otherwise, expect some odd readings.

int sensorPin = 0; //set up the sensor pin for reading the voltage
int sensorValue = 0; //variable to store the value coming from the sensor

void setup()
{
//This is the default value, but we can set it anyways
analogReference(DEFAULT); //5V Reference on UNO
Serial.begin(9600); //initialize serial communication
}

void loop()
{
sensorValue = analogRead(sensorPin); //set sensorValue as an analog read of the A0 pin
//print the value of the sensor multiplied by 0.00326 to get true voltage reading.
//this is a value of 0 – 1023 coming from the sensor pin and has to be converted.
Serial.println(“Battery Voltage Is”);
Serial.println(sensorValue * 0.00951);

delay(1000); //give a delay between readings.
}

IMAG0758

Helping Others With What We Know

Switch to our mobile site

%d bloggers like this: