Closed Lucamenghini closed 2 years ago
I doubt this will work but change the order
and try reordering the begins Wire.begin();Serial.begin(9600); Serial2.begin(9600);
Thanks, Kris @.***
On Thursday, August 19, 2021, 05:50:21 PM CDT, Lucamenghini ***@***.***> wrote:
Hi Kris another issue. I defined:
SHT31 sht;
and in the setup i setted: Wire.begin(); sht.begin(SHT31_ADDRESS); Wire.setClock(100000);
I've got to use EBYTE to transmit, Wire to set the clock and sht31.h to manage a umidity&temeprature sensor.
I debugged the sketch because the transmitting doesn't work and I found that the line "Wire.begin();" doesn't not permit the transceiver to work How can I solve? please help me thank you bye
the complete sketch here:
// definizioni per SHT30
uint32_t start; uint32_t stop; SHT31 sht; uint32_t connectionFails = 0;
// altre definizioni String strid = "";
/ WARNING: IF USING AN ESP32 DO NOT USE THE PIN NUMBERS PRINTED ON THE BOARD YOU MUST USE THE ACTUAL GPIO NUMBER /
// i recommend putting this code in a .h file and including it // from both the receiver and sender modules struct DATA { unsigned long Count; int Bits; float Volts; float Amps;
};
int Chan; DATA MyData; unsigned long Last; EBYTE Transceiver(&Serial2, PIN_M0, PIN_M1, PIN_AX);
void setup() { Serial.begin(9600); Serial2.begin(9600); Serial.println("Starting Reader"); Serial.println(Transceiver.init()); Transceiver.PrintParameters();
// GESTIONE SHT30 Serial.println("Inizializzazione SHT30"); Serial.println(FILE); Serial.print("SHT31_LIB_VERSION: \t"); Serial.println(SHT31_LIB_VERSION); Wire.begin(); sht.begin(SHT31_ADDRESS); Wire.setClock(100000); uint16_t stat = sht.readStatus(); Serial.print(stat, HEX); Serial.println(); //inizializzo LORA
strid=getMacAddress(); Serial.println(strid); }
void loop() { // lettura dati SHT31 if ( sht.isConnected() ) { start = micros(); sht.read(); // default = true/fast slow = false stop = micros(); Serial.print("Temperatura : "); Serial.print(sht.getTemperature(), 1); Serial.println(" °C"); Serial.print("Umidità : "); Serial.print(sht.getHumidity(), 1); Serial.println(" %");
} else { connectionFails++; Serial.print(millis()); Serial.print("\tNot connected:\t"); Serial.print(connectionFails); // sht.reset(); } // delay di 2 secondi con a capo Serial.println();
// measure some data and save to the structure MyData.Count++; MyData.Bits=(sht.getTemperature(), 1); MyData.Volts=(sht.getHumidity(), 1);
// i highly suggest you send data using structures and not // a parsed data--i've always had a hard time getting reliable data using // a parsing method Transceiver.SendStruct(&MyData, sizeof(MyData)); // note, you only really need this library to program these EBYTE units // you can call write directly on the EBYTE Serial object // Serial2.write((uint8_t*) &Data, PacketSize );
// let the use know something was sent Serial.print("Sending: "); Serial.println(MyData.Count); delay(100); }
// FUNZIONE CHE RITORNA UN id UNIVOCO PER SCHEDA String getMacAddress() { uint8_t baseMac[6]; // Get MAC address for WiFi station esp_read_mac(baseMac, ESP_MAC_WIFI_STA); char baseMacChr[18] = {0}; sprintf(baseMacChr, "%02X:%02X:%02X:%02X:%02X:%02X", baseMac[0], baseMac[1], baseMac[2], baseMac[3], baseMac[4], baseMac[5]); String ris=String(baseMacChr); ris.replace(":",""); return String(ris); }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
reversing order will probably not work, stuff to try
try #include
On Thursday, August 19, 2021, 05:50:21 PM CDT, Lucamenghini @.***> wrote:
Hi Kris another issue. I defined:
SHT31 sht;
and in the setup i setted: Wire.begin(); sht.begin(SHT31_ADDRESS); Wire.setClock(100000);
I've got to use EBYTE to transmit, Wire to set the clock and sht31.h to manage a umidity&temeprature sensor.
I debugged the sketch because the transmitting doesn't work and I found that the line "Wire.begin();" doesn't not permit the transceiver to work How can I solve? please help me thank you bye
the complete sketch here:
// definizioni per SHT30
uint32_t start; uint32_t stop; SHT31 sht; uint32_t connectionFails = 0;
// altre definizioni String strid = "";
/ WARNING: IF USING AN ESP32 DO NOT USE THE PIN NUMBERS PRINTED ON THE BOARD YOU MUST USE THE ACTUAL GPIO NUMBER /
// i recommend putting this code in a .h file and including it // from both the receiver and sender modules struct DATA { unsigned long Count; int Bits; float Volts; float Amps;
};
int Chan; DATA MyData; unsigned long Last; EBYTE Transceiver(&Serial2, PIN_M0, PIN_M1, PIN_AX);
void setup() { Serial.begin(9600); Serial2.begin(9600); Serial.println("Starting Reader"); Serial.println(Transceiver.init()); Transceiver.PrintParameters();
// GESTIONE SHT30 Serial.println("Inizializzazione SHT30"); Serial.println(FILE); Serial.print("SHT31_LIB_VERSION: \t"); Serial.println(SHT31_LIB_VERSION); Wire.begin(); sht.begin(SHT31_ADDRESS); Wire.setClock(100000); uint16_t stat = sht.readStatus(); Serial.print(stat, HEX); Serial.println(); //inizializzo LORA
strid=getMacAddress(); Serial.println(strid); }
void loop() { // lettura dati SHT31 if ( sht.isConnected() ) { start = micros(); sht.read(); // default = true/fast slow = false stop = micros(); Serial.print("Temperatura : "); Serial.print(sht.getTemperature(), 1); Serial.println(" °C"); Serial.print("Umidità : "); Serial.print(sht.getHumidity(), 1); Serial.println(" %");
} else { connectionFails++; Serial.print(millis()); Serial.print("\tNot connected:\t"); Serial.print(connectionFails); // sht.reset(); } // delay di 2 secondi con a capo Serial.println();
// measure some data and save to the structure MyData.Count++; MyData.Bits=(sht.getTemperature(), 1); MyData.Volts=(sht.getHumidity(), 1);
// i highly suggest you send data using structures and not // a parsed data--i've always had a hard time getting reliable data using // a parsing method Transceiver.SendStruct(&MyData, sizeof(MyData)); // note, you only really need this library to program these EBYTE units // you can call write directly on the EBYTE Serial object // Serial2.write((uint8_t*) &Data, PacketSize );
// let the use know something was sent Serial.print("Sending: "); Serial.println(MyData.Count); delay(100); }
// FUNZIONE CHE RITORNA UN id UNIVOCO PER SCHEDA String getMacAddress() { uint8_t baseMac[6]; // Get MAC address for WiFi station esp_read_mac(baseMac, ESP_MAC_WIFI_STA); char baseMacChr[18] = {0}; sprintf(baseMacChr, "%02X:%02X:%02X:%02X:%02X:%02X", baseMac[0], baseMac[1], baseMac[2], baseMac[3], baseMac[4], baseMac[5]); String ris=String(baseMacChr); ris.replace(":",""); return String(ris); }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
Hi I tried to exclude the wire.h and the sensor works properly and the measurement of temperature & umidity are perfect the same. But the E32 continue not working. The sensor is OK but it doesn't transmitt, the code is here, what could I do anymore?
// SHT30 definitions
uint32_t start; uint32_t stop; SHT31 sht; uint32_t connectionFails = 0;
// board ID String strid = "";
struct DATA { unsigned long Count; int Bits; float Volts; float Amps;
}; int Chan; DATA MyData; unsigned long Last;
EBYTE Transceiver(&Serial2, PIN_M0, PIN_M1, PIN_AX);
void setup() { Serial.begin(115200); Serial2.begin(9600); Serial.println("Starting Reader"); Serial.println(Transceiver.init()); Transceiver.SetAirDataRate( ADR_300); // 300, 1200, 2400 (default), 4800, 9600, 19200 baud rate Transceiver.SaveParameters(PERMANENT); Transceiver.PrintParameters();
// SHT30 Serial.println("Inizializzazione SHT30"); Serial.println(FILE); Serial.print("SHT31_LIB_VERSION: \t"); Serial.println(SHT31_LIB_VERSION); sht.begin(SHT31_ADDRESS); uint16_t stat = sht.readStatus(); Serial.print(stat, HEX); Serial.println(); // UID strid=getMacAddress(); Serial.print("ID-SCHEDA: "); Serial.println(strid); }
void loop() { if ( sht.isConnected() ) { start = micros(); sht.read(); // default = true/fast slow = false stop = micros(); Serial.print("Temperatura : "); Serial.print(sht.getTemperature(), 1); Serial.println(" °C"); Serial.print("Umidità : "); Serial.print(sht.getHumidity(), 1); Serial.println(" %"); } else { connectionFails++; Serial.print(millis()); Serial.print("\tNot connected:\t"); Serial.print(connectionFails); // sht.reset(); }
// data structure MyData.Count++; MyData.Bits=(sht.getTemperature(), 1); MyData.Volts=(sht.getHumidity(), 1); Transceiver.SendStruct(&MyData, sizeof(MyData)); Serial.print("Sending: "); Serial.println(MyData.Count); delay(3000); }
// uid function String getMacAddress() { uint8_t baseMac[6]; // Get MAC address for WiFi station esp_read_mac(baseMac, ESP_MAC_WIFI_STA); char baseMacChr[18] = {0}; sprintf(baseMacChr, "%02X:%02X:%02X:%02X:%02X:%02X", baseMac[0], baseMac[1], baseMac[2], baseMac[3], baseMac[4], baseMac[5]); String ris=String(baseMacChr); ris.replace(":",""); return String(ris); }
Update on the last post above: I tried to switch on and then switch off the sht and then the Transceiver switch on and then switch off (init .... stuff .... reset) But nothing changes, the transceiver appears not available when SHT.begin(ADDRESS) is previously executed. Thanks Kris for your support Bye
// definizioni per SHT30
uint32_t start; uint32_t stop; SHT31 sht; uint32_t connectionFails = 0;
// altre definizioni String strid = "";
//variabili di passaggio temp e umid float temp; float umid;
struct DATA { unsigned long Count; int Bits; float Volts; float Amps;
};
// these are just dummy variables, replace with your own int Chan; DATA MyData; unsigned long Last;
// create the transceiver object, passing in the serial and pins EBYTE Transceiver(&Serial2, PIN_M0, PIN_M1, PIN_AX);
void setup() { Serial.begin(115200); Serial2.begin(9600); Serial.println("Starting Reader");
// GESTIONE SHT30 Serial.println("Inizializzazione SHT30"); Serial.println(FILE); Serial.print("SHT31_LIB_VERSION: \t"); Serial.println(SHT31_LIB_VERSION); sht.begin(SHT31_ADDRESS); // <------ this line block the transceiver uint16_t stat = sht.readStatus(); Serial.print(stat, HEX); Serial.println(); sht.reset();
strid=getMacAddress(); Serial.print("ID-SCHEDA: "); Serial.println(strid);
Serial.println(Transceiver.init()); Transceiver.SetAirDataRate( ADR_300); // 300, 1200, 2400 (default), 4800, 9600, 19200 baud rate Transceiver.SaveParameters(PERMANENT); Transceiver.PrintParameters(); Transceiver.Reset(); }
void loop() { //SHT management sht.begin(SHT31_ADDRESS); delay(200); if ( sht.isConnected() ) { start = micros(); sht.read(); // default = true/fast slow = false stop = micros(); //storing temp & umid data temp=sht.getTemperature(); umid=sht.getHumidity(); Serial.print("Temperatura : "); Serial.print(temp, 1); Serial.println(" °C"); Serial.print("Umidità : "); Serial.print(umid, 1); Serial.println(" %"); } else { connectionFails++; Serial.print(millis()); Serial.print("\tNot connected:\t"); Serial.print(connectionFails); // sht.reset(); } sht.reset();
MyData.Count++; MyData.Bits=(temp, 1); MyData.Volts=(umid, 1);
Serial.println(Transceiver.init()); Transceiver.SetAirDataRate( ADR_300); // 300, 1200, 2400 (default), 4800, 9600, 19200 baud rate Transceiver.SaveParameters(PERMANENT); Transceiver.PrintParameters(); if (Transceiver.available() ) { Serial.println("Transceiver available!!"); Transceiver.SendStruct(&MyData, sizeof(MyData)); } else { Serial.println("Transceiver not available"); } Transceiver.Reset();
Serial.print("Sending: "); Serial.println(MyData.Count); delay(3000); }
// FUNZIONE CHE RITORNA UN id UNIVOCO PER SCHEDA String getMacAddress() { uint8_t baseMac[6]; // Get MAC address for WiFi station esp_read_mac(baseMac, ESP_MAC_WIFI_STA); char baseMacChr[18] = {0}; sprintf(baseMacChr, "%02X:%02X:%02X:%02X:%02X:%02X", baseMac[0], baseMac[1], baseMac[2], baseMac[3], baseMac[4], baseMac[5]); String ris=String(baseMacChr); ris.replace(":",""); return String(ris); }
see below (my comments preceded with \\\\\) Thanks, Kris On Sunday, August 22, 2021, 05:05:11 PM CDT, Lucamenghini @.***> wrote:
Hi I tried to exclude the wire.h and the sensor works properly and the measurement of temperature & umidity are perfect the same. But the E32 continue not working. The sensor is OK but it doesn't transmitt, the code is here, what could I do anymore?
// SHT30 definitions
uint32_t start; uint32_t stop; SHT31 sht; uint32_t connectionFails = 0;
// board ID \\\\\ this is probably not the problem but you should never use String--this data type \\\\\ is poorly implemented and will fragment memory String strid = "";
struct DATA { unsigned long Count; int Bits; float Volts; float Amps;
}; int Chan; DATA MyData; unsigned long Last;
EBYTE Transceiver(&Serial2, PIN_M0, PIN_M1, PIN_AX);
void setup() { Serial.begin(115200); Serial2.begin(9600); Serial.println("Starting Reader");
Serial.println(Transceiver.init());
\\\\\ I'm surprised you get reliable data transfer at 300 baud. waiting 3 seconds is the reason \\\\\ but a very slow rate. if it works, great, if data doesn't transmit, this is where I would start Transceiver.SetAirDataRate( ADR_300); // 300, 1200, 2400 (default), 4800, 9600, 19200 baud rate \\\\\ you only need to call SetAirDataRate and save once, after this call, data is permamentely \\\\\ stored in the EBYTE Transceiver.SaveParameters(PERMANENT); Transceiver.PrintParameters();
// SHT30 Serial.println("Inizializzazione SHT30"); Serial.println(FILE); Serial.print("SHT31_LIB_VERSION: \t"); Serial.println(SHT31_LIB_VERSION); sht.begin(SHT31_ADDRESS); uint16_t stat = sht.readStatus(); Serial.print(stat, HEX); Serial.println(); // UID strid=getMacAddress(); Serial.print("ID-SCHEDA: "); Serial.println(strid); }
void loop() { if ( sht.isConnected() ) { start = micros(); sht.read(); // default = true/fast slow = false stop = micros(); Serial.print("Temperatura : "); Serial.print(sht.getTemperature(), 1); Serial.println(" °C"); Serial.print("Umidità : "); Serial.print(sht.getHumidity(), 1); Serial.println(" %"); } else { connectionFails++; Serial.print(millis()); Serial.print("\tNot connected:\t"); Serial.print(connectionFails); // sht.reset(); }
// data structure
MyData.Count++; \\\\\ what data type is getTemperature returning? probably a float right? \\\\\ what datatype is .Bits? \\\\\ this must get fixed MyData.Bits=(sht.getTemperature(), 1); MyData.Volts=(sht.getHumidity(), 1); Transceiver.SendStruct(&MyData, sizeof(MyData)); Serial.print("Sending: "); Serial.println(MyData.Count); delay(3000); }
// uid function \\\\\ i'll admint dealing with chars is a pain, but strings are badString getMacAddress() { uint8_t baseMac[6]; // Get MAC address for WiFi station esp_read_mac(baseMac, ESP_MAC_WIFI_STA); char baseMacChr[18] = {0}; sprintf(baseMacChr, "%02X:%02X:%02X:%02X:%02X:%02X", baseMac[0], baseMac[1], baseMac[2], baseMac[3], baseMac[4], baseMac[5]); String ris=String(baseMacChr); ris.replace(":",""); return String(ris); }
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
Try without the library. If the transceivers still don't work there is an issue with your hardware.
You only really need this library to program these EBYTE units. For reading data structures, you can call readBytes directly on the EBYTE Serial object
ESerial.readBytes((uint8_t*)& MyData, (uint8_t) sizeof(MyData));
for writing data structures you can call write directly on the EBYTE Serial object
ESerial.write((uint8_t*) &Data, PacketSize );
Hi Kris another issue. I defined:
include "EBYTE.h"
include "Wire.h"
include "SHT31.h"
define SHT31_ADDRESS 0x44
SHT31 sht;
and in the setup i setted: Wire.begin(); sht.begin(SHT31_ADDRESS); Wire.setClock(100000);
I've got to use EBYTE to transmit, Wire to set the clock and sht31.h to manage a umidity&temeprature sensor.
I debugged the sketch because the transmitting doesn't work and I found that the line "Wire.begin();" doesn't not permit the transceiver to work How can I solve? please help me thank you bye
the complete sketch here:
include "EBYTE.h"
include "Wire.h"
include "SHT31.h"
// definizioni per SHT30
define SHT31_ADDRESS 0x44
uint32_t start; uint32_t stop; SHT31 sht; uint32_t connectionFails = 0;
// altre definizioni String strid = "";
/ WARNING: IF USING AN ESP32 DO NOT USE THE PIN NUMBERS PRINTED ON THE BOARD YOU MUST USE THE ACTUAL GPIO NUMBER /
define PIN_RX 16 // Serial2 RX (connect this to the EBYTE Tx pin)
define PIN_TX 17 // Serial2 TX pin (connect this to the EBYTE Rx pin)
define PIN_M0 4 // D4 on the board (possibly pin 24)
define PIN_M1 22 // D2 on the board (possibly called pin 22)
define PIN_AX 21 // D15 on the board (possibly called pin 21)
// i recommend putting this code in a .h file and including it // from both the receiver and sender modules struct DATA { unsigned long Count; int Bits; float Volts; float Amps;
};
int Chan; DATA MyData; unsigned long Last; EBYTE Transceiver(&Serial2, PIN_M0, PIN_M1, PIN_AX);
void setup() { Serial.begin(9600); Serial2.begin(9600); Serial.println("Starting Reader"); Serial.println(Transceiver.init()); Transceiver.PrintParameters();
// GESTIONE SHT30 Serial.println("Inizializzazione SHT30"); Serial.println(FILE); Serial.print("SHT31_LIB_VERSION: \t"); Serial.println(SHT31_LIB_VERSION); Wire.begin(); sht.begin(SHT31_ADDRESS); Wire.setClock(100000); uint16_t stat = sht.readStatus(); Serial.print(stat, HEX); Serial.println();
strid=getMacAddress(); Serial.println(strid); }
void loop() { // lettura dati SHT31 if ( sht.isConnected() ) { start = micros(); sht.read(); // default = true/fast slow = false stop = micros();
} else { connectionFails++; Serial.print(millis()); Serial.print("\tNot connected:\t"); Serial.print(connectionFails); // sht.reset(); } // delay di 2 secondi con a capo Serial.println();
// measure some data and save to the structure MyData.Count++; MyData.Bits=(sht.getTemperature(), 1); MyData.Volts=(sht.getHumidity(), 1);
// i highly suggest you send data using structures and not // a parsed data--i've always had a hard time getting reliable data using // a parsing method Transceiver.SendStruct(&MyData, sizeof(MyData));
// let the use know something was sent Serial.print("Sending: "); Serial.println(MyData.Count); delay(100); }
// FUNZIONE CHE RITORNA UN id UNIVOCO PER SCHEDA String getMacAddress() { uint8_t baseMac[6]; // Get MAC address for WiFi station esp_read_mac(baseMac, ESP_MAC_WIFI_STA); char baseMacChr[18] = {0}; sprintf(baseMacChr, "%02X:%02X:%02X:%02X:%02X:%02X", baseMac[0], baseMac[1], baseMac[2], baseMac[3], baseMac[4], baseMac[5]); String ris=String(baseMacChr); ris.replace(":",""); return String(ris); }