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

j

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