Commit 3f46c099 authored by Nelso Jost's avatar Nelso Jost
Browse files

NEW: structure refactor; commom pio Makefile usage; DEV: esplogger with...

NEW: structure refactor; commom pio Makefile usage; DEV: esplogger with arduino software serial suport tested
parent b4ff0355
/home/nelso/devel/meteorolog/utils/pioman/Makefile
\ No newline at end of file
include ../utils/platformio/Makefile
INOPROJECT = meteorolog
BAUD = 9600
BOARD = uno
monitor: qtmonitor
#
PORT :=
BAUD := 115200
PIOBOARD = nodemcuv2
PIOPROJ = firmware/esplogger
PIODIR = .pio
.PHONY: firmware monitor reset getport
all: firmware
install-pip3:
wget https://bootstrap.pypa.io/get-pip.py && \
sudo python3 get-pip.py && rm get-pip.py
install-platformio:
wget https://bootstrap.pypa.io/get-pip.py && \
sudo python get-pip.py && rm get-pip.py
sudo pip install platformio
$(MAKE) add-udev-rules
$(MAKE) add-dialout
add-dialout:
sudo usermod -a -G dialout $$USER
add-udevrules:
wget https://raw.githubusercontent.com/platformio/platformio/develop/scripts/99-platformio-udev.rules
sudo cp -v 99-platformio-udev.rules /etc/udev/rules.d
sudo service udev restart
firmware: build upload monitor
build:
which platformio || $(MAKE) install-platformio
@ echo "$$PIO_BUILD" | sh
upload:
which platformio || $(MAKE) install-platformio
cd $(PIODIR) && platformio run -t upload
monitor:
platformio device monitor
reset: getport
@ echo "-----------------------------------------"
@ echo "Reseting the board"
esptool.py --port /dev/$(PORT) run
@ python -c "import time; time.sleep(1)"
getport:
@ $(eval PORT := `python utils/getport.py`)
@ echo $(PORT)
example-blink:
$(eval PIOPROJ := examples/blink)
@ echo "$$PIO_BUILD" | sh
example-wifiscan:
$(eval PIOPROJ := examples/wifiscan)
@ echo "$$PIO_BUILD" | sh
$(MAKE) monitor
example-sdcardinfo:
$(eval PIOPROJ := examples/sd_card_info)
@ echo "$$PIO_BUILD" | sh
$(MAKE) monitor
help:
@ echo "$$HELP_MAKEFILE"
clean:
rm -rfv $(PIODIR)
define HELP_MAKEFILE
Usage: make <target> where <target> can be:
firmware Build and upload the esplogger firmware using platformio
monitor Start the picocom serial monitor (autodetect port)
reset Attempt a soft reset of the ESP devkit board
example-____ Build and upload one of the examples/ projects:
blink -- turn on and off the led on pin 2
wifiscan -- detect and print all available SSIDs
endef
export HELP_MAKEFILE
define PY_GET_PORT
import os
ports = [x for x in os.listdir("/dev") if x.startswith("ttyUSB")
or x.startswith("ttyACM")]
if ports and isinstance(ports[0], str):
print(ports[0])
else:
print("Error: Unable to find a ttyUSB/ttyACM serial port")
raise SystemExit(1)
endef
export PY_GET_PORT
define PIO_BUILD
mkdir -p $(PIODIR)
rm -rf $(PIODIR)/src
platformio init --board $(PIOBOARD) -d $(PIODIR)
cp -rf $(PIOPROJ)/* $(PIODIR)/src/
cd $(PIODIR) && platformio run
endef
export PIO_BUILD
Purpose
-------
Data logger firmware that runs on the ESP12e NodeMCU board connected an Arduino via software serial for sensor reading. This firmware is being designed to accomplish the following tasks:
* Read sensor data from the Arduino board (established platform for plugging sensors);
* Save the data locally onto an SD card;
* Attempt to send the data onto the server (if fail, try again later);
* Serial REPL (Read-Eval-Print-Loop) interpreter for sending commands;
** Used on initial setup and debugging tasks;
This software is part o the project EMM at CTA-UFRGS. See the official page for more details:
http://cta.if.ufrgs.br/projects/estacao-meteorologica-modular/wiki/Wiki
Usage
-----
The Makefile present on the root directory provide a quick commands for the most commom operations. Type "make" or "make help" for showing the help message. Some commands require external tools to be installed, like Platformio.
The project firmware is under the "firmware/" directory and is ArduinoIDE-compatible. Alternatively you can build/upload it via terminal using "make firmware" command, that uses the excelent PlatformIO tool (use "make install-platformio" if not present).
The examples folder contains several Arduino-IDE compatible little projects for demonstration of key features of the ESP12e.
Development
-----------
The software is still on its early stages, so new functionality will be added frequently.
#include <Arduino.h>
#define LED_PIN 2
#define SLEEP_INTERVAL 500 // milliseconds
void setup()
{
Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
}
void loop()
{
digitalWrite(LED_PIN, HIGH);
delay(SLEEP_INTERVAL);
digitalWrite(LED_PIN, LOW);
delay(SLEEP_INTERVAL);
}
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "WProgram.h" #include "WProgram.h"
#endif #endif
#include <Adafruit_Sensor.h> #include "Adafruit_Sensor.h"
#ifdef __AVR_ATtiny85__ #ifdef __AVR_ATtiny85__
#include "TinyWireM.h" #include "TinyWireM.h"
......
include ../../utils/platformio/Makefile
BAUD = 115200
BOARD = uno
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "Adafruit_Sensor.h" #include "Adafruit_Sensor.h"
#include "Adafruit_BMP085_U.h" #include "Adafruit_BMP085_U.h"
#define BAUDRATE 9600 #define BAUDRATE 115200
/* This driver uses the Adafruit unified sensor library (Adafruit_Sensor), /* This driver uses the Adafruit unified sensor library (Adafruit_Sensor),
which provides a common 'type' for sensor data and some helper functions. which provides a common 'type' for sensor data and some helper functions.
......
/home/nelso/devel/meteorolog/utils/pioman/Makefile
\ No newline at end of file
include ../../utils/platformio/Makefile
BAUD = 115200
BOARD = nodemcuv2
#include <Arduino.h> #include <Arduino.h>
#define LED_PIN 2 #define LED_PIN 2 // NODEMCU D4
#define SLEEP_INTERVAL 500 // milliseconds #define SLEEP_INTERVAL 500 // milliseconds
void setup() void setup()
......
include ../../utils/platformio/Makefile
BAUD = 115200
BOARD = nodemcuv2
include ../../utils/platformio/Makefile
BAUD = 115200
BOARD = nodemcuv2
include ../utils/platformio/Makefile
INOPROJECT = esplogger
BAUD = 115200
BOARD = nodemcuv2 # from $ platformio boards esp8266
#monitor: qtmonitor
#
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment