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: DHT HX711 libmDot-mbed5 ISL29011
Fork of Dot-Examples by
Revision 27:3f2cb700dd45, committed 2018-04-17
- Comitter:
- Santi1990
- Date:
- Tue Apr 17 18:10:04 2018 +0000
- Parent:
- 26:8bc4079c4c8d
- Commit message:
- Esta version usamos para la primera Expo de Xavia (Expo IOT 2018 - Strada Hotel).
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DHT.lib Tue Apr 17 18:10:04 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/Wimpie/code/DHT/#9b5b3200688f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HX711.lib Tue Apr 17 18:10:04 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/mcm/code/HX711/#d7a5cd03ed09
--- a/examples/example_config.h Wed Jan 03 07:14:33 2018 +0000 +++ b/examples/example_config.h Tue Apr 17 18:10:04 2018 +0000 @@ -9,7 +9,7 @@ // the active example is the one that will be compiled #if !defined(ACTIVE_EXAMPLE) -#define ACTIVE_EXAMPLE CLASS_C_EXAMPLE +#define ACTIVE_EXAMPLE OTA_EXAMPLE #endif // the active channel plan is the one that will be compiled @@ -21,7 +21,7 @@ // CP_AS923 // CP_AS923_JAPAN // CP_IN865 -#define CHANNEL_PLAN CP_IN865 +#define CHANNEL_PLAN CP_US915 #if !defined(CHANNEL_PLAN) #define CP_IN865 #endif
--- a/examples/src/ota_example.cpp Wed Jan 03 07:14:33 2018 +0000
+++ b/examples/src/ota_example.cpp Tue Apr 17 18:10:04 2018 +0000
@@ -1,5 +1,10 @@
#include "dot_util.h"
#include "RadioEvent.h"
+#include "HX711.h"
+#include "DHT.h"
+#include <iostream>
+#include <string>
+#include <sstream>
#if ACTIVE_EXAMPLE == OTA_EXAMPLE
@@ -22,12 +27,12 @@
// * either the network name and passphrase can be used or //
// the network ID (8 bytes) and KEY (16 bytes) //
/////////////////////////////////////////////////////////////
-static std::string network_name = "MultiTech";
-static std::string network_passphrase = "MultiTech";
+static std::string network_name = "xaviaiot";
+static std::string network_passphrase = "xaviaiot";
static uint8_t network_id[] = { 0x6C, 0x4E, 0xEF, 0x66, 0xF4, 0x79, 0x86, 0xA6 };
static uint8_t network_key[] = { 0x1F, 0x33, 0xA1, 0x70, 0xA5, 0xF1, 0xFD, 0xA0, 0xAB, 0x69, 0x7A, 0xAE, 0x2B, 0x95, 0x91, 0x6B };
-static uint8_t frequency_sub_band = 0;
-static bool public_network = false;
+static uint8_t frequency_sub_band = 1;
+static bool public_network = true;
static uint8_t ack = 0;
static bool adr = true;
@@ -42,13 +47,6 @@
Serial pc(USBTX, USBRX);
-#if defined(TARGET_XDOT_L151CC)
-I2C i2c(I2C_SDA, I2C_SCL);
-ISL29011 lux(i2c);
-#else
-AnalogIn lux(XBEE_AD0);
-#endif
-
int main() {
// Custom event handler for automatically displaying RX data
RadioEvent events;
@@ -129,43 +127,56 @@
logInfo("restoring network session from NVM");
dot->restoreNetworkSession();
}
+ uint16_t temp;
+ uint16_t hum;
+ uint16_t weight;
+ std::string datos;
+
+
+ while (true) {
- while (true) {
- uint16_t light;
- std::vector<uint8_t> tx_data;
+ uint8_t array[8];
+ //std::vector<uint8_t> tx_data;
// join network if not joined
if (!dot->getNetworkJoinStatus()) {
join_network();
}
+
-#if defined(TARGET_XDOT_L151CC)
- // configure the ISL29011 sensor on the xDot-DK for continuous ambient light sampling, 16 bit conversion, and maximum range
- lux.setMode(ISL29011::ALS_CONT);
- lux.setResolution(ISL29011::ADC_16BIT);
- lux.setRange(ISL29011::RNG_64000);
+ temp = 20;//dht.ReadTemperature(CELCIUS);
+ hum = 30; //dht.ReadHumidity();
+ weight = 10;
+
+ pc.printf("Temperatura: %d/t Humedad: %d/t Peso: %d\n",temp,hum,weight);
+
+ //for (std::string::iterator it = datos.begin(); it != datos.end(); it++)
+ //tx_data.push_back((temp >> 8) & 0xFF);
+ //tx_data.push_back(temp & 0xFF);
- // get the latest light sample and send it to the gateway
- light = lux.getData();
- tx_data.push_back((light >> 8) & 0xFF);
- tx_data.push_back(light & 0xFF);
- logInfo("light: %lu [0x%04X]", light, light);
- send_data(tx_data);
+int i;
+for (i = 0; i < 8; i++)
+{
+ array[i] = (temp >> (8 * i)) & 0xff;
+}
- // put the LSL29011 ambient light sensor into a low power state
- lux.setMode(ISL29011::PWR_DOWN);
-#else
- // get some dummy data and send it to the gateway
- light = lux.read_u16();
- tx_data.push_back((light >> 8) & 0xFF);
- tx_data.push_back(light & 0xFF);
- logInfo("light: %lu [0x%04X]", light, light);
- send_data(tx_data);
-#endif
+ send(array);
+
+ //length = sprintf(pepe, "%d;%d;%d", weight, temp, hum);
+ //std::vector<uint8_t> vec(pepe, pepe+ length / chat);
+
+ //datos.clear();
+
+
+
+
+
+
// if going into deepsleep mode, save the session so we don't need to join again after waking up
// not necessary if going into sleep mode since RAM is retained
- if (deep_sleep) {
+
+ if (deep_sleep) {
logInfo("saving network session to NVM");
dot->saveNetworkSession();
}
@@ -179,4 +190,5 @@
return 0;
}
+
#endif
