quarta-feira, 28 de julho de 2021

U-BLOX NINA W106 SENDO ACESSADO VIA WEBTHINGS - ARDUINO - LOG TEMPERATURA/UMIDADE

 U-BLOX NINA W106 SENDO ACESSADO VIA WEBTHINGS - ARDUINO - LOG TEMPERATURA/UMIDADE

O objetivo deste BLOG é demonstrar como é possível utilizar o ARDUINO para programar o módulo U-BLOX NINA W106 e acessá-lo de qualquer lugar pelo WEBTHING, da Mozzila e acompanhar LOG de temperatura e umidade por semanas obtido pelo BME680.

    MOZZILA E WEBTHING


A missão da Mozilla é "garantir que a Internet seja um recurso público global, aberto e acessível a todos. Uma Internet que realmente coloca as pessoas em primeiro lugar, onde os indivíduos podem moldar sua própria experiência e são empoderados, seguros e independentes."

A missão da equipe da Mozilla IoT é criar uma implementação da Web of Things que incorpore esses valores e ajude a impulsionar os padrões de IoT para segurança, privacidade e interoperabilidade.

Mozilla WebThings é uma plataforma aberta para monitorar e controlar dispositivos pela web, incluindo:
  • WebThings Gateway – uma distribuição de software para gateways domésticos inteligentes focados em privacidade, segurança e interoperabilidade
  • WebThings Framework – uma coleção de componentes de software reutilizáveis para ajudar os desenvolvedores a construir suas próprias coisas web


WebThings Gateway está disponível para download, inclui recursos que permitem registrar dados privados de todos os seus dispositivos domésticos inteligentes, um novo recurso de alarmes e uma nova interface de UI de configurações de rede.

Logs


Você já quis saber quantas vezes a porta foi aberta e fechada enquanto você estava fora? Você está curioso sobre o consumo de energia de aparelhos conectados em seus plugues inteligentes? Com os novos recursos de logs, você pode registrar dados privados de todos os seus dispositivos domésticos inteligentes e visualizar esses dados usando gráficos interativos.

Alarmes


Segurança e segurança doméstica estão entre os grandes benefícios potenciais de sistemas domésticos inteligentes. Se um de seus alarmes for acionado enquanto estiver no trabalho, como você vai saber? Mesmo que alguém na vizinhança ouça, eles vão agir? Eles sabem para quem ligar? O WebThings Gateway 0.8 oferece uma nova capacidade de alarmes para dispositivos como alarmes de fumaça, alarmes de monóxido de carbono ou alarmes de roubo.

Configurações de rede


Com a versão 0.8, agora é possível reconfigurar as configurações de rede do gateway a partir da interface web. Essas novas configurações podem ser encontradas em Configurações ➡ Rede.

Instalando WEBTHINGS


Hello,

Welcome to your WebThings Gateway! 

Your gateway can be accessed at https://wisintainer.webthings.io.
Após a criação do Gateway, o domínio https://xxxxxxx.webthings.io será criado para que você acesse seu NINA W106 de qualquer lugar do mundo!

BME680
Bme680 é um sensor de baixa potência que pode detectar temperatura, umidade, pressão atmosférica e gás voc com um alto grau de linearidade e precisão. Inclui relações spi e i2c, e pode integrar com microcontroladores .

Arduino

Conecte no U-BLOX NINA W106 na serial e identifique a COMx.

1) Baixe e instale a última versão da IDE do Arduino

https://www.arduino.cc/en/Main/Software

2) Execute a IDE do Arduino e click em files-->preferences


e digite
https://dl.espressif.com/dl/package_esp32_index.json e click OK

3) Vá agora em Tools > Board > Boards Manager



4) Procure por "ESP32 by Espressif" e instale


Aguarde alguns minutos para instalação do SDK. 

Instale WEBSTHING e dependências, como exemplo ESPAsyncWebServer


Instale LIB Adafruit Sensor
Instale LIB do BME680
Instale LIB Adafruit busIO


5) Selecione em tools-->board o módulo u-blox NINA-W10 series


Atualize os BINS abaixo do Package ESP32 (opcional hoje)

ÓTIMA REFERÊNCIA PARA PINOS DO ARDUINO E PINOS (GPIOS) DO NINA W106


Consulte

NINA-W10 series, data sheet (u-blox.com)

I2C -BME 680

 i2c

BREAKOUT W106

COMPONENTE


IO8/IO20

BME680

DIGITAL

SDA/SCL


MONTAGEM



Copie o Exemplo abaixo, para entender melhor o código, veja

#define LARGE_JSON_BUFFERS 1 #define ARDUINOJSON_USE_LONG_LONG 1 #include <ArduinoJson.h> #include <Arduino.h> #include <Adafruit_Sensor.h> #include "Adafruit_BME680.h" #include <SPI.h> #include <Wire.h> #include <Thing.h> #include <WebThingAdapter.h> char ssid[] = "Andreia Oi Miguel 2.4G"; // your network SSID (name) char pass[] = "xxxxxxxx"; // your network password (WPA)- seriously, don't use WEP Adafruit_BME680 bme; // I2C WebThingAdapter *adapter; const char *bme680Types[] = {"TemperatureSensor", nullptr}; // Creating the Webthing // "Exmpbme680": unique name for every connected "Webthing", // "Example BME680 Weather Sensor": name in Webthings, // bme680Types: as above ThingDevice weather("ExmpBME680", "Example BME680 Weather Sensor", bme680Types); // Set temperature property ThingProperty weatherTemp("temperature", "", NUMBER, "TemperatureProperty"); // Set humidity as level-property ThingProperty weatherHum("humidity", "", NUMBER, "LevelProperty"); ThingProperty weatherPres("pressure", "", NUMBER, nullptr); ThingProperty weatherGas("air-quality", "", NUMBER, nullptr); void setup() { Serial.begin(115200); //connecting to a WiFi network Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); /* Explicitly set the ESP8266 to be a WiFi-client, otherwise, it by default, would try to act as both a client and an access-point and could cause network-issues with your other WiFi-devices on your WiFi-network. */ WiFi.mode(WIFI_STA); WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); if (!bme.begin()) { Serial.println("Could not find a valid BME680 sensor, check wiring!"); while (1); } // Set up oversampling and filter initialization bme.setTemperatureOversampling(BME680_OS_8X); bme.setHumidityOversampling(BME680_OS_2X); bme.setPressureOversampling(BME680_OS_4X); bme.setIIRFilterSize(BME680_FILTER_SIZE_3); bme.setGasHeater(320, 150); // 320*C for 150 ms // unique name for adapter (here: same as device above) and localIP adapter = new WebThingAdapter("ExmpBME680", WiFi.localIP()); // Set unit for temperature weatherTemp.unit = "degree celsius"; // Set title to "Humidity" weatherHum.title = "Humidity"; // Set unit for humidity (%) weatherHum.unit = "percent"; // Set humidity as read only // (otherweise you may change the values in the gateway interface) weatherHum.readOnly = "true"; // Set title to "Pressure" weatherPres.title = "Pressure"; // Set unit for pressure to hPa weatherPres.unit = " hPa"; // Set pressure to read only weatherPres.readOnly = "true"; // Set title to "Env. Air Quality" weatherGas.title = "Env. Air Quality"; // Set unit for pressure to KOhms weatherGas.unit = " KOhms"; // Set environmental gas to read only weatherGas.readOnly = "true"; weather.addProperty(&weatherTemp); weather.addProperty(&weatherPres); weather.addProperty(&weatherHum); weather.addProperty(&weatherGas); adapter->addDevice(&weather); adapter->begin(); } void loop() { if (! bme.performReading()) { Serial.println("Failed to perform reading : ("); return; } float temp = bme.temperature; float hum = bme.humidity; float pres = bme.pressure / 100.0F; float gas = bme.gas_resistance / 1000.0F; Serial.print("Temperature = "); Serial.print(temp); Serial.println(" *C"); Serial.print("Pressure = "); Serial.print(pres); Serial.println(" hPa"); Serial.print("Humidity = "); Serial.print(hum); Serial.println(" % "); Serial.print("Gas = "); Serial.print(gas); Serial.println(" KOhms"); Serial.println(); ThingPropertyValue value; value.number = pres; weatherPres.setValue(value); value.number = temp; weatherTemp.setValue(value); value.number = hum; weatherHum.setValue(value); value.number = gas; weatherGas.setValue(value); adapter->update(); //uncomment if energy-saving is important //Serial.println("Light Slepp 5 min"); //wifi_set_sleep_type(LIGHT_SLEEP_T); //delay(300000); delay(2000); }
Compilação, Gravação e Execução

WebThing (Gateway)





Log

Vá ao menu LOG


Adicione os Elementos que desejas fazer LOG e por quanto TEMPO


Gráficos (Log)





Terminal


Questões: suporte@smartcore.com.br

FONTES: 

Sobre a SMARTCORE

A SmartCore fornece módulos para comunicação wireless, biometria, conectividade, rastreamento e automação.
Nosso portfólio inclui modem 2G/3G/4G/NB-IoT/Cat.M, satelital, módulos WiFi, Bluetooth, GNSS / GPS, Sigfox, LoRa, leitor de cartão, leitor QR code, mecanismo de impressão, mini-board PC, antena, pigtail, LCD, bateria, repetidor GPS e sensores.
Mais detalhes em www.smartcore.com.br

Nenhum comentário:

Postar um comentário