Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 00002 /* 00003 **************************************************************************************************** 00004 Wireless temperature transmitter with ER400TRS wireless transceiver and MCP9700 temperature sensor. 00005 433 MHz transceiver. 180 bytes of data. 19200 Baud. 00006 MCP9700 temperature sensor: -40ºC - +125ºC. 00007 00008 Wiring MCP9700: 00009 p1: +3V3. p2(Vout): mBed's p15. p3: ground. 00010 00011 Wiring ER400TRS: 00012 p1: antenna(17 cm). p2,p7(Host Ready Input) and p9: ground. 00013 p6(Serial Data In): mBed's p9(tx). p8: Vcc = +5 V. 00014 00015 Author: Lluis Nadal. August 2011. 00016 ***************************************************************************************************** 00017 */ 00018 00019 #include "mbed.h" 00020 //#include "TextLCD.h" . Optional 00021 00022 // LCD optional 00023 // Define LCD connections. 00024 //TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d4, d5, d6, d7 00025 00026 Serial pc(USBTX, USBRX); // tx, rx 00027 Serial transmitter(p9, p10); // tx, rx 00028 AnalogIn temp(p15); 00029 00030 char s1[10]; 00031 char s2[10]; 00032 float T; 00033 00034 00035 float tempRead() { 00036 00037 float Ta = 0.0; 00038 float t = temp.read(); // read the analog data 00039 Ta = ((t * 3.3) - 0.5)/ 0.01; 00040 00041 return Ta; // return the temp 00042 } 00043 00044 00045 int main() { 00046 00047 //lcd.cls(); 00048 pc.printf("Init: 19200 Baud\r\n\r\n"); 00049 //lcd.printf("Init: 19200 Baud"); 00050 wait(2); 00051 transmitter.baud(19200); 00052 00053 while (1) { 00054 T = tempRead(); 00055 sprintf(s1, "%.1f", T); 00056 sprintf(s2, "%.1f\n", T); //scanf in the receiver needs a whitespace or newline character 00057 transmitter.printf(s2); 00058 //lcd.cls(); 00059 sprintf(s1,"%s C", s1); 00060 pc.printf(" %s\r\n", s1); 00061 //lcd.printf(s1); 00062 00063 wait(2); 00064 } 00065 }
Generated on Tue Jul 19 2022 01:35:22 by
1.7.2