CubeCell: OneWire Library

Hi Guy´s, there must exist some kind of problem when you not using the git methode, we get all sorts of problem with the compiler for some reason…

We install from the setup ("/quick_start.html#install-cubecell-relevant-framework") ->Install .zip version of arduino, make the changes for http://119.23.153.38/download/package_CubeCell_index.json and install the package in the library manager

OneWire works ok standalone, but when you include dallastemperature all sort of things happen, first it says that we have multiple instances of Onewire.h, wich there is not, then it says " as normal cannot find dallas temperatur.h ". when you go in and install dallas, it says- multiple instances of this one to…
Ok , well fine lets put it to the programmer suggested search path

#include “C:\Users\willh\AppData\Local\Arduino15\packages\CubeCell\hardware\CubeCell\0.0.4\libraries\OneWire\onewire.h”
#include “C:\Users\willh\Documents\Arduino\libraries\DallasTemperature\DallasTemperature.h”

Then hell brakes loose :slight_smile: AND among the things below it a the end says
“”"" Multiple libraries were found for “OneWire.h” Use: C:\Users\willh\AppData\Local\Arduino15\packages\CubeCell\hardware\CubeCell\0.0.4\libraries\OneWire""" wich we are!!

Anyone have any idea to whats going on, we have tried to reinstall everyting twice, but no change, the Lora section compiles just fine as is with only onewire.h

We need this to work, we are constructing a buch of new sensors to use with the Cube Cell

See below, looks like it cannot adress dallas for some reason

Best Regards
/A


sketch\prov_ds18b20.ino.cpp.o: In function `setup()’:

C:\Users\willh\Documents\Arduino\prov_ds18b20/prov_ds18b20.ino:29: undefined reference to `DallasTemperature::begin()’

sketch\prov_ds18b20.ino.cpp.o: In function `loop()’:

C:\Users\willh\Documents\Arduino\prov_ds18b20/prov_ds18b20.ino:40: undefined reference to `DallasTemperature::requestTemperatures()’

C:\Users\willh\Documents\Arduino\prov_ds18b20/prov_ds18b20.ino:45: undefined reference to `DallasTemperature::getTempCByIndex(unsigned char)’

sketch\prov_ds18b20.ino.cpp.o: In function `__static_initialization_and_destruction_0’:

C:\Users\willh\Documents\Arduino\prov_ds18b20/prov_ds18b20.ino:12: undefined reference to `DallasTemperature::DallasTemperature(OneWire*)’

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for “OneWire.h”
Use C:\Users\willh\AppData\Local\Arduino15\packages\CubeCell\hardware\CubeCell\0.0.4\libraries\OneWire
exit status 1
Error compiling for board CubeCell-Board.

if you use the version with the arduino board manager you do not install the latest version.
please use the git version to get the newest version.

Ok, Thanks, we will focus on that tomorrow
Have you updated the onewire and platform in the git version yet?

Have a nice evening

Br

/A

Hi guy´s and thanks, we are up and running, was loosing my mind here for a while :slight_smile: we are normally using Kiel and i thought that this would be a piece of cake with the arduino IDE but it played tricks on me all the time…
Is there an AT-syntax/command set chart available for download commands from MQTT for ex. in HEX?

Have a wonderful evening Gentlemen

/A

1 Like

Hi just put up a quick demo version for single sensor DS18Bxx LoRaWAN with the 650 dev. board, works fine with ttn if someone needs it
Cube_Cell_650_lorawan_DS18Bxx

BR

/A

@willhelmx, thanks for your offer

Do you have a github account or page? It will be great if your demo code be published.

I am putting together documentation which as a section for tested sample code, and it would be great to include it

Will confirm if that could be shared here or otherwise

Cheers

Yea, was all working in the end
#include “Arduino.h”
#include <OneWire.h>
#include <DallasTemperature.h>
#include “LoRaWan_APP.h”

#define timetosleep 5000
#define timetowake 3593000


#define RF_FREQUENCY                                868000000 // Hz

#define TX_OUTPUT_POWER                             14        // dBm

#define LORA_BANDWIDTH                              0         // [0: 125 kHz,
                                                              //  1: 250 kHz,
                                                              //  2: 500 kHz,
                                                              //  3: Reserved]
#define LORA_SPREADING_FACTOR                       7         // [SF7..SF12]
#define LORA_CODINGRATE                             1         // [1: 4/5,
                                                              //  2: 4/6,
                                                              //  3: 4/7,
                                                              //  4: 4/8]
#define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT                         0         // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON                  false
#define LORA_IQ_INVERSION_ON                        false
int16_t txnumber;
#define BUFFER_SIZE                                 80 // Define the payload size here
static RadioEvents_t RadioEvents;
char txpacket[BUFFER_SIZE];


static TimerEvent_t sleep;
static TimerEvent_t wakeup;
uint8_t lowpower=1;
String type = "soil";

void OnSleep()
{
  Serial.printf("into lowpower mode, %d ms later wake up.\r\n",timetowake);
  pinMode(GPIO6, OUTPUT);
  digitalWrite(GPIO6,LOW);
  OneWire  oneWire(GPIO0);
  DallasTemperature sensors(&oneWire);
  delay(2000);
  sensors.begin();
  sensors.requestTemperatures();
   float temperature = sensors.getTempCByIndex(0);
   float battery = GetBatteryVoltage();
  String jsonOutput = "{\"type\":\""+type+"\",\"temp\":"+ String(temperature,2) + ",\"battery\":" + String(battery/1000,2)+ "}";
  Serial.println(jsonOutput);
  digitalWrite(GPIO6, HIGH);
  radioSend(jsonOutput);
  lowpower=1;
  
  //timetosleep ms later wake up;
  TimerSetValue( &wakeup, timetowake );
  TimerStart( &wakeup );
}
void OnWakeup()
{
  Serial.printf("wake up, %d ms later into lowpower mode.\r\n",timetosleep);
  lowpower=0;
  
  //timetosleep ms later into lowpower mode;
  TimerSetValue( &sleep, timetosleep );
  TimerStart( &sleep );
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  BoardInitMcu();
  Radio.Sleep( );
  TimerInit( &sleep, OnSleep );
  TimerInit( &wakeup, OnWakeup );
  OnSleep();
}

void loop() {
  if(lowpower == 1){
      LowPower_Handler();
  }
  // put your main code here, to run repeatedly:
}

void radioSend(String message){
    RadioEvents.TxDone = OnTxDone;
    RadioEvents.TxTimeout = OnTxTimeout;
    Radio.Init( &RadioEvents );
    Radio.SetChannel( RF_FREQUENCY );
    Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
                                   LORA_SPREADING_FACTOR, LORA_CODINGRATE,
                                   LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
                                   true, 0, 0, LORA_IQ_INVERSION_ON, 3000 );

    Radio.SetSyncWord(0x34);
    int messageLen = message.length();
//    message.getBytes(txpacket,message.length());
    message.toCharArray(txpacket,message.length());
    Radio.Send((uint8_t *)txpacket, strlen(txpacket));
    
  }
 void OnTxDone(void){
  Radio.Sleep();
  }

void OnTxTimeout(void){
  Radio.Sleep();}

This was my code in the end, was just from the low power example, and I added in some simple little bits, its not very streamlined, but it worked. Except one of my sensors has gone a bit off now… Still goes through the code, but I’m not receiving anything anywhere… Not sure if the LoRa module isn’t actually transmitting, or the frequency is off…

1 Like

Hello,
Would you like to share your example of DS18Bxx and TTN with 650dev board.
I would need to try that, but I’m quite newbie… so a working example would be really nice :slight_smile:

Br
Harri

Hi Gipsyblues, sorry for the delay, dident get any notis about your question if you ahvent solved it yet here is the code

LMSYSTEMS/ Cube_Cell_650_lorawan_DS18Bxx

BR

/ A

Hi Harria, as to Gypsy, dident see your request until now, sorry for that - link to Github below
LMSYSTEMS/ Cube_Cell_650_lorawan_DS18Bxx

BR

/A

1 Like

Hello,

Thank you :slight_smile: Have been busy, but will test your code soon

Br
Harri

Is there an example how to use the OneWire Library with Platform.io? I had to remove the OneWire library from the library manager because Platform.io used the main library instead of the one for the CubeCell platform. But now also the DallasTemperature.h has some errors during compiling:

.platformio/lib/DallasTemperature_ID54/DallasTemperature.cpp:12:10: fatal error: WConstants.h: No such file or directory

Edit: I found out that using the version 3.8.0 of the DallasTemperature library the compilation works when I also add build_flags = -DARDUINO=101 to the platformio.ini. But I only get a -127 temperature from the sensor. When I compile the same code in the Arduino IDE I get the correct temperature. Any idea what could be the problem?

Edit2: @rsmedia I just analyzed the signal with an oscilloscope and it seems as the signal is interrupted for some reason when the code is compiled with Platform.io. When compiling in Arduino IDE I can see the whole signal. I now used just used the OneWire code from the ASR650x-Arduino library to search for sensors. Here are two screenshots from the oscilloscope:

Platform.io:

Arduino IDE:

Any idea what could make this difference between Platform.io and Arduino IDE?

Edit3: I just found the problem. I forgot to copy the util folder of the OneWire library. I guess if the files are not copied Platform.io just uses some other file for the compilation that is not compatible with the CubeCell platform.