Compare commits
9 Commits
78f5edbd8e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| d49cdb8a0e | |||
| bbddb40147 | |||
| bb581cb18f | |||
| aa53b5aca1 | |||
| 77ee263d78 | |||
| 9a82880086 | |||
| 12575174ec | |||
| 1c8c8951a2 | |||
| ab61523800 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,3 +3,7 @@
|
|||||||
.vscode/c_cpp_properties.json
|
.vscode/c_cpp_properties.json
|
||||||
.vscode/launch.json
|
.vscode/launch.json
|
||||||
.vscode/ipch
|
.vscode/ipch
|
||||||
|
src/.vscode/c_cpp_properties.json
|
||||||
|
.vscode/extensions.json
|
||||||
|
.vscode/extensions.json
|
||||||
|
platformio.ini
|
||||||
|
|||||||
@@ -12,5 +12,9 @@
|
|||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = esp32cam
|
board = esp32cam
|
||||||
framework = arduino
|
framework = arduino
|
||||||
monitor_port = COM[13678]
|
monitor_port = /dev/ttyUSB0
|
||||||
monitor_speed = 115200
|
monitor_speed = 460800
|
||||||
|
monitor_rts = 0
|
||||||
|
monitor_dtr = 0
|
||||||
|
lib_deps =
|
||||||
|
enviromonitor/BME280_Light@0.0.0-alpha+sha.600667f3a6
|
||||||
|
|||||||
50
read.sh
50
read.sh
@@ -1,50 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
host="172.16.1.254"
|
|
||||||
topic="esp32/strecha"
|
|
||||||
url="https://meranie.bh.ttx.sk/upload/"
|
|
||||||
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
echo "measure"
|
|
||||||
|
|
||||||
input=
|
|
||||||
while [[ $input = "" ]]; do
|
|
||||||
read input
|
|
||||||
done
|
|
||||||
read t h p <<< $input
|
|
||||||
|
|
||||||
IFS="="
|
|
||||||
read v k <<< $t
|
|
||||||
echo $k > /dev/tty
|
|
||||||
t=$k
|
|
||||||
|
|
||||||
read v k <<< $h
|
|
||||||
echo $k > /dev/tty
|
|
||||||
h=$k
|
|
||||||
|
|
||||||
read v k <<< $p
|
|
||||||
echo $k > /dev/tty
|
|
||||||
p=$k
|
|
||||||
|
|
||||||
unset IFS
|
|
||||||
|
|
||||||
break
|
|
||||||
done </dev/ttyUSB0 >/dev/ttyUSB0
|
|
||||||
|
|
||||||
echo mosquitio_pub -h $host -t $topic/temperature -m N:$t
|
|
||||||
echo mosquitio_pub -h $host -t $topic/humidity -m N:$h
|
|
||||||
echo mosquitio_pub -h $host -t $topic/pressure -m N:$p
|
|
||||||
|
|
||||||
echo "capture" > /dev/ttyUSB0
|
|
||||||
echo "rb" > /dev/ttyUSB0
|
|
||||||
rb --ymodem </dev/ttyUSB0 >/dev/ttyUSB0
|
|
||||||
|
|
||||||
echo "free" > /dev/ttyUSB0
|
|
||||||
|
|
||||||
curl -v -F filename=camera.jpg -F upload=@camera.jpg $url
|
|
||||||
rm camera.jpg
|
|
||||||
sleep 300
|
|
||||||
done
|
|
||||||
51
src/ascii.txt
Normal file
51
src/ascii.txt
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
## Font attributes ##
|
||||||
|
# off
|
||||||
|
off = '\x1b[0m' # off
|
||||||
|
default = '\x1b[39m' # default foreground
|
||||||
|
DEFAULT = '\x1b[49m' # default background
|
||||||
|
#
|
||||||
|
bd = '\x1b[1m' # bold
|
||||||
|
ft = '\x1b[2m' # faint
|
||||||
|
st = '\x1b[3m' # standout
|
||||||
|
ul = '\x1b[4m' # underlined
|
||||||
|
bk = '\x1b[5m' # blink
|
||||||
|
rv = '\x1b[7m' # reverse
|
||||||
|
hd = '\x1b[8m' # hidden
|
||||||
|
nost = '\x1b[23m' # no standout
|
||||||
|
noul = '\x1b[24m' # no underlined
|
||||||
|
nobk = '\x1b[25m' # no blink
|
||||||
|
norv = '\x1b[27m' # no reverse
|
||||||
|
# colors
|
||||||
|
black = '\x1b[30m'
|
||||||
|
BLACK = '\x1b[40m'
|
||||||
|
red = '\x1b[31m'
|
||||||
|
RED = '\x1b[41m'
|
||||||
|
green = '\x1b[32m'
|
||||||
|
GREEN = '\x1b[42m'
|
||||||
|
yellow = '\x1b[33m'
|
||||||
|
YELLOW = '\x1b[43m'
|
||||||
|
blue = '\x1b[34m'
|
||||||
|
BLUE = '\x1b[44m'
|
||||||
|
magenta = '\x1b[35m'
|
||||||
|
MAGENTA = '\x1b[45m'
|
||||||
|
cyan = '\x1b[36m'
|
||||||
|
CYAN = '\x1b[46m'
|
||||||
|
white = '\x1b[37m'
|
||||||
|
WHITE = '\x1b[47m'
|
||||||
|
# light colors
|
||||||
|
dgray = '\x1b[90m'
|
||||||
|
DGRAY = '\x1b[100m'
|
||||||
|
lred = '\x1b[91m'
|
||||||
|
LRED = '\x1b[101m'
|
||||||
|
lgreen = '\x1b[92m'
|
||||||
|
LGREEN = '\x1b[102m'
|
||||||
|
lyellow = '\x1b[93m'
|
||||||
|
LYELLOW = '\x1b[103m'
|
||||||
|
lblue = '\x1b[94m'
|
||||||
|
LBLUE = '\x1b[104m'
|
||||||
|
lmagenta = '\x1b[95m'
|
||||||
|
LMAGENTA = '\x1b[105m'
|
||||||
|
lcyan = '\x1b[96m'
|
||||||
|
LCYAN = '\x1b[106m'
|
||||||
|
lgray = '\x1b[97m'
|
||||||
|
LGRAY = '\x1b[107m'
|
||||||
92
src/main.cpp
92
src/main.cpp
@@ -6,6 +6,11 @@
|
|||||||
#include "soc/rtc_cntl_reg.h" // Disable brownour problems
|
#include "soc/rtc_cntl_reg.h" // Disable brownour problems
|
||||||
#include "driver/rtc_io.h"
|
#include "driver/rtc_io.h"
|
||||||
#include <EEPROM.h> // read and write from flash memory
|
#include <EEPROM.h> // read and write from flash memory
|
||||||
|
#include <Wire.h>
|
||||||
|
#include <BME280_t.h> // import BME280 template library
|
||||||
|
|
||||||
|
char bufout[10];
|
||||||
|
BME280<> BMESensor;
|
||||||
|
|
||||||
// define the number of bytes you want to access
|
// define the number of bytes you want to access
|
||||||
#define EEPROM_SIZE 1
|
#define EEPROM_SIZE 1
|
||||||
@@ -59,11 +64,14 @@ void reboot_esp32(char *aLine)
|
|||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
void recv_ymodem(char *aLine)
|
void set_speed(char *aLine)
|
||||||
{
|
{
|
||||||
xmodem.sendFile(fb->buf, fb->len, "camera.jpg");
|
char *speed = aLine + strlen(aLine) + 1;
|
||||||
|
Serial.updateBaudRate(atol(speed));
|
||||||
|
Serial.printf("[OK] SETTING SPEED %s",speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void capture_image(char *aLine)
|
void capture_image(char *aLine)
|
||||||
{
|
{
|
||||||
fb = esp_camera_fb_get();
|
fb = esp_camera_fb_get();
|
||||||
@@ -76,15 +84,54 @@ void free_image(char *aLine)
|
|||||||
Serial.println("[OK] FREE CAPTURED IMAGE");
|
Serial.println("[OK] FREE CAPTURED IMAGE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void recv_ymodem(char *aLine)
|
||||||
|
{
|
||||||
|
xmodem.sendFile(fb->buf, fb->len, "camera.jpg");
|
||||||
|
Serial.println("[OK] SEND IMAGE");
|
||||||
|
free_image(aLine);
|
||||||
|
}
|
||||||
|
|
||||||
void print_measurement(char *aLine)
|
void print_measurement(char *aLine)
|
||||||
{
|
{
|
||||||
Serial.printf("temperature=%.2f humidity=%.2f pressure=%.2f\n",temperatureRead(),60.2,903.45);
|
BMESensor.refresh(); // read current sensor dat
|
||||||
|
Serial.printf("temperature=%.2f humidity=%.2f pressure=%.2f\n",BMESensor.temperature,BMESensor.humidity,BMESensor.pressure / 100.0F);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_brightness(char *aLine)
|
||||||
|
{
|
||||||
|
char *str = aLine + strlen(aLine) + 1;
|
||||||
|
sensor_t * s = esp_camera_sensor_get();
|
||||||
|
s->set_brightness(s, atol(str)); // -2 to 2
|
||||||
|
Serial.print("[OK] SETTING BRIGHTNESS ");
|
||||||
|
Serial.println(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_saturation(char *aLine)
|
||||||
|
{
|
||||||
|
char *str = aLine + strlen(aLine) + 1;
|
||||||
|
sensor_t * s = esp_camera_sensor_get();
|
||||||
|
s->set_saturation(s, atol(str)); // -2 to 2
|
||||||
|
Serial.print("[OK] SETTING SATURATION ");
|
||||||
|
Serial.println(str);;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_contrast(char *aLine)
|
||||||
|
{
|
||||||
|
char *str = aLine + strlen(aLine) + 1;
|
||||||
|
sensor_t * s = esp_camera_sensor_get();
|
||||||
|
s->set_contrast(s, atol(str)); // -2 to 2
|
||||||
|
Serial.print("[OK] SETTING CONTRAST ");
|
||||||
|
Serial.println(str);
|
||||||
|
}
|
||||||
|
|
||||||
const command_action_t commands[] = {
|
const command_action_t commands[] = {
|
||||||
// Name of command user types, function that implements the command.
|
// Name of command user types, function that implements the command.
|
||||||
{"reboot", reboot_esp32},
|
{"reboot", reboot_esp32},
|
||||||
|
{"bright",set_brightness},
|
||||||
|
{"satur",set_saturation},
|
||||||
|
{"contr",set_contrast},
|
||||||
|
{"speed", set_speed},
|
||||||
{"capture", capture_image},
|
{"capture", capture_image},
|
||||||
{"free", free_image},
|
{"free", free_image},
|
||||||
{"measure", print_measurement},
|
{"measure", print_measurement},
|
||||||
@@ -120,7 +167,7 @@ void execute(char *aLine) {
|
|||||||
void setup() {
|
void setup() {
|
||||||
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
|
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(460800);
|
||||||
while (!Serial) {
|
while (!Serial) {
|
||||||
; // wait for serial port to connect. Needed for Leonardo only
|
; // wait for serial port to connect. Needed for Leonardo only
|
||||||
}
|
}
|
||||||
@@ -149,11 +196,11 @@ camera_config_t config;
|
|||||||
|
|
||||||
if(psramFound()){
|
if(psramFound()){
|
||||||
config.frame_size = FRAMESIZE_UXGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA
|
config.frame_size = FRAMESIZE_UXGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA
|
||||||
config.jpeg_quality = 10;
|
config.jpeg_quality = 7;
|
||||||
config.fb_count = 2;
|
config.fb_count = 2;
|
||||||
} else {
|
} else {
|
||||||
config.frame_size = FRAMESIZE_SVGA;
|
config.frame_size = FRAMESIZE_SVGA;
|
||||||
config.jpeg_quality = 12;
|
config.jpeg_quality = 10;
|
||||||
config.fb_count = 1;
|
config.fb_count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +211,31 @@ camera_config_t config;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sensor_t * s = esp_camera_sensor_get();
|
||||||
|
s->set_brightness(s, 0); // -2 to 2
|
||||||
|
s->set_contrast(s, 0); // -2 to 2
|
||||||
|
s->set_saturation(s, 0); // -2 to 2
|
||||||
|
s->set_special_effect(s, 0); // 0 to 6 (0 - No Effect, 1 - Negative, 2 - Grayscale, 3 - Red Tint, 4 - Green Tint, 5 - Blue Tint, 6 - Sepia)
|
||||||
|
s->set_whitebal(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_awb_gain(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_wb_mode(s, 0); // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home)
|
||||||
|
s->set_exposure_ctrl(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_aec2(s, 0); // 0 = disable , 1 = enable
|
||||||
|
s->set_ae_level(s, 0); // -2 to 2
|
||||||
|
s->set_aec_value(s, 300); // 0 to 1200
|
||||||
|
s->set_gain_ctrl(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_agc_gain(s, 0); // 0 to 30
|
||||||
|
s->set_gainceiling(s, (gainceiling_t)0); // 0 to 6
|
||||||
|
s->set_bpc(s, 0); // 0 = disable , 1 = enable
|
||||||
|
s->set_wpc(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_raw_gma(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_lenc(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_hmirror(s, 0); // 0 = disable , 1 = enable
|
||||||
|
s->set_vflip(s, 0); // 0 = disable , 1 = enable
|
||||||
|
s->set_dcw(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_colorbar(s, 0); // 0 = disable , 1 = enable
|
||||||
|
|
||||||
|
|
||||||
// Take Picture with Camera
|
// Take Picture with Camera
|
||||||
fb = esp_camera_fb_get();
|
fb = esp_camera_fb_get();
|
||||||
if(!fb) {
|
if(!fb) {
|
||||||
@@ -172,6 +244,12 @@ camera_config_t config;
|
|||||||
}
|
}
|
||||||
esp_camera_fb_return(fb);
|
esp_camera_fb_return(fb);
|
||||||
|
|
||||||
|
Wire.begin(14,15);
|
||||||
|
|
||||||
|
BMESensor.begin();
|
||||||
|
|
||||||
|
print_commands("");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t bytesIn;
|
uint8_t bytesIn;
|
||||||
@@ -184,8 +262,8 @@ void loop() {
|
|||||||
if (b != -1) {
|
if (b != -1) {
|
||||||
switch (b) {
|
switch (b) {
|
||||||
case '\n':
|
case '\n':
|
||||||
|
if (bytesIn && aLine[bytesIn-1] == '\0') break;
|
||||||
case '\r':
|
case '\r':
|
||||||
if (b == '\n' && bytesIn && aLine[bytesIn-1] == '\0') break;
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
aLine[bytesIn] = '\0';
|
aLine[bytesIn] = '\0';
|
||||||
execute(aLine);
|
execute(aLine);
|
||||||
|
|||||||
Reference in New Issue
Block a user