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 OneWire DHT22 TSL2561 SSD1306
main.cpp
- Committer:
- Pipou
- Date:
- 2017-10-02
- Revision:
- 5:e3a7dc396048
- Parent:
- 4:2767fb09ac47
- Child:
- 6:998a618b5385
File content as of revision 5:e3a7dc396048:
#include "mbed.h"
#include "OneWire.h"
#include "TSL2561.h"
#include "DHT22.h"
//Déclaration variables
TSL2561 Lum(PB_7,PB_6); // Luminosité (I2C:SDA,SCL)
DHT22 Tem_Hum_A(PA_11); // Température & Humidité air
OneWire Tem_S(PA_8); // Température sol
AnalogIn Hum_S(PA_0); // Huminidité sol
Serial pc(PA_2,PA_3); //Serial : Tx,Rx
int main() {
//OneWire Tem_S
char _id[16];
DeviceAddresses* devAddresses = Tem_S.getFoundDevAddresses();
uint8_t foundNum = Tem_S.getFoundDevNum();
while(1) {
OneWireDeviceTemperature::startConversationForAll(&Tem_S, OWTEMP_11_BIT);
for (uint8_t i = 0; i < foundNum; i++) {
OneWireDevice* owDevice = OneWireDeviceFactory::init(&Tem_S, (*devAddresses)[i]);
if (owDevice->getFamily() != ONEWIRE_DS18B20_FAMILY) // currently only DS18B20 supports
continue;
owDevice->generateId(_id);
Tem_Hum_A.sample();
printf( "Lum: %f \tTemp_A: %f \tHum_A: %f \tTemp_S: %f \tHum_S: %f\r\n", Lum.lux(),Tem_Hum_A.getTemperature()/10.0, Tem_Hum_A.getHumidity()/10.0,owDevice->sendGetCommand(GET_TEMPERATURE),Hum_S.read());
delete owDevice;
}
wait(5); // Frenquence : 200Hz
}
}
