Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "EBYTE.h"
- #define PIN_M0 18 // pin 18 on the ESP
- #define PIN_M1 19 // pin 19 on the ESP
- #define PIN_AX 21 // pin 21 on the ESP
- struct DATA {
- // due to how 32 bit MCU and 8-bit MCU pack structs
- // you will need same data type for everything
- // or try EasyTransfer.h
- uint16_t Count;
- uint16_t Bits34;
- uint16_t Bits35;
- uint16_t Volts34;
- uint16_t Volts35;
- };
- DATA MyData;
- // create the transceiver object, passing in the serial and pins
- // pin TX2 on ESP32 connect to EBYTE Rx
- // pin RX2 on ESP32 connect to EBYTE Tx
- EBYTE Transceiver(&Serial2, PIN_M0, PIN_M1, PIN_AX);
- void setup() {
- Serial.begin(9600);
- while (!Serial) {}
- Serial2.begin(9600);
- Serial.println("Starting Sender");
- while (!Serial) {}
- Transceiver.init();
- Transceiver.PrintParameters();
- }
- void loop() {
- // measure some data and save to the structure
- MyData.Count++;
- MyData.Bits34 = analogRead(34);
- MyData.Bits35 = analogRead(35);
- MyData.Volts34 = MyData.Bits34 * ( 3.3 / 4096.0 ) * 100;
- MyData.Volts35 = MyData.Bits35 * ( 3.3 / 4096.0 ) * 100;;
- Serial2.write((uint8_t*) &MyData, sizeof(MyData));
- // let the use know something was sent
- Serial.print("Sending: "); Serial.println(MyData.Count);
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement