Working with Bytes &float(MKRwan 1300)

Thank you .
How about the code now?
by using MKrWan 1300 ,Can I access to TTN directly or do I need gateway device?
In the case of using the LoraWan gateway, do I need to connect the gateway to Wifi?

Code looks good.

Transmissions have to be heard by a gateway so you need one near by or have one of your own. Some gateways do connect via Wifi

In the ‘other platform’ aka Payload Formatter

It shifts the first number 8 bits to the left and then adds the second byte - so it’s reversing the split in to bytes that was done on the device. Google bit shift for Binary maths 5 otherwise known as 101.

I think that’s a mess and means you aren’t following the documentation and really do need to learn Binary 5 (ie 101).

Read here for Class

mqtt-node-red-for-large-or-small-decoders-howto
payload-formats-howto

That is a very good point. I just started experimenting with LoRa, and drained a battery very quick by sending all data as string (in my foolness together with description “Outside Temperature: 21,55 Celsius”.
Way too much …
As many newbies I also started with using examples as a base for my sketch. th LoRa send example for my Arduino MKRWAN 1300 board sends strings. Using your approach, and modify the payload, I got errors.

Can you show, how the sending part of the sketch should look like?

modem.beginPacket();
modem.print(payload);

?

This is derived from working code:

uint8_t payload[30];    // Allow for up to 30 byte payload, increase/decrease as appropriate
uint8_t payloadSize; 

// Take & process readings
float degC = readTemperatureTo2DP();
uint16_t tempToSend = (uint16_t) ((degC +100) * 100);

// Add bytes to payload
payload[0] = highByte(tempToSend);
payload[1] = lowByte(tempToSend);
payloadSize = 2;

// Transfer to modem
modem.beginPacket();
for (uint8_t c = 0; c < payloadSize; c++) {
  modem.write(payload[c]);
}
err = modem.endPacket(confirmed);


Passing one byte at a time could possibly be refined but the MKRWAN library using Templates and other sophistications isn’t something I want to mess with. It works, but it’s not the best DIY device around as it’s a bit pricey and hard to get below 40uA when asleep.

Thank you very much for taking the time to help a beginner, and for the explanation, it helped me a lot, I will try to implement this.

So you say, MKRWAN is not a good choice for DIY battery operated LoRa Sensor stuff?
What about this one: https://www.tindie.com/products/iotmcu/lora-radio-node-v10/

Thats a 433Mhz module, you sure thats the right frequency for your part of the World ?

Its also based on a ATmega328P, which can struggle memory wise with some sensor setups.

And a sleep current of 300uA is very poor.

Sorry, I got the wrong link. My version is a 868 MHz suitable for my Country.
So this is also not the best choice you say …

I see both 433 & 868Mhz appear out of stock saving you some pain! :wink: Pehaps start looking at the well documented/supported, and well known in the parts, LMIC-node implementation and its supported boards:-

created and curated by friend of TTN & fellow mod @bluejedi
Well covered by Leonel and others in posts across the forum (search is your freind), with other people adapting to alternate boards…

Not the best choice for free-range development. It’s OK if you only need one or two simple sensors on digital or analog, not much room left for any other libraries and as mentioned above, worse on battery performance.

Like all device/car/laptop/house/partner choices, it’s all about what you want to do.

So if you tell us what you want to do and how much hardware & software experience you have, the advice can be tailored to suit.

Well my hardware/software experience I would characterise as hobbist/beginner. I have some experience with aruino boards, and mainstream sensors (DHT22, DS2810, …) and already built some units for my smart home system, but all of them based on WIFI. Now I would like to extend my system for outside stuff, (greenhouse monitoring, soil temp and humidity monitoring, Water level monitoring in rainwater tanks and pond, and so on) where there is no WIFI coverage, therefore I started to look at LoRa.

Does that library support ATMega328P etc ?

Are you within range of a LoRaWAN Gateway, or are you thinking of adding your own ?

It does but it doesn’t do sleep out of the box. And as above, you can barely fit any other libraries in.

Technically I believe yes, but as noted I wouldnt go for that these days given its constraints and limitations! :wink: Devboards with externa(SPI) LoRa Module or better yet the full list on the original github link…
image

Are there a table available as to compare Board to sleep current and memory?

Did you look :wink:

So unlikely.

As for memory, pretty much everything apart from the ATmega328/32U4 has plenty and they have not enough.

No my :telescope:, it is broken :smiley:

Well volunteered …