Hallo Zusammen
Ich versuche Temperaturdaten vom Dragino Lora Shield 868 MHz v1.4 welches aufgesteckt auf dem Aruino UNO ist auf das TTN network zu senden.
Hardware: Dragino Lora Shield 868 MHz v1.4 / Arduino UNO
Ich kann den Code nicht kompilieren und die untenstehende Fehlremeldung kommt. Mir ist nun nicht klar was ich im Code ändern muss damit es schlussentlich funktioniert.
Folgender Code habe ich verwendet:
// MIT License
// https://github.com/gonzalocasas/arduino-uno-dragino-lorawan/blob/master/LICENSE
// Based on examples from https://github.com/matthijskooijman/arduino-lmic
// Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman
// Adaptions: Andreas Spiess
#include <OneWire.h>
#include <DallasTemperature.h>
#include <DHT_U.h>
#include <DHT.h>
#include <Adafruit_Sensor.h>
#include <lmic.h>
#include <hal/hal.h>
#define ONE_WIRE_BUS_1 2
//#include <credentials.h>
OneWire bedroom_temp(ONE_WIRE_BUS_1);
DallasTemperature C(&bedroom_temp);
#ifdef CREDENTIALS
static const u1_t NWKSKEY[16] = NWKSKEY1;
static const u1_t APPSKEY[16] = APPSKEY1;
static const u4_t DEVADDR = DEVADDR1;
#else
static const u1_t NWKSKEY[16] = { XXXX, 0x2A, 0x1B, XXXX, 0x43, 0x27, XXXX, 0xFE, 0xD3, XXXX, 0xFE, XXXX, 0xD9, 0xBE, 0xA7, 0x95 };
static const u1_t APPSKEY[16] = { 0xB5, 0xEE, 0x7E, 0x01, xxxx, xxxx, 0x4D, xxxx, 0xEF, 0x3D, 0x54, xxxx, 0x1A, 0xF7, 0x3F, 0x24 };
static const u4_t DEVADDR = 0xxxxxxxxx;
#endif
// These callbacks are only used in over-the-air activation, so they are
// left empty here (we cannot leave them out completely unless
// DISABLE_JOIN is set in config.h, otherwise the linker will complain).
void os_getArtEui (u1_t* buf) { }
void os_getDevEui (u1_t* buf) { }
void os_getDevKey (u1_t* buf) { }
static osjob_t sendjob;
// Schedule TX every this many seconds (might become longer due to duty
// cycle limitations).
const unsigned TX_INTERVAL = 60;
// Pin mapping Dragino Shield
const lmic_pinmap lmic_pins = {
.nss = 10,
.rxtx = LMIC_UNUSED_PIN,
.rst = 9,
.dio = {2, 6, 7},
};
void onEvent (ev_t ev) {
if (ev == EV_TXCOMPLETE) {
Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
// Schedule next transmission
os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
}
}
void do_send(osjob_t* j){
// Payload to send (uplink)
//static uint8_t message[] = "Hallo zusammen";
uint8_t message[2];
message[0] = bedroom_temp;
// Check if there is not a current TX/RX job running
if (LMIC.opmode & OP_TXRXPEND) {
Serial.println(F("OP_TXRXPEND, not sending"));
} else {
// Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(1, message, sizeof(message)-1, 0);
Serial.println(F("Sending uplink packet..."));
}
// Next TX is scheduled after TX_COMPLETE event.
}
void setup() {
Serial.begin(115200);
Serial.println(F("Starting..."));
// LMIC init
os_init();
// Reset the MAC state. Session and pending data transfers will be discarded.
LMIC_reset();
// Set static session parameters.
LMIC_setSession (0x1, DEVADDR, NWKSKEY, APPSKEY);
// Disable link check validation
LMIC_setLinkCheckMode(0);
// TTN uses SF9 for its RX2 window.
LMIC.dn2Dr = DR_SF9;
// Set data rate and transmit power for uplink (note: txpow seems to be ignored by the library)
LMIC_setDrTxpow(DR_SF12,14);
// Start job
do_send(&sendjob);
sensor_bedroom.begin();
}
void loop() {
os_runloop_once();
sensor_bedroom.requestTemperatures();
float bedroom_temp = sensor_bedroom.getTempCByIndex(0);
// Serial.print("bedroom_temp");
// Serial.print(",");
// Serial.print(bedroom_temp,2);
// delay (2000);
}
Folgende Fehlermeldung kommt:
/home/linus/Arduino/sketch_apr14a/sketch_apr14a.ino: In function 'void do_send(osjob_t*)':
sketch_apr14a:67:16: error: cannot convert 'OneWire' to 'uint8_t {aka unsigned char}' in assignment
message[0] = bedroom_temp;
^
/home/linus/Arduino/sketch_apr14a/sketch_apr14a.ino: In function 'void setup()':
sketch_apr14a:107:5: error: 'sensor_bedroom' was not declared in this scope
sensor_bedroom.begin();
^
/home/linus/Arduino/sketch_apr14a/sketch_apr14a.ino: In function 'void loop()':
sketch_apr14a:113:5: error: 'sensor_bedroom' was not declared in this scope
sensor_bedroom.requestTemperatures();
^
Multiple libraries were found for "DallasTemperature.h"
Used: /home/linus/Arduino/libraries/DallasTemperature
Not used: /home/linus/Arduino/libraries/Arduino-Temperature-Control-Library-master
Using library OneWire-master at version 2.3.4 in folder: /home/linus/Arduino/libraries/OneWire-master
Using library DallasTemperature at version 3.8.0 in folder: /home/linus/Arduino/libraries/DallasTemperature
Using library DHT-sensor-library-master at version 1.3.1 in folder: /home/linus/Arduino/libraries/DHT-sensor-library-master
Using library Adafruit_Sensor-master at version 1.0.2 in folder: /home/linus/Arduino/libraries/Adafruit_Sensor-master
Using library arduino-lmic-master at version 1.5.0+arduino-2 in folder: /home/linus/Arduino/libraries/arduino-lmic-master
Using library SPI at version 1.0 in folder: /opt/arduino-1.8.8/hardware/arduino/avr/libraries/SPI
exit status 1
cannot convert 'OneWire' to 'uint8_t {aka unsigned char}' in assignment