PDA

View Full Version : Creating a temperature sensor that feeds into a php script....help?



whoracle
11-30-2006, 03:57 AM
Right now i am using the basic stamp homework board and i have a DS1620 digital Thermometer and Thermostate chip en route. I want the basic stamp to read in the temperature from the chip and pass that information along to the computer hooked up to the pure basic board and inject into a php script.

I figured the easiest thing to do would have the basic stamp write all information to a file on my computer and have the php script inject the file into a mysql db and run the app from there.

I cant find much information about purebasic 2.5 online (the version thats currently on my stamp). Does anyone have any more resources or know if/how the basic stamp can write to the computer it is hooked up to?

Any suggestions or help would be greatly appreciated.

LSB
11-30-2006, 04:31 AM
There have been some recent threads on this, search for Visual Basic (VB) and Basic Stamp communications. It is possible to do what you are suggesting, but the way it works is that the Stamp delivers data via the serial port (as to debug) and VB handles the filing and FTP (I assume). I've used VB6 to do this locally, but never uploaded-- should be easy enough to figure out, if you have the tools (ie FTP, VB...). Post again if you need help after searching the related threads.

Chris Savage
11-30-2006, 04:34 AM
Hello,
·
·· PBASIC is not Pure BASIC…Parallax BASIC would be more accurate.· In any event the BASIC Stamp cannot write data to your Hard Drive directly.· If it could imagine the security implications for computers if something serial had that kind of access…What you will need is a program on the PC side expecting the data serially through the COM Port that the BASIC Stamp is programmed through.· That PC application will have to handle the data for you.· You could look into StampDAQ which will import the data into an Excel spreadsheet, but you’d still need to get it to your PHP page.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support

whoracle
11-30-2006, 06:13 AM
Ok so now i have a better idea of what i need to do.

Have the temp sensor send data through the serial port and have a program waiting on the other end to intercept it.
So i just need a program to take handle data and store it to file on my computer. Language really doesnt matter at this point. I just need something that doesnt require much tinkering....

Im still looking and havent found much through the search function.

Kevin Wood
11-30-2006, 06:29 AM
The standard forum search engine doesn't work very well, so Parallax installed a Google box. It gets much better results:

search.parallax.com (http://search.parallax.com)

Try the advanced search option, and in the domain field, type forums.parallax.com. You find stuff for VB, VB.Net, C#, C++, Matlab, Python, RealBasic, Excel, etc.

Lastly, if you just want to log the data to pass off to MySQL, take a look at StampPlot Pro, by Selmaware. It does logging & graphing, and is very reasonably priced.

whoracle
11-30-2006, 07:28 AM
Well i goofed and forgot to mention something else....

I have the stamp set up to a serial to usb converter, because i dont have an extra serial port on my computer....

the stamp basic editor has no problems with this, recognizes it as com3

Im getting so lost right now lol

Kevin Wood
11-30-2006, 08:08 AM
What is the overall design goal of your system? Are you trying to display the temperature info on a webpage, or store it in a database?

As for the USB adapter, if it shows up as a com port, you should be able to access via any programming language that supports serial comms. The general idea that you want to follow here is:

On BS2:
1. Read temperature sensor
2. Send info to PC
3. Repeat process

On PC:
1. Create serial connection
2. Read incoming data from BS2
3. Close serial connection
3. Open log file
4. Write data to file
5. Close file
6. Process log file with other application
7. Repeat process

Whether or not you keep the connection and log file opened during the process would depend on your programming skills and design goals. As I mentioned, StampPlot Pro should allow you to easily generate the log file. It is a Windows app, so if you are on a different system, you would probably need to use something else.

whoracle
11-30-2006, 09:47 AM
This is the overall design goals for my system.

1) Using DS16120 and basic stamp 2 read the temperature
2) Send to my pc
3) Save the Data in a file on my pc
4) Handle the saved file with a php script

I dont know how to take the raw data and save it to file on my computer...

Martin Hebel
11-30-2006, 10:33 AM
StampPlot Pro can save the raw data. Depending what you want to save....

DEBUG "!NAMD c:\test.txt",CR ' defines file name
DEBUG "!DELD", CR ' Deletes current file if need be
DEBUG "!TSMP OFF",CR ' Turn off time stamping if you like
DEBUG "!LOGD ", DEC temp,cr 'Log value of temp to file

Oh, depending on the directory, you'll need to turn security off in the FILE menu.

Using LOGD you can actually make entire scripts if you like, with some limitation on characters used
DEBUG "!LOGD <B> The temp is: ", dec temp, "<\B>",CR

-Martin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control (http://www.stampplot.com/)
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers (http://www.selmaware.com/appbee)·

tj60647
12-01-2006, 02:18 AM
You may want to check out this "Web Server for Serial Line Communication"

http://www.hcilab.org/resources/webserver.htm

You should be able to access the file this creates with PHP.
Or, if you want to use sockets, I've presented a socketToSerial server in the "Getting Basic Stamp and Macromedia Flash to talk to each other" thread [see the zip file].

T
12-26-2006, 10:59 AM
I took a look at the posts so far. I am really new to the programming world, but nontheless, I've been working for a couple hours trying to send information to a COM port. That was the reason why I visited this forum, was to look for the answer. I have been able to use QBASIC, to open up COM1 (I had to switch the COM port being used by my BASIC Stamp homework board, to 1 (QBASIC didnt like COM3). Here is where I am at so far. I am able to run the qbasic program, it listens to COM1. What ever information that is supposed to DEBUG to the display terminal is captured by the QBASIC program, and is displayed through QBASIC. (I have to watch out though, cause when I restarted my computer the first time after running the test, Windows recognized my Homework board as a Serial Mouse, and when I ran the program (filled with ASCII translations to Binary, and HEX values), my curser went ape crap, and started clicking through things automatically (i was impressed, like you couldnt believe, cause in my eyes this is a breakthrough.) Anyhow, if you chaps are still interested, shoot me an e-mail, or let me know this thread is still alive, and I will throw the Qbasic code (which is REALLY simple) your way, to use and manipulate.

My next task is to send that information from QBASIC, to a DAT file, so information can be recorded.

**WHORACLE - I like your idea, to have a live feed of sensory information gathered from your breadboard. (like you I only have one COM, lol)

T
12-26-2006, 11:42 AM
I have done it! I have written the output of the PBASIC board to a DAT File, which is now on my harddrive! Thank you QBASIC!
(Can I go to sleep now)

This is a good first day of coding, indeed.