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: mbed BME280 SI1145
main.cpp
- Committer:
- jonathanyost
- Date:
- 2017-06-27
- Revision:
- 1:423c669d0306
- Parent:
- 0:4354437a1033
- Child:
- 2:2bdf15b94f18
File content as of revision 1:423c669d0306:
#include "mbed.h"
#include <string>
#define node_id (0x01)
#define tx (PA_9)
#define rx (PA_10)
const int nodeID = 1;
Serial xb(tx, rx);
Serial pc(D1, D0);
//send_sensor_data(temp, pressure, humidity, motion, uv, ir, vis, noise);
//"id:2,te:2,pr:3,mo:4,uv:5,ir:6,vi:7,no:8"
void send_sensor_data(int t, int p, int h, int m, int u, int ir, int v, int n){
//" id:2, te:%2,pr:%3,mo:%4,uv:%5,ir:%6,vi:%7,no:%8"
xb.printf("id:%d,te:%d,pr:%d,hu:%d,mo:%d,uv:%d,ir:%d,vi:%d,no:%d",nodeID,t,p,h,m,u,ir,v,n);
}
void send_pir_data(int pir){
xb.printf("PIR:%d",pir);
}
int main() {
pc.printf("echo!!\n\r");
// initialize read data chars
char pc_data = 'e';
char buffer[128];
/* Sensor Data
format: "id:2,te:2,pr:3,mo:4,uv:5,ir:6,vi:7,no:8"
*/
int temp = 0;
int pressure = 0;
int humidity = 0;
int motion = 0;
int uv = 0;
int ir = 0;
int vis = 0;
int noise = 0;
while(true){
if(pc.readable()){
pc_data = pc.getc();
pc.printf("%c", pc_data);
xb.printf("%c", pc_data);
}
if(xb.readable()){
xb.gets(buffer, 4);
pc.printf("%s", buffer);
}
if(xb.writeable()){
send_sensor_data(temp, pressure, humidity, motion, uv, ir, vis, noise);
}
}
}