using websocket to dynamic display sensor data on webpage; sends alert email from mbed.
Dependencies: BroadcastSend EthernetInterface OneWire2 SimpleSMTPClient mbed-rpc mbed-rtos
Revision 3:26beaa8b94ce, committed 2016-02-18
- Comitter:
- cryptoc
- Date:
- Thu Feb 18 20:04:08 2016 +0000
- Parent:
- 2:6d4f47f0341a
- Commit message:
- .
Changed in this revision
--- a/OneWire.lib Thu Feb 18 19:57:26 2016 +0000 +++ b/OneWire.lib Thu Feb 18 20:04:08 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/cryptoc/code/OneWire2/#4022f4bb304a +https://developer.mbed.org/users/cryptoc/code/OneWire2/#1927aaa3b624
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demo_for_temperature.cpp Thu Feb 18 20:04:08 2016 +0000 @@ -0,0 +1,79 @@ +/**Author: Zhongying Qiao +Date: 02/03/2014*/ +#include "mbed.h" +#include "rtos.h" +#include "OneWire.h" +#include "Network.h" +#include "DS1920.h" + +Serial pc(USBTX, USBRX); + +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); + +Timeout t; +float temperature=0.0; + +// one wire ONE +OneWire owi(p21); +OneWire_Instruction owtrans; +OneWire_ROM rom; +onewire::ds1920::scratchpad_t scratchpad; +TransportSearchPersist search; +osThreadId controlthread; + + +char readbuffer[16]; + + +//led1 flashing at incresing speed + +void device_detect(OneWire * which){ + osSignalSet(controlthread, 1); +} + +void reset_thread() { + wait(3.0); + //owi.detecthandle = &device_detect; + //controlthread = Thread::gettid(); + //Thread::signal_wait(0); + //osSignalSet(controlthread, 0); + led4 = 1; + search.clear(); + while(!search.done){ + OWNetwork::search(&owtrans, &search); + OWNetwork::no_transport(&owtrans); + if(owi.send(&owtrans, 1)){ + if(owi.error == NO_PRESENCE) puts("device might have been removed\r"); + else if(owi.error == CRC_ERROR) puts("results may have been comprimised by a transmission error\r"); + else puts("UNEXPECTED ERROR\r"); + break; + } + else{ + if((uint64_t)search.rom == 0){ + puts("the line was grounded\r"); + break; + } + printf("detected device %llX\r\n", (uint64_t)search.rom); + rom = search.rom; + OWNetwork::match(&owtrans, &rom); + onewire::ds1920::convert_temperature(&owtrans); + if(owi.send(&owtrans, 1)){ + puts("an error occured sending measure temperature transaction\r"); + break; + } + Thread::wait(1000); + onewire::ds1920::read_scratchpad(&owtrans, &scratchpad); + if(owi.send(&owtrans, 1)){ + puts("an error occured reading the scratchpad\r"); + break; + } + + temperature= scratchpad.temperature_accurate(); + printf("Temperature measured at %f degrees C.\r\n", temperature); + + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demo_for_temperature.h Thu Feb 18 20:04:08 2016 +0000 @@ -0,0 +1,7 @@ +/**Author: Zhongying Qiao +Date: 02/03/2014*/ +#include "mbed.h" +extern float temperature; +void reset_thread(); +extern OneWire_ROM rom; +extern onewire::ds1920::scratchpad_t scratchpad; \ No newline at end of file