Carga
This commit is contained in:
2025-04-17 00:35:33 -06:00
parent 4977462629
commit 67fc72aed5
1333 changed files with 1077639 additions and 0 deletions

90
ARDUINO/FIJOS/FIJOS.ino Normal file
View File

@@ -0,0 +1,90 @@
#include <math.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFiMulti.h>
#include <WiFiClient.h>
// defino credenciales red
const char* ssid = "CASA";
const char* password = "Caramel0";
float val;
float temp;
String ids = "T00";
int id = 1;
int temp1;
int hume1;
WiFiClient client;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.print("Conectando...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Conexión OK!");
Serial.print("IP Local: ");
Serial.println(WiFi.localIP());
}
void loop() {
val = analogRead(A0);
temp = log(((10240000 / val) - 10000));
temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * temp * temp )) * temp );
temp = temp - 318.15;
Serial.print(temp);
Serial.println("°C");
delay(10000);
EnvioDatos();
double temp;
}
// rutina de envio de datos por POST
void EnvioDatos() {
if (WiFi.status() == WL_CONNECTED) {
temp1 = random(2,8);
hume1 = random(2,8);
HTTPClient http; // creo el objeto http
String datos_a_enviar = "idsensor=" + ids + id + "&temp=" + temp1 + "&hume=" + hume1;
http.begin(client, "http://server.mxsig.com.mx:9000/sensoresf/");
http.addHeader("Content-Type", "application/x-www-form-urlencoded"); // defino texto plano..
int codigo_respuesta = http.POST(datos_a_enviar);
if (codigo_respuesta > 0) {
Serial.println("Código HTTP: " + String(codigo_respuesta));
if (codigo_respuesta == 200) {
String cuerpo_respuesta = http.getString();
Serial.println("El servidor respondió: ");
Serial.println(cuerpo_respuesta);
}
} else {
Serial.print("Error enviado POST, código: ");
Serial.println(codigo_respuesta);
}
if (id < 4){
id++ ;
} else {
id =1 ;
}
Serial.print("temp: ");
Serial.print(temp1);
Serial.print(" hume: ");
Serial.println(hume1);
http.end(); // libero recursos
} else {
Serial.println("Error en la conexion WIFI");
}
delay(500); //espera 60s
}

View File

@@ -0,0 +1,115 @@
#include <math.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFiMulti.h>
#include <WiFiClient.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#define BMP_SCK (13)
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS (10)
Adafruit_BMP280 bmp;
// defino credenciales red
const char* ssid = "CASA";
const char* password = "Caramel0";
float val;
float temp;
String ids = "T0";
int id = 11;
WiFiClient client;
void setup() {
Serial.begin(9600);
WiFi.begin(ssid, password);
Serial.print("Conectando...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Conexión OK!");
Serial.print("IP Local: ");
Serial.println(WiFi.localIP());
while ( !Serial ) delay(100); // wait for native usb
Serial.println(F("BMP280 test"));
unsigned status;
//status = bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID);
status = bmp.begin();
if (!status) {
Serial.println(F("Could not find a valid BMP280 sensor, check wiring or "
"try a different address!"));
Serial.print("SensorID was: 0x"); Serial.println(bmp.sensorID(),16);
Serial.print(" ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n");
Serial.print(" ID of 0x60 represents a BME 280.\n");
Serial.print(" ID of 0x61 represents a BME 680.\n");
while (1) delay(10);
}
/* Default settings from datasheet. */
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
Adafruit_BMP280::FILTER_X16, /* Filtering. */
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
}
void loop() {
temp = bmp.readTemperature();
Serial.print(F("Temperature = "));
Serial.print(bmp.readTemperature());
Serial.println(" *C");
delay(10000);
EnvioDatos();
double temp;
}
// rutina de envio de datos por POST
void EnvioDatos() {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http; // creo el objeto http
String datos_a_enviar = "idsensor=" + ids + id + "&temp=" + temp + "&hume=" + temp;
http.begin(client, "http://server.mxsig.com.mx:9000/sensoresf/");
http.addHeader("Content-Type", "application/x-www-form-urlencoded"); // defino texto plano..
int codigo_respuesta = http.POST(datos_a_enviar);
if (codigo_respuesta > 0) {
Serial.println("Código HTTP: " + String(codigo_respuesta));
if (codigo_respuesta == 200) {
String cuerpo_respuesta = http.getString();
Serial.println("El servidor respondió: ");
Serial.println(cuerpo_respuesta);
Serial.println(id);
}
} else {
Serial.print("Error enviado POST, código: ");
Serial.println(codigo_respuesta);
}
if (id < 15){
id++ ;
} else {
id = 11 ;
}
http.end(); // libero recursos
} else {
Serial.println("Error en la conexion WIFI");
}
delay(500); //espera 60s
}