changes
This commit is contained in:
parent
498f558fd6
commit
dd72f6f2d3
@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
#include <LoRa.h>
|
#include <LoRa.h>
|
||||||
|
//#include <EEPROM.h>
|
||||||
#define Serial SerialUSB
|
|
||||||
|
|
||||||
uint16_t temp ;
|
uint16_t temp ;
|
||||||
uint16_t hum ;
|
uint16_t hum ;
|
||||||
@ -11,9 +9,9 @@ uint16_t IDMESSAGE;
|
|||||||
|
|
||||||
#define DelaiEntreMessages 1 // en minutes. Pour 140 messages par jour mettre 11 minutes (10,28 si c'est possible)
|
#define DelaiEntreMessages 1 // en minutes. Pour 140 messages par jour mettre 11 minutes (10,28 si c'est possible)
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
//Wire.begin();
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
Serial.println("LoRa Sender");
|
Serial.println("LoRa Sender");
|
||||||
|
|
||||||
@ -25,7 +23,9 @@ void setup()
|
|||||||
delay(2000);
|
delay(2000);
|
||||||
Serial.println("RaLo OK");
|
Serial.println("RaLo OK");
|
||||||
}
|
}
|
||||||
IDSTATION = 1; // Lecture de l'id
|
IDSTATION = 1; // Lecture de l'id de la station écrit dans l'EEPROM
|
||||||
|
//IDMESSAGE = EEPROM.read(4)*256+EEPROM.read(5); // relecture du prochain timestamp à utiliser
|
||||||
|
//IDMESSAGE = 456;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
@ -47,9 +47,7 @@ void loop() {
|
|||||||
hum = LireHumidite();
|
hum = LireHumidite();
|
||||||
pluie = LirePluie();
|
pluie = LirePluie();
|
||||||
delay(1000);
|
delay(1000);
|
||||||
LoRa.beginPacket();
|
RadioEnvoyer(IDSTATION, IDMESSAGE, temp, hum, pluie);
|
||||||
LoRa.print("0107770002004000C8");
|
|
||||||
LoRa.endPacket();
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
67
fakestation/DHT12.cpp
Normal file
67
fakestation/DHT12.cpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
DHT12.cpp - Library for DHT12 sensor.
|
||||||
|
v0.0.1 Beta
|
||||||
|
Created by Bobadas, July 30,2016.
|
||||||
|
Released into the public domain.
|
||||||
|
*/
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "Wire.h"
|
||||||
|
#include "DHT12.h"
|
||||||
|
|
||||||
|
DHT12::DHT12(byte scale,byte id)
|
||||||
|
{
|
||||||
|
if (id==0 || id>126) _id=0x5c;
|
||||||
|
else _id=id;
|
||||||
|
if (scale==0 || scale>3) _scale=CELSIUS;
|
||||||
|
else _scale=scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte DHT12::read()
|
||||||
|
{
|
||||||
|
|
||||||
|
Wire.beginTransmission(_id);
|
||||||
|
Wire.write(0);
|
||||||
|
if (Wire.endTransmission()!=0) return 1;
|
||||||
|
Wire.requestFrom(_id, 5);
|
||||||
|
for (int i=0;i<5;i++) {
|
||||||
|
datos[i]=Wire.read();
|
||||||
|
};
|
||||||
|
delay(50);
|
||||||
|
if (Wire.available()!=0) return 2;
|
||||||
|
if (datos[4]!=(datos[0]+datos[1]+datos[2]+datos[3])) return 3;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float DHT12::readTemperature(byte scale)
|
||||||
|
{
|
||||||
|
float resultado=0;
|
||||||
|
byte error=read();
|
||||||
|
|
||||||
|
//Serial.println(error);
|
||||||
|
|
||||||
|
|
||||||
|
if (error!=0) return (float)error/100;
|
||||||
|
if (scale==0) scale=_scale;
|
||||||
|
switch(scale) {
|
||||||
|
case CELSIUS:
|
||||||
|
resultado=(datos[2]+(float)datos[3]/10);
|
||||||
|
break;
|
||||||
|
case FAHRENHEIT:
|
||||||
|
resultado=((datos[2]+(float)datos[3]/10)*1.8+32);
|
||||||
|
break;
|
||||||
|
case KELVIN:
|
||||||
|
resultado=(datos[2]+(float)datos[3]/10)+273.15;
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
return resultado;
|
||||||
|
}
|
||||||
|
|
||||||
|
float DHT12::readHumidity()
|
||||||
|
{
|
||||||
|
float resultado;
|
||||||
|
byte error=read();
|
||||||
|
if (error!=0) return (float)error/100;
|
||||||
|
resultado=(datos[0]+(float)datos[1]/10);
|
||||||
|
return resultado;
|
||||||
|
}
|
||||||
|
|
||||||
29
fakestation/DHT12.h
Normal file
29
fakestation/DHT12.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
DHT12.h - Library for DHT12 sensor.
|
||||||
|
v0.0.1 Beta
|
||||||
|
Created by Bobadas, July 30,2016.
|
||||||
|
Released into the public domain.
|
||||||
|
*/
|
||||||
|
#ifndef DHT12_h
|
||||||
|
#define DHT12_h
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "Wire.h"
|
||||||
|
|
||||||
|
#define CELSIUS 1
|
||||||
|
#define KELVIN 2
|
||||||
|
#define FAHRENHEIT 3
|
||||||
|
|
||||||
|
class DHT12
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DHT12(byte scale = 0, byte id = 0);
|
||||||
|
float readTemperature(byte scale = 0);
|
||||||
|
float readHumidity();
|
||||||
|
private:
|
||||||
|
byte read();
|
||||||
|
byte datos[5];
|
||||||
|
byte _id;
|
||||||
|
byte _scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -1,6 +1,7 @@
|
|||||||
// renvoie le taux d'humidité en % du DHT12
|
// renvoie le taux d'humidité en % du DHT12
|
||||||
uint16_t LireHumidite() {
|
uint16_t LireHumidite() {
|
||||||
float H = random(0,100);
|
//float H = dht12.readHumidity(); //lecture du taux d'humidité
|
||||||
|
float H = random(0,100); //lecture du taux d'humidité
|
||||||
return (uint16_t)H; // 0% à 100%
|
return (uint16_t)H; // 0% à 100%
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
// DHT12 va de -25 à 75° avec resolution de 0,1°
|
// DHT12 va de -25 à 75° avec resolution de 0,1°
|
||||||
// on renvoie la (Température+40)*10
|
// on renvoie la (Température+40)*10
|
||||||
uint16_t LireTemperature() {
|
uint16_t LireTemperature() {
|
||||||
float T = random(0,35);
|
//float T = dht12.readTemperature(); //lecture de la température
|
||||||
|
float T = random(5,40); //lecture de la température
|
||||||
return (uint16_t)((T + 40.0) * 10.0); // renvoie 150 -> -25°C et 1050 -> 75°C
|
return (uint16_t)((T + 40.0) * 10.0); // renvoie 150 -> -25°C et 1050 -> 75°C
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ void setup(){
|
|||||||
|
|
||||||
//Ethernet.begin(mac, ip); // initialize Ethernet shield using the set mac adress and set IP
|
//Ethernet.begin(mac, ip); // initialize Ethernet shield using the set mac adress and set IP
|
||||||
Ethernet.begin(mac); // initialize Ethernet shield uding the set mac and DHCP for the IP
|
Ethernet.begin(mac); // initialize Ethernet shield uding the set mac and DHCP for the IP
|
||||||
server.begin(); // initialize WebServer part of the librairy
|
Server.begin(); // initialize WebServer part of the librairy
|
||||||
Serial.print("server is at "); // display on serial the IP you can find the webpage
|
Serial.print("server is at "); // display on serial the IP you can find the webpage
|
||||||
Serial.println(Ethernet.localIP());
|
Serial.println(Ethernet.localIP());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user