Bonjour à tous

j'aurai besoin de votre éclairage pour transférer désormais ma mesure VBAT
issue d'un calcul interne à l'ESP32 à savoir :
Pont de mesure 2x 100kOhms sur PIN35
cette mesure varie de 3,40v -> 2,9V

Je transmets déjà actuellement 4 messages différents

sur interruptions EXT1
- 1 , 2 pour les alarmes et 3 Btn acquit
sur Timer 60s
- 4 pour tester la liaison

ceux sont là des messages simples que vous m'avez aidés à décrypter en réception
selon vous comment devrai-je faire pour transmettre cette mesure VBAT calculée à l'aide de :
car ce n'est pas une mesure analogique d'entrée comme pour l'être un capteur externe par ex

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
 VBAT = (float)(analogRead(vbatPin)) / 4095*2*3.3*1.1;
je remets le croquis de l’émetteur pour aider à la compréhension


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
 
/*************************************/
//    EMETTEUR    
//
// SCK     5    // GPIO5  -- SX1278's SCK
// MISO    19   // GPIO19 -- SX1278's MISO
// MOSI    27   // GPIO27 -- SX1278's MOSI
// SS      18   // GPIO18 -- SX1278's CS
// RST     14   // GPIO14 -- SX1278's RESET
// DI0     26   // GPIO26 -- SX1278's IRQ(Interrupt Request)
// BAND    433E6
//
// I2C_SDA      4
// I2C_SCL      15
// OLED_RST     16
 
/**************************************/
 
#include <LoRa.h>
#include <SPI.h>
#include <Wire.h>
//Libraries for OLED Display
#include "SSD1306.h" 
#include "boards.h"
#include <OneButton.h> //  <a href="http://www.mathertel.de/Arduino/OneButtonLibrary.aspx" target="_blank">http://www.mathertel.de/Arduino/OneButtonLibrary.aspx</a>
 
SSD1306Wire display(0x3c, I2C_SDA, I2C_SCL);
 
const byte pinBouton1 = 32;
const byte pinBouton2 = 33;
const byte pinBouton3 = 13;
const uint8_t vbatPin = 35;
 
#define BUTTON_PIN_BITMASK 0x300002000 // PIN13+PIN32+PIN33 in hex
#define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP 60 /* Time ESP32 will go to sleep (in seconds) */
 
RTC_DATA_ATTR int bootCount = 0;
 
OneButton sw1(pinBouton1);
int value1;
OneButton sw2(pinBouton2);
int value2;
OneButton sw3(pinBouton3);
int value3;
 
float VBAT;  // battery voltage from ESP32 ADC read
 
// CALLBACKS BOUTON 1
void sw1Click()       {loraMessage("1");}
void sw1DoubleClick() {loraMessage("11");}
void sw1DebutLong()   {loraMessage("1D");}
void sw1FinLong()     {loraMessage("1F");}
 
// CALLBACKS BOUTON 2
void sw2Click()       {loraMessage("2");}
void sw2DoubleClick() {loraMessage("21");}
void sw2DebutLong()   {loraMessage("2D");}
void sw2FinLong()     {loraMessage("2F");}
 
// CALLBACKS BOUTON 3
void sw3Click()       {loraMessage("3");}
void sw3DoubleClick() {loraMessage("31");}
void sw3DebutLong()   {loraMessage("3D");}
void sw3FinLong()     {loraMessage("3F");}
 
//**********************************************
// SETUP
//**********************************************
void setup() {
  Serial.begin(115200);
  initBoard();
  display.init();
  display.flipScreenVertically();
  display.setFont(ArialMT_Plain_10);
 
  while (!Serial) yield();
    SPI.begin(RADIO_SCLK_PIN,RADIO_MISO_PIN,MOSI,RADIO_MOSI_PIN );
    LoRa.setPins(RADIO_CS_PIN,RADIO_RST_PIN,RADIO_DIO_PIN);
    Serial.println("LoRa Sender");
  if (!LoRa.begin(LoRa_frequency)) { // LoRa_frequency 
    Serial.println("Starting LoRa failed!");
    while (true) yield();
  }
  Serial.println("init ok");
  display.init();
  display.flipScreenVertically(); 
  display.setFont(ArialMT_Plain_10);
  display.setTextAlignment(TEXT_ALIGN_CENTER);
  display.drawString(64, 22, "Emetteur: OK"); 
  display.display();
  delay(100);
 
  //Increment boot number and print it every reboot
  ++bootCount;
  Serial.println("Boot number: " + String(bootCount));
 
  // BTN1
  sw1.attachClick(sw1Click);
  sw1.attachDoubleClick(sw1DoubleClick);
  sw1.attachLongPressStart(sw1DebutLong);
  sw1.attachLongPressStop(sw1FinLong);
 
  // BTN2
  sw2.attachClick(sw2Click);
  sw2.attachDoubleClick(sw2DoubleClick);
  sw2.attachLongPressStart(sw2DebutLong);
  sw2.attachLongPressStop(sw2FinLong);
 
  // BTN3
  sw3.attachClick(sw3Click);
  sw3.attachDoubleClick(sw3DoubleClick);
  sw3.attachLongPressStart(sw3DebutLong);
  sw3.attachLongPressStop(sw3FinLong);
 
  //Print the GPIO used to wake up
  print_wakeup_reason();
  print_GPIO_wake_up();  
  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
  esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH);
 
  esp_deep_sleep_start();
 
}
 
//**********************************************
// LOOP
//**********************************************
void loop() {
}
 
//***********************************************
void loraMessage(const char * message) {
  LoRa.beginPacket();
  LoRa.println(message);
  LoRa.endPacket();
}
 
//************************************************
void print_GPIO_wake_up(){
  uint64_t GPIO_reason = esp_sleep_get_ext1_wakeup_status();
  Serial.print("GPIO qui a déclenché le réveil : GPIO ");
  Serial.println((log(GPIO_reason))/log(2), 0);
  int val = (int)((log(GPIO_reason))/log(2));
  switch (val)
  {
  case 32: loraMessage("1"); break;
  case 33: loraMessage("2"); break;
  case 13:
  loraMessage("3");
  AffVBAT();
  break;
  default : Serial.printf("Aucun GPIO n'a déclenché le réveil :"); break;
  }
}
 
char string[25];
void drawFontFaceDemo(float Vbat) {
    // Font Demo1
    // create more fonts at <a href="http://oleddisplay.squix.ch/" target="_blank">http://oleddisplay.squix.ch/</a>
    display.setTextAlignment(TEXT_ALIGN_LEFT);
    display.setFont(ArialMT_Plain_10);
    display.drawString(0, 0, "Battery");
    display.setFont(ArialMT_Plain_16);
    display.drawString(0, 10, "Monitoring");
    display.setFont(ArialMT_Plain_24);
    itoa(Vbat,string,10);
    sprintf(string,"%7.5f",Vbat);
    display.drawString(0, 26, string);
}
 
void AffVBAT() {
  // Battery Voltage
  VBAT = (float)(analogRead(vbatPin)) / 4095*2*3.3*1.1;
  Serial.println("Vbat = "); Serial.print(VBAT); Serial.println(" Volts");
  display.clear();
  drawFontFaceDemo(VBAT);
  display.display();
  delay(2000);
}
 
void print_wakeup_reason(){
   esp_sleep_wakeup_cause_t source_reveil;
   source_reveil = esp_sleep_get_wakeup_cause();
   switch(source_reveil){
      case ESP_SLEEP_WAKEUP_TIMER : 
      Serial.println("Réveil causé par un timer");
      loraMessage("4");
      break;
      default : Serial.printf("Réveil pas causé par le Deep Sleep: %d\n",source_reveil); break;
   }
}
pardonnez moi mais je construis mon projet par petit bout à la fois
merci par avance pour votre compréhension