Issues transmitting sensor readings using HC-12's

Good afternoon all!

My team and I are using a Sparkfun board with Arduino to take readings from pH, temperature, and dissolved oxygen sensors. We are having issues transmitting the data from the host board (with the sensors) to a base station board using HC-12 transceivers. When running the HC-12 code we are able to type and send messages manually, but when attempting to transmit the data packages no data is received. What are we doing wrong?

Temp Sensor: Temperature Sensor - Waterproof (DS18B20) - SEN-11050 - SparkFun Electronics
HC-12: https://www.amazon.com/Icstation-HC-12-SI4463-Module-Bluetooth/dp/B01FW6UIS0

*Note that for testing purposes we are just attempting to transmit the temperature sensors data.

Transmitting:

#include <OneWire.h>
#include <DallasTemperature.h>
#include <SoftwareSerial.h>
#define ONE_WIRE_BUS A3

const byte HC12RxdPin = 11;
const byte HC12TxdPin = 10;    

SoftwareSerial HC12(HC12TxdPin, HC12RxdPin);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature tempsensor(&oneWire);

void setup() {

  Serial.begin(9600);
  tempsensor.begin();
  HC12.begin(9600);

}

void loop() {

  tempsensor.requestTemperatures();
  double temp = tempsensor.getTempCByIndex(0);
  HC12.write(temp);
  
}

Receiving:

/*    Arduino Long Range Wireless Communication using HC-12
                      Example 01
   by Dejan Nedelkovski, www.HowToMechatronics.com
*/

#include <SoftwareSerial.h>

SoftwareSerial HC12(10, 11); // HC-12 TX Pin, HC-12 RX Pin

void setup() {
  Serial.begin(9600);             // Serial port to computer
  HC12.begin(9600);               // Serial port to HC12

}

void loop() {
  while (HC12.available()) {        // If HC-12 has data
    Serial.write(HC12.read());      // Send the data to Serial monitor
  }
  while (Serial.available()) {      // If Serial monitor has data
    HC12.write(Serial.read());      // Send that data to HC-12
  }
}

This is the code that is sending the data. Where's the other half of your code - the one that receives this message?

blh64:
This is the code that is sending the data. Where's the other half of your code - the one that receives this message?

Whoops sorry about that! original post updated!

HC12.write(temp);

That will simply convert your double variable 'temp' to an integer in the range 0 to 255 and send it as binary. Probably not what you want.

Also, on an AVR processor, double is the same as float (32-bit floating point).

gfvalvo:

HC12.write(temp);

That will simply convert your double variable 'temp' to an integer in the range 0 to 255 and send it as binary. Probably not what you want.

Say, I have temp = 32.45; I am executing HC12.write(temp);. What 8-bit value will be written into the Soft UART Port? Is it 32? (32.45 ---> 32)

@OP
Please, see the little one line change I have made in your transmit program. This adjustment in your program is in line with the spirit of the above quote. If you are happy with the solution, it is fine; however if you are curious to know the difference between 'HC12.print(temp, 2);' and 'HC12.write(temp);', we will be happy to present some explanations.
The adjusted program:

#include <OneWire.h>
#include <DallasTemperature.h>
#include <SoftwareSerial.h>
#define ONE_WIRE_BUS A3

const byte HC12RxdPin = 11;
const byte HC12TxdPin = 10;    

SoftwareSerial HC12(HC12TxdPin, HC12RxdPin);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature tempsensor(&oneWire);

void setup() {

  Serial.begin(9600);
  tempsensor.begin();
  HC12.begin(9600);

}

void loop() {

  tempsensor.requestTemperatures();
  double temp = tempsensor.getTempCByIndex(0);
  HC12.print(temp, 2);//HC12.write(temp);
  HC12.println();
  delay(1000);
  
}

sm80.png

sm80.png

RedTide:
to take readings from pH, temperature, and dissolved oxygen sensors. We are having issues transmitting the data from the host board (with the sensors) to a base station board using HC-12 transceivers.

As an asside, what are you doing to ensure that the received sensor data is not corrupted ?

Its no unknown for the 434Mhz band to be subject to interference, which could affect your readings.

srnet:
As an asside, what are you doing to ensure that the received sensor data is not corrupted ?

As an aside, is asside a misspelling or some kind of variant for aside?

GolamMostafa:
Say, I have temp = 32.45; I am executing HC12.write(temp);. What 8-bit value will be written into the Soft UART Port? Is it 32? (32.45 ---> 32)

Which the receiver code will print as an ASCII Space character. Other temperatures will print similar nonsense.