Commit 20a07891 authored by Amadej Arh's avatar Amadej Arh
Browse files

bme 680 nora posodobitev

parent f9f86e98
......@@ -3,9 +3,9 @@
#include <Wire.h>
#include <SPI.h>
#include "Adafruit_BME680.h"
#include <MPU9250_asukiaaa.h>
/*
Pini v uporabi:
-VCC
......@@ -51,7 +51,7 @@ void setup()
mpu.beginAccel();
mpu.beginGyro();
bme.begin();
bme.begin(0x76);
bme.setTemperatureOversampling(BME680_OS_8X);
bme.setHumidityOversampling(BME680_OS_2X);
......@@ -100,11 +100,8 @@ void loop()
if (pada)
{
bme.performReading();
bme.beginReading();
ultra_pomembni_podatki.temp = bme.temperature;
ultra_pomembni_podatki.humidity = bme.humidity;
ultra_pomembni_podatki.pressure = bme.pressure / 100.0;
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]);
// }
bme.endReading();
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);
}
}
ultra_pomembni_podatki.temp = bme.temperature;
ultra_pomembni_podatki.humidity = bme.humidity;
ultra_pomembni_podatki.pressure = bme.pressure / 100.0;
}
}
......
......@@ -8,7 +8,11 @@ import time
def main():
with open("logfile", "a+") as log:
with open("beshrukt.uk2", "wb+") as smolOut:
try:
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