Creating a temperature sensor that feeds into a php script....help?
whoracle
Posts: 6
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.
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.
Comments
·
·· 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
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.
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.
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
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.
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...
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
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
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 [noparse][[/noparse]see the zip file].
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)
(Can I go to sleep now)
This is a good first day of coding, indeed.