hello, it’s a wemos mini pro
// This example shows how to connect to Cayenne using an ESP8266 and send/receive sample data.
// Make sure you install the ESP8266 Board Package via the Arduino IDE Board Manager and select the correct ESP8266 board before compiling.
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
#include <stdio.h>
float T_CUVE, T_SURF ;
int resistance_on;
char DONNE_SERIE_RX[20];
int bufferSize= 64 ;
int nbrecaractere =19;
// WiFi network info.
char ssid[] = "";
char wifiPassword[] = "";
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "";
char password[] = "";
char clientID[] = "";
//boolean tempo = 1;
//**********////
#define VIRTUAL_CHANNEL1 1
#define VIRTUAL_CHANNEL2 2
#define VIRTUAL_CHANNEL3 3
#define VIRTUAL_CHANNEL4 4
char mychar;
int i=0;
int T_CUVE_100,T_SURF_100,LDR =0;
String string1,string2,string3,string4;
// int tempo =0;
unsigned long int DELAIS = 0;
void setup() {
Serial.begin(115200);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
Serial.print("WEMOS 11072019");
}
void loop() {
Cayenne.loop();
if(Serial.available()) {
do {
mychar = Serial.read(); // read char from UART
Serial.print(mychar); //test
}
while ( mychar != '*');
DONNE_SERIE_RX[i] = mychar;
for (i=1; i<19 ; i++ ) {mychar= Serial.read();DONNE_SERIE_RX[i]=mychar;} //18--> 16
Serial.print (DONNE_SERIE_RX[0]);Serial.println (DONNE_SERIE_RX[17]);
if ((DONNE_SERIE_RX[0] == '*') && (DONNE_SERIE_RX[17] =='#')) { // verifie que les data sont corect
// sprintf(DONNE_SERIE, "*%04d;%04d;%04d;%1d#\r\n", t1,t2,ldr,resistance_on);
Serial.println ( "data ok"); //test
for (i=1; i < nbrecaractere; i++) {
if ((char)DONNE_SERIE_RX[i]==';') {i++;break;}
string1+=((char)DONNE_SERIE_RX[i]); }
// Serial.println(string1);
for (i; i < nbrecaractere; i++) {
if ((char)DONNE_SERIE_RX[i]==';') {i++;break;}
string2+=((char)DONNE_SERIE_RX[i]); }
// Serial.println(string2);
for (i; i < nbrecaractere+1; i++) {
if ((char)DONNE_SERIE_RX[i]==';') {i++;break;}
string3+=((char)DONNE_SERIE_RX[i]); }
for (i; i < nbrecaractere+1; i++) {
if ((char)DONNE_SERIE_RX[i]=='#') {i++;break;}
string4+=((char)DONNE_SERIE_RX[i]); }
// Serial.println(string3);
T_CUVE_100=(int)string1.toInt();
T_CUVE = float (T_CUVE_100/100);
T_SURF_100=(int)string2.toInt();
T_SURF = float( T_SURF_100/100);
LDR=(int)string3.toInt();
resistance_on=(int)string4.toInt();
Cayenne.virtualWrite(1, T_CUVE,"temp","c");
Cayenne.virtualWrite(2, T_SURF,"temp","c");
Cayenne.virtualWrite(3, LDR, "lum" ,"lux");
Cayenne.virtualWrite(4, resistance_on,"digital_sensor","d");
//Serial.flush();
}