Bonjour a tous,

Bonne santé et année 2022.

Pour ceux que le sujet intéresse je vous invite a suivre la calibration de
mon capteur de Co2 sur ThingSpeak depuis 13h05 :
SCD30 - ThingSpeak IoT <https://thingspeak.com/channels/1628404>

Voici le code source sous arduino pour donner une idée :
// Basic demo for readings from Adafruit SCD30
#include <Adafruit_SCD30.h>

#include "ThingSpeak.h"

#include <WiFi.h>

#include "ccs811.h"  // CCS811 library

#include <TFT_eSPI.h>
#include <SPI.h>

char ssid[] = "iot_1"; // your network SSID (name)
char pass[] = "password1234"; // your network password
int keyIndex = 0; // your network key Index number (needed only for WEP)
WiFiClient client;

// Timer variables
unsigned long lastTime = 0;
unsigned long timerDelay = 30000;

unsigned long myChannelNumber = 00000;
const char * myWriteAPIKey = "xxxxxxx";


Adafruit_SCD30  scd30;


void setup(void) {
  Serial.begin(115200);
  while (!Serial) delay(10);     // will pause Zero, Leonardo, etc until
serial console opens

  Serial.println("Adafruit SCD30 test!");

  // Try to initialize!
  if (!scd30.begin()) {
    Serial.println("Failed to find SCD30 chip");
    while (1) { delay(10); }
  }
  Serial.println("SCD30 Found!");


  // if (!scd30.setMeasurementInterval(10)){
  //   Serial.println("Failed to set measurement interval");
  //   while(1){ delay(10);}
  // }
  Serial.print("Measurement Interval: ");
  Serial.print(scd30.getMeasurementInterval());
  Serial.println(" seconds");

  WiFi.mode(WIFI_STA);

  ThingSpeak.begin(client); // Initialize ThingSpeak

  Serial.print("I2C port > SDA: "); Serial.print(SDA);Serial.print(" SCL:
"); Serial.println(SCL);



}

void loop() {

  if (scd30.dataReady()){
    Serial.println("SCD30 Data available!");

    if (!scd30.read()){ Serial.println("Error reading sensor data");
return; }

// Connect or reconnect to WiFi
  if (WiFi.status() != WL_CONNECTED)
  {
    Serial.print("Attempting to connect to SSID: ");
    //Serial.println(SECRET_SSID);
    while (WiFi.status() != WL_CONNECTED)
    {
      WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network. Change this
line if using open or WEP network
      Serial.print(".");
      delay(5000);
    }
    Serial.println("\n Wifi Connected.");
  }


    Serial.print("Temperature: ");
    Serial.print(scd30.temperature);
    Serial.print(" degrees C |");

    Serial.print("Relative Humidity: ");
    Serial.print(scd30.relative_humidity);
    Serial.print(" % |");

    Serial.print("CO2: ");
    Serial.print(scd30.CO2, 3);
    Serial.println(" ppm");
    Serial.println("");

    // ComputeAvgVelues();
    //  PublishOnThingSpeak();


    //void PublishOnThingSpeak( )
    // set the fields with the values
    ThingSpeak.setField(1, scd30.CO2);
    ThingSpeak.setField(2, scd30.relative_humidity);
    ThingSpeak.setField(3, scd30.temperature);
//    ThingSpeak.setField(4, humidity);
//    ThingSpeak.setField(5, pressure);
//    ThingSpeak.setField(6, ppm);


    // Write to ThingSpeak. There are up to 8 fields in a channel, allowing
you to store up to 8 different
    // pieces of information in a channel.  Here, we write to field 1.
    int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);

    if (x == 200) {
      Serial.println("Channel update successful.");
    }
    else {
      Serial.println("Problem updating channel. HTTP error code " +
String(x));
    }

  delay(15000);
}
}

Bon weekend a tous

Richard


Le dim. 26 déc. 2021 à 18:33, Raphaël Jacquot <sxp...@sxpert.org> a écrit :

>
>
> Le 24/12/2021 à 16:00, guilla...@ophane.net a écrit :
> > On 23/12/2021 10:38, Remi Desgrange wrote:
> >> Au bureau, on a des capteurs dans les open spaces qui fonctionne bien.
> Un
> >> petit lien avec les détails :
> >>
> >>
> https://www.camptocamp.com/en/news-events/how-open-source-contribute-to-safer-offices
> >>
> >>
> >
> > CH2O aussi fait mal à la tête -_^ (SFA30).
> >
>
> tu confonds très certainement avec C2H5OH...
>
>
> ---------------------------
> Liste de diffusion du FRnOG
> http://www.frnog.org/
>

---------------------------
Liste de diffusion du FRnOG
http://www.frnog.org/

Répondre à