M
Tool chain (firmware + logger) para aquisição de dados meteorológicos utilizando a placa Arduino. Confira a Wiki https://git.cta.if.ufrgs.br/meteorolog/logger/wikis/home. – README.md

README.md

Meteorolog

This repository contains several applications devoted to perform data logging of sensor data from the EMM boards (Modular Meteorological Station, or "Estações Meteorológicas Modulares" in portuguese).

Applications included are:

  • Arduino firmware - Read sensor data upon serial commands like read,dt,t (which returns the RTC datetime and the temperature as comma-separated values);

  • NodeMCU firmware - Communicate with Arduino via software serial to retrieve sensor data and perform data logging into SD card and remote server via wifi (ESP8266);

  • PyLogger software (Linux) - Alternative data logger that can run on a RaspberryPi (or any Linux PC) with he Arduino plugged on the USB;

This document describe briefly how to get started using those applications. A more comprehensive documentation is present at the /doc directory of this repository.

Arduino + NodeMCU Guide

What follow is a suscint list of steps to get your EMM board up and running using Arduino + NodeMCU.

1. Hardware assembling

The Modular Meteorological Station (EMM in portuguese) concept starts with the use of cheap but reliable sensors plugged onto the popular open-source hardware Arduino board. The basic kit includes:

  • DHT22 for reading temperature and air humidity;
  • BMP180 for reading atmospheric pressure and also temperature;
  • LDR for reading luminosity (not calibrated for lux);
  • RTC DS1307/DS3231 (Real-time Clock) to provide reliable timestamps;

Some sensors are connected on dedicated GPIO pins like DHT22 and LDR and others onto an I2C bus, like BMP180 and RTC DS1307. As for microcontrollers you'll need the following development boards:

  • Arduino (Uno/Nano/Due): Have lots of GPIO and a very stable framework;
  • NodeMCU (ESP8266-12): Cheapest wifi solution for IoT. Have less GPIO than Arduino;

Both boards already come with USB interface for easy upload of firmware. Communication between Arduino and NodeMCU is done by Software Serial. Since the boards work on different voltages (Arduino with 5 V logic and NodeMCU with 3 V logic), you'll also need:

The assemblying steps are:

  1. Connect all the sensors to the Arduino board.
  2. Connect the Arduino TX/RX pins to the software serial RX/TX pins on NodeMCU (ex: D1/D2) using the level shifter;
  3. (optional) connect the micro SD module to the NodeMCU board;
  4. Use a good, regulated, 5V/1A power suply to power both boards (Vin/GND pins) at the same time;

2. Upload firmware

There are two firmwares you will need to install:

  • arduino/meteorolog contains the code for the Arduino board;
  • nodemcu/esplogger contains the code for the NodeMCU board;

Both are Arduino IDE compatible, which means that you can build/upload them simply using the standard IDE.

Note: For the NodeMCU firmware you'll need to have IDE version >= 1.6 and follow the steps indicated here https://github.com/esp8266/Arduino#installing-with-boards-manager.

Alternatively you can use PlatformIO by executing make <target> commands inside the folders with a Makefile. Execute make help for a list of all actions, but the basic steps are:

  1. Make sure you have the tool with make install-platformio (need just once);
  2. (Arduino only) Edit the Makefile BOARD variable with your board model;
    • Run platformio boards arduino for listing all the models.
  3. Simply execute make to build, upload and open serial monitor (port auto-detected).

For more info check utils/platformio/Makefile;

3. Test sensors

  • Check all the available sensor names on the Arduino:

    arduino listall
    
  • Check the reading of the sensors you want:

    arduino read,dt,t,p
    

    for instance will return the RTC datetime, temperature and pressure as comma-separated values.

4. Setup wifi connection

  • List available networks in range:

    wifiscan
    
  • Connect to one of them:

    wificonnect <ssid> <password>
    
  • Check your current status:

    wifistatus
    

    If you got an IP address, you good to go!

5. Setup server authentication

This will communicate with the web site API for retrieving your "board_hash" authentication token.

Two things can go wrong:

  1. If you got a [HTTP] POST message with code different from 200, you have a internet connection issue. Try a different network and/or reseting the board.
  2. Code 200 means server communication is OK, but you can still get and "error" response for using wrong credentials. Double check CAPSLOCK and try it again.

If the configuration file 'LOGGER.CONF' was sucessfully updated you should see a print of it containing the "board_hash" authentication token. This means that you are good to go: the configuration is stored on the NodeMCU flash memory and will be reloaded on board reset.

6. Start the data logger

  • Assuming you already test your sensors (with read,dt,t,p), start the logger with a short interval like so: meteorolog 0.5 read,dt,t,p

If all goes well, re-run this command with a larger interval. This configuration will be stored on the internal configuration file and reload on board reset.

As for debuging you can follow the serial monitor messages for a while, or just watch how the built-in NodeMCU led blinks:

  • 1 blink means everything is OK;
  • 2 blinks means problem with the serial connection between Arduino and NodeMCU;
  • 3 blinks means problem with the server connection (data was not uploaded, but saved on the SD card);
  • 4 blinks means problem with the SD card only (data was sent to the server);
  • 5 blinks means problem with both server and SD card (CRITICAL: data was lost!);

Usage

Arduino Firmware

The following commands can be sent via serial monitor on the Arduino port:

  • read,<name1>,<name2>,...,<nameN>

Read one or more sensor values by using the full name as registered on the web site (http://dados.cta.if.ufrgs.br/emm) or the respective short nickname. Retunrs a list of comma-separated values.

Example: read,dt,t returns the RTC datetime and the DHT22 temperature.

  • setrtc,<year>,<month>,<day>,<hour>,<minute>,<second>

Configure the real time clock (RTC either DS1307 or DS3231) with given datetime.

  • listall

List all available sensores along with their nicknames.

  • help

Show the list of all available commands.

NodeMCU firmware

The following commands can be sent via serial monitor on the Arduino port:

  • help: Lists all of the available commands.

PyLogger