electronicramblings.com

Electronic Projects

Raspberry Pi 3 Giveaway – Free Shipping

by on Mar.03, 2016, under Electronic Projects, General Statements, Raspberry Pi, STUFF!!!!

Our friends at Random Nerd Tutorials are giving away a free raspberry pi 3 this month ( March 2016 ). Click on the link below to try your and at Lady Luck.

Win a Raspberry Pi 3

Till next time, thanks for your time.

 

Leave a Comment more...

RTD Simulator using dip switches and SMD resistors or basic decade box!!!

by on Feb.22, 2015, under Electronic Projects

Decade box (RTD Simultator) using dip switched and SMD resistors.

To start off I did not come up with this idea.

(Search on Hackaday dot com or Thinkcreate).

I work in a world of instrumentation and we have field techs who do not like to return shiny expensive equipment when they leave our employment, so came up with a cheaper and less shiny looking device and may be they will not want to take it as there own.

This is the schematic:

decade box smd

 

Very basic but brilliant design. If you take 1,2, and two 3 ohm resistors you can make each value between 0-9 ohms. Just increase each back by x10 to create your decade box.

For me I started at 0.1,0.2 and 0.3. I wanted to build RTD simulator.(This also creates a 999.9 ohm Decade box)

Now I tried a new PCB maker. Dirtypcbs.com. They have a 5cm x 5cm board size $14.00 with free shipping. (Took 1 month receive my boards from the China)

They say you may get 10 boards or less or more, I got lucky and got 12. Should have bought a lottery ticket that day… 🙂

They came in a nice little box and shrink wrapped like this:

IMG_8704

I am a cheap bastard and like to get the most for my money, so I put two decade units on my main board to use up the 5cm x 5cm board.

IMG_8705

 

My thoughts was to cut them into separate boards, but then came up with a better idea.  Make a high and low side for testing the span on the transmitters we work with.

Also if you want to create a full decade box you could by daisy chaining the two units on the board to give you 8 x10 ranges like below.

Dip 1=.9 ohms, dip 2=9 ohms, dip 3=90 ohms, dip 4=900 ohms, dip 4=9 kohms, dip 5=90 kohms, dip 6=900 kohms, dip 7= 9 mohms and dip 8=90 mohms. (99999999.9 ohms)

Or adjust the resistor values to your requirements. (Try to use 0.1 to 0.5 % resistors for the lower ranges, and 1% for the higher)

My Dual range RTD Simulator:

IMG_8714 IMG_8715 IMG_8713

 

You can purchase boards from Dirtypcbs.com using this link:

http://dirtypcbs.com/view.php?share=4264&accesskey=736429b690631de89faccaf4c55754f0

 

Parts:

All resistors are 0805 SMD

My Digikey order per Side (double your order for a dual range unit):

QTY
1   CRL0805-FW-R100ELFCT-ND .1 ohm resistor 805 R1
1   CRL0805-FW-R200ELFCT-ND .2 ohm resistor 805 R2
2   CRL0805-FW-R300ELFCT-ND .3 ohm resistor 805 R3/R4

1   311-1.00CRCT-ND 1 ohm resistor 805 R5
1   311-2.00CRCT-ND 2 ohm resistor 805 R6
2   311-3.00CRCT-ND 3 ohm resistor 805 R7/R7

1   311-10.0CRCT-ND 10 ohm resistor 805 R8
1   311-20.0CRCT-ND 20 ohm resistor 805 R9
2   311-30.0CRCT-ND 30 ohm resistor 805 R10/R11

1   CR0805-FX-1000ELFCT-ND 100 ohm resistor 805 R12
1   CR0805-FX-2000ELFCT-ND 200 ohm resistor 805 R13
2   CR0805-FX-3000ELFCT-ND 300 ohm resistor 805 R14/R15

4   GH7170-ND 4 position rocker switch SW1/2/3/4

1   WM4393-ND Terminal dual X1

 

I would recommend a Gold contact switch if you are decide to make the dual range unit. (Digikey part 360-1181-ND)

I am very pleased on how this proof of concept project turned out. I also hope it helps you on one of your projects.

Till next time, Thanks for your time.

 

 

 

 

 

 

 

 

 

 

2 Comments more...

Raspberry Pi Arch Linux: Another thing I have learned. NTPd

by on Apr.16, 2014, under Electronic Projects, Raspberry Pi

A quick post.

NTPd service should not be installed as root. Specially if you want to run it as a daemon.
Make sure you install from a less user.

So install ntpd like so:
sudo pacman -S ntp

Enable the systemd:
sudo systemctl enable ntpd

sudo nano /etc/conf.d/ntpd.conf
NTPD_ARGS=”-g -i /var/lib/ntp -u ntp:ntp”

sudo nano /etc/ntp.conf 
#driftfile /var/lib/ntp/ntp.drift
driftfile /ntp.drift

Now configure the chroot environment:

mkdir /var/lib/ntp/etc /var/lib/ntp/lib /var/lib/ntp/proc
touch /var/lib/ntp/etc/resolv.conf /var/lib/ntp/etc/services

sudo nano /etc/fstab
#ntpd chroot mounts
/etc/resolv.conf /var/lib/ntp/etc/resolv.conf none bind 0 0
/etc/services /var/lib/ntp/etc/services none bind 0 0
/lib /var/lib/ntp/lib none bind 0 0
/proc /var/lib/ntp/proc none bind 0 0

Reboot or run this:
sudo systemctl restart ntpd

Leave a Comment more...

Raspberry Pi TreeCam project Arch Linux Motion USB Cam Gdrive Gmail

by on Apr.13, 2014, under Electronic Projects, Raspberry Pi

 

 

Finished my TreeCam project.

IMG_7504-800

Just a reminder, I am pretty much documenting my adventure for a reminder to myself of what I did.  If others can use what I have done, so be it.  However I am still learning and go to the great and all powerful GOOGLE to find answers to the questions I seek when I just don’t know or understand something.

To start you should head to the net and read how to load a image of Arch Linux for the raspberry pi. 

Get your pi running Arch and then head over to this page. Kean has done great job of explaining the loading of the software, python scripts and getting the system running. If you follow his directions, you will have a working system when done.

Note: If you have a problem loading the gdata package like I did. You might have a unit with only 256k. To fix this, create a swap file on the system. 128k swap will be enough. (my first Raspberry Pi post talks about this)

Here is a video of my unit in action watching the cat post.
I have the motion.conf set to show 5 frames before motion is detected and 30 frames after motion has stopped in the video. Makes for a more complete video.
2014-03-30-07-44-51-08

Now down to business.

The Parts:

Raspberry Pi B1 256mb (market price)
4gig SD card (DX.com $4)
Arch Linux (Free….)
Microsoft LifeCam HD-3000 Camera (used at garage sale $5, got to love garage sales!!!!!)
Wifi Dongle (Comfast CF-WU720N, bought it from DX.com  $8)
     -next time purchasing one with the external antenna.CF-WU730A $10
12 volt to 5 volts converter (DX.com as well $4)
JB Enclousure (HomeDepot 6x6x4″ $20)
White Vacuum couplers and tubing.(Leftovers from Centeral Vac install)
Clear glass cut to fit White Vacuum coupler ($5)
Misc stuff ($5)

Now if you want, you can down load my image from *****.  It fits on a 4gig or larger card and make the changes mentioned below and have a running system in a short while. (if this file is not accessible by the link, contact me and I will send a link to the file to you.)

You can use Win32diskimager to load the image on to the SD card.
My image is for a 4gig or larger SD card. You should not have to expand to full size of your SD if 4gigs or  larger, as all storage of video files is done on Google’s gdrive.

Ethernet is set to DHCP, so you will have to find your Ip address on the network before accessing the unit using Putty, Xshell or terminal program. ( I run my system headless… no monitor, keyboard or mouse)
Wifi is set DHCP.

Things you need to update to have working system:

Setup a Gmail account and gdrive information in the uploader file: /etc/motion/uploader.cfg
Wifi information: run wifi-menu , follow the programs prompts.  If you want to make static edit /etc/netctl/wlan0-??? file. Search the net for the proper information to place here. This is what I would have in mine:(the ESSID and Key will already be there from when you ran the wifi-menu script.)

Interface=wlan0
Connection=wireless
Security=wpa
ESSID=????
IP=static
#IP=dhcp
Key=\”fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Address=(‘192.168.0.211/24’)
gateway=(‘192.168.0.1’)
DNS=(‘8.8.8.8’ ‘8.8.4.4’)

Motion information(if you want it act differently): Edit /etc/motion/motion.conf

Now change the Passwords for root and pi to make it your own.
Default for this image are:
User: root     Password: root
User: pi          Password: rpi

Reboot the unit and cross your fingers and you should be catching the neighbour’s dog pooping on your lawn.
Below I have attached pictures of the unit. Very simple and easy to build. If you can not cut the glass, visit your local glass shop, they can do it for you, if you ask nicely. Also plexi-glass will work as well.

Till next time, thanks for your time.

Pictures:

IMG_7531-800 IMG_7536-800 IMG_7533-800 IMG_7545-800 IMG_7522-800 IMG_7517-800 IMG_7529-800

 

 

 

Leave a Comment more...

Raspberry PI Arch Linux visudo (sudoers file) edit using nano

by on Mar.30, 2014, under Electronic Projects, Raspberry Pi

Very Quick one!!!!

To be able to edit visudo using nano instead of vi, is great thing. This is not a permit fix, so you have to do it every time you need to edit visudo after a reboot.

export EDITOR=nano && sudo -E visudo
allows you to edit the sudoers file with nano.

Extra one for you…if you want to edit crontab with nano…
export EDITOR=nano
Will work for this. Same as above, it reset with a reboot.

Till next time, thanks for your time.

Leave a Comment more...

Raspberry PI SSH Terminal Putty Xshell

by on Mar.30, 2014, under Electronic Projects, Raspberry Pi

This is a quick one. If you are using Putty for Windows and find it limited on its options, try Xshell. It is free for students or home use.

I like it as I can easily do tunneling and also allows me to do a simple cut an paste from window to window, or  to a text or word document with out it trying to paste it my command line. Also allows one to have multiple  tabs linked to the same location…great when working in two different areas in the RPI or different users.

NetSarang(Xshell)

Till next time, thanks for your time.

 

 

 

 

 

 

Leave a Comment more...

Raspberry Pi Arch Linux Not Enough Memory Issue

by on Mar.30, 2014, under Electronic Projects, Raspberry Pi

Been a long time.

But pretty much have been wandering around wondering what to do. I got a used Raspberry Pi a some time ago and decided to start working in the Linux world for me and not just for work. 

The Arch Linux is a very robust and reliable. You add in only what you need to do the job.  But know that support from the general community is not as large as other loads. So be patient when looking for answers. This version is mostly for those who have a good understanding of Linux world.

I was working on project that required me to load in gdata. ( Google’s python library for many things, but for me I wanted the gdrive function)

Now my Raspberry Pi is of the older variety and it only has 256 mb memory. Which would be enough to run my project….but not enough to load the gdata library.

After a lot of reading and then taking the plunge…installed a swap file. (not a fan of swap files on embedded processors….can take up way to much of the processor and read/writes to a SD card)

-fallocate -l 128M /swapfile

-chmod 600 /swapfile

-mkswap /swapfile

-swapon /swapfile

Then add the following line to /etc/fstab.
/swapfile none swap defaults 0 0

After doing the above and rebooting….BAM…. and was able to installed gdata and the project moved forward. Great days!!!!

If wondering on a good place to start with the gdata, take a look at:

Motion-Dection RPI

Till next time, thanks for your time.

 

 

 

Leave a Comment more...

Truck Temperature Gauge ATtiny85 DS18S20 DS18B20 LCD

by on Apr.13, 2013, under Arduino, ATtiny, Electronic Projects

Well, finally built something useful with the ATtiny85.

Again this is more for reference then a how to.  So please use with a grain of salt.

I used the Halogen M16 Light housing as a template for the PCB boards.  Bought these from Ebay a few years ago to attempt to build a simple LED tachometer for my Cruiser(2006 Kawasaki Vulcan Nomad), but instead found a cheap 2″ gauge to do the job, so the lights were just sitting in my archives till I decided to build a temperature sensor for my Ford Ranger.  Will be mounting this gauge on the windshield column using the OH Shit!!! handle. When I get the bracket built will have pictures of the actual install.  Below this is the Lamps housing.  Can’t find it on ebay any more.  So if anyone know where to find them, let me know…I have a few ideas of what to put in them next. 🙂

April 13 iphone4 2013 141-800

The interesting thing I found is the M16 Lamp has a glass lens over the actual bulb.  Not like the other M16 bulbs I have in my home that have the bulb open to the air. (M16 EXN 12VDC 50 Watt is the lamp with a glass shield over the bulb)

So to protect my display on the LCD I decided to get a glass shop to cut me couple of circles of glass that I would silicon into the face of the housing.  This will make the unit able to be used on my Cruiser as well as my truck.

This is more of a picture post, hope is give you ideas of doing your own gauge.  If you do one, let me know as I do like seeing how other have done there projects.

Housing parts:

April 13 iphone4 2013 147-800

 

Electronics assembled reading for hiding way into the housing.

 

April 13 iphone4 2013 157-800

 

Back View, So you can see how the electronics are held into the housing.

 

April 13 iphone4 2013 160-800

 

 

 

 

April 13 iphone4 2013 163-800

 

Finished display. Now the hard part, figuring out how to mount without harming the original molding in the Truck.

April 13 iphone4 2013 167-800

 

 

Thoughts on other setups for this configuration: 

Oil Temperature
Oil Pressure
OBDII Readings(this one will take a lot of work, will have to go a at least a ATmega328 chip for this one)
Any other gauge one can think of!

Other configuration ideas:
No CPU in the gauge housing, but just a SPI LCD display and a electronics box under the dash to do all the gathering of information and controlling of the displays.

Boards:
Eagle Cad Boards:  ATtinyx5 LCD 8×2 V3

Note on board build:
Did not install the reset circuit, or the resonator. Not needed for this project. The Main board was setup for just project.(One Wire DS18S20 or DS18B20 temperature sensors)
If you use these boards, add in extra set of headers for external wiring, I got lucky and was able to solder my external wires to the pins on the header.
The boards were setup with through hole parts for two reasons, I was home etching the boards, and I have a lot of parts I wanted to use up. If I were to manufacturer these boards I would go to surface mount.

Sketch Notes:
Used the Arduino Digispark interface 1.03, BUT did not load into the ATtiny85 the boot loader!
The interface has most of the libraries need to do this project.  The rest of the libraries are in previous post. Please look back to find them. (Post)

Till next time, thanks for your time.

Sketch:

/*
April 12, 2013
Digispark Arduino interface 1.03 used to compile
Digispark(Tiny Core)
ATtiny85 Clock PLL-16Mhz
LCD control PCF8475A ([A]extended address chip) wired to use the DFRRobot Library
Eagle board “ATtinyx5 ***** V3”
(Actually uses a header for 8×2 LCD)

I2C LCD connects to SDA, SCL +5v, Gnd
Uses a 8×2 I2C LCD Backlight Display

DS18x20 x2 Temperature chip on pin P4
4k7 pullup between pin P4 and +5v.
Hard code addresses of sensor to make code smaller and easier.

Pin connections of ATtiny85
P0 = SDA Pin 5
P1 = Pin 6
P2 = SCL Pin 7
P3 = Pin 2
P4 = DS18B20 Pin 3
P5 = Pin 1

*/

#include <OneWire.h>
#define ONE_WIRE_BUS 4 // DS18B20 is on P4
#include <TinyWireM.h> // I2C Master lib for ATTinys which use USI – comment this out to use with standard arduinos
#include <LiquidCrystal_I2C.h> // for LCD w/ GPIO MODIFIED for the ATtiny85
#define GPIO_ADDR 0x38 //LCD address, PCF8475A extended address

OneWire ds(ONE_WIRE_BUS);
LiquidCrystal_I2C lcd(GPIO_ADDR,16,2); // set address & 16 chars / 2 lines

//DS18S20 temperature senor MAC address
byte addr[8]={0x10, 0x22, 0xE1, 0x48, 0x00, 0x08, 0x00, 0xBE};//long sensor cable [outside]
//DS18S20 temperature senor MAC address
byte addr1[8]={0x10, 0xEC, 0xA7, 0x48, 0x00, 0x08, 0x00, 0x47};//Short sensor cable [inside]

//
int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract;
char buf[20];

int HighBytea, LowBytea, TReadinga, SignBita, Tc_100a, Wholea, Fracta;
char bufa[20];

//________________________________________________________________________________
void setup(void) {
// set up the LCD’s number of rows and columns:

TinyWireM.begin(); // initialize I2C lib

lcd.init(); // initialize the lcd
lcd.clear();
lcd.noCursor();
lcd.backlight(); // Turn on the backlight

// Print a message to the LCD.
lcd.setCursor(0,0); // First position (0) and first line (0)
lcd.print (“Arduino “);
lcd.setCursor(0,1); // First position (0) and second line (1)
lcd.print (“Dual”);
delay(3000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print (“Temp”);
lcd.setCursor(0,1);
lcd.print (“Gauge”);
delay(4000);
lcd.clear();

}
//________________________________________________________________________________

void loop(void) {

sensorRead();
delay(4000);
sensor2Read();
delay(4000);

}

//________________________________________________________________________________

void sensorRead()
{
byte i;
byte present = 0;
byte data[12];

ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end

delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.

present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad

for ( i = 0; i < 9; i++)
{ // we need 9 bytes
data[i] = ds.read();
}

LowByte = data[0];
HighByte = data[1];
TReading = (HighByte << 8) + LowByte;
SignBit = TReading & 0x8000; // test most sig bit
if (SignBit) // negative
{
TReading = (TReading ^ 0xffff) + 1; // 2’s comp
}
Tc_100 = (TReading*100/2);

Whole = Tc_100 / 100; // separate off the whole and fractional portions
Fract = Tc_100 % 100;

sprintf(buf, “%c%d.%d\337C “,SignBit ? ‘-‘ : ‘+’, Whole, Fract < 10 ? 0 : Fract);
lcd.clear();
lcd.setCursor(0,1);
lcd.print(buf);
lcd.setCursor(0,0);
lcd.print(“Outside”);
}
//________________________________________________________________________________
void sensor2Read()
{
byte j;
byte presenta = 0;
byte dataa[12];

ds.reset();
ds.select(addr1);
ds.write(0x44,1); // start conversion, with parasite power on at the end

delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.

presenta = ds.reset();
ds.select(addr1);
ds.write(0xBE); // Read Scratchpad

for ( j = 0; j < 9; j++)
{ // we need 9 bytes
dataa[j] = ds.read();
}

LowBytea = dataa[0];
HighBytea = dataa[1];
TReadinga = (HighBytea << 8) + LowBytea;
SignBita = TReadinga & 0x8000; // test most sig bit
if (SignBita) // negative
{
TReadinga = (TReadinga ^ 0xffff) + 1; // 2’s comp
}
Tc_100a = (TReadinga*100/2);

Wholea = Tc_100a / 100; // separate off the whole and fractional portions
Fracta = Tc_100a % 100;

sprintf(bufa, “%c%d.%d\337C “,SignBita ? ‘-‘ : ‘+’, Wholea, Fracta < 10 ? 0 : Fracta);
lcd.clear();
lcd.setCursor(0,1);
lcd.print(bufa);
lcd.setCursor(0,0);
lcd.print(“Inside”);

}

Leave a Comment more...

Digispark ATtiny85 LCD I2C DS18S20 DS18B20 Temperature Monitor

by on Apr.01, 2013, under Arduino, ATtiny, Electronic Projects

Well this has been a great adventure!!!

I wanted to build a simple interior and exterior temperature sensor for my truck. This was a bigger adventure than I expected.  I started off by doing research of a the three main components that I wanted to use ( ATtiny85, DS18x20,LCD,).  I stumbled upon the Digispark project on Kickstarter and what they have done.  Searching more I found a article published in a magazine called the “The Shed” that used the Digispark to accomplish the reading of the DS18x20 temperature chip, but could not do negative number very well.  (The project in The Shed magazine/DigiStump forum also had a max/min and relay control).  So will look at that code later for running my smoker.

As I was still searching for code snippets that would work for me, I decided to build up the circuit that matched the DigiSpark on my trusty bread board minus the relay control.  The reason I am going with the DigiSpark circuit is that I am going to use the Arduino 1.03 Digispark inteface. It already has a lot of the libraries need for this small processor.  I WILL NOT be loading on the boot loader, so in fact you get 2k more space if you need it. Just have to modify the Arduino interface files to reflect that.

April 01 2013 049

I have a lot of older DS18x20 chips around so that is why I am using them up in projects.  (I have a vast archive of semiconductors and components from when I ran a repair and design company, oh so long ago….)  In the picture you may notice two arduino boards, and one with a shield with a mess of wirewrap on it, that is my dedicated Arduino as a ISP with my hand built ATtiny85/84 programmer shield.

When starting with the ATTiny and wanting to use the Arduino interface, this is the place.  They did a lot of great work there.

Now this is where the adventure truly started…..  Bricking the ATtiny 85 on the first try.

I followed the direction given by the MIT people, but then thinking I am smarter than the average bear I decided to program the fuses myself using one of the many AVR programmers I have with the AVR Studio software.  That is where I went wrong….word of warning….never set the reset fuse!!! I did and could not program the ATtiny flash or the fuses.  So this is where I learned of the High Voltage Programming circuit and software to fix the fuses. You can find a good write up this here.  So seeing that this must be a problem out here I made a Arduino shield up for this to.

Zip of the Attiny LV and HV Programmer shield I put together.

ATTINY Fuse Fix

 

After getting my Attiny85 unbricked, I still had to program the Clock fuse to what I needed. I could have figured out what was needed using this web page as a reference. Fuse Calculator And then used the HV circuit to set the fuses.  But, still a wanting to do it my way!  I went back to my trusty AVR programmer, and finished programming my ATtiny85 to have a clock speed of 16mHz (PLL).

Now we are cooking with fire….  This is where I was at, a ATtiny85, LCD 16×2 with a I2C backpack, and handful of DS18x20 chips.  I decided not to write any code at this time, but modify The Shed’s code to match my components to see if my wiring was working.  I always like to start from a known point and then really screw it up after that!  Well, some god’s of electronic adventures was good to me and we had a temperature show up on the LCD. And better yet it changed.  The bad part is it had a problem reading negative temperatures, so had to start working out a method that would give me a negative value. (It gets dam cold around here in the winter. Alberta, Canada) And the sketch below is the code that will do the job.  You will also see that I have hard coded in the DS18x20 addresses.  Did this so the correct reading matches up with the text on the LCD.

I then layed out a board fast, etched, drilled and stuff in a couple of hours to test out my new code.

A wack of Pics showing a semi completed project:

April 01 2013 046 April 01 2013 045 April 01 2013 044 April 01 2013 041

 

April 01 2013 047

I am including my eagle cad drawing for the project as well as the library folder from the Arduino 1.03 Digispark interface.   The PCB is pretty dam poor designing, I am not good at doing 2 sided boards at home yet.  Something like 12 jumpers one has to solder in on this one, however, it only took me 30 minutes to do the schematic and PCB layout.

Zip of my files:

Digispark_DS18x20_LCD_2_sensors_march_2013_v4_

The next one will use the 8×2 display and be more modular. Thinking of going with a power supply board, ATTiny board and LCD interface board that match the 8×2 8 pin dual row header.

 

Till next time, thanks for your time.

 

 

Sketch:

/*
April 01, 2013

electronicramblings.com
Digispark Arduino interface 1.03 used to compile code
Digispark(Tiny Core)
ATtiny85 Clock PLL-16Mhz
LCD control PCF8475A ([A]extended address chip) wired to use the DFRRobot Library
Eagle board “LCD 8×2 dual DS18x20 Ver2.brd”
(actually uses a header for 16×2 LCD) Was going to use a 8×2 but it was damaged.

I2C LCD connects to SDA, SCL +5v, Gnd (Don’t forget the 4k7ohm pull up resistors for the SDA SCL pins)
Uses a 16×2 I2C LCD Backlight Display

DS18B20 x2 Temperature chip on pin P4
4k7 pullup between pin P4 and +5v.
Hard code addresses of sensor to make code smaller and easier.

Pin connections of ATtiny85
P0 = SDA Pin 5
P1 = Pin 6
P2 = SCL Pin 7
P3 = Pin 2
P4 = DS18B20 Pin 3
P5 = Pin 1

*/

#include <OneWire.h>
#define ONE_WIRE_BUS 4 // DS18B20 is on P4
#include <TinyWireM.h> // I2C Master lib for ATTinys which use USI – comment this out to use with standard arduinos
#include <LiquidCrystal_I2C.h> // for LCD w/ GPIO MODIFIED for the ATtiny85
#define GPIO_ADDR 0x38 //LCD address, PCF8475A extended address

OneWire ds(ONE_WIRE_BUS);
LiquidCrystal_I2C lcd(GPIO_ADDR,16,2); // set address & 16 chars / 2 lines

//DS18S20 temperature senor MAC address
byte addr[8]={0x10, 0x22, 0xE1, 0x48, 0x00, 0x08, 0x00, 0xBE};//long sensor cable [outside]
//DS18S20 temperature senor MAC address
byte addr1[8]={0x10, 0xEC, 0xA7, 0x48, 0x00, 0x08, 0x00, 0x47};//Short sensor cable [inside]

//
int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract;
char buf[20];

int HighBytea, LowBytea, TReadinga, SignBita, Tc_100a, Wholea, Fracta;
char bufa[20];

//________________________________________________________________________________
void setup(void) {
// set up the LCD’s number of rows and columns:

TinyWireM.begin(); // initialize I2C lib

lcd.init(); // initialize the lcd
lcd.clear();
lcd.noCursor();
lcd.backlight(); // Turn on the backlight

// Print a message to the LCD.
lcd.setCursor(0,0); // First position (0) and first line (0)
lcd.print (“Arduino “);
lcd.setCursor(2,1); // First position (0) and second line (1)
lcd.print (“Temp Sensors”);
delay(4000);
lcd.clear();

}
//________________________________________________________________________________

void loop(void) {
sensorRead();
sensor2Read();
delay(3000);

}

//________________________________________________________________________________

void sensorRead()
{
byte i;
byte present = 0;
byte data[12];

ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end

delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.

present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad

for ( i = 0; i < 9; i++)
{ // we need 9 bytes
data[i] = ds.read();
}

LowByte = data[0];
HighByte = data[1];
TReading = (HighByte << 8) + LowByte;
SignBit = TReading & 0x8000; // test most sig bit
if (SignBit) // negative
{
TReading = (TReading ^ 0xffff) + 1; // 2’s comp
}
Tc_100 = (TReading*100/2);

Whole = Tc_100 / 100; // separate off the whole and fractional portions
Fract = Tc_100 % 100;

sprintf(buf, “%c%d.%d\337C “,SignBit ? ‘-‘ : ‘+’, Whole, Fract < 10 ? 0 : Fract);
lcd.setCursor(0,0);
lcd.print(buf);
lcd.setCursor(9,0);
lcd.print(“Outside”);
}
//________________________________________________________________________________
void sensor2Read()
{
byte j;
byte presenta = 0;
byte dataa[12];

ds.reset();
ds.select(addr1);
ds.write(0x44,1); // start conversion, with parasite power on at the end

delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.

presenta = ds.reset();
ds.select(addr1);
ds.write(0xBE); // Read Scratchpad

for ( j = 0; j < 9; j++)
{ // we need 9 bytes
dataa[j] = ds.read();
}

LowBytea = dataa[0];
HighBytea = dataa[1];
TReadinga = (HighBytea << 8) + LowBytea;
SignBita = TReadinga & 0x8000; // test most sig bit
if (SignBita) // negative
{
TReadinga = (TReadinga ^ 0xffff) + 1; // 2’s comp
}
Tc_100a = (TReadinga*100/2);

Wholea = Tc_100a / 100; // separate off the whole and fractional portions
Fracta = Tc_100a % 100;

sprintf(bufa, “%c%d.%d\337C “,SignBita ? ‘-‘ : ‘+’, Wholea, Fracta < 10 ? 0 : Fracta);
lcd.setCursor(0,1);
lcd.print(bufa);
lcd.setCursor(9,1);
lcd.print(“Inside”);

}

 

_________________________________________________________________

Keywords: Dallas Maxim Temperature ATtiny ATMEL AVR Studio I2C IIc

 

 

2 Comments more...

Arduino TVout DS18S20 DS18B20 with Graphing!!!

by on Mar.04, 2013, under Arduino, Arduino ATmega328, Electronic Projects

Another Great Visual Arduino Adventure.

Again this is a more of a reminder for me of the sketch and a working sketch for others to start from.

Now I searched Google for TVout graphing….and found this site: TVout with video overlay.

From this site was able to modify the sketch to be able to graph my DS18x20 sensor. Now that may not seem like a big thing, but I was impressed by being able to do this with a simple 8 bit processor.

The graph up dates about every second and shows the graphed data point in the top left corner. Picture not so good.(Iphone3 just can’t handle the flash that happens on my monitor)

March 03 2013 008

To x,y axis show up on the second rotation of the graph, have not figured out why at this time, but will repost once I do.

Till next time, thanks for your time.

Sketch:
/*
************
Video out with DS18x20 Sensors Graphing
************
electroinicramblings.com
***********
//http://nootropicdesign.com/projectlab/2011/03/20/text-and-graphics-overlay/
Above is where I got the graphing code.
//
Video Out with Maxim/Dallas DS18x20 temperature sensors displayed.
Pin 3 is for 1-wire
Video setup as discribed in Arduino.cc
This simple sketch is to show 1 temperatures on a tv or video monitor
Updates graph aprox. every 1 seconds.
Graph on TV!!!!
March 03, 2013

Important:
any delays you require should be TV.delay(), if not you will loose video.

*/
#include <TVout.h>
#include <font4x6.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port 10 on the Arduino
#define ONE_WIRE_BUS 3
#define TEMPERATURE_PRECISION 12

TVout TV;

unsigned char x,y;
unsigned char originx = 5;
unsigned char originy = 80;
unsigned char plotx = originx;
unsigned char ploty = 40;
unsigned int n = 0;
int index = 0;

 

//Varibles for temperature Video Out
float T1;

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

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

//Device is a DS18S20 : 10-EC-A7-48-00-08-00-47
DeviceAddress tempa={0X10, 0XEC, 0XA7, 0X48, 0X00, 0X08, 0X00, 0X47}; //DS18S20 temperature senor MAC address

void gtemp()
{
sensors.requestTemperatures(); //Get temperature of all sensors
TV.delay(750);
T1=(sensors.getTempC(tempa));
}

void setup(void)
{
TV.fill(0);
drawGraph();
// randomSeed(analogRead(0));
sensors.begin();
// set the resolution to 12 bit
sensors.setResolution(tempa, TEMPERATURE_PRECISION); //Setup Dallas sensor resolution and address

//Video out setup
TV.begin(NTSC,136,96);
TV.select_font(font4x6);
}

void loop(void)
{
gtemp();

for(int x=6;x>=0;x–) {
if (x<6) {
TV.delay_frame(1);
}

for(byte y=87;y<96;y++) {
TV.draw_line(0, y, 5, y, 0);
TV.draw_line(128, y, 134, y, 0);
}
}

index++;
if (index > 45) {
index = 0;
}

 

TV.print(0,0,” C ARDUINO TEMPERATURE GRAPH”);
TV.print(0,0,T1);

if (plotx++ > 120) {
TV.fill(0);
drawGraph();
plotx = originx + 1;
return;
}
byte newploty = (1/T1)*1000;
newploty = constrain(newploty, 15, originy);

TV.draw_line(plotx-1, ploty, plotx, newploty, 1);
ploty = newploty;
}

void drawGraph()
{
TV.draw_line(originx, 15, originx, originy, 1);
TV.draw_line(originx, originy, 120, originy, 1);
for(byte y=originy;y>15;y -= 4) {
TV.set_pixel(originx-1, y, 1);
TV.set_pixel(originx-2, y, 1);
}
for(byte x=originx;x<120;x += 4) {
TV.set_pixel(x, originy+1, 1);
TV.set_pixel(x, originy+2, 1);
}
}

 

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...