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.
Dependencies: DS1820 SDFileSystem mbed RHT03
Fork of frdm_serial by
Revision 9:27360d48afcd, committed 2016-02-29
- Comitter:
- fgmpinheiro
- Date:
- Mon Feb 29 14:42:03 2016 +0000
- Parent:
- 8:164088fcf57b
- Commit message:
- Estacao meteorologica fgmp
Changed in this revision
| RHT03.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RHT03.lib Mon Feb 29 14:42:03 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/tristanjph/code/RHT03/#153e20f26d54
--- a/main.cpp Thu Sep 03 12:36:09 2015 +0000
+++ b/main.cpp Mon Feb 29 14:42:03 2016 +0000
@@ -1,11 +1,14 @@
#include "mbed.h"
#include "SDFileSystem.h"
#include "DS1820.h"
+#include "RHT03.h" //Include neede to use the RHT03 lib
/*******************************************************************************************/
DigitalOut myled(LED_GREEN);
Serial pc(USBTX, USBRX);
Serial gps(PTC17, PTC16);
-AnalogIn analog_value(A1);
+AnalogIn ps(PTB10);//(A2);
+AnalogIn qc(PTB11);//(A2);
+
SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS
DS1820 ds1820(PTB3); // substitute PA_9 with actual mbed pin name connected to the DS1820 data pin
/*******************************************************************************************/
@@ -24,14 +27,17 @@
int h_time,m_time,s_time,d_date,m_date,a_date;
float speed,course,utcdate,magvar;
int j;
- float v1,temp;
+ float v1,v2,temp;
+ int done=0;
+ float temp2,hum;
+ RHT03 humtemp(PTB2); //Initalise the RHT03 (change pin number to the pin its connected to)
wait(2);
pc.baud(115200);
gps.baud(9600);
pc.printf("\nHello World! I am ALPINHA 4\n");
mkdir("/sd/test1", 0777);
- fp = fopen("/sd/alpinha2.txt", "w");
+ fp = fopen("/sd/GPS.txt", "w");
if (fp == NULL)
{ // that it was created.
pc.printf("\nnao possivel abrir o arquivo\n");; // Return error.
@@ -43,25 +49,32 @@
fclose(fp);
ds1820.begin();
ds1820.setResolution(12);
+ ds1820.startConversion();
wait(1.0); // let DS1820 complete the temperature conversion
pc.printf("temp = %3.3f\r\n", ds1820.read()); // read temperatura
while (1)
- {
+ {
+ if(humtemp.readData() == RHT_ERROR_NONE) done=1; //Request data from the RHT03
+ temp2 = humtemp.getTemperatureC(); //Gets the current temperature in centigrade
+ hum = humtemp.getHumidity(); //Gets the current humidity in percentage
i=0;
while(gps.getc()!='$');
while( (gps_data[i]=gps.getc()) != '\r') i++;
gps_data[i]='\0';
aval='\0';
- for i=0 to 100
- v1 =v1+ analog_value;//.read();
- end;
-
+ v1=0.0;v2=0;
+ for (j=0;j<20;j=j+1)
+ {
+ v1 =v1+ps*3300;//.read();
+ v2 =v2+qc*3300;//.read();
+ }
+ v1=v1/20.0;v2=v2/20.0;
if((gps_data[2]=='R')&(gps_data[3]=='M')&(gps_data[4]=='C'))
{
temp=ds1820.read();
ds1820.startConversion();
- for(j=0;j<i-1;j++) if(gps_data[j]==',') gps_data[j]=' ';
- sscanf(gps_data,"%s %f %c %f %c %f %c %f %f %f %s", str1,&utctime,&aval,&hokui,&ns,&tokei,&ew,&speed,&course,&utcdate,str2);
+ for(j=0;j<i-1;j++) if(gps_data[j]==',') gps_data[j]=' ';
+ sscanf(gps_data,"%s %f %c %f %c %f %c %f %f %f %s", str1,&utctime,&aval,&hokui,&ns,&tokei,&ew,&speed,&course,&utcdate,str2);
//if(aval=='A')
{
//latitude
@@ -83,15 +96,13 @@
m_date = int((utcdate - d_date*10000)/100);
a_date = int(utcdate - d_date*10000 - m_date*100);
- pc.printf("%02d/%02d/%02d %02d:%02d:%02d %c %4.6f %4.6f %4.6f %3.3f --->%f\n",d_date,m_date,a_date,h_time,m_time,s_time,aval,g_hokui,g_tokei,speed,temp,v1);
+ pc.printf("%02d/%02d/%02d %02d:%02d:%02d %c %4.6f %4.6f %4.6f %3.3f %3.3f %3.3f --->%f %f\n",d_date,m_date,a_date,h_time,m_time,s_time,aval,g_hokui,g_tokei,speed,temp,temp2,hum,v1,v2);
fp = fopen("/sd/alpinha2.txt", "a");
if (fp == NULL)
{ // that it was created.
- pc.printf("\nnao possivel abrir o arquivo\n");; // Return error.
- } else {
- pc.printf("\n turma do curso\n");;
- fprintf(fp,"%2d/%2d/%2d %2d:%2d:%2d %c %4.6f %4.6f %4.6f %3.3f\r\n",d_date,m_date,a_date,h_time,m_time,s_time,aval,g_hokui,g_tokei,speed,temp);
- }
+ pc.printf("\nnao possivel abrir o arquivo\n"); // Return error.
+ } else
+ fprintf(fp,"%2d/%2d/%2d %2d:%2d:%2d %c %4.6f %4.6f %4.6f %3.3f %3.3f %3.3f %3.3f %3.3f\r\n",d_date,m_date,a_date,h_time,m_time,s_time,aval,g_hokui,g_tokei,speed,temp,temp2,hum,v1,v2);
fclose(fp);
}
