Compare commits

..

6 Commits

Author SHA1 Message Date
d49cdb8a0e Add 'src/ascii.txt' 2021-11-19 09:46:46 +01:00
bbddb40147 fix speed 2021-10-15 21:24:37 +02:00
bb581cb18f Merge branch 'master' of https://git.bh.ttx.sk/jaro/ESPSerialCAM 2021-10-15 18:27:33 +02:00
aa53b5aca1 speed 460800, commands bright, satur, contr 2021-10-15 18:22:06 +02:00
77ee263d78 Fix prameters
Add upload camera.jpg
2021-02-07 16:13:55 +01:00
9a82880086 fix names 2021-02-01 22:39:38 +01:00
9 changed files with 460 additions and 385 deletions

4
.gitignore vendored
View File

@@ -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

View File

@@ -12,7 +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 = lib_deps =
enviromonitor/BME280_Light@0.0.0-alpha+sha.600667f3a6 enviromonitor/BME280_Light@0.0.0-alpha+sha.600667f3a6

50
read.sh
View File

@@ -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
View 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'

View File

@@ -64,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();
@@ -81,6 +84,13 @@ 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)
{ {
BMESensor.refresh(); // read current sensor dat BMESensor.refresh(); // read current sensor dat
@@ -88,9 +98,40 @@ void print_measurement(char *aLine)
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},
@@ -126,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
} }
@@ -155,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;
} }
@@ -170,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) {
@@ -182,6 +248,8 @@ camera_config_t config;
BMESensor.begin(); BMESensor.begin();
print_commands("");
} }
uint8_t bytesIn; uint8_t bytesIn;