chandrawi / LoRaRF-Arduino

Arduino library for basic transmitting and receiving data using LoRa and FSK modulation
MIT License
53 stars 15 forks source link

Transmitting Value between 0 and 1023 #11

Closed jayonexx closed 1 year ago

jayonexx commented 1 year ago

Im trying to transmit my analog input from Arduino to a Raspberry pi using your example code on both devices. However im receiving only a value of 255 at the Rapi. Is there a way to get it working with the full 10 bit ADC value ? Thanks in advance

chandrawi commented 1 year ago

Yes, there is a way. You must split your 10-bit ADC value into 2 bytes. On arduino (transmitter), the code would be like this

  int val = analogRead(0);
  unit8_t valBytes[2] = {val >> 8, val};
  LoRa.beginPacket();
  LoRa.write(valBytes, 2);
  LoRa.endPacket();