![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Cubesat V1.0 2016 Código para mbed que envía y recibe datos
Dependencies: Adafruit_GFX Adafruit_RTCLib MPL3115A2 SHTx mbed
Diff: main.cpp
- Revision:
- 0:fcfcf58e17ac
- Child:
- 1:92c8991a4213
diff -r 000000000000 -r fcfcf58e17ac main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 27 19:27:39 2016 +0000 @@ -0,0 +1,75 @@ +#include "mbed.h" +#include "SHTx/sht15.hpp" +#include "Adafruit_SSD1306.h" +#include "MPL3115A2.h" +#include<stdio.h> + +//Puertos serial +Serial pc(USBTX,USBRX); +//Serial mx(p13,p14); +Serial mm(p13,p14); + +//Sensores +SHTx::SHT15 sensor(p21, p22); //Humedad sht +I2C i2c(p28, p27); +//MPL3115A2 sensors(&i2c, &pc); //Altitud +I2C myI2C(p9,p10); //Display +Adafruit_SSD1306_I2c o(myI2C,D13,0x7A,64,128); + + + +int main() { + //sensors.init(); //Para sensor de altitud + //Altitude a; + //sensors.setOffsetAltitude(83); + sensor.setOTPReload(false); + sensor.setResolution(true); + //mx.baud(115200); + while(1) { + sensor.update(); //Humedad sht + //sensors.readAltitude(&a); + + + //Imprimir valores + char buffer[100]; + char buffers[100]; + mm.gets(buffer, 100); + for(int h=0; h<=100; h++) + { + if(buffer[h] == '@'){ + for(int t=0; t<=100; t++) + { + buffers[t]=buffer[h]; + h++; + if(buffer[h] == '#') + { + h=101; + t=101; + } + + }}} + //pc.printf("%c", buffers[h]); + //pc.printf("%c", buffer[h]); + + //pc.printf("\nSensor de humedad\nTemperature: [ %3.2f C ]\n", sensor.getTemperature()); + //pc.printf("Humdity:[ %3.2f %% ]\r\r\r\n\n", sensor.getHumidity()); //Humedad sht + + //pc.printf(" '%s'\n", buffers); + + //pc.printf("Altitude: %s#\r\n", a.print()); + + //.printf ("%s\n",buffer); + mm.printf("%s", buffers); + mm.printf(",%2.2f,%3.1f, #\n", sensor.getTemperature(),sensor.getHumidity()); + //mm.printf("%s,#", a.print()); + + o.setTextCursor(0,0); + o.clearDisplay(); + o.printf("%s", buffers); + o.printf(",%2.2f,%3.1f, #\n", sensor.getTemperature(),sensor.getHumidity()); + //o.printf("%s,#", a.print()); + + o.display(); + } + +} \ No newline at end of file