|!Punctuation|!Location|!Function|\n|{{{@@...@@}}}|surrounding text|@@highlighted text@@|\n|{{{//...//}}}|surrounding text|//italicized text//|\n|{{{==...==}}}|surrounding text|==strikethrough text==|\n|{{{''...''}}}|surrounding text|''boldfaced text''|\n|{{{__...__}}}|surrounding text|__underlined text__|\n|{{{[[text|url]]}}}|around text/url pair|[[text|http://gri.gallaudet.edu/]] link to url|\n|{{{ {...} }}}|''__tripled__'' surrounding text|{{{in-line literal text}}}|\n|{{{ {...} }}}|''__tripled__'' surrounding ''__lines__''|literal block|\n|{{{<<<}}}|surrounding ''__lines__''|blockquotes|\n|{{{!}}}|at start of line|subheading|\n|{{{|...|...|}}}|line sectioned by vertical bars|table row|\n|{{{!}}}|in a table|!table heading|\n|{{{----}}}|alone on line|horizontal rule|\n|{{{*}}}|at start of line|bulleted list item|\n|{{{#}}}|at start of line|numbered list item|\nsource: Kevin Cole, January 2007
TTiddlyWiki uses Wiki style markup, a way of lightly "tagging" plain text so it can be transformed into HTML. Edit this Tiddler to see samples.\n\n! Header Samples\n!Header 1\n!!Header 2\n!!!Header 3\n!!!!Header 4\n!!!!!Header 5\n\n! Unordered Lists:\n* Lists are where it's at\n* Just use an asterisk and you're set\n** To nest lists just add more asterisks...\n***...like this\n* The circle makes a great bullet because once you've printed a list you can mark off completed items\n* You can also nest mixed list types\n## Like this\n\n! Ordered Lists\n# Ordered lists are pretty neat too\n# If you're handy with HTML and CSS you could customize the [[numbering scheme|http://www.w3schools.com/css/pr_list-style-type.asp]]\n## To nest, just add more octothorpes (pound signs)...\n### Like this\n* You can also\n** Mix list types\n*** like this\n# Pretty neat don't you think?\n\n! Tiddler links\nTo create a Tiddler link, just use mixed-case WikiWord, or use [[brackets]] for NonWikiWordLinks. This is how the GTD style [[@Action]] lists are created. \n\nNote that existing Tiddlers are in bold and empty Tiddlers are in italics. See CreatingTiddlers for details.\n\n! External Links\nYou can link to [[external sites|http://google.com]] with brackets. You can also LinkToFolders on your machine or network shares.\n\n! Images\nEdit this tiddler to see how it's done.\n[img[http://img110.echo.cx/img110/139/gorilla8nw.jpg]]\n\n!Tables\n|!th1111111111|!th2222222222|\n|>| colspan |\n| rowspan |left|\n|~| right|\n|colored| center |\n|caption|c\n\nFor a complex table example, see PeriodicTable.\n\n! Horizontal Rules\nYou can divide a tiddler into\n----\nsections by typing four dashes on a line by themselves.\n\n! Blockquotes\n<<<\nThis is how you do an extended, wrapped blockquote so you don't have to put angle quotes on every line.\n<<<\n>level 1\n>level 1\n>>level 2\n>>level 2\n>>>level 3\n>>>level 3\n>>level 2\n>level 1\n\n! Other Formatting\n''Bold''\n==Strike==\n__Underline__\n//Italic//\nSuperscript: 2^^3^^=8\nSubscript: a~~ij~~ = -a~~ji~~\n@@highlight@@\n@@color(green):green colored@@\n@@bgcolor(#ff0000):color(#ffffff):red colored@@\n
Temperature Sensor Project
make Dallas Semi Temperature Sensor work easy
RS232 Female to RJ45 Plug Adapter (Wired to [[EIA-561|http://www.marchansen.com/tn103/#6]])\n|!RJ-45 Pin |! Color |! DB-9 Pin|! Signal |\n| 1 |Blue| 1 | DCD|\n| 2 |Red|||\n| 3 |Black| 9 | RI|\n| 4 |Orange| 5 | GND|\n| 5 |Green| 2 | RXD|\n| 6 |Yellow| 3 | TXD|\n| 7 |Brown|| |\n| 8 |White|||\nNOTE this is pinning from the back side of our connector adaptor\n[img[http://www.aggsoft.com/rs232-pinout-cable/images/9-pinout.gif]]\n[[Additional Source|http://www.marchansen.com/tn103/]]
[[overview]]\n[[progress]]\n\n
[[Solarfest Presentation|http://docbox.flint.com/~flint/sfhtml/Solarfest_2013-07-12-5.html]]\n\nBuild the simplest possible PC based temperature sensor\n\n[[Live view of tsp on inside of house|http://docbox.flint.com/~flint/tsp/itemp/]]\n[[Live view of tsp on outside of house|http://docbox.flint.com/~flint/tsp/otemp/]]\n[[Live view of tsp on inside and outside of house|http://docbox.flint.com/~flint/temp.html]]\n\n* [[cross-link to original page|http://docbox.flint.com:8081/geekland#TempratureSensor]]\n\n[img[http://www.hoppie.nl/tempsens/ds18s20.png]]\n\nI want to painlessly get this sensor to work with a [[standard old school PC 9 pin serial connector|RS232connector]]. I now realize that the way to go is the new school USB serial device, in Linux /dev/ttyACM? (insert binary number for ?).\n\nMaxim/Dallas call these iButtons temp sensors Thermochrons and humitidy sensors Hygrochron \n\n[[This is another approach|http://www.projects.privateeyepi.com/home/temperature-gauge]]\n
\n* [[Actual hard adapter pictures|http://public.rz.fh-wolfenbuettel.de/~hamannm/general/digitemp.html]]\n* [[Very good mult-project|http://www.hoppie.nl/tempsens/]]\n* [[Adapter in the connector|http://hackedgadgets.com/2006/06/13/temperature-measurement-under-windowslinux-with-ds1820-sensor/]]\n* [[Note that schematic shows ground as the RXD line|http://hackedgadgets.com/wp-content/temp_sensor_6.gif]]\n* [[One wire|http://www.1wire.org/]]
|!Reference HTML|! Description|\n|[[What we bought |http://www.ibuttonlink.com/linkusb.aspx]]||\n|[[Other Ibuttons |http://www.ibuttonlink.com/other-ibuttons-dallas.aspx]]||\n|[[1 Wire DB9's |http://www.ibuttonlink.com/1-wire-interface-masters.aspx]]||\n|[[Order Complete |https://www.ibuttonlink.com/ssl/Confirm.aspx]]||\n|[[Expensive Software |http://www.ibuttonlink.com/software-thermodata.aspx]]||\n|[[catalog |http://www.ibuttonlink.com/thermochrons-hygrochrons.aspx]]||\n|[[Sale items |http://www.ibuttonlink.com/scratchdent.aspx]]| 03/18/2012 two cables and a sensor|\n\n\n
[[Source:|http://apartment-automation.blogspot.com/2009/09/installing-1-wire-usb-adapter-ds9490r.html]]\nFollowing the Dallas Standard for RJ11/12, you have:\n\n''RJ-11 Wiring'' \n|!Pin |!Color |! Description|\n|1 |White or Orange | Regulated 5VDC < 50mA |\n|2 |Black | Power Return Ground|\n|3 |Red | One Wire Data OWIO / DQ|\n|4 |Green | One Wire Return OWRTN / Ground|\n|5 |Yellow | Not Connected|\n|6 |Blue | Unregulated supply < 500 mA|\n\n\nPin Color Description\n-----------------------------------------\n1 White / Regulated 5VDC < 50mA\nOrange\n2 Black Power Return / Ground\n3 Red One Wire Data / OWIO / DQ\n4 Green One Wire Return / OWRTN / Ground\n5 Yellow Not Connected\n6 Blue Unregulated supply < 500 mA\n\nMaybe you'd like to go for RJ45? Then, I'd suspect to follow the proposed 1W-RJ45 Standard from Springbok.
|!Reference HTML|! Description|\n|[[getting_the_linux_1wire_file_system_owfs_to_work |http://jack-kelly.com/getting_the_linux_1wire_file_system_owfs_to_work]]| Basic description of udev isue|\n|[[owfs and usb |http://owfs.org/index.php?page=udev-and-usb]]| Annotated description of udev isue|\n|[[example usb |http://automation.binarysage.net/?p=1244]]| |\n|[[google reference |http://www.google.com/search?client=ubuntu&channel=fs&q=open+source+ibutton&ie=utf-8&oe=utf-8#hl=en&client=ubuntu&channel=fs&sclient=psy-ab&q=owfs+usb+Compile-time+options+ubuntu&oq=owfs+usb+Compile-time+options+ubuntu&aq=f&aqi=&aql=&gs_l=serp.3...759370l760070l5l760262l6l6l0l0l0l0l189l742l2j4l6l0.frgbld.&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=fdbe2e7e0bbb2d6e&biw=986&bih=769]]||\n|[[apartment-automation |http://apartment-automation.blogspot.com/2009/09/installing-1-wire-usb-adapter-ds9490r.html]]||\n|[[configuration man page |http://owfs.org/index.php?page=configuration]]||\n|[[Maxim Reference |http://www.maxim-ic.com/app-notes/index.mvp/id/4373]]||\n|[[Springbrook Standard |http://1wire.org/index.html?target=p_2.html&lang=en-us]]| RJ-45 Standard wiring|\n
owfs.rules\n\n{{{\nSUBSYSTEM!="usb_device", ACTION!="add", GOTO="owfs_rules_end"\n \n# DS2490 1-Wire adapter\nSYSFS{idVendor}=="0403", SYSFS{idProduct}=="6001", MODE="660", GROUP="fuse"\n \nLABEL="owfs_rules_end"\n}}}
Use this to read the temperature in celsius\n\n{{{\n cat /media/1-wire/28.624F3C020000/temperature\n}}}
\nThis command snippet is loosely based upon the chunk of code below:\n{{{\necho "9 * $(cat /media/1-wire/28.624F3C020000/temperature) / 5 + 32" | bc\n}}}\n\n[[SOURCE:|http://bash.cyberciti.biz/decision-making/fahrenheit-to-celsius-temperature-conversion/]]\n\n{{{\n#!/bin/bash\n# Shell script to convert Fahrenheit to Celsius Temperature or Celsius\n# to Fahrenheit Temperature\n# -------------------------------------------------------------------------\n# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>\n# This script is licensed under GNU GPL version 2.0 or above\n# -------------------------------------------------------------------------\n# This script is part of nixCraft shell script collection (NSSC)\n# Visit http://bash.cyberciti.biz/ for more information.\n# -------------------------------------------------------------------------\n# Fahrenheit and Celsius Temperature Scales more info:\n# http://en.wikipedia.org/wiki/Temperature_conversion_formulas\n# --------------------------------------------------------------------\necho "*** Converting between the different temperature scales ***"\necho "1. Convert Celsius temperature into Fahrenheit"\necho "2. Convert Fahrenheit temperatures into Celsius"\necho -n "Select your choice (1-2) : "\nread choice\n \nif [ $choice -eq 1 ]\nthen\n echo -n "Enter temperature (C) : "\n read tc\n # formula Tf=(9/5)*Tc+32\n tf=$(echo "scale=2;((9/5) * $tc) + 32" |bc)\n echo "$tc C = $tf F"\nelif [ $choice -eq 2 ]\nthen\n echo -n "Enter temperature (F) : "\n read tf\n # formula Tc=(5/9)*(Tf-32)\n tc=$(echo "scale=2;(5/9)*($tf-32)"|bc)\n echo "$tf = $tc"\nelse\n echo "Please select 1 or 2 only"\n exit 1\n\n}}}
This is a [[photo of a wiring detail |http://3.bp.blogspot.com/_sMLHPV923IY/SsOg7biAoeI/AAAAAAAAAuI/2Wi306RW7WE/s1600-h/sensor.jpg]]\n\n!1wire.org web site\n|!Reference HTML|! Description|\n|[[USB Adapters |http://1wire.org/index.html?target=p_2.html&lang=en-us]]||\n|[[Wiring Guide |http://1wire.org/en-us/dept_27.html]]||\n|[[Standard Page |http://1wire.org/index.html?target=p_1.html&lang=en-us]]||\n|[[Community |http://1wire.org/en-us/dept_2.html]]||\n|[[Change List |http://1wire.org/en-us/pg_9.html]]||\n|[[Publications |http://1wire.org/en-us/dept_63.html#item_165]]||\n|[[Interesting Projects |http://1wire.org/index.html?target=p_165.html&lang=en-us]]||\n|[[BBS |http://1wire.org/en-us/pg_8.html]]||
Signals off RJ45:\n\nFemale RJ45 Plug Adapter (Wired to [[EIA-561|http://www.marchansen.com/tn103/#6]])\n|!RJ-45 Pin |! Color |! DB-9 Pin|! Signal |\n| 1 |Blue| 1 | |\n| 2 |Red|| |\n| 3 |Black| 9 | RI|\n| 4 |Orange| 5 | GND|\n| 5 |Green| 2 | RXD|\n| 6 |Yellow| 3 | TXD|\n| 7 |Brown|| |\n| 8 |White|||\nNOTE this is pinning from the back side of our connector adapter\n\n|>|>| !TOP| !VDC|\n|wt/or||| 0|\n|or/wt|| ???| 11.27|\n|wt/bl| 3 | txd| 11.27|\n|bl/wt||| o|\n\n|>|>| !BOTTOM| !VDC|\n|wt/or| 2 | rxd||\n|or/wt||| 0|\n|wt/bl| 5 | gnd| n/a|\n|bl/wt||| 0|
Signals off RJ45:\n\nFemale RJ45 Plug Adapter (Wired to [[EIA-561|http://www.marchansen.com/tn103/#6]])\n|! Color|! Eboard|! |! Sig|! Eboard Color! |! |! |! VDC|\n| 1 |Blue| 1 | |B wt/bl| 1|5 gnd| n/a|\n| 2 |Red|| |B bl/wt| 2| |0|\n| 3 |Black| 9 | RI|T bl/wt| 3|| o|\n| 4 |Orange| 5 | GND|B wt/or| 4| 2 rxd||\n| 5 |Green| 2 | RXD|B or/wt| 5|| 0|\n| 6 |Yellow| 3 | TXD|T wt/bl| 6|3 txd| 11.27|\n| 7 |Brown|| |T wt/or| 7|| 0|\n| 8 |White|||T or/wt| 8| ???| 11.27|\n\n\n\n\n|!{{{RJ-45}}} Pin |! Jack Color |! Eboard Color|! 1 Wire Signal |\n| 1 |Blue| 1 | |\n| 2 |Red|| |\n| 3 |Black| 9 | RI|\n| 4 |Orange| 5 | GND|\n| 5 |Green| 2 | RXD|\n| 6 |Yellow| 3 | TXD|\n| 7 |Brown|| |\n| 8 |White|||\n\n\nNOTE this is pinning from the back side of our connector adapter\n\n|>|>| !TOP| !VDC|\n|! Color|! Eboard|! Sig|! |\n|wt/or| 7|| 0|\n|or/wt| 8| ???| 11.27|\n|wt/bl| 6|3 txd| 11.27|\n|bl/wt| 3|| o|\n\n|>|>| !BOTTOM| !VDC|\n|! Color|! Eboard|! Sig|! |\n|wt/or| 4| 2 rxd||\n|or/wt| 5|| 0|\n|wt/bl| 1|5 gnd| n/a|\n|bl/wt| 2| |0|
! Eboard Wiring\n|! RJ-45|! Color|! Eboard Color! |! 1 Wire |! Designation|! VDC|! T568B|! Ref|\n| 1 |Blue|B wt/bl||| n/a| Slate| 1|\n| 2 |Red|B bl/wt||| n/a|Wt or Or| 2|\n| 3 |Black|T bl/wt|OWGND|1 wire to 3|0|Black| 3|\n| 4 |Orange|B wt/or|OWIO||5|Red| 4|\n| 5 |Green|B or/wt|OWRTN|3 wire to 1|0|Green| 5|\n| 6 |Yellow|T wt/bl||| n/a|Yellow| 6|\n| 7 |Brown|T wt/or||| n/a|Blue| 7|\n| 8 |White|T or/wt||| n/a|Brown| 8|
Type the text for Step-by-step, based on [[Apartment Automation|http://apartment-automation.blogspot.com/2009/09/installing-1-wire-usb-adapter-ds9490r.html]]\n\n# Install [[Support Software|AAss]]\n# [[Download|http://sourceforge.net/project/showfiles.php?group_id=85502]], owfs-2.8p14.tar.gz (1.4 MB)\n## [[Unzip|GunzipOW]], \n## [[Configure|ConfigureOW]]\n## [[Install|MakeOW]]\n
Type the text for 'New Tiddler'\n\n{{{\n apt-get install automake autoconf autotools-dev gcc g++ libtool libusb-dev fuse-utils libfuse-dev swig python2.4-dev tcl8.4-dev php5-dev \n}}}
Installing One Wire\n\n[[Source:|http://apartment-automation.blogspot.com/2009/09/installing-1-wire-usb-adapter-ds9490r.html]]\n\n/etc/udev/rules.d/owfs.rules\n{{{\nSUBSYSTEM!="usb_device", ACTION!="add", GOTO="owfs_rules_end"\n \n# DS2490 1-Wire adapter\nSYSFS{idVendor}=="04fa", SYSFS{idProduct}=="2490", MODE="660", GROUP="fuse"\n \nLABEL="owfs_rules_end"\n}}}\n\n[[Excellent Source of information |http://owfs.sourceforge.net/install.html]]\n[[Another goodie |https://sites.google.com/a/jhouse.pl/index/installation/installing-owfs]]\n\n{{{\n.configure --enable-usb\n}}}
gunzip with the works...\n{{{\ntar -zxvf owfs-2.8p16.tar.gz\n}}}
SOURCE:README\n\nIf you downloaded the source package:\n ./configure\n make install\n /opt/owfs/bin/owfs -d /dev/ttyS0 /mnt/1wire # (for example)\n\nor\n /opt/owfs/bin/owfs -d /dev/ttyUSB0 /mnt/1wire # (for example)\n\n\n
SOURCES\n\n# run lsusb | wc -l, remember number\n# Plug in tsp. lsusb | wc -l. Should go up by one.\n# type dmesg see [[dmesg result|dmesgResult]]\n# type {{{mkdir -p /media/1-wire}}}\n# type {{{chmod 777 /media/1-wire}}}\n# type {{{/opt/owfs/bin/owfs --allow_other -u /media/1-wire}}} \n# type {{{/opt/owfs/bin/owfs /dev/ttyUSB0 /media/1-wire}}}\n# [[troubleshooting|USBissues]]\n# Test {{{}}}\n# Test {{{echo $( (9/5) * 'cat /media/1-wire/28.624F3C020000/temperature' ) + 32 |bc)\necho "9 * $(cat /media/1-wire/28.624F3C020000/temperature) / 5 + 32" | bc\n\n}}}\n# Test {{{echo "9 * $(cat /media/1-wire/28.624F3C020000/temperature) / 5 + 32" | bc}}}
Type the text for 'New Tiddler'\n\ntype dmesg:\n{{{\ndmesg | grep FTDI\n}}}\n\nsee \n\n{{{\n[ 1032.208161] usb 4-1: FTDI USB Serial Device converter now attached to ttyUSB0\n}}}
Type the text for 'New Tiddler'\n\n 76 /opt/owfs/bin/owhttpd -u -p 4444\n 149 /opt/owfs/bin/owfs --allow_other -u /media/1-wire\n 153 /opt/owfs/bin/owfs --allow_other -u /media/1-wire\n 154 sudo /opt/owfs/bin/owfs u -m /media/1-wire\n 156 sudo /opt/owfs/bin/owfs u -m /var/lib/1wire\n
Messages:\n\n* [[Cannot open USB bus master]]\n* [[No valid 1-wire buses found]]\n\nTools\n* {{{watch "dmesg | tail -20"}}} - keep an eye on dmesg\n\n{{{\nkillall owfs\numount /mnt/1-wire\numount /media/1-wire\nrm -rf /media/1-wire\nmkdir -p /media/1-wire\nchmod 777 /media/1-wire\n/opt/owfs/bin/owfs --allow_other -u /media/1-wire\n/opt/owfs/bin/owfs /dev/ttyUSB0 /media/1-wire\n/opt/owfs/bin/owfs /dev/ttyUSB1 /media/1-wire\n}}}\n\n
\n\n{{{\n#!/bin/bash\n# pflint Mon Jun 4 21:23:29 EDT 2012\n# run as root...\n# Make sure only root can run our script\nif [[ $EUID -ne 0 ]]; then\n echo "This script must be run as root" 1>&2\n exit 1\nfi\necho "Lets go!"\n# unmount and remount owfs device\n# Kill daemons\nkillall owfs\n# Unmount device area\numount /media/1-wire\n# remove device area\nrm -rf /media/1-wire\n# renew device area\nmkdir -p /media/1-wire\n# set permissions for device area\nchmod 777 /media/1-wire\nDEVICE=$(dmesg | grep FTDI | rev | cut -d " " -f 1 | rev | tail -1)\necho $DEVICE\n/opt/owfs/bin/owfs /dev/$DEVICE /media/1-wire\ncd /media/1-wire\nls -alt\necho "all done!"\n}}}
{{{\n\n// This Arduino sketch reads DS18B20 "1-Wire" digital\n// temperature sensors.\n// Tutorial:\n// http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html\n\n#include <OneWire.h>\n#include <DallasTemperature.h>\n\n// Data wire is plugged into pin 3 on the Arduino\n#define ONE_WIRE_BUS 6\n\n// Setup a oneWire instance to communicate with any OneWire devices\nOneWire oneWire(ONE_WIRE_BUS);\n\n// Pass our oneWire reference to Dallas Temperature. \nDallasTemperature sensors(&oneWire);\n\n// Assign the addresses of your 1-Wire temp sensors.\n// See the tutorial on how to obtain these addresses:\n// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html\n\nDeviceAddress insideThermometer = { 0x28, 0x41, 0xB8, 0x4D, 0x03, 0x00, 0x00, 0xB4 };\nDeviceAddress outsideThermometer = { 0x28, 0xE9, 0xEE, 0x4D, 0x03, 0x00, 0x00, 0x40 };\n\nvoid setup(void)\n{\n // start serial port\n Serial.begin(9600);\n // Start up the library\n sensors.begin();\n // set the resolution to 10 bit (good enough?)\n sensors.setResolution(insideThermometer, 10);\n\n}\n\nvoid printTemperature(DeviceAddress deviceAddress)\n{\n float tempC = sensors.getTempC(deviceAddress);\n if (tempC == -127.00) {\n Serial.print("Error getting temperature");\n } else {\n Serial.print("C: ");\n Serial.print(tempC);\n Serial.print(" F: ");\n Serial.print(DallasTemperature::toFahrenheit(tempC));\n }\n}\n\nvoid loop(void)\n{ \n delay(100);\n sensors.requestTemperatures();\n Serial.write(27); //Print "esc"\n Serial.print("[2J");\n \n Serial.print("Inside temperature is: ");\n printTemperature(insideThermometer);\n Serial.println(' ');\n Serial.print("Outside temperature is: ");\n printTemperature(outsideThermometer);\n\n}\n\n}}}
{{{\n\n#ifndef OneWire_h\n#define OneWire_h\n\n#include <inttypes.h>\n\n#if ARDUINO >= 100\n#include "Arduino.h" // for delayMicroseconds, digitalPinToBitMask, etc\n#else\n#include "WProgram.h" // for delayMicroseconds\n#include "pins_arduino.h" // for digitalPinToBitMask, etc\n#endif\n\n// You can exclude certain features from OneWire. In theory, this\n// might save some space. In practice, the compiler automatically\n// removes unused code (technically, the linker, using -fdata-sections\n// and -ffunction-sections when compiling, and Wl,--gc-sections\n// when linking), so most of these will not result in any code size\n// reduction. Well, unless you try to use the missing features\n// and redesign your program to not need them! ONEWIRE_CRC8_TABLE\n// is the exception, because it selects a fast but large algorithm\n// or a small but slow algorithm.\n\n// you can exclude onewire_search by defining that to 0\n#ifndef ONEWIRE_SEARCH\n#define ONEWIRE_SEARCH 1\n#endif\n\n// You can exclude CRC checks altogether by defining this to 0\n#ifndef ONEWIRE_CRC\n#define ONEWIRE_CRC 1\n#endif\n\n// Select the table-lookup method of computing the 8-bit CRC\n// by setting this to 1. The lookup table enlarges code size by\n// about 250 bytes. It does NOT consume RAM (but did in very\n// old versions of OneWire). If you disable this, a slower\n// but very compact algorithm is used.\n#ifndef ONEWIRE_CRC8_TABLE\n#define ONEWIRE_CRC8_TABLE 1\n#endif\n\n// You can allow 16-bit CRC checks by defining this to 1\n// (Note that ONEWIRE_CRC must also be 1.)\n#ifndef ONEWIRE_CRC16\n#define ONEWIRE_CRC16 1\n#endif\n\n#define FALSE 0\n#define TRUE 1\n\n// Platform specific I/O definitions\n\n#if defined(__AVR__)\n#define PIN_TO_BASEREG(pin) (portInputRegister(digitalPinToPort(pin)))\n#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin))\n#define IO_REG_TYPE uint8_t\n#define IO_REG_ASM asm("r30")\n#define DIRECT_READ(base, mask) (((*(base)) & (mask)) ? 1 : 0)\n#define DIRECT_MODE_INPUT(base, mask) ((*(base+1)) &= ~(mask))\n#define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) |= (mask))\n#define DIRECT_WRITE_LOW(base, mask) ((*(base+2)) &= ~(mask))\n#define DIRECT_WRITE_HIGH(base, mask) ((*(base+2)) |= (mask))\n\n#elif defined(__PIC32MX__)\n#include <plib.h> // is this necessary?\n#define PIN_TO_BASEREG(pin) (portModeRegister(digitalPinToPort(pin)))\n#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin))\n#define IO_REG_TYPE uint32_t\n#define IO_REG_ASM\n#define DIRECT_READ(base, mask) (((*(base+4)) & (mask)) ? 1 : 0) //PORTX + 0x10\n#define DIRECT_MODE_INPUT(base, mask) ((*(base+2)) = (mask)) //TRISXSET + 0x08\n#define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) = (mask)) //TRISXCLR + 0x04\n#define DIRECT_WRITE_LOW(base, mask) ((*(base+8+1)) = (mask)) //LATXCLR + 0x24\n#define DIRECT_WRITE_HIGH(base, mask) ((*(base+8+2)) = (mask)) //LATXSET + 0x28\n\n#else\n#error "Please define I/O register types here"\n#endif\n\n\nclass OneWire\n{\n private:\n IO_REG_TYPE bitmask;\n volatile IO_REG_TYPE *baseReg;\n\n#if ONEWIRE_SEARCH\n // global search state\n unsigned char ROM_NO[8];\n uint8_t LastDiscrepancy;\n uint8_t LastFamilyDiscrepancy;\n uint8_t LastDeviceFlag;\n#endif\n\n public:\n OneWire( uint8_t pin);\n\n // Perform a 1-Wire reset cycle. Returns 1 if a device responds\n // with a presence pulse. Returns 0 if there is no device or the\n // bus is shorted or otherwise held low for more than 250uS\n uint8_t reset(void);\n\n // Issue a 1-Wire rom select command, you do the reset first.\n void select( uint8_t rom[8]);\n\n // Issue a 1-Wire rom skip command, to address all on bus.\n void skip(void);\n\n // Write a byte. If 'power' is one then the wire is held high at\n // the end for parasitically powered devices. You are responsible\n // for eventually depowering it by calling depower() or doing\n // another read or write.\n void write(uint8_t v, uint8_t power = 0);\n\n void write_bytes(const uint8_t *buf, uint16_t count, bool power = 0);\n\n // Read a byte.\n uint8_t read(void);\n\n void read_bytes(uint8_t *buf, uint16_t count);\n\n // Write a bit. The bus is always left powered at the end, see\n // note in write() about that.\n void write_bit(uint8_t v);\n\n // Read a bit.\n uint8_t read_bit(void);\n\n // Stop forcing power onto the bus. You only need to do this if\n // you used the 'power' flag to write() or used a write_bit() call\n // and aren't about to do another read or write. You would rather\n // not leave this powered if you don't have to, just in case\n // someone shorts your bus.\n void depower(void);\n\n#if ONEWIRE_SEARCH\n // Clear the search state so that if will start from the beginning again.\n void reset_search();\n\n // Look for the next device. Returns 1 if a new address has been\n // returned. A zero might mean that the bus is shorted, there are\n // no devices, or you have already retrieved all of them. It\n // might be a good idea to check the CRC to make sure you didn't\n // get garbage. The order is deterministic. You will always get\n // the same devices in the same order.\n uint8_t search(uint8_t *newAddr);\n#endif\n\n#if ONEWIRE_CRC\n // Compute a Dallas Semiconductor 8 bit CRC, these are used in the\n // ROM and scratchpad registers.\n static uint8_t crc8( uint8_t *addr, uint8_t len);\n\n#if ONEWIRE_CRC16\n // Compute the 1-Wire CRC16 and compare it against the received CRC.\n // Example usage (reading a DS2408):\n // // Put everything in a buffer so we can compute the CRC easily.\n // uint8_t buf[13];\n // buf[0] = 0xF0; // Read PIO Registers\n // buf[1] = 0x88; // LSB address\n // buf[2] = 0x00; // MSB address\n // WriteBytes(net, buf, 3); // Write 3 cmd bytes\n // ReadBytes(net, buf+3, 10); // Read 6 data bytes, 2 0xFF, 2 CRC16\n // if (!CheckCRC16(buf, 11, &buf[11])) {\n // // Handle error.\n // } \n // \n // @param input - Array of bytes to checksum.\n // @param len - How many bytes to use.\n // @param inverted_crc - The two CRC16 bytes in the received data.\n // This should just point into the received data,\n // *not* at a 16-bit integer.\n // @return True, iff the CRC matches.\n static bool check_crc16(uint8_t* input, uint16_t len, uint8_t* inverted_crc);\n\n // Compute a Dallas Semiconductor 16 bit CRC. This is required to check\n // the integrity of data received from many 1-Wire devices. Note that the\n // CRC computed here is *not* what you'll get from the 1-Wire network,\n // for two reasons:\n // 1) The CRC is transmitted bitwise inverted.\n // 2) Depending on the endian-ness of your processor, the binary\n // representation of the two-byte return value may have a different\n // byte order than the two bytes you get from 1-Wire.\n // @param input - Array of bytes to checksum.\n // @param len - How many bytes to use.\n // @return The CRC16, as defined by Dallas Semiconductor.\n static uint16_t crc16(uint8_t* input, uint16_t len);\n#endif\n#endif\n};\n\n#endif\n\n}}}
{{{\n\n\n#ifndef DallasTemperature_h\n#define DallasTemperature_h\n\n#define DALLASTEMPLIBVERSION "3.7.2"\n\n// This library is free software; you can redistribute it and/or\n// modify it under the terms of the GNU Lesser General Public\n// License as published by the Free Software Foundation; either\n// version 2.1 of the License, or (at your option) any later version.\n\n// set to true to include code for new and delete operators\n#ifndef REQUIRESNEW\n#define REQUIRESNEW false\n#endif\n\n// set to true to include code implementing alarm search functions\n#ifndef REQUIRESALARMS\n#define REQUIRESALARMS true\n#endif\n\n#include <inttypes.h>\n#include <OneWire.h>\n\n// Model IDs\n#define DS18S20MODEL 0x10\n#define DS18B20MODEL 0x28\n#define DS1822MODEL 0x22\n\n// OneWire commands\n#define STARTCONVO 0x44 // Tells device to take a temperature reading and put it on the scratchpad\n#define COPYSCRATCH 0x48 // Copy EEPROM\n#define READSCRATCH 0xBE // Read EEPROM\n#define WRITESCRATCH 0x4E // Write to EEPROM\n#define RECALLSCRATCH 0xB8 // Reload from last known\n#define READPOWERSUPPLY 0xB4 // Determine if device needs parasite power\n#define ALARMSEARCH 0xEC // Query bus for devices with an alarm condition\n\n// Scratchpad locations\n#define TEMP_LSB 0\n#define TEMP_MSB 1\n#define HIGH_ALARM_TEMP 2\n#define LOW_ALARM_TEMP 3\n#define CONFIGURATION 4\n#define INTERNAL_BYTE 5\n#define COUNT_REMAIN 6\n#define COUNT_PER_C 7\n#define SCRATCHPAD_CRC 8\n\n// Device resolution\n#define TEMP_9_BIT 0x1F // 9 bit\n#define TEMP_10_BIT 0x3F // 10 bit\n#define TEMP_11_BIT 0x5F // 11 bit\n#define TEMP_12_BIT 0x7F // 12 bit\n\n// Error Codes\n#define DEVICE_DISCONNECTED -127\n\ntypedef uint8_t DeviceAddress[8];\n\nclass DallasTemperature\n{\n public:\n\n DallasTemperature(OneWire*);\n\n // initalise bus\n void begin(void);\n\n // returns the number of devices found on the bus\n uint8_t getDeviceCount(void);\n \n // Is a conversion complete on the wire?\n bool isConversionComplete(void);\n \n // returns true if address is valid\n bool validAddress(uint8_t*);\n\n // finds an address at a given index on the bus \n bool getAddress(uint8_t*, const uint8_t);\n \n // attempt to determine if the device at the given address is connected to the bus\n bool isConnected(uint8_t*);\n\n // attempt to determine if the device at the given address is connected to the bus\n // also allows for updating the read scratchpad\n bool isConnected(uint8_t*, uint8_t*);\n\n // read device's scratchpad\n void readScratchPad(uint8_t*, uint8_t*);\n\n // write device's scratchpad\n void writeScratchPad(uint8_t*, const uint8_t*);\n\n // read device's power requirements\n bool readPowerSupply(uint8_t*);\n\n // get global resolution\n uint8_t getResolution();\n \n // set global resolution to 9, 10, 11, or 12 bits\n void setResolution(uint8_t);\n\n // returns the device resolution, 9-12\n uint8_t getResolution(uint8_t*);\n\n // set resolution of a device to 9, 10, 11, or 12 bits\n bool setResolution(uint8_t*, uint8_t);\n \n // sets/gets the waitForConversion flag\n void setWaitForConversion(bool);\n bool getWaitForConversion(void);\n \n // sets/gets the checkForConversion flag\n void setCheckForConversion(bool);\n bool getCheckForConversion(void);\n \n // sends command for all devices on the bus to perform a temperature conversion \n void requestTemperatures(void);\n \n // sends command for one device to perform a temperature conversion by address\n bool requestTemperaturesByAddress(uint8_t*);\n\n // sends command for one device to perform a temperature conversion by index\n bool requestTemperaturesByIndex(uint8_t);\n\n // returns temperature in degrees C\n float getTempC(uint8_t*);\n\n // returns temperature in degrees F\n float getTempF(uint8_t*);\n\n // Get temperature for device index (slow)\n float getTempCByIndex(uint8_t);\n \n // Get temperature for device index (slow)\n float getTempFByIndex(uint8_t);\n \n // returns true if the bus requires parasite power\n bool isParasitePowerMode(void);\n \n bool isConversionAvailable(uint8_t*);\n\n #if REQUIRESALARMS\n \n typedef void AlarmHandler(uint8_t*);\n\n // sets the high alarm temperature for a device\n // accepts a char. valid range is -55C - 125C\n void setHighAlarmTemp(uint8_t*, const char);\n\n // sets the low alarm temperature for a device\n // accepts a char. valid range is -55C - 125C\n void setLowAlarmTemp(uint8_t*, const char);\n\n // returns a signed char with the current high alarm temperature for a device\n // in the range -55C - 125C\n char getHighAlarmTemp(uint8_t*);\n\n // returns a signed char with the current low alarm temperature for a device\n // in the range -55C - 125C\n char getLowAlarmTemp(uint8_t*);\n \n // resets internal variables used for the alarm search\n void resetAlarmSearch(void);\n\n // search the wire for devices with active alarms\n bool alarmSearch(uint8_t*);\n\n // returns true if ia specific device has an alarm\n bool hasAlarm(uint8_t*);\n\n // returns true if any device is reporting an alarm on the bus\n bool hasAlarm(void);\n\n // runs the alarm handler for all devices returned by alarmSearch()\n void processAlarms(void);\n \n // sets the alarm handler\n void setAlarmHandler(AlarmHandler *);\n \n // The default alarm handler\n static void defaultAlarmHandler(uint8_t*);\n\n #endif\n\n // convert from celcius to farenheit\n static float toFahrenheit(const float);\n\n // convert from farenheit to celsius\n static float toCelsius(const float);\n\n #if REQUIRESNEW\n\n // initalize memory area\n void* operator new (unsigned int);\n\n // delete memory reference\n void operator delete(void*);\n \n #endif\n\n private:\n typedef uint8_t ScratchPad[9];\n \n // parasite power on or off\n bool parasite;\n\n // used to determine the delay amount needed to allow for the\n // temperature conversion to take place\n uint8_t bitResolution;\n \n // used to requestTemperature with or without delay\n bool waitForConversion;\n \n // used to requestTemperature to dynamically check if a conversion is complete\n bool checkForConversion;\n \n // count of devices on the bus\n uint8_t devices;\n \n // Take a pointer to one wire instance\n OneWire* _wire;\n\n // reads scratchpad and returns the temperature in degrees C\n float calculateTemperature(uint8_t*, uint8_t*);\n \n void blockTillConversionComplete(uint8_t*,uint8_t*);\n \n #if REQUIRESALARMS\n\n // required for alarmSearch \n uint8_t alarmSearchAddress[8];\n char alarmSearchJunction;\n uint8_t alarmSearchExhausted;\n\n // the alarm handler function pointer\n AlarmHandler *_AlarmHandler;\n\n #endif\n \n};\n#endif\n\n}}}
{{{\n\n/*************************************************************\nRemote Control Car W/ 1 wire\nBY: Chris Yarger\n\n*************************************************************/\n// load 1 wire libs\n#include <OneWire.h>\n#include <DallasTemperature.h>\n\n// Data wire is plugged into pin 6 on the Arduino\n\n#define ONE_WIRE_BUS 6\n\n// Setup a oneWire instance to communicate with any OneWire devices\n\nOneWire oneWire(ONE_WIRE_BUS);\n\n// Pass our oneWire reference to Dallas Temperature. \n\nDallasTemperature sensors(&oneWire);\n\n// Assign the addresses of your 1-Wire temp sensors.\n// See the tutorial on how to obtain these addresses:\n// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html\n\nDeviceAddress insideThermometer = { 0x28, 0x41, 0xB8, 0x4D, 0x03, 0x00, 0x00, 0xB4 };\n\n//Initialize Drive Pins\n\nint ADir = 12;\nint ABrake = 9;\nint ASpin = 3;\nint Aout = 0; \n//initialize Steering Pins\nint BDir = 13;\nint BBrake = 8;\nint BSpin = 11;\nint Bout = 1;\n// Initialize input\nint incomingByte; // a variable to read incoming serial data into\nint Aout1 = 999;\nint Bout1 = 999;\nint i = 22;\n\n\n\nvoid setup(void) {\n \n //Setup Channel A\n pinMode(ADir, OUTPUT); //Initiates Motor Channel A pin\n pinMode(ABrake, OUTPUT); //Initiates Brake Channel A pin\n pinMode(Aout, INPUT); // digital sensor is on digital pin 2\n // Setup Chanel B \n pinMode(BDir, OUTPUT); //Initiates Motor Channel A pin\n pinMode(BBrake, OUTPUT); //Initiates Brake Channel A pin\n pinMode(Bout, INPUT); // digital sensor is on digital pin 2\n//set pins for input\n Serial.begin(9600);\n // Start up the library\n sensors.begin();\n // set the resolution to 10 bit (good enough?)\n sensors.setResolution(insideThermometer, 10);\n}\n\n\n\nvoid printTemperature(DeviceAddress deviceAddress)\n{\n float tempC = sensors.getTempC(deviceAddress);\n if (tempC == -127.00) {\n Serial.print("Error getting temperature");\n } else {\n Serial.print("C: ");\n Serial.print(tempC);\n Serial.print(" F: ");\n Serial.print(DallasTemperature::toFahrenheit(tempC));\n }\n}\n\n\n\nvoid loop(){\n if (i == 22) {\n Serial.write(27); //Print "esc"\n Serial.print("[2J");\n Aout1 = analogRead(Aout)/4;\n Bout1 = analogRead(Bout)/4;\n Serial.print("Aout="); \n Serial.println(Aout1); \n Serial.print("Bout="); \n Serial.println(Bout1);\n\n sensors.requestTemperatures();\n \n Serial.print("Inside temperature is: ");\n printTemperature(insideThermometer);\n delay(1000); \n }\n\n\n\n//Parse Serial data in to motor actions\n\n //Dir HIGH = Forward\n //Dir LOW = Reverse\n //forward @ full speed\n\nif (Serial.available() > 0) {\n // read the oldest byte in the serial buffer:\n incomingByte = Serial.read();\n\n\n\n if (incomingByte == 'W') {\n digitalWrite(ADir, HIGH); //Establishes forward direction of Channel A\n digitalWrite(ABrake, LOW); //Disengage the Brake for Channel A\n analogWrite(ASpin, 2000); //Spins the motor on Channel A at full speed\n }\n\n\n if (incomingByte == 'S') {\n digitalWrite(ADir, LOW); //Establishes forward direction of Channel A\n digitalWrite(ABrake, LOW); //Disengage the Brake for Channel A\n analogWrite(ASpin, 2000); //Spins the motor on Channel A at full speed\n }\n\n \n\n \n //Steering Wheel control\n\n if (incomingByte == 'D') {\n digitalWrite(BDir, LOW); //Establishes forward direction of Channel B\n digitalWrite(BBrake, LOW); //Disengage the Brake for Channel B\n analogWrite(BSpin, 500); //Spins the motor on Channel B \n//Pauses for next command long enough to turn steering wheels 1/2 turn\ndelay(425);\n// Engages Brake for channel B\n digitalWrite(BBrake, HIGH); //Engage the Brake for Channel B\n analogWrite(BSpin, 0); //Stops spins on motor B\n \n }\n \n if (incomingByte == 'A') {\n digitalWrite(BDir, HIGH); //Establishes forward direction of Channel B\n digitalWrite(BBrake, LOW); //Disengage the Brake for Channel B\n analogWrite(BSpin, 500); //Spins the motor on Channel B \n//Pauses for next command long enough to turn steering wheels 1/2 turn\ndelay(425);\n// Engages Brake for channel B\n digitalWrite(BBrake, HIGH); //Engage the Brake for Channel B\n analogWrite(BSpin, 0); //Stops spins on motor B\n }\n\n//Emergency Brakes\n if (incomingByte == 'Q') {\n digitalWrite(BBrake, HIGH); //Engage the Brake for Channel B\n analogWrite(BSpin, 0); //Stops spins on motor B\n digitalWrite(ABrake, HIGH); //Engage the Brake for Channel A\n analogWrite(ASpin, 0); //Stops spins on motor A\n }\n }\n\n}\n}}}
{{{\n\n// This sketch looks for 1-wire devices and\n// prints their addresses (serial number) to\n// the UART, in a format that is useful in Arduino sketches\n// Tutorial: \n// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html\n\n#include <OneWire.h>\n\nOneWire ds(6); // Connect your 1-wire device to pin 3\n\nvoid setup(void) {\n Serial.begin(9600);\n discoverOneWireDevices();\n}\n\nvoid discoverOneWireDevices(void) {\n byte i;\n byte present = 0;\n byte data[12];\n byte addr[8];\n \n Serial.print("Looking for 1-Wire devices...\sn\sr");\n while(ds.search(addr)) {\n Serial.print("\sn\srFound \s'1-Wire\s' device with address:\sn\sr");\n for( i = 0; i < 8; i++) {\n Serial.print("0x");\n if (addr[i] < 16) {\n Serial.print('0');\n }\n Serial.print(addr[i], HEX);\n if (i < 7) {\n Serial.print(", ");\n }\n }\n if ( OneWire::crc8( addr, 7) != addr[7]) {\n Serial.print("CRC is not valid!\sn");\n return;\n }\n }\n Serial.print("\sn\sr\sn\srThat's it.\sr\sn");\n ds.reset_search();\n return;\n}\n\nvoid loop(void) {\n // nothing to see here\n}\n\n\n\n}}}
Result of owfs .configure\n\n{{{\nCurrent configuration:\n\n Deployment location: /opt/owfs\n\nCompile-time options:\n Caching is enabled\n USB is DISABLED\n I2C is enabled\n HA7Net is enabled\n W1 is enabled\n Multithreading is enabled\n Parallel port DS1410E is enabled\n TAI8570 barometer is enabled\n Thermocouple is enabled\n Zeroconf/Bonjour is enabled\n Debug-output is enabled\n Profiling is DISABLED\nTracing memory allocation is DISABLED\n1wire bus traffic reports is DISABLED\n\nModule configuration:\n owlib is enabled\n owshell is enabled\n owfs is DISABLED\n owhttpd is enabled\n owftpd is enabled\n owserver is enabled\n owexternal is enabled\n ownet is enabled\n ownetlib is enabled\n owtap is enabled\n owmon is enabled\n owcapi is enabled\n swig is DISABLED\n owperl is DISABLED\n owphp is DISABLED\n owpython is DISABLED\n owtcl is DISABLED\n}}}\n
The Arduino based method works with a gathering python script coupled to bash based display scripts that attach to [[mrtg|http://docbox.flint.com:8081/mrtg]]
Having access to the dallas semiconductor 1 wire sensor and an arduino board i decided to try to get them to work nicely together\n\n\nhere is how it works\n\nExtract the following 2 files into your Arduino/libraries folder\n\n[[DallasTemperature.zip|http://docbox.flint.com/~cpyarger/DallasTemperature.zip]]\n[[OneWire.zip|http://docbox.flint.com/~cpyarger/OneWire.zip]]\n\nextract the following two files into your Arduino projects directory:\n\n[[one_wire_address_finder.zip|http://docbox.flint.com/~cpyarger/one_wire_address_finder.zip]]\n[[arduino_ds18b20_temperature_sensor.zip|http://docbox.flint.com/~cpyarger/arduino_ds18b20_temperature_sensor.zip]]\n\nwire the Arduino as such:\n\n|>|>|!flat side facing|\n| 1 | 2 | 3 |\n|Left | Middle | Right|\n|Ground | I/O | +5v|\n|>|>| pin3 <--4.7k--> +5 |\n|Dallas 1-wirs [[A-standard]]|c\n\n\nBoth of the programs above output to the serial connection.\nas i am using windows XP i connect through hyper terminal and receive the data\nUse the one wire address finder to discover the address of your sensor and to check that it is wired correctly\nreplace the address int he one wire temperature sensor file with the one found by the address finder\n\nRun the one wire temperature sensor sketch\nI should output the data in both Fahrenheit and Celsius.\n\n\n* Please note that if using the arduino motor sheild Pins 3, 9, 11, 12,13, 0, and 1 are already used, adjust the program to use an open PWM pin such as 6 or 5\nsource: http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html\n\nchris's 1 wire address\n0x28, 0x41, 0xB8, 0x4D, 0x03, 0x00, 0x00, 0xB4\n\n
Signals off RJ45:\n\nFemale RJ45 Plug Adapter (Wired to [[EIA-561|http://www.marchansen.com/tn103/#6]])\n|!RJ-45 Pin |! USOC Color |! A-wire color|! Signal |\n| 1 |Blue| wt/bl | Data I/O|\n| 2 |Red| nc | |\n| 3 |Black| nc | |\n| 4 |Orange| nc | |\n| 5 |Green| nc | |\n| 6 |Yellow| nc | |\n| 7 |Brown| wt/or | +5 Vcc|\n| 8 |White| gn/wt | Ground|\nNOTE These are [[pictures of the A-standard connector adapter]]\n\n
! Minicom Settings\n{{{\n+-----------------------------------------------------------------------+\n| A - Serial Device : /dev/ttyACM0 |\n| B - Lockfile Location : /var/lock |\n| C - Callin Program : |\n| D - Callout Program : |\n| E - Bps/Par/Bits : 9600 8N1 |\n| F - Hardware Flow Control : No |\n| G - Software Flow Control : No |\n| |\n| Change which setting? |\n+-----------------------------------------------------------------------+\n}}}\n\nFrom working minicom
To set the Arduino Temp Sensor Up:\n\n# run {{{watch 'dmesg | grep tty | grep -i usb'}}}\n# plug in the USB port from the Arduino\n# Observe the port activated, typically /dev/ttyACM0 or /dev/ttyACM1\n# run {{{minicom -s}}}\n# set the port\n# exit to minicom and observe tempature output
Interface with python.\n\nThe python code we are using to harvest data is here:\n{{{\n#!/usr/bin/python\n# pflint Thu Aug 2 11:08:41 EDT 2012\nimport serial\nimport io\nimport time\n# now = datetime.datetime.now()\nser = serial.Serial('/dev/ttyACM0', 9600, timeout=5)\ntime.sleep(.1)\nsio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))\nsio.flush() # clear buffering get the data out *now*\nline1 = ser.readline().strip() # read a '\sn' terminated line1\nline2 = ser.readline().strip() # read a '\sn' terminated line2\nline3 = ser.readline().strip() # read a '\sn' terminated line3\nline4 = ser.readline().strip() # read a '\sn' terminated line4\nser.close()\nprint (time.strftime("%Y-%m-%d %H:%M"))\n# print (now.strftime("%Y-%m-%d %H:%M"))\n# print (time.strftime("%Y%m%d"))\nprint " ",(line3)\nprint (line4)\n\n}}}\n\n\nThe result is we loose lines... see?\nMinicom output:\n{{{\nThe Arduino Reports\nThe Burlington Data Center Temperature is:\n Temp inside the yello box: C: 25.75 F: 78.35 \nTemperature at external probe: C: 25.25 F: 77.45 \n}}}\n\nexample good:\n{{{\nflint@gompers:~/arduino$ ./get-temp.py \n2012-08-03 12:49\n Temp inside the yello box: C: 25.75 F: 78.35\nTemperature at external probe: C: 25.25 F: 77.45\n}}}\n\n\nExample bad:\n{{{\nflint@gompers:~/arduino$ ./get-temp.py \n2012-08-03 12:48\n a Center Temperature is:\nTemp inside the yello box: C: 25.75 F: 78.35\n}}}\n\n[[test with minicom|SerialSettings]]\n[[use pyserial|http://pypi.python.org/pypi/pyserial]]\n[[how-to set and read serial port|http://pyserial.sourceforge.net/shortintro.html]]\n[[Adruino freak with same problem|http://www.hellboundhackers.org/articles/923-pyserial-and-serial-devices.html]]\n\nThursday, August 02 2012\n|!Reference HTML|! Description|\n|[[playground interfacing python |http://arduino.cc/playground/Interfacing/Python]]||\n|[[pyserial hot |http://stackoverflow.com/tags/pyserial/hot]]||\n|[[geek mountain |http://geekmountain.blogspot.com/2009_07_01_archive.html?zx=a3edac9fa78eee87]]||\n|[[pyserial |http://www.akeric.com/blog/?tag=pyserial]]||\n|[[full examples of using pyserial package |http://stackoverflow.com/questions/676172/full-examples-of-using-pyserial-package]]||\n|[[how to get current date and time in |http://www.saltycrane.com/blog/2008/06/how-to-get-current-date-and-time-in/]]||\n|[[python forum |http://www.python-forum.org/pythonforum/viewtopic.php?f=3&t=17290]]||\n|[[python forum |http://www.python-forum.org/pythonforum/viewtopic.php?f=3&t=23635]]||\n|[[python pyserial read line timeout |http://stackoverflow.com/questions/3437303/python-pyserial-read-line-timeout]]||\n|[[pyserial shortintroduction |http://pyserial.sourceforge.net/shortintro.html]]||\n|[[how to print in python without newline or space |http://stackoverflow.com/questions/493386/how-to-print-in-python-without-newline-or-space]]||\n|[[hellboundhackers |http://www.hellboundhackers.org/articles/923-pyserial-and-serial-devices.html]]||
[img[https://lh5.googleusercontent.com/-oqmKMhFkEwA/UBg6li8SovI/AAAAAAAAAHE/Jf_UgiwsatQ/w497-h373/12%2B-%2B1]]\n\n\n[img[http://docbox.flint.com/~flint/arduino/Jack_detail_cover_off.gif]]\nWrong pinout!!\n\n|Dallas 1-wirs [[A-standard]]|c\n\n[img[http://docbox.flint.com/~flint/arduino/Jack_detail_cover_off_v1.gif]]\nWrong pinout!!\n|Dallas 1-wire [[A-standard]] close up detail|c\n
pyserial working:\n\n{{{\nflint@gompers:~/arduino/pyserial-2.6/serial$ ls\n__init__.py serialcli.py serialposix.py serialwin32.py tools win32.py\nrfc2217.py serialjava.py serialutil.py sermsdos.py urlhandler\nflint@gompers:~/arduino/pyserial-2.6/serial$ python\nPython 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) \n[GCC 4.4.5] on linux2\nType "help", "copyright", "credits" or "license" for more information.\n>>> import serial\n>>> \nflint@gompers:~/arduino/pyserial-2.6/serial$ \n\n}}}
This is the code as of 11:39Thursday, August 02 2012 :\n\n{{{\n#!/usr/bin/python\nimport serial\nimport io\nimport datetime\nnow = datetime.datetime.now()\nser = serial.Serial('/dev/ttyACM0', 9600, timeout=1)\nsio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))\nsio.flush() # clear buffering get the data out *now*\nline1 = ser.readline() # read a '\sn' terminated line1\nline2 = ser.readline() # read a '\sn' terminated line2\nline3 = ser.readline() # read a '\sn' terminated line3\nline4 = ser.readline() # read a '\sn' terminated line4\nser.close()\nprint (now.strftime("%Y-%m-%d %H:%M"))\nprint (line3),\nprint (line4),\n}}}\n\nThis reads the data ok every other time, and also has problems every other time it is run.\n
Type the text for 'New Tiddler'\n\nThis works suprisingly well:\n\n{{{\n\npython -m serial.tools.miniterm /dev/ttyACM0\n}}}\n\nGot to figure out how to stop it...\n[[This site|http://pyserial.sourceforge.net/examples.html#miniterm]] says:\n\nMiniterm defaults:\n--- Miniterm on /dev/ttyS0: 9600,8,N,1 ---\n--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---\n\n\nCtrl+T maps to something in Gnome Terminal, but \nCtro "]" (bracket) works to stop the beast...\n\nso the next obvious step is:\n{{{\npython -m serial.tools.miniterm /dev/ttyACM0 > temp.log\n}}}\n\nBut I really want data upon request...\n\nHm...\n\n\n
1 September 2012\n\nhttp://devel.ringlet.net/sysutils/timelimit/\n\napt-get install timelimt\napt-get install python-serial\n
Try this:\n1. ssh into the unit with the arduino hooked up to it.\n\n2. run this commmand\n{{{\ntimeout 5 python -m serial.tools.miniterm /dev/ttyACM0 ;reset\n}}}\n\n
{{{\n#include <SPI.h>\n#include <Ethernet.h>\n#include <OneWire.h>\n#include <DallasTemperature.h>\n\n// Data wire is plugged into port 2 on the Arduino\n#define ONE_WIRE_BUS 6\nconst int buttonPin = 2;\nOneWire oneWire(ONE_WIRE_BUS);\n\n// Pass our oneWire reference to Dallas Temperature. \nDallasTemperature sensors(&oneWire);\n\n// Enter a MAC address and IP address for your controller below.\n// The IP address will be dependent on your local network:\nbyte mac[] = { \n 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };\nIPAddress ip(192,168,1, 177);\nIPAddress gateway(192,168,1, 1);\nIPAddress subnet(255, 255, 0, 0);\n// Enter the IP address of the server you're connecting to:\nIPAddress server(64,5,53,104); \n\n// Initialize the Ethernet client library\n// with the IP address and port of the server \n// that you want to connect to (port 23 is default for telnet;\n// if you're using Processing's ChatServer, use port 10002):\nEthernetClient client;\n\nvoid setup() {\n \n\n // Start up the library\n sensors.begin();\n pinMode(buttonPin, INPUT);\n // start the Ethernet connection:\n Ethernet.begin(mac);\n // start the serial library:\n Serial.begin(9600);\n // give the Ethernet shield a second to initialize:\n delay(1000);\n // print your local IP address:\n Serial.print("My IP address: ");\n ip = Ethernet.localIP();\n for (byte thisByte = 0; thisByte < 4; thisByte++) {\n // print the value of each byte of the IP address:\n Serial.print(ip[thisByte], DEC);\n Serial.print("."); \n }\n Serial.println("0 connecting...");\n\n // if you get a connection, report back via serial:\n if (client.connect(server, 25)) {\n Serial.println("1 connected");\n } \n else {\n // if you didn't get a connection to the server:\n Serial.println("2 connection failed");\n }\n}\n\nvoid loop()\n{\n\n\n // call sensors.requestTemperatures() to issue a global temperature \n // request to all devices on the bus\n \n sensors.requestTemperatures(); // Send the command to get temperatures\n \n \n \n\n\n // if there are incoming bytes available \n // from the server, read them and print them:\n\n\n // if the state has changed, increment the counter\n\n\n // save the current state as the last state, \n //for next time through the loop\n if (client.available()) {\n char c = client.read();\n Serial.print(c);\n }\n\n // as long as there are bytes in the serial queue,\n // read them and send them out the socket if it's open:\n\n\n char inChar = Serial.read();\n if (client.connected()) {\n client.print(inChar); \n Serial.println("connected");\n client.println("EHLO www.flint.com");\n client.println("MAIL FROM:<testing@docbox.flint.com>");\n client.println("RCPT TO:<cpyarger@docbox.flint.com>");\n client.println("DATA");\n client.println("From: <arduinotesting@docbox.flint.com>");\n client.println("TO: <cpyarger@docbox.flint.com>");\n client.print("SUBJECT: The temp is ");\n client.println(sensors.getTempFByIndex(0));\n client.println();\n client.println("The Temp is:");\n client.println(sensors.getTempFByIndex(0));\n client.println(".");\n client.println(".");\n delay(300000);\n } \n else {\n Serial.println("connection failed");\n Serial.println(client.read());\n }\n \n\n // if the server's disconnected, stop the client:\n if (!client.connected()) {\n Serial.println();\n Serial.println("disconnecting.");\n client.stop();\n // do nothing:\n while(true);\n }\n}\n\n\n\n\n}}}
http://code.google.com/apis/maps/documentation/javascript/v2/introduction.html#Obtaining_Key.\n\nFlint, The google map Issue i solved ages ago. Start redirecting people to [[bosivt.org/directions|http://bosivt.org/directions]]
http://fritzing.org/
Type the text for 'New Tiddler'\n\nhttp://appinventor.mit.edu/
Type the text for 'New Tiddler'\n\nhttp://research.gallaudet.edu/Tutorials/linux_tips.php#145\nhttp://appinventor.mit.edu/
This is the Monitor Code\n\n{{{\n#!/bin/bash\n# pflint Tue 18 Dec 2012 07:35:16 AM EST Start Program Design\n# \nversion="0.01"\n#\n# hold environment\nexport S=$PWD\n#* move to the appropriate directorygrep '^\s#\s*' tparse.sh\n# cd ??\n#\n#* check location of vital programs, sanity check\n# timeout\n# python 2.6\n# pythhon serial\n# miniterm\n#\n#* check location of vital files, sanity check\n# ??\n#\n# Define files to be used\n# uid="" ; if [ "$uid" == "" ]; then echo "Set user id!"; exit; fi\n# passwd="" ; if [ "$passwd" == "" ]; then echo "Set user passwd!"; exit; fi\n# ??\n#\n#* function help - Help function for template basic help goes here\nfunction help(){\nclear;\necho "This is "$0" "$version\ncat $0 | grep '^## ' | sed -e 's/##//'\n# echo "This is the help function"\n## *****DOCUMENTATION*****\n## You get this documentation when you put in the wrong number of arguments...\n## The name of this program is tparse.sh, a collection of tools \n## This is released under GPL I\n## The syntax is:\n## - tparse.sh status details what the current situation is\n## - tparse.sh tempf <1-N> details a current or temperature\n## the output in Fahrenheit is delivered to the screen...\n## - tparse.sh tempc <1-N> details a current or temperature\n## the output in Centigrade is delivered to the screen...\n## - tparse.sh cleanup [test] optionally a rehearsal\n## Output is delivered to the directory you are in...\n## - tparse.sh dummy tests the dummy function\n## Output is delivered to the screen...\n## For structure information type "grep '^\s#\s*' tparse.sh"\n## :^)\n## (C) P Flint, Vermont Department of Labor Liscensed under GPLI\n##\n# *****Documentation Loop ends here the rest is function******\n#\n} # Test: tparse.sh\n#\n#* function dummy - Rename and fill stuff in between braces\nfunction dummy(){\necho "This is the dummy function"\n} # Test:\n#\n#\n#* function status - Outputs the whole line...\nfunction status(){\necho "This is the status function to end use <ctrl> ]"\npython /usr/share/doc/python-serial/examples/miniterm.py -p /dev/ttyACM0 -D |sed 's|\s\sx1b\s[2J|\sn|' \n} # Test:\n#\n#\n#* function tempf - Outputs the whole line...\nfunction tempf(){\n#debug echo $#" "$var1" "$var2" "$var3" "$ARGS \necho -n "temp$var2 in Fahrenheit is: "\nresult=""\n# until [[ "$result" =~ ^[0-9]+([.][0-9]+)?$ ]] \n# while [[ "$result" -eq "$result" ]] \n# while [[ "$result" -eq "$result" ]] \n# while [[ expr "$result + 1" 2> /dev/null ]]\n# do\ntimeout 5 python /usr/share/doc/python-serial/examples/miniterm.py -p /dev/ttyACM0 -D 2>/dev/null |\n while read line; do if [[ "$line" == *"temp$var2"* ]]; then echo $line; fi; done | \n head -1 | \n rev | \n cut -d " " -f 1 | \n rev\n# done\nstty sane\n# if ! [[ "$result" =~ ^[0-9]+([.][0-9]+)?$ ]] ; then\nif [[ "$result" =~ ^[0-9]+([.][0-9]+)?$ ]] ; then\n echo "error" \n tempf $var2 \nelse \n echo $result \nfi\n} # Test:./2tp.sh tempf 1\n#\n#* function tempc - Outputs the whole line...\nfunction tempc(){\n#debug echo $#" "$var1" "$var2" "$var3" "$ARGS \necho -n "temp$var2 in Centigrade is: "\nresult=$(timeout 5 python /usr/share/doc/python-serial/examples/miniterm.py -p /dev/ttyACM0 -D 2>/dev/null |\n while read line; do if [[ "$line" == *"temp$var2"* ]]; then echo $line; fi; done | \n head -1 | \n rev | \n cut -d " " -f 3 | \n rev )\nstty sane\nif ! [[ "$result" =~ ^[0-9]+([.][0-9]+)?$ ]] ; then\n echo "error" \nelse \n echo $result \nfi\n\necho \n} # Test:./2tp.sh tempc 1\n#\n#* function stmnth - Gives a status indication of the backup area for a paticular month...\nfunction stmnth(){\n#debug echo "This is the stmnth function"\necho "The current location is: "$PWD\nmonth=$(printf "%.2d" "$dmonth")\necho "Directories unfiled for "$(year=$(date +%y) ; echo $(date --date="$month/1/$year" +%B|tr [:upper:] [:lower:]))" are:"\n# ls -1 | grep backup | grep -e "\s-$month\s-" | grep -v "\s-$month\s-backup"\ndu -h --max-depth=1 2>/dev/null | grep backup | grep -e "\s-$month\s-" | grep -v "\s-$month\s-backup"\nspause\necho "Directories in "$PWD"/"$dname" are:"\ndu -h --max-depth=1 2>/dev/null $dname\n} # Test: tparse.sh stdmnth 11\n#\n#* function defvbl - default variables for no arguments\nfunction defvbl(){\n#debug echo "This is the defvbl function" #debug \n#debug echo $#" "$var1" "$var2" "$var3" "$ARGS #debug \ndmonth=$(date +%m); # month is the current month\ndname=$(year=$(date +%Y) ; echo $(date +%b|tr [:upper:] [:lower:]))"-"$(date +%Y)".bu" # current\necho "The month is: "$dmonth\necho "the backup location is: "$dname\n} # Test:\n#\n#\n#* function waiw - figures out which argument is which...\nfunction waiw(){\n#debug echo $#" "$var1" "$var2" "$var3" "$ARGS \n#debug echo "This is the waiw function"\nif [ "$var2" -eq "$var2" ] 2>/dev/null; then\n echo "The first variable is a number so it is the month"; dmonth=$var2; dtest=$var3\nelse\n echo " the first variable is not a number so it is the test directive"; dmonth=$var3; dtest=$var2\nfi\n#\nif [[ $dmonth -lt 1 || $dmonth -gt 12 ]]; then echo "out of range using default"; dmonth=$(date +%m); fi\nmonth=$dmonth\ndname=$(year=$(date +%Y) ; echo $(date --date="$month/1/$year" +%b|tr [:upper:] [:lower:]))"-"$(date +%Y)".bu"\necho "The month is: "$dmonth\necho "The test directive: "$dtest\necho "the backup location is: "$dname\n} # Test: tparse.sh waiw\n#\n#* function domnth - Rename and fill stuff in between braces\nfunction domnth(){\necho "This is the domnth function"\n#debug echo $#" "$var1" "$var2" "$var3" "$ARGS \n\n} # Test:\n#\n#\n#\n#* function cleanup - Cleanup function deletes all the day directories in current directory\nfunction cleanup(){\n#debug echo "This is the clean up function"\n#debug echo $#" "$var1" "$var2" "$var3" "$ARGS \n# Clean up stuff that remains in the current directory note TEST function\nvalf=$(printf "%.2d" "$dmonth"); #debug echo $dmonth $month $valf\ndirno=$(ls -1 | grep backup | grep -e "\s-$valf\s-" | grep -v "\s-$valf\s-backup" | wc -l)\n#\nif [ "$(echo $dtest | tr [:lower:] [:upper:])" == "TEST" ];\nthen\n echo "I was only kidding! We would have erased these $dirno directories:" \n du -h --max-depth=1 2>/dev/null | grep backup | grep -e "\s-$valf\s-" | grep -v "\s-$valf\s-backup" \n exit 1 \nfi\necho "we are cleaning these up now:"\n# ls -1 | grep backup | grep -e "\s-$month\s-" | grep -v "\s-$valf\s-backup"\ndu -h --max-depth=1 2>/dev/null | grep backup | grep -e "\s-$valf\s-" | grep -v "\s-$valf\s-backup" \nspause\necho "Deleting the following:"\nls -1 | grep backup | grep -e "\s-$valf\s-" | grep -v "\s-$valf\s-backup"\nls -1 | grep backup | grep -e "\s-$valf\s-" | grep -v "\s-$valf\s-backup" |xargs -I xxx rm -rf xxx\n} # Test: tparse.sh cleanup\n#\n# \n#*######################################STANDARD AND MAYBE USEFUL FUNCTIONS BELOW\n#\n#\n#\n#* function spause - A simple tarry...\nfunction spause(){\n # -t sets time\n # read -t $pt -p "$*" ans\n read -p "Hit enter to continue..." ans\n echo $ans\n}\n#\n#* function pause - Allows many ways to tarry...\nfunction pause(){\n#debug echo "Vairables in Pause are: "\n#debug echo $#" "$-e 1" "$ARGS \n # -t sets time\n # read -t $var3 -p "$*" ans$(ls -1 | grep backup |wc -l)\ncase "$ARGS" in\n "6") read -t $time -p "$prompt";;\n "5") read -p "$prompt";;\n "1") read;;\nesac # end of choices\n # echo $ans\n} # TESTS: tparse.sh pause; tparse.sh pause "Testing wait"; tparse.sh pause 3 "Testing 1,2,3";\n#\n#* function fwatch - Watches the end of a file indefinitely\nfunction fwatch(){\n#debug echo $#" "$var2" "$ARGS\n watch tail -20 $var2\n} # Test: tparse.sh fwatch var/log/messages\n#\n#\n#*###################################### MAIN ENTRY POINT AND COMPOUND CASE\n#\necho "tparse.sh v 0.2 starts"\n#* Evaluator Routine\n# Note the evaluator allows for many cases and error checking...\n# ARGS=$# # carries the number of args into the functions...\nif [ "$#" -eq "1" ] && [ "$1" = "status" ]; then ARGS="1"; fi\nif [ "$#" -eq "2" ] && [ "$1" = "tempf" ]; then ARGS="2"; fi\nif [ "$#" -eq "2" ] && [ "$1" = "tempc" ]; then ARGS="2"; fi\nif [ "$#" -eq "1" ] && [ "$1" = "spause" ]; then ARGS="1"; fi\nif [ "$#" -eq "1" ] && [ "$1" = "pause" ]; then ARGS="1"; fi\nif [ "$#" -eq "2" ] && [ "$1" = "pause" ]; then ARGS="5"; fi\nif [ "$#" -eq "3" ] && [ "$1" = "pause" ]; then ARGS="6"; fi\nif [ "$#" -eq "2" ] && [ "$1" = "waiw" ]; then ARGS="2"; fi\nif [ "$#" -eq "3" ] && [ "$1" = "waiw" ]; then ARGS="3"; fi\nif [ "$#" -eq "1" ] && [ "$1" = "cleanup" ]; then ARGS="7"; fi\nif [ "$#" -eq "2" ] && [ "$1" = "cleanup" ]; then ARGS="8"; fi\nif [ "$#" -eq "3" ] && [ "$1" = "cleanup" ]; then ARGS="9"; fi\nif [ "$#" -eq "1" ] && [ "$1" = "defvbl" ]; then ARGS="1"; fi\nif [ "$#" -eq "1" ] && [ "$1" = "dummy" ]; then ARGS="1"; fi\nif [ "$#" -eq "1" ] && [ "$1" = "help" ]; then ARGS="9"; fi\n# this tests the evaluator...\n#debug echo $#" "$1" "$2" "$3" "$ARGS \n# typical cases, be careful to make your own...\ncase "$ARGS" in\n "0") clear; cat $0 | grep '^## ' | sed -e 's/##//'; exit 1;; # got nothing, display help and go\n "1") $1 ;; # run the command\n "2") var2=$2; $1 ;; # run the command with an argument\n "3") var3=$3; var2=$2; $1 ;; # run the command with two arguments\n "4") var4=$4; var3=$3; var2=$2; $1 ;; # run the command with three arguments\n "5") prompt=$2; $1 ;; # run the command with a different argument\n "6") time=$3; prompt=$2; $1 ;; # run the command with two different arguments\n "7") defvbl; $1 ;; # run the command and default variables\n "8") var2=$2; waiw; $1 ;; # run the command and settle variables\n "9") var3=$3; var2=$2; waiw; $1 ;; # run the command and settle variables\n *) clear; cat $0 | grep '^## '| sed -e 's/##//'; exit 1;; # Anything else run help and exit...\nesac # End main loop. To TEST:\n#\n# echo " ";\necho "tparse.sh stops"\n# That's all folks!!\n# Junk shop\n# if [ "$#" -eq "3" ] && [ "$1" = "get" ] && [ "$2" = "all" ]; then ARGS="7"; fi\n# "2") secs=$2; while read line ; do $1; done;; # read from a file and process\n# *) clear; cat $0 | grep '^## ' | sed -e 's/##//'; exit 1;;\n#* restore environment\ncd $S\n\n}}}
testing 1123
testing 123
gtsp.py - Get Temperature Sensing Process\n\nFor all it's warts and goiters this is version 0.3\n\n{{{\n#!/usr/bin/python\n# -*- coding: utf-8 -*-\nimport signal\nimport time\nimport os\nimport re\nimport serial\nimport io\nimport csv\nimport sys\nfrom subprocess import call\nfrom serial import Serial\n# import MySQLdb\n#\n# this was stolen from the furmon project and needs a little work...\n# note that this works from a linux command line:\n# device="/dev/ttyACM0";miniterm.py -p $device |strings -n12\n# Connect to Mysql DB\n#\nFILTER=''.join([(len(repr(chr(x)))==3) and chr(x) or '.' for x in range(256)])\n\ndef dump(src, length=8):\n N=0; result=''\n while src:\n s,src = src[:length],src[length:]\n hexa = ' '.join(["%02X"%ord(x) for x in s])\n s = s.translate(FILTER)\n result += "%04X %-*s %s\sn" % (N, length*3, hexa, s)\n N+=length\n return result\n\n"""\n# this is an example which works if you uncomment this block\ns=("This 10 line function is just a sample of pyhton power "\n "for string manipulations.\sn"\n "The code is \sx07even\sx08 quite readable!")\n\nprint dump(s)\n"""\n#\n\n# portread = os.system("dmesg |grep ttyACM |tail -n 1|cut -d : -f3")\n# Open connection to the arduino, \n# port = "/dev/ttyACM0" + str(portread)\ndef main():\n # out = open('mstp.data','a')\n out = open('/var/www/temp.log','w')\n port = "/dev/ttyACM0"\n # ser = Serial(port="/dev/ttyACM0", baudrate=9600 ) # set the parameters to what you want\n ser = Serial(port="/dev/ttyACM0", baudrate=9600, timeout=6) # set the parameters to what you want 5 is good as well\n # dataline="the quick brown fox" # sample data\n def signal_handler(signal, frame):\n print " - You pressed Ctrl+C! "\n print time.time() - start_time, "seconds"\n sys.exit(0)\n signal.signal(signal.SIGINT, signal_handler)\n print 'Press Ctrl+C for interrupt'\n #while True:\n while ( time.time() - start_time ) < 10:\n pac_start=time.time()\n if ser.inWaiting():\n # temp = ser.read()\n dataline = ser.readline()\n # print dump(temp)\n # print ser.readline()\n # print dump(ser.readline())\n # print dump(dataline)\n # print (dataline)\n # print(dataline, file='furmon.data')\n # print time.time() - pac_start, "seconds"\n # print "After ",time.time() - pac_start," seconds, the length of the data is: ",len(dataline) \n print 'After %d seconds the length of the data is:' % ( time.time() - pac_start ), len(dataline)\n if len(dataline) > 50: out.write(dataline)\n ser.close() \n out.close()\n\n\n \n #\n#\n\n"""\n#now = datetime.datetime.now()\n# ser = serial.Serial(port, 9600, timeout=5) \n#open connection to the arduino\n#sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser)) # clear buffering get the data out *now*\n#sio.flush()\n#t time.sleep(.75) # Give the buffer time to clear \n#line3 = ser.readline()\n#t clearline = ser.readline() # read a '\sn' terminated line1 usually the one line with misformatted text\n# dataline = ser.readline() # read a '\sn' terminated line4\n# print (line1), ('line1')\n# print (clearline)\n# print (dataline)\n#\n\nif __name__ == "__main__":\n main()\n"""\nstart_time = time.time()\nmain()\nprint time.time() - start_time, "seconds"\n}}}
Light+Humidity+Temperature\n\n!! Serial Protocol\n|!Start Byte|! Length|!Frame|!Checksum?|\n|255|MSB,LSB|Data Type, Data Contents|0xFF-frame bytes|\n\n|!Data Types|!Feilds|!Description|\n|0x01|1|Temperature|\n|0x02|1|Humidity|\n|0x03|1|light|
Using Jquery flot rrdjavascript, php and ajax I have cobbled together a Home Thermostat running on a raspberry pi\n\nTake a look at http://home.cpyarger.com/therm.html\n\n\nHere is the PHP File YHtPHP\nHere is my Javascript file YHtJS\nhere is my HTML file YHtHTML\nTemperatures are in Centigrade
This is the needed PHP file for my thermostat\n{{{\n\n<?php\n\n\n function rctemp()\n {\n $myFile = "ctemp.txt";\n $fh = fopen($myFile, 'r');\n $theData = fread($fh, filesize($myFile));\n fclose($fh);\n echo $theData;\n }\n\n function wstate()\n {\n $state = "state.txt";\n $fh = fopen($state, 'w') or die("can't open file");\n $stringData = $_GET['state'];\n fwrite($fh, $stringData);\n fclose($fh);\n echo $stringData;\n }\n\n\n function rstate()\n {\n $status = "status.txt";\n $fh = fopen($status, 'r');\n $theData = fread($fh, filesize($status));\n fclose($fh);\n echo $theData;\n }\n\n function rstemp()\n {\n $stemp = "stemp.txt";\n $fh = fopen($stemp, 'r');\n $theData = fread($fh, filesize($stemp));\n fclose($fh);\n echo $theData;\n }\n\n\n function wstemp($stringData)\n {\n $myFile = "stemp.txt";\n $fh = fopen($myFile, 'w') or die("can't open file");\n $stringData = $_GET['tsetter'];\n fwrite($fh, $stringData);\n fclose($fh);\n echo $stringData;\n\n }\n\nif(function_exists($_GET['f'])) {\n $_GET['f']();\n}\n?>\n\n}}}
{{{\n\n\n\n\n // fname and rrd_data are the global variable used by all the functions below\n fname="dht11.rrd";\n rrd_data="dht11.rrd";\n\n // This function updates the Web Page with the data from the RRD archive header\n // when a new file is selected\n function update_fname() {\n // Finally, update the file name and enable the update button\n\nctemp();\n var graph_opts={points: { show: false },\n \n yaxis: { autoscaleMargin: .25},\n tooltip: true,\n tooltipOpts: { content: "<h4>%s</h4> Value: %y.3" }\n };\n\n var ds_graph_opts={'t0':{ label: 'Temp', color: "#ff0000", \n lines: { show: true, fill: true}\n },\n 'h0':{ label: 'Hum', color: "#00c0c0", \n lines: { show: true, fill: true}\n }\n };\n\n var rrdflotv={ graph_only:false, \n multi_ds:true,\n tooltip: true,\n tooltipOpts: { content: "<h4>%s</h4> Value: %y.3" },\n use_checked_DSs:true,\n checked_DSs:['h0-GAUGE','t0-GAUGE'], \n use_windows:false, \n window_min: 1,\n window_max: 13,\n timezone: -5\n };\n\n // the rrdFlot object creates and handles the graph\n function update() {\n var f=new rrdFlot("mygraph",rrd_data,graph_opts,ds_graph_opts,rrdflotv);\n setTimeout(update, 5*60000)\n };\n function update2() {\n \n setTimeout(update2, 300);\n seTemp();\n ctemp();\n status();\n btnupd()\n };\n update()\n update2()\n }\n \n // This is the callback function that,\n // given a binary file object,\n // verifies that it is a valid RRD archive\n // and performs the update of the Web page\n function update_fname_handler(bf) {\n var i_rrd_data=undefined;\n if (bf.getLength()<1) {\n alert("File "+fname+" is empty (possibly loading failed)!");\n return 1;\n }\n try {\n var i_rrd_data=new RRDFile(bf); \n } catch(err) {\n alert("File "+fname+" is not a valid RRD archive!\sn"+err);\n return 1;\n }\n if (i_rrd_data!=undefined) {\n rrd_data=i_rrd_data;\n update_fname()\n }\n }\n\n // this function is invoked when the RRD file name changes\n function fname_update() {\n fname="dht11.rrd";\n try {\n FetchBinaryURLAsync(fname,update_fname_handler);\n } catch (err) {\n alert("Failed loading "+fname+"\sn"+err);\n }\n\n }\nfunction ctemp(){\nvar ajaxRequest; // The variable that makes Ajax possible!\n \n try{\n // Opera 8.0+, Firefox, Safari\n ajaxRequest = new XMLHttpRequest();\n } catch (e){\n // Internet Explorer Browsers\n try{\n ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");\n } catch (e) {\n try{\n ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");\n } catch (e){\n // Something went wrong\n alert("Your browser broke!");\n return false;\n }\n }\n }\n // Create a function that will receive data sent from the server\n ajaxRequest.onreadystatechange = function(){\n if(ajaxRequest.readyState == 4){\nvar fieldNameElement = document.getElementById("temp");\n while(fieldNameElement.childNodes.length >= 1) {\n fieldNameElement.removeChild(fieldNameElement.firstChild);\n }\n fieldNameElement.appendChild(fieldNameElement.ownerDocument.createTextNode(ajaxRequest.responseText));\n\n }\n }\n ajaxRequest.open("GET", "thermostat.php?f=rctemp", true);\n ajaxRequest.send(null); \n\n }\n \n\n\nfunction seTemp(){\n var ajaxRequest; // The variable that makes Ajax possible!\n \n try{\n // Opera 8.0+, Firefox, Safari\n ajaxRequest = new XMLHttpRequest();\n } catch (e){\n // Internet Explorer Browsers\n try{\n ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");\n } catch (e) {\n try{\n ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");\n } catch (e){\n // Something went wrong\n alert("Your browser broke!");\n return false;\n }\n }\n }\n // Create a function that will receive data sent from the server\n ajaxRequest.onreadystatechange = function(){\n if(ajaxRequest.readyState == 4){\nvar fieldNameElement = document.getElementById("stemp");\n while(fieldNameElement.childNodes.length >= 1) {\n fieldNameElement.removeChild(fieldNameElement.firstChild);\n }\n fieldNameElement.appendChild(fieldNameElement.ownerDocument.createTextNode(ajaxRequest.responseText));\n\n }\n }\n ajaxRequest.open("GET", "thermostat.php?f=rstemp", true);\n ajaxRequest.send(null); \n\n }\n\nfunction tp(){ \n var javascriptVariable = document.getElementById("tsetter").value;\n $.ajax({\n type:'post',\n url:"thermostat.php?f=wstemp&tsetter=" + javascriptVariable,\n success:function(res){\n seTemp();\n }\n });\n};\nfunction run(){ \n\n $.ajax({\n type:'post',\n url:"thermostat.php?f=wstate&state=run",\n success:function(res){\n seTemp();\n }\n });\n};\nfunction stop(){ \n\n $.ajax({\n type:'post',\n url:"thermostat.php?f=wstate&state=stop",\n success:function(res){\n seTemp();\n }\n });\n};\n \n\n function tup(){\n var otemp = parseInt(document.getElementById("stemp").innerHTML, 10); \n var ntemp = otemp + 1;\n $.ajax({\n type:'post',\n url:"thermostat.php?f=wstemp&tsetter=" + ntemp,\n success:function(res){\n seTemp();\n }\n });\n };\n\n function tdown(){\n var otemp = parseInt(document.getElementById("stemp").innerHTML, 10);\n var ntemp = otemp + -1\n $.ajax({\n type:'post',\n url:"thermostat.php?f=wstemp&tsetter=" + ntemp,\n success:function(res){\n seTemp();\n }\n }); \n \n }\nfunction status(){\nvar ajaxRequest; // The variable that makes Ajax possible!\n \n try{\n // Opera 8.0+, Firefox, Safari\n ajaxRequest = new XMLHttpRequest();\n } catch (e){\n // Internet Explorer Browsers\n try{\n ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");\n } catch (e) {\n try{\n ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");\n } catch (e){\n // Something went wrong\n alert("Your browser broke!");\n return false;\n }\n }\n }\n // Create a function that will receive data sent from the server\n ajaxRequest.onreadystatechange = function(){\n if(ajaxRequest.readyState == 4){\nvar fieldNameElement = document.getElementById("statusBtn");\n while(fieldNameElement.childNodes.length >= 1) {\n fieldNameElement.removeChild(fieldNameElement.firstChild);\n }\n fieldNameElement.appendChild(fieldNameElement.ownerDocument.createTextNode(ajaxRequest.responseText));\n\n }\n }\n ajaxRequest.open("GET", "thermostat.php?f=rstate", true);\n ajaxRequest.send(null); \n\n\n}\nfunction btnupd(){\nstate = document.getElementById("statusBtn").outerText;\nif(state == "Disconnected")\n\ndocument.getElementById("statusBtn").className = "btn btn-Warning";\n\nif(state == "off")\ndocument.getElementById("statusBtn").className = "btn btn-inverse";\nif(state == "Running")\ndocument.getElementById("statusBtn").className = "btn btn-success";\nif(state == "Error")\ndocument.getElementById("statusBtn").className = "btn btn-danger";\n}\n\n}}}
{{{\n\n\n<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="utf-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <meta name="description" content="">\n <meta name="author" content="Christopher P. Yarger <cpyarger@gmail.com>">\n <link rel="shortcut icon" href="/assets/ico/favicon.png">\n <title>Thermometer - 108 Henry Street</title>\n <!-- Bootstrap core CSS -->\n <link href="/dist/css/bootstrap.css" rel="stylesheet">\n <!-- Custom styles for this template -->\n <link href="justified-nav.css" rel="stylesheet">\n <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->\n <!--[if lt IE 9]>\n <script src="/assets/js/html5shiv.js"></script>\n <script src="/assets/js/respond.min.js"></script>\n <![endif]-->\n</head>\n\n<body onload="fname_update()">\n <div class="container">\n <div class="masthead">\n <h4 class="text-muted">Thermometer Control</h4>\n <ul class="nav nav-justified">\n <li ><a href="/">Home</a></li>\n <li class="active"><a href="#">Thermostat</a></li>\n <li><a href="notes.html">Notes</a></li>\n <li><a href="downloads.html">Downloads</a></li>\n <li><a hrlef="about.html">About</a></li>\n <li><a href="contact.html">Contact</a></li>\n </ul>\n </div>\n <div id="mygraph" align="center"></div>\n <div class="row" align="center">\n <div class="col-lg-2">\n <div class="panel-heading"><h4>Status</h4></div>\n <div class="panel-body">\n <button class="btn btn-warning" id="statusBtn" onclick="status()">Disconected</button>\n </div>\n </div>\n\n <div class="col-lg-2">\n <div class="panel-heading"><h4>Current Temp</h4></div>\n <div class="panel-body"><h1><b><div id="temp" color="#ff0000">XX</div></b></h1></div>\n </div>\n\n <div class="col-lg-2">\n <div class="panel-heading"><h4>Current Set Temp</h4></div>\n <div class="panel-body"><h1><b><div id="stemp" color="#ff0000">XX</div></b></h1></div>\n </div>\n\n <div class="col-lg-2">\n <div class="panel-heading"><h4>Temp Controls</h4></div>\n <div class="panel-body">\n <p><a class="btn btn-lg btn-danger" onclick="tup()">UP</a>\n <p><a class="btn btn-lg btn-info" onclick="tdown()">Down</a> \n </div>\n </div>\n\n <div class="col-lg-2">\n <div class="panel-heading"><h4>master control</h4></div>\n <div class="panel-body">\n <p><a class="btn btn-lg btn-danger" onclick="run()">RUN</a>\n <p><a class="btn btn-lg btn-info" onclick="stop()">Stop</a> \n </div>\n </div>\n\n <div class="col-lg-2">\n <div class="panel panel-default">\n <div class="panel-heading">\n <h4>Set Temp</h4>\n </div>\n <div class="panel-body"> \n <input type="text" placeholder="Set Temp" id="tsetter">\n <a class="btn btn-lg btn-success" onclick="tp()">Set</a>\n </div> \n </div>\n </div> \n </div> <!-- End Row --> \n <div class="footer">\n <p>&copy; CPYarger IT Services 2013</p></center>\n </div>\n </div> <!-- /container -->\n\n\n <!-- Bootstrap core JavaScript\n ================================================== -->\n <!-- Placed at the end of the document so the pages load faster -->\n <script src="/assets/js/jquery.js"></script>\n <script src="/dist/js/bootstrap.min.js"></script>\n <script type="text/javascript" src="../lib/binaryXHR.js"></script>\n <script type="text/javascript" src="../lib/rrdFile.js"></script>\n <!-- rrdFlot class needs the following four include files !-->\n <script type="text/javascript" src="../lib/rrdFlotSupport.js"></script>\n <script type="text/javascript" src="../lib/rrdFlot.js"></script>\n <script type="text/javascript" src="../../flot/jquery.js"></script>\n <script type="text/javascript" src="../../flot/jquery.flot.js"></script>\n <script type="text/javascript" src="../../flot/jquery.flot.selection.js"></script>\n <script type="text/javascript" src="therm.js"></script>\n <script type="text/javascript" src="../../flot/jquery.flot.tooltip.js"></script>\n </body>\n</html>\n\n\n}}}
10/08/15\nThis is being written about 3 years after the Temperature Sensor Project has been running, but yet needs to be written.\nThe problem is network time protocol is not working.\nThe reason NTP is not working is that it cannot resolve ntp servers.\nThe reason it cannot resolve ntp servers is that there is not route out.\n{{{route add default gateway 10.0.1.21}}}\nfixes this!\n\nThe data is dumped into MRTG.\nThe data comes from {{{/var/www/bin/gtsp.py}}}|
{{{\nroot@localhost:/var/www# crontab -l\nSHELL=/bin/bash\nHOME=/root\nPATH=/home/flint/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin\n# m h dom mon dow command\n*/1 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/pbug.cfg 2>>/var/www/pbug/logs/pbug.log >> /var/www/pbug/logspbug.log \n*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/itemp.cfg 2>>/var/www/itemp/logs/itemp.log >> /var/www/itemp/logs/itemp.log \n*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/otemp.cfg 2>>/var/www/otemp/logs/otemp.log >> /var/www/otemp/logs/otemp.log \n# */1 * * * * . /etc/profile; /var/www/bin/mtsp.sh stemp 2>>/var/www/temp.log >> /var/www/temp.log\n*/4 * * * * . /etc/profile; /var/www/bin/gtsp.py #2>>/var/www/temp.log >> /var/www/temp.log\n}}}
Was this written by FN?\n\n{{{\n#!/usr/bin/python\n# -*- coding: utf-8 -*-\nimport signal\nimport time\nimport os\nimport re\nimport serial\nimport io\nimport csv\nimport sys\nfrom subprocess import call\nfrom serial import Serial\n# import MySQLdb\n#\n# this was stolen from the furmon project and needs a little work...\n# note that this works from a linux command line:\n# device="/dev/ttyACM0";miniterm.py -p $device |strings -n12\n# Connect to Mysql DB\n#\nFILTER=''.join([(len(repr(chr(x)))==3) and chr(x) or '.' for x in range(256)])\n\ndef dump(src, length=8):\n N=0; result=''\n while src:\n s,src = src[:length],src[length:]\n hexa = ' '.join(["%02X"%ord(x) for x in s])\n s = s.translate(FILTER)\n result += "%04X %-*s %s\sn" % (N, length*3, hexa, s)\n N+=length\n return result\n\n"""\n# this is an example which works if you uncomment this block\ns=("This 10 line function is just a sample of pyhton power "\n "for string manipulations.\sn"\n "The code is \sx07even\sx08 quite readable!")\n\nprint dump(s)\n"""\n#\n\n# portread = os.system("dmesg |grep ttyACM |tail -n 1|cut -d : -f3")\n# Open connection to the arduino, \n# port = "/dev/ttyACM0" + str(portread)\ndef main():\n # out = open('mstp.data','a')\n out = open('/var/www/temp.log','w')\n port = "/dev/ttyACM0"\n # ser = Serial(port="/dev/ttyACM0", baudrate=9600 ) # set the parameters to what you want\n ser = Serial(port="/dev/ttyACM0", baudrate=9600, timeout=6) # set the parameters to what you want 5 is good as well\n # dataline="the quick brown fox" # sample data\n def signal_handler(signal, frame):\n print " - You pressed Ctrl+C! "\n print time.time() - start_time, "seconds"\n sys.exit(0)\n signal.signal(signal.SIGINT, signal_handler)\n print 'Press Ctrl+C for interrupt'\n #while True:\n while ( time.time() - start_time ) < 10:\n pac_start=time.time()\n if ser.inWaiting():\n # temp = ser.read()\n dataline = ser.readline()\n # print dump(temp)\n # print ser.readline()\n # print dump(ser.readline())\n # print dump(dataline)\n # print (dataline)\n # print(dataline, file='furmon.data')\n # print time.time() - pac_start, "seconds"\n # print "After ",time.time() - pac_start," seconds, the length of the data is: ",len(dataline) \n print 'After %d seconds the length of the data is:' % ( time.time() - pac_start ), len(dataline)\n if len(dataline) > 50: out.write(dataline)\n ser.close() \n out.close()\n\n\n \n #\n#\n\n"""\n#now = datetime.datetime.now()\n# ser = serial.Serial(port, 9600, timeout=5) \n#open connection to the arduino\n#sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser)) # clear buffering get the data out *now*\n#sio.flush()\n#t time.sleep(.75) # Give the buffer time to clear \n#line3 = ser.readline()\n#t clearline = ser.readline() # read a '\sn' terminated line1 usually the one line with misformatted text\n# dataline = ser.readline() # read a '\sn' terminated line4\n# print (line1), ('line1')\n# print (clearline)\n# print (dataline)\n#\n\nif __name__ == "__main__":\n main()\n"""\nstart_time = time.time()\nmain()\nprint time.time() - start_time, "seconds"\n\n}}}
{{{\nport=$(dmesg |grep ACM | tail -1|tr -s " " | cut -d " " -f 5 |tr -d ":");echo $port;/usr/bin/miniterm.py /dev/$port\n}}}