2 HC-12 modules each connected to an Arduino communicate succesfully sending a piece of text from the serial interface from the one to the serial output/interface of the other and vice versa. Code below. Source: https://www.allaboutcircuits.com/projects/understanding-and-implementing-the-hc-12-wireless-transceiver-module/
Now I am looking to send data collected from three (or more) sensors on the one Arduino (A) and send these values once a minute (or once an hour, whatever) to the other Arduino (B).
These values will be integers (2 bytes).
B has to store these values to do lots of calculations, so I want to put them in a database with FIFO setup, and with maximum 10 values to be stored. So, ten minutes (or ten hours depending on the TX side setup).
EDIT: correction, not ten minutes, or ten hours, but one minute (or hour)
What would be the best concept to send these values every time: as a one piece of data in some sort of string, or as individual integers with a precursor marker (ie a byte or single letter to identify the sensor from which the value comes from? Or another way of transmitting these three values every minute (or hour)?
//https://www.allaboutcircuits.com/projects/understanding-and-implementing-the-hc-12-wireless-transceiver-module/
/* HC12 Send/Receive Example Program 1
By Mark J. Hughes
for AllAboutCircuits.com
Connect HC12 "RXD" pin to Arduino Digital Pin 4
Connect HC12 "TXD" pin to Arduino Digital Pin 5
Connect HC12 "Set" pin to Arduino Digital Pin 6
Do not power over USB. Per datasheet,
power HC12 with a supply of at least 100 mA with
a 22 uF - 1000 uF reservoir capacitor.
Upload code to two Arduinos connected to two computers.
Transceivers must be at least several meters apart to work.
*/
#include <SoftwareSerial.h>
const byte HC12RxdPin = 4; // Recieve Pin on HC12
const byte HC12TxdPin = 5; // Transmit Pin on HC12
SoftwareSerial HC12(HC12TxdPin,HC12RxdPin); // Create Software Serial Port
void setup() {
Serial.begin(9600); // Open serial port to computer
HC12.begin(9600); // Open serial port to HC12
}
void loop() {
if(HC12.available()){ // If Arduino's HC12 rx buffer has data
Serial.write(HC12.read()); // Send the data to the computer
}
if(Serial.available()){ // If Arduino's computer rx buffer has data
HC12.write(Serial.read()); // Send that data to serial
}
}