<commit_before>/***************************************************
  Adafruit MQTT Library ESP8266 Example

  Must use ESP8266 Arduino from:
    https://github.com/esp8266/Arduino

  Works great with Adafruit's Huzzah ESP board:
  ----> https://www.adafruit.com/product/2471
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by <NAME> for Adafruit Industries.
  Adafruit IO example additions by <NAME>.
  MIT license, all text above must be included in any redistribution
 ****************************************************/
#include <ESP8266WiFi.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include <Wire.h>
#include <Adafruit_AM2315.h>

/************************* WiFi Access Point *********************************/

#define WLAN_SSID       "...your SSID..."
#define WLAN_PASS       "...<PASSWORD>..."

/************************* Adafruit.io Setup *********************************/

#define AIO_SERVER      "io.adafruit.com"
#define AIO_SERVERPORT  1883
#define AIO_USERNAME    "...your AIO username (see https://accounts.adafruit.com)..."
#define AIO_KEY         "...your AIO key..."

/************ Global State (you don't need to change this!) ******************/

// Create an ESP8266 WiFiClient class to connect to the MQTT server.
WiFiClient client;

// Store the MQTT server, client ID, username, and password in flash memory.
// This is required for using the Adafruit MQTT library.
const char MQTT_SERVER[] PROGMEM    = AIO_SERVER;
// Set a unique MQTT client ID using the AIO key + the date and time the sketch
// was compiled (so this should be unique across multiple devices for a user,
// alternatively you can manually set this to a GUID or other random value).
const char MQTT_CLIENTID[] PROGMEM  = __TIME__ AIO_USERNAME;
const char MQTT_USERNAME[] PROGMEM  = AIO_USERNAME;
const char MQTT_PASSWORD[] PROGMEM  = AIO_KEY;

// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, AIO_SERVERPORT, MQTT_CLIENTID, MQTT_USERNAME, MQTT_PASSWORD);

/****************************** Feeds ***************************************/

// Setup a group called 'weather' for publishing changes.
// Notice MQTT group CSV paths for AIO follow the form: <username>/groups/<groupname>/csv
const char WEATHER_FEED[] PROGMEM = AIO_USERNAME "/groups/weather/csv";
Adafruit_MQTT_Publish weather = Adafruit_MQTT_Publish(&mqtt, WEATHER_FEED);

/*************************** Sketch Code ************************************/

Adafruit_AM2315 am2315;

void setup() {

  Serial.begin(115200);

  Serial.println(F("Adafruit IO Example"));

  // Connect to WiFi access point.
  Serial.println(); Serial.println();
  delay(10);
  Serial.print(F("Connecting to "));
  Serial.println(WLAN_SSID);

  WiFi.begin(WLAN_SSID, WLAN_PASS);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(F("."));
  }
  Serial.println();

  Serial.println(F("WiFi connected"));
  Serial.println(F("IP address: "));
  Serial.println(WiFi.localIP());

  if (! am2315.begin()) {
    Serial.println(F("AM2315 not found, check wiring & pullups!"));
    while (1);
  }

  // connect to adafruit io
  connect();

}

void loop() {

  // ping adafruit io a few times to make sure we remain connected
  if(! mqtt.ping(3)) {
    // reconnect to adafruit io
    if(! mqtt.connected())
      connect();
  }

  char sendbuffer[80];
  char numberbuffer[20];
  float temp = (am2315.readTemperature() * 1.8) + 32;
  float humidity = am2315.readHumidity();

  // add temp feed name
  strcpy(sendbuffer, "temp,");

  // add temp value
  dtostrf(temp, 2, 6, numberbuffer);
  strcat(sendbuffer, numberbuffer);

  // add new line and humidity feed name
  strcat(sendbuffer, "\nhumidity,");

  // Now we can publish stuff!
  Serial.println(F("\nSending: "));
  Serial.println(sendbuffer);

  if (! weather.publish(sendbuffer))
    Serial.println(F("Failed."));<commit_msg>fix humidity value in esp group sensor sketch<commit_after>/***************************************************
  Adafruit MQTT Library ESP8266 Example

  Must use ESP8266 Arduino from:
    https://github.com/esp8266/Arduino

  Works great with Adafruit's Huzzah ESP board:
  ----> https://www.adafruit.com/product/2471
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by <NAME> for Adafruit Industries.
  Adafruit IO example additions by <NAME>.
  MIT license, all text above must be included in any redistribution
 ****************************************************/
#include <ESP8266WiFi.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include <Wire.h>
#include <Adafruit_AM2315.h>

/************************* WiFi Access Point *********************************/

#define WLAN_SSID       "...your SSID..."
#define WLAN_PASS       "...<PASSWORD>..."

/************************* Adafruit.io Setup *********************************/

#define AIO_SERVER      "io.adafruit.com"
#define AIO_SERVERPORT  1883
#define AIO_USERNAME    "...your AIO username (see https://accounts.adafruit.com)..."
#define AIO_KEY         "...your AIO key..."

/************ Global State (you don't need to change this!) ******************/

// Create an ESP8266 WiFiClient class to connect to the MQTT server.
WiFiClient client;

// Store the MQTT server, client ID, username, and password in flash memory.
// This is required for using the Adafruit MQTT library.
const char MQTT_SERVER[] PROGMEM    = AIO_SERVER;
// Set a unique MQTT client ID using the AIO key + the date and time the sketch
// was compiled (so this should be unique across multiple devices for a user,
// alternatively you can manually set this to a GUID or other random value).
const char MQTT_CLIENTID[] PROGMEM  = __TIME__ AIO_USERNAME;
const char MQTT_USERNAME[] PROGMEM  = AIO_USERNAME;
const char MQTT_PASSWORD[] PROGMEM  = AIO_KEY;

// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, AIO_SERVERPORT, MQTT_CLIENTID, MQTT_USERNAME, MQTT_PASSWORD);

/****************************** Feeds ***************************************/

// Setup a group called 'weather' for publishing changes.
// Notice MQTT group CSV paths for AIO follow the form: <username>/groups/<groupname>/csv
const char WEATHER_FEED[] PROGMEM = AIO_USERNAME "/groups/weather/csv";
Adafruit_MQTT_Publish weather = Adafruit_MQTT_Publish(&mqtt, WEATHER_FEED);

/*************************** Sketch Code ************************************/

Adafruit_AM2315 am2315;

void setup() {

  Serial.begin(115200);

  Serial.println(F("Adafruit IO Example"));

  // Connect to WiFi access point.
  Serial.println(); Serial.println();
  delay(10);
  Serial.print(F("Connecting to "));
  Serial.println(WLAN_SSID);

  WiFi.begin(WLAN_SSID, WLAN_PASS);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(F("."));
  }
  Serial.println();

  Serial.println(F("WiFi connected"));
  Serial.println(F("IP address: "));
  Serial.println(WiFi.localIP());

  if (! am2315.begin()) {
    Serial.println(F("AM2315 not found, check wiring & pullups!"));
    while (1);
  }

  // connect to adafruit io
  connect();

}

void loop() {

  // ping adafruit io a few times to make sure we remain connected
  if(! mqtt.ping(3)) {
    // reconnect to adafruit io
    if(! mqtt.connected())
      connect();
  }

  char sendbuffer[80];
  char numberbuffer[20];
  float temp = (am2315.readTemperature() * 1.8) + 32;
  float humidity = am2315.readHumidity();

  // add temp feed name
  strcpy(sendbuffer, "temp,");

  // add temp value
  dtostrf(temp, 2, 6, numberbuffer);
  strcat(sendbuffer, numberbuffer);

  // add new line and humidity feed name
  strcat(sendbuffer, "\nhumidity,");
  
  // add humidity value
  dtostrf(humidity, 2, 6, numberbuffer);
  strcat(sendbuffer, numberbuffer);
  
  // Now we can publish stuff!
  Serial.println(F("\nSending: "));
  Serial.println(sendbuffer);

  if (! weather.publish(sendbuffer))
    Serial.println(F("Failed."));
{'fraction_non_alphanumeric': 0.1988883518608023, 'fraction_numerical': 0.01933301111648139, 'mean_word_length': 4.2286797220467465, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6799152', 'n_tokens_mistral': 2804, 'n_tokens_neox': 2542, 'n_words': 777}