Commit 52ba7cf4 authored by Amadej Arh's avatar Amadej Arh
Browse files

j

parents bace661a cfe29603
...@@ -17,5 +17,5 @@ upload_port = /dev/ttyUSB0 ...@@ -17,5 +17,5 @@ upload_port = /dev/ttyUSB0
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 921600 upload_speed = 921600
lib_deps = lib_deps =
adafruit/Adafruit BME280 Library@^2.2.2
asukiaaa/MPU9250_asukiaaa@^1.5.11 asukiaaa/MPU9250_asukiaaa@^1.5.11
adafruit/Adafruit BME680 Library@^2.0.2
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
#include <Wire.h> #include <Wire.h>
#include <SPI.h> #include <SPI.h>
#include <Adafruit_BME280.h>
#include <MPU9250_asukiaaa.h>
#include "Adafruit_BME680.h"
#include <MPU9250_asukiaaa.h>
/* /*
Pini v uporabi: Pini v uporabi:
-VCC -VCC
...@@ -29,11 +29,9 @@ V Adafruit_BME280.h sta BME280_ADDRESS_ALTERNATE in BME280_ADDRESS zamenjana. ...@@ -29,11 +29,9 @@ V Adafruit_BME280.h sta BME280_ADDRESS_ALTERNATE in BME280_ADDRESS zamenjana.
#define STOP 'E' #define STOP 'E'
#define PICTURE 'P' #define PICTURE 'P'
Adafruit_BME280 bme; // use I2C interface #define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_Sensor *bme_temp = bme.getTemperatureSensor();
Adafruit_Sensor *bme_pressure = bme.getPressureSensor();
Adafruit_Sensor *bme_humidity = bme.getHumiditySensor();
Adafruit_BME680 bme; // use I2C interface
MPU9250_asukiaaa mpu; MPU9250_asukiaaa mpu;
unsigned long pol = 0; unsigned long pol = 0;
...@@ -42,10 +40,10 @@ float absolute_value(float vrednost); ...@@ -42,10 +40,10 @@ float absolute_value(float vrednost);
void setup() void setup()
{ {
Serial2.setRxBufferSize(2048);
Serial.begin(115200); Serial.begin(115200);
Serial1.begin(19200); // antena Serial1.begin(19200); // antena
Serial2.begin(115200); // rpi Serial2.begin(115200); // rpi
Serial2.setRxBufferSize(2048);
Wire.begin(21, 22); Wire.begin(21, 22);
mpu.setWire(&Wire); mpu.setWire(&Wire);
...@@ -53,8 +51,13 @@ void setup() ...@@ -53,8 +51,13 @@ void setup()
mpu.beginAccel(); mpu.beginAccel();
mpu.beginGyro(); mpu.beginGyro();
bme.begin(); bme.begin(0x76);
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
} }
char buffer_le_drugi[132]; char buffer_le_drugi[132];
...@@ -97,14 +100,8 @@ void loop() ...@@ -97,14 +100,8 @@ void loop()
if (pada) if (pada)
{ {
sensors_event_t temp_event, pressure_event, humidity_event; bme.beginReading();
bme_temp->getEvent(&temp_event);
bme_pressure->getEvent(&pressure_event);
bme_humidity->getEvent(&humidity_event);
ultra_pomembni_podatki.temp = temp_event.temperature;
ultra_pomembni_podatki.humidity = humidity_event.relative_humidity;
ultra_pomembni_podatki.pressure = pressure_event.pressure;
if (mpu.accelUpdate() == 0) if (mpu.accelUpdate() == 0)
{ {
...@@ -149,16 +146,6 @@ void loop() ...@@ -149,16 +146,6 @@ void loop()
cajt = 0; cajt = 0;
} }
// Serial2.write(PICTURE);
// delayMicroseconds(1000);
// if (Serial2.available() == 132) {
// Serial2.readBytes(buffer_le_drugi, 132);
// memcpy(ultra_pomembni_podatki.umetnost, buffer_le_drugi, 132);
// } else {
// for (int i = 0; i < 132; i++) {
// ultra_pomembni_podatki.umetnost[i] = 0;
// }
// }
char c; char c;
if (Serial2.available() >= 3) if (Serial2.available() >= 3)
...@@ -187,53 +174,35 @@ void loop() ...@@ -187,53 +174,35 @@ void loop()
Serial.println("[PACKET]"); Serial.println("[PACKET]");
char bufr[2]; char bufr[2];
int a = Serial2.readBytes((char *)&rpi_packt.num, sizeof(rpi_packt.num)); int a = Serial2.readBytes((char *)&rpi_packt.num, sizeof(rpi_packt.num));
Serial.printf("Header Bytes: %d> %02d %02d %02d %02d\n", a, rpi_packt.num[0], rpi_packt.num[1], rpi_packt.num[2], rpi_packt.num[3]); Serial.printf("Header Bytes: %d> %02d %02d %02d %02d\n", a, rpi_packt.num[0], rpi_packt.num[1], rpi_packt.num[2], rpi_packt.num[3]);
ultra_pomembni_podatki.packet_number = ((unsigned long)rpi_packt.num[0] << 24) + ((unsigned long)rpi_packt.num[1] << 16) + ((unsigned long)rpi_packt.num[2] << 8) + (unsigned long)rpi_packt.num[3];
// ultra_pomembni_podatki.packet_number = (unsigned long)rpi_packt.num[0] * 65536 + (unsigned long)rpi_packt.num[1] * 65536 + (unsigned long)rpi_packt.num[2] * 256 + (unsigned long)rpi_packt.num[3];
Serial.printf("Stevilo paketa: %08x %02x\n", ultra_pomembni_podatki.packet_number); Serial.printf("Stevilo paketa: %08x %02x\n", ultra_pomembni_podatki.packet_number);
Serial.printf("Stevilo paketa: %lu\n", ultra_pomembni_podatki.packet_number); Serial.printf("Stevilo paketa: %lu\n", ultra_pomembni_podatki.packet_number);
Serial2.readBytes(rpi_packt.arr, 128); Serial2.readBytes(rpi_packt.arr, 128);
memcpy(ultra_pomembni_podatki.umetnost, rpi_packt.arr, 128);
Serial.printf("kaj not: %c%c\n", rpi_packt.arr[0], rpi_packt.arr[1]); Serial.printf("kaj not: %c%c\n", rpi_packt.arr[0], rpi_packt.arr[1]);
Serial2.readBytes(bufr, 1); Serial2.readBytes(bufr, 1);
ultra_pomembni_podatki.packet_number = ((unsigned long)rpi_packt.num[0] << 24) + ((unsigned long)rpi_packt.num[1] << 16) + ((unsigned long)rpi_packt.num[2] << 8) + (unsigned long)rpi_packt.num[3];
memcpy(ultra_pomembni_podatki.umetnost, rpi_packt.arr, 128);
if (bufr[0]=='-') Serial.print("[END]"); if (bufr[0]=='-') Serial.print("[END]");
Serial.printf("Bytes in buffer:%d ", Serial2.available()); Serial.printf("Bytes in buffer:%d ", Serial2.available());
//break; //break;
} }
} }
// for (int i = 0; i < 134; i++) {
// Serial.write(b);
// }
// while (1) { // if (millis() > pol) {
// char c = Serial2.read(); //pol = millis() + 0;
// Serial.write(c); int a = Serial1.write((char *)&ultra_pomembni_podatki, sizeof(ultra_pomembni_podatki));
// if (c == '-') { Serial2.write(PICTURE);
// break;
// }
// } // }
// Serial.printf("rpi bytes waiting: %d\n", Serial2.available()); bme.endReading();
// if (Serial2.available() > 137) {
// char buffer[137]; ultra_pomembni_podatki.temp = bme.temperature;
// Serial2.read(buffer, 137); ultra_pomembni_podatki.humidity = bme.humidity;
// Serial.printf("rpi packet: %d", (uint32_t)&buffer[3]); ultra_pomembni_podatki.pressure = bme.pressure / 100.0;
// }
if (1)
{
// Serial.printf("Bytes sent: %d\n", a);
//delay(200);
if (millis() > pol) {
pol = millis() + 200;
int a = Serial1.write((char *)&ultra_pomembni_podatki, sizeof(ultra_pomembni_podatki));
Serial2.write(PICTURE);
//delay(50);
}
}
} }
} }
......
This diff is collapsed.
...@@ -12,7 +12,7 @@ def main(): ...@@ -12,7 +12,7 @@ def main():
ser = serial.Serial("/dev/ttyUSB1", 19200) ser = serial.Serial("/dev/ttyUSB1", 19200)
except: except:
ser = serial.Serial("/dev/ttyUSB0", 19200) ser = serial.Serial("/dev/ttyUSB0", 19200)
print(ser.name) print(ser.name)
print("\033[2J") print("\033[2J")
......
...@@ -95,7 +95,7 @@ int main (int argc, char ** argv) { ...@@ -95,7 +95,7 @@ int main (int argc, char ** argv) {
} }
CHECK CHECK
//offset = ntohl(offset); //offset = ntohl(offset);
printf("%lu\n",offset); //printf("%lu\n",offset);
//offset--; //offset--;
int na_eni_sliki = offset % (VIŠINA*5); int na_eni_sliki = offset % (VIŠINA*5);
// fprintf(stderr, "offset: %u, na_eni_sliki: %u\n", offset, na_eni_sliki); // fprintf(stderr, "offset: %u, na_eni_sliki: %u\n", offset, na_eni_sliki);
......
Supports Markdown
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