ATtiny84 LoRa – Frequently Asked Questions

I’ve had several mail with questions about my project. Even some have ordered the PCB and reproduced or extended my initial project. I like that very much, and please when you do, please send me an e-mail (with pictures) of your project and application.

What development environment are you using?

I use PlatformIO as development environment. It is an extension of the Atom editor/IDE. I use this one because it is like a professional IDE, where I have an overview of libraries, and Git integrated.
(https://platformio.org)

You will find no .ino file. You can use main.cpp as you base of your .ino file. Be sure to add the libraries from this project to your Arduino environment.

How do you upload the code to the ATtiny84?

I use the USBASP programmer (https://www.fischl.de/usbasp/).

You can use connectors/wires and a breadboard to program a single chip. However I use a 28-Pen DIP ZIF socket:

How long will the batteries last?

I do have some information on the batteries. It depends on the conditions like temperature and time between measurements. On all LoRa devices on batteries I measure and send every 5 minutes data. I do not use a brown out detector, so you have to know on what voltage it will stop sending data. The experience I have so far in oktober 2018:

I’ve one in the freezer (-20 C) and it is still holding very strong:
(start using)
2018-02-01 00:13:08 CET TTN03 127.0.0.1 vccVoltage 3.618
2018-02-01 00:13:08 CET TTN03 127.0.0.1 temperature -22.37
2018-02-01 00:13:08 CET TTN03 127.0.0.1 humidity 59.83
2018-10-04 22:14:11 CEST TTN03 127.0.0.1 vccVoltage 3.618
2018-10-04 22:14:11 CEST TTN03 127.0.0.1 temperature -20.36
2018-10-04 22:14:11 CEST TTN03 127.0.0.1 humidity 76.85
It’s a LS14500 Battery (Lithium)
I’ve also been testing with a 675 Battery (Zinc-Air) battery. In my first experiment it drops out on (last measurement before drop out:)
2018-06-08 20:08:45 CEST TTN05 127.0.0.1 vccVoltage 2.930
2018-06-08 20:08:45 CEST TTN05 127.0.0.1 temperature 23.23
2018-06-08 20:08:45 CEST TTN05 127.0.0.1 humidity 30.44
What kind of LoRa activation do you use?
It uses the ABP activation, due to battery lifetime. OTAA does take a longer time to get an ID due to negotiation over the air. Remember to set the Frame Counter Width to 16 bits and eventually disable the Frame Counter Check when starting with you project due to reseting the counter on power-loss.
Can I decode the information FROM/on TTN network?
Some people have done it in this way:
Here is the code to copy and paste:
function Decoder(Data, port) {
var vccVoltage = (Data[0] << 8) | Data[1];
var temp = (Data[2] << 8) | Data[3];
var hum = (Data[4] << 8 ) | Data[5];

return {
vcc: vccVoltage / 1000,
temperature: temp / 100,
humidity: hum / 100,
};
}
As you can see the data is send in 6 Bytes. Every two bytes makes a 16 bit number that should be recalculated to get the actual values.
Remember when you use your own API (as I do in Java) to convert the data from Base 64:
byte[] byteData = Base64.getDecoder().decode(payload_raw);
And then use unsigned int:
// voltage level
int vccVoltage = (byteData[0] << 8) + toUnsignedInt(byteData[1]);
float vccVFl = vccVoltage/1000F;
vccVoltageStr = String.format("%.3f", vccVFl);
Can I USE the pressure?

Thanks to Kim, who tried to get my device working to measure pressure, we have found out that it is not possible at this moment. When you enable the pressure features (the code is already there) the compiled code is far to big to fit into the flash memory of the ATtiny84.
The reason for growing so big is that the sensor and thus software uses calibration data from the BME280 chip to calculate the real information. There are a few workarounds: Get the calibration data from the BME280 chip and send the raw data and then do the calculation on the (receiving) sever side. You have to bare in mind that every chip has its own calibration data. A other workaround is to use an other microcontroller. That is the path I’m walking on. I am switching to STM32L – chips (als SMD types). This will take a while, because I have to learn how to program them and make new prototypes.

== UPDATE ==
Rob has found example code at https://github.com/ClemensRiederer/TinyLoRa-BME280 from Clemens Riederer. He modified this code and was able to squeeze it into 8k memory (99% full). I was able to test this in the Arduino IDE, and it was working beautifully.

Any questions?

Please contact me through the comment on this or other pages. I will try to mail you back a soon as possible.

2 thoughts on “ATtiny84 LoRa – Frequently Asked Questions

  1. Hi Leo,

    I was able to get the pressure function to work on the Attiny84 by using a slightly modified code from the attiny85 project on the things network site. It now reports temp, humidity, pressure and voltage and uses all 8 channels of Lorawan on TTN (and stil a couple bytes of memory to spare ).

    I am no programmer but you can get far with cut & paste of code snippets on the internet. You can make it low power (+/- 4.8 ua) with the resistor cut of the BME sensor but also without (just bij swithing some ports to input & low as also was done in the project at the things network site).

    I have been using your hardware design for all types of applications, besides the temp sensor I use it for door sensors, sensor for mailbox, PIR sensor, and plant moisture sensor (with a modified board including a MCP1703 LDO for lithium battery operation and a capacitive I2C moisture sensor).

    Can share pictures & the code for the Attiny/BME280 if you want (as said I am no programmer so it probably doesn’t look tidy or is meeting all the conventions but it does work)

    Anyway, thanks for the great project. It openend my eyes for all kind of applications with the Attiny84.

    Grt,
    Rob

Leave a Reply

Your email address will not be published. Required fields are marked *