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.
Fork of WeatherMeters by
main.cpp
00001 #include "mbed.h" 00002 #include "SCP1000.h" 00003 #include "SHTx/sht15.hpp" 00004 #include "WeatherMeters.h" 00005 00006 Serial Xbee1(p13, p14); 00007 DigitalOut rst1(p16); 00008 00009 SCP1000 scp1000(p5,p6,p7,p17); 00010 00011 SHTx::SHT15 sensor(p28, p27); 00012 00013 AnalogIn ain(p20); 00014 DigitalOut busy(LED1); 00015 00016 Serial pc(USBTX, USBRX); 00017 00018 WeatherMeters station(p8, p15, p10, Weather_auto); 00019 00020 float w_speed = 0.0; 00021 float w_direction = 0.0; 00022 float w_raingauge = 0.0; 00023 00024 char a = 'T'; 00025 char data[15]; 00026 00027 void xbeesend(float x) 00028 { 00029 sprintf(data, "%5.1f", x); 00030 00031 int i = 0; 00032 while (data[i] != NULL) 00033 { 00034 Xbee1.putc(data[i]); 00035 i++; 00036 } 00037 00038 Xbee1.putc (' '); 00039 } 00040 00041 int main() { 00042 00043 rst1 = 0; //Set reset pin to 0 00044 wait_ms(1); 00045 rst1 = 1; //Set reset pin to 1 00046 wait_ms(1); 00047 00048 while(1) { 00049 00050 w_speed = station.get_windspeed(); 00051 w_direction = station.get_windvane(); 00052 w_raingauge = station.get_raingauge(); 00053 00054 pc.printf("Wind speed: %4.1f m/s\r\n", w_speed); 00055 Xbee1.putc ('S'); 00056 xbeesend (w_speed); 00057 00058 pc.printf("Wind direction: %4.0f\r\n", w_direction); 00059 xbeesend (w_direction); 00060 00061 pc.printf("Rain Gauge: %4.1f\r\n\n", w_raingauge); 00062 xbeesend (w_raingauge); 00063 00064 00065 busy = true; 00066 sensor.update(); 00067 busy = false; 00068 00069 sensor.setOTPReload(false); 00070 sensor.setResolution(true); 00071 00072 sensor.setScale(false); 00073 pc.printf("Temperature [ %3.1f C ]\r\n", sensor.getTemperature()); 00074 00075 xbeesend (sensor.getTemperature()); 00076 00077 pc.printf("Humdity [ %3.1f %% ]\r\n\n", sensor.getHumidity()); 00078 xbeesend (sensor.getHumidity()); 00079 00080 pc.printf("The pressure is %d Pa \r\n\n", scp1000.readPressure()); 00081 xbeesend (scp1000.readPressure()); 00082 00083 pc.printf("Sun light intensity is %3.1f %%\r\n\n", ain * 100); 00084 xbeesend (ain * 100); 00085 00086 Xbee1.putc ('@'); 00087 00088 wait(5); 00089 } 00090 } 00091
Generated on Thu Jul 21 2022 06:05:44 by
1.7.2
