Cubecell and DS18B20


I cannot get the DS18B20 onewire sensor to work on cubecell devboard and I just can’t understand what I’m doing wrong… I tried all of the onewire examples available in arduino, but cannot get it working…
I get error: No more addresses.
or : then it just gives -127 as reading for the sensor, depending on the example I use.

Can anyone help? would be really happy for any ideas :slight_smile:


have you tried the examples in the CubeCell repository?

Yes, have tried also that example and only get:
“Temperature for the device 1 (index 0) is: -127.00”

So I really don’t have ideas what could be wrong… measured voltage on the sensor and that is okay, also tried with 3 different sensors (one of them has been working before with another board).


are you using parasite oder external power for the sensor?
have you the resistor in place?

Here is a picture of how it is connected, I believe it should be right connected, powered from Vext from the dev board, 4,7kohm resistor between Vdd and data.

Tried it on capsulo, same problem…

Did you solve it? otherwize try and connect to the 3.3 or 5v and see if it works



Hello @willhelmx

Now finally I got the sensors to work, but on the capsulo, not on dev board… could it be faulty dev board?

But still having some problems to get it to work with TTN… will try some more later today


Hi Harria

Well we had problems with the VEXT output giving a very low voltage after reset, this seems to be a general issue if you browse the community, however somewhat neccesary unless you use some other io´s and set them low or high to turn on the DS18B20, be shure to insert a wait state and after this a reset for the device before reading so it can stabilize itself


Power on 3.3v/5v
Wait state at least 500msek
float xxxx = (sensors.getTempCByIndex(0));

Use the TTN decoder at
This is just a markup / Copy of Aarons decoder that will work with a single DS18xxx


Hello willhelmx,

No, still cant get it to work on the devboard… I’m also kind of running out of time, I would need in couple of weeks a working 2* DS18B20 temp sensor with preferable cubecell devboard and data to TTN.

Are anyone willing to help to develop that? I’m willing to buy a working solution, if it is affordable price :slight_smile: I know that at least @wasn has a shop and has made tests with 18b20 sensor, can you sell a devboard + working code for this project? Of course I don’t mind to buy it from you willhelmx also, but need to get a receipt of the order, because it will be paid by my employer…


hi @harria

our ModularNode is working good with those DS18B20 sensors, but we are currently out of stock.
You can find the Firmware for these nodes in the Heltec repository under the name LoRaWAN-Multisensor.


Surely we should be able to help harria with this…

Harria, whats your setup today? devboard, i know + 2 DS18B20? gateway? transmission ABP or OTAA?



Hi Harria

As a reply we are a company dealing in invironmental sensorsystems… But it seems unessesary to send you something when we surely would be able to help you here…

What seems to be the nr:1 problem?

  1. Will the code compile without errors?
  2. Can you read the sensor at all?
  3. If so, do you get message in serial monitor = Joined?



yes we can help that is why i directed him to a working source code.

if you post your source code and the serial output of the dev board.
we can have a look and try to get it working.

Hello willhelmx,

Here are the main problems:

  1. with the devboard I cannot get any of the example codes to read the ds18b20 sensor and also the code you had working did not find the sensors (tried with 3 different sensors)
  2. have tried both with 3.3V and 5V to sensors, and also all GPIOs on the board…
  3. With the Capsulo I got the examples (Multiple, Onewire search and single) to find the sensors (tried with 2) and it seems to work.
  4. But again with Capsulo I cannot get your example to work, it reads the temp as -127C and also does not join the lora network… but it is possible that it does not join because I did not add the keys to the comissioning.h file, but did it afterwards with the configurator, I also got some command not supported error when it tries to join…

With the precompiled software uploaded with cubecell configurator it joins network, so at least my Capsulo is working, but unfortunately it does not support the 18b20 sensors, I only get the bus error message…

Actually I don’t mind to use the capsulo for my project, if you can help me to get that working with two onewire sensors, I would be happy.

I’ll try to compile the code again and then if I don’t get it working, I’ll post it here so you can check what I’m possible doing wrong.

Thanks wilhelmx and wasn that you are willing to help :slight_smile:

Hello @willhelmx

I tried now a couple of things and the capsulo reads temperature from the sensor okay, so that is working.
After that I have tried your example code, but cant get that to work… I does not compile, I edited the comissioning.h to add there my Lora keys and then changed this:

/*LoraWan Class*/
DeviceClass_t  CLASS=A;
/*OTAA or ABP*/
/*ADR enable*/
bool LORAWAN_ADR_ON = true;
/* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */
bool KeepNet = true;
/*LoraWan REGION*/

First error is the LoraWan class, it does not like my class=A…
if uncomment that, next error is
AppDataSize = 4;//AppDataSize max value is 64

and the error is: ‘AppDataSize’ was not declared in this scope

And here is a longer error log from arduino:
WARNING: library LoRa claims to run on ASR650x-Arduino architecture(s) and may be incompatible with your current board which runs on CubeCell architecture(s).
WARNING: library RGB claims to run on ASR650x-Arduino architecture(s) and may be incompatible with your current board which runs on CubeCell architecture(s).
D:\Cube_Cell_650_lorawan_DS18Bxx\LM_LoraWan_Cube_Cell_DS18Bxx_ttn\LM_LoraWan_Cube_Cell_DS18Bxx_ttn.ino: In function ‘void PrepareTxFrame(uint8_t)’:

LM_LoraWan_Cube_Cell_DS18Bxx_ttn:85:3: error: 'AppDataSize' was not declared in this scope

   AppDataSize = 4;//AppDataSize max value is 64


LM_LoraWan_Cube_Cell_DS18Bxx_ttn:87:2: error: 'AppData' was not declared in this scope

  AppData[0] = tempout[0]; 


D:\Cube_Cell_650_lorawan_DS18Bxx\LM_LoraWan_Cube_Cell_DS18Bxx_ttn\LM_LoraWan_Cube_Cell_DS18Bxx_ttn.ino: In function 'void setup()':

LM_LoraWan_Cube_Cell_DS18Bxx_ttn:100:16: error: 'BoardInitMcu' was not declared in this scope



LM_LoraWan_Cube_Cell_DS18Bxx_ttn:118:15: error: 'Enable_AT' was not declared in this scope



LM_LoraWan_Cube_Cell_DS18Bxx_ttn:120:5: error: 'DeviceState' was not declared in this scope

     DeviceState = DEVICE_STATE_INIT;


LM_LoraWan_Cube_Cell_DS18Bxx_ttn:121:13: error: 'class LoRaWanClass' has no member named 'Ifskipjoin'



D:\Cube_Cell_650_lorawan_DS18Bxx\LM_LoraWan_Cube_Cell_DS18Bxx_ttn\LM_LoraWan_Cube_Cell_DS18Bxx_ttn.ino: In function 'void loop()':

LM_LoraWan_Cube_Cell_DS18Bxx_ttn:126:11: error: 'DeviceState' was not declared in this scope

   switch( DeviceState )


LM_LoraWan_Cube_Cell_DS18Bxx_ttn:134:49: error: 'CLASS' was not declared in this scope

    Serial.printf("LoRaWan Class%X  start! \r\n",CLASS+10);   


LM_LoraWan_Cube_Cell_DS18Bxx_ttn:135:12: error: 'class LoRaWanClass' has no member named 'Init'



LM_LoraWan_Cube_Cell_DS18Bxx_ttn:141:12: error: 'class LoRaWanClass' has no member named 'Join'



LM_LoraWan_Cube_Cell_DS18Bxx_ttn:149:12: error: 'class LoRaWanClass' has no member named 'Send'



LM_LoraWan_Cube_Cell_DS18Bxx_ttn:156:4: error: 'TxDutyCycleTime' was not declared in this scope

    TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( 0, APP_TX_DUTYCYCLE_RND );


LM_LoraWan_Cube_Cell_DS18Bxx_ttn:157:12: error: 'class LoRaWanClass' has no member named 'Cycle'



LM_LoraWan_Cube_Cell_DS18Bxx_ttn:163:12: error: 'class LoRaWanClass' has no member named 'Sleep'



Edit to my last mesage:
Modified the code so that it is not using comissioning.h anymore (or I believe so), and now got the Lora connection to work and it sends data to TTN.
But now i does not anymore read the DS18B20 sensors… not even with the example code that worked earlier… I just get -127 as reading from the sensor…

Can you try it with an other sensor?

Well, now it is working again, I think I just had some bad connection…
But still have the problem to get the data on to TTN, or actually it does only read -127C, and when I try to add a function to read the sensors before sending data, it gets stuck after it has joined the network.
Here is the code if someone can help (I deleted lora keys and other things that are working and does not affect the reading of sensor)

#include "LoRaWan_APP.h"
#include "Arduino.h"
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into GPIO1 on the CubeCell

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

/* Application port */
uint8_t appPort = 2;

uint8_t confirmedNbTrials = 8;

/* Prepares the payload of the frame */

static void prepareTxFrame( uint8_t port )

    // Read temperatures from DS18xxx
  float temp = (sensors.getTempCByIndex(0));
  Serial.print("Content of temp float value from Sensor: = ");
  Serial.println (" Degrees Celsius");
  Serial.println ("Preparing to send data via Semtex Radio ");
  delay(500); // Wait for a while before proceeding
  unsigned char *tempout;
  tempout = (unsigned char *)(&temp);
	uint16_t batteryVoltage = getBatteryVoltage();

  appDataSize = 6;
	appData[0] = tempout[0];
	appData[1] = tempout[1];
	appData[2] = tempout[2];
	appData[3] = tempout[3];

	appData[4] = (uint8_t)(batteryVoltage>>8);
	appData[5] = (uint8_t)batteryVoltage;

void setup() {
  pinMode(Vext, OUTPUT);
  digitalWrite(Vext, LOW);
  Serial.println("LORAWAN (LM) Dallas Temperature IC Control single sensor demo");
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.print("Temperature for the device 1 (index 0) is: ");
  Serial.println (" Celsius");
	deviceState = DEVICE_STATE_INIT;

void loop()
	switch( deviceState )
			deviceState = DEVICE_STATE_JOIN;
    sensors.requestTemperatures(); // Send the command to get temperatures again to refresh at every transmission
			prepareTxFrame( appPort );
			deviceState = DEVICE_STATE_CYCLE;
			// Schedule next packet transmission
			txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND );
			deviceState = DEVICE_STATE_SLEEP;
			deviceState = DEVICE_STATE_INIT;

is the serial console of the cubecell outputting -127C for the sensor value or TTN?
please post your decoder as well.

Both the serial monitor and TTN are showing -127
But I wonder if these rows in the code has something to do with that:

case DEVICE_STATE_SEND: { sensors.requestTemperatures(); // Send the command to get temperatures again to refresh at every transmission delay(750);

If I have them in my code it will join the network, but after Joined message nothing happens, so it does not send any data. If I take that away from the code, it sends data.
Here example from the console:

30.04.20 13.42.25: Content of temp float value from Sensor: = -127.00 Degrees Celsius

30.04.20 13.42.25: Preparing to send data via Semtex Radio 

30.04.20 13.42.25: 

30.04.20 13.42.26: BatteryVoltage:4180

30.04.20 13.42.26: confirmed uplink sending ...

30.04.20 13.42.27: receive data: rssi = -95, snr = -2, datarate = 5

And here are my decoder (I know that battery voltage is missing):

function Decoder(bytes, port) {
    var decoded = {};

  return decoded;
}function tofloat32(a1,a2,a3,a4){
                                var s=(a1&0xff)>>7;
                                var E=(a1<<1&0xff)|a2>>7;
                                var M0=(a2&0x7f)<<16|a3<<8|a4;
                                var M=1;
                                for(var i=0;i<23;i++)
                                var result=Math.pow(-1,s)*M*Math.pow(2,E-127);
                                return result;

function Decoder(bytes, Port)
                      var temperature = tofloat32(bytes[3],bytes[2],bytes[1],bytes[0]);
                      var result={
                                    " ":{
                                               "Temperature Celsius":temperature,
                         return  result;