<commit_before>#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>

#include <DallasTemperature.h>

#include <OneWire.h>

const int LIGHT_SENSOR_ID = 1;
const int TEMP_SENSOR_ID = 2;
const int MOISTURE_SENSOR_1_ID = 3;
const int MOISTURE_SENSOR_2_ID = 4;
const int MOISTURE_SENSOR_3_ID = 5;

/* Analog */
const int lightSensorPin = 0;
const int m1Pin = 1;
const int m2Pin = 2;
const int m3Pin = 3;

/* Digital */
const int tempSensorPin = 2;

// Setup a oneWire instance to communicate with any OneWire devices 
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(tempSensorPin);
 
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

int lightLevel, temp, m1,m2,m3 = 0;

RF24 radio(9,10);

void setup() {
  radio.begin();
  radio.setPALevel(RF24_PA_MAX);
  radio.setChannel(0x76);
  radio.openWritingPipe(0xF0F0F0F0E1LL);
  radio.enableDynamicPayloads();
  radio.powerUp();

  // Turn off moisture sensor
  pinMode(3,OUTPUT);
  digitalWrite(3,LOW);
  sensors.begin();
  
}

void sendRadioMessage(String s){
  char msgChar[100];
  s.toCharArray(msgChar,100);
  radio.write(&msgChar,sizeof(msgChar));
}

void loop() {
  digitalWrite(3,HIGH);
  delay(500);
  lightLevel = analogRead(lightSensorPin);
  sensors.requestTemperatures();
  temp = sensors.getTempCByIndex(0);

  m1 = analogRead(m1Pin);
  m2 = analogRead(m2Pin);
  m3 = analogRead(m3Pin);

  digitalWrite(3,LOW);
  String lightMsg = String(LIGHT_SENSOR_ID) + ":" + lightLevel;
  String tempMsg = String(TEMP_SENSOR_ID) + ":" + temp;
  String m1Msg = String(MOISTURE_SENSOR_1_ID) + ":" + m1;
  String m2Msg = String(MOISTURE_SENSOR_2_ID) + ":" + m2;
  String m3Msg = String(MOISTURE_SENSOR_3_ID) + ":" + m3;
  
  sendRadioMessage(m1Msg+","+m2Msg+","+m3Msg+","+lightMsg+","+tempMsg);
  delay(600000);
  
}<commit_msg>Using an analog multiplexer to add more sensors!<commit_after>#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>

#include <DallasTemperature.h>

#include <OneWire.h>

const int LIGHT_SENSOR_ID = 1;
const int TEMP_SENSOR_ID = 2;
const int MOISTURE_SENSOR_1_ID = 3;
const int MOISTURE_SENSOR_2_ID = 4;
const int MOISTURE_SENSOR_3_ID = 5;

/* Analog */
const int lightSensorPin = 0;
const int muxOutPin = 1;

/* Digital */
const int tempSensorPin = 2;

/* Mux */
const int muxPins[3] = {4,5,6};

// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(tempSensorPin);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

int lightLevel, temp, m1,m2,m3 = 0;

RF24 radio(9,10);

void setup() {
  radio.begin();
  radio.setPALevel(RF24_PA_MAX);
  radio.setChannel(0x76);
  radio.openWritingPipe(0xF0F0F0F0E1LL);
  radio.enableDynamicPayloads();
  radio.powerUp();

  // Turn off moisture sensor
  pinMode(3,OUTPUT);
  digitalWrite(3,LOW);
  sensors.begin();

  // Set up mux
  for (int i=0; i<3; i++)
  {
    pinMode(muxPins[i], OUTPUT);
    digitalWrite(muxPins[i], LOW);
  }
  pinMode(muxOutPin, INPUT);

}

void sendRadioMessage(String s){
  char msgChar[100];
  s.toCharArray(msgChar,100);
  radio.write(&msgChar,sizeof(msgChar));
}

void selectMuxPin(byte pin) {
  if(pin >7){
    return;
  }

  digitalWrite(muxPins[0], bitRead(pin,0));
  digitalWrite(muxPins[1], bitRead(pin,1));
  digitalWrite(muxPins[2], bitRead(pin,2));
}

void loop() {
  digitalWrite(3,HIGH);
  delay(500);
  lightLevel = analogRead(lightSensorPin);
  sensors.requestTemperatures();
  temp = sensors.getTempCByIndex(0);

  String muxMessage = "";
  for(byte pin=0;pin<8;pin++){
    selectMuxPin(pin);
    int pinValue = analogRead(muxOutPin);
    muxMessage += String(pin+5) + ":" + pinValue + ",";
  }

  digitalWrite(3,LOW);
  String lightMsg = String(LIGHT_SENSOR_ID) + ":" + lightLevel;
  String tempMsg = String(TEMP_SENSOR_ID) + ":" + temp;

  sendRadioMessage(muxMessage+lightMsg+","+tempMsg);
  delay(600000);

}
{'fraction_non_alphanumeric': 0.14292816306239126, 'fraction_numerical': 0.039025602783992044, 'mean_word_length': 4.831884057971014, 'pattern_counts': {'":': 8, '<': 19, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '940283', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1582, 'n_words': 321}