The message "Hello world" gets through. How do i send just the "battvolts"
Please help
Thanks
// Mastershortend.ino sends the data
#include <ESP8266WiFi.h>
extern "C" {
#include <espnow.h>
}
uint8_t remoteMac[] = {0x36, 0x33, 0x33, 0x33, 0x33, 0x33}; //Address of slave which receives
#define WIFI_CHANNEL 4
const int analogPin = A0; //ADC for reading battery voltage
int batt = 0; // 0-1023
int battvolts = 0; // 0-1023 to volts
struct __attribute__((packed)) DataStruct { // What
char text[32]; // is
}; // This
DataStruct myData; // about?
void setup() {
pinMode(analogPin, INPUT);
Serial.begin(9600);
WiFi.mode(WIFI_STA); // Station mode for Master
WiFi.disconnect(); // shut off org esp wifi
esp_now_init();
esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER);
esp_now_add_peer(remoteMac, ESP_NOW_ROLE_SLAVE, WIFI_CHANNEL, NULL, 0);
esp_now_register_send_cb(sendCallBackFunction);
strcpy(myData.text, "Hello World"); // this message get through
// How would I implament battvolts?
Serial.println();
Serial.println(myData.text);
}
void loop() {
batt = analogRead(analogPin); // read the A0 input pin 0-1023
battvolts = batt * 0.0161 // converts to actual volt reading
sendData();
}
void sendData() {
uint8_t bs[sizeof(myData)];
memcpy(bs, &myData, sizeof(myData));
esp_now_send(NULL, bs, sizeof(myData));
Serial.println("Sleep zzzzzzz");
ESP.deepSleep(0); // deep sleep until PIR grounds reset
}
void sendCallBackFunction(uint8_t* mac, uint8_t sendStatus) {
}